Skip to main content

AnnoTuneAgent

PyPI version PyPI downloads Python versions Documentation Status CI License DOI

Documentation: Read the Docs.

Cluster-level cell-type annotation for single-cell RNA-seq. One fine-tuned language model runs locally, and a check rule reads the marker measurements.

Each cluster gets a marker score and a name-model result. The check rule keeps that name, replaces it, or drops it. The marker score can still name the cluster when the check drops the proposal. Every call stays auditable.

What is fine-tuned

The current name model is one Q6_K GGUF, Qwen3.5-4B-annotune-v9k-name.Q6_K.gguf. It is loaded with -m and no LoRA. If that server was started with --api-key, set ANNOTUNE_API_KEY. The same value is sent as a bearer token.

Step What it does Input Output
name Choose a cell-type name from the marker dictionary Cluster marker evidence and dictionary_hits A name copied from dictionary_hits
check A fixed rule, not a model The proposed name and each candidate's marker measurements Keep the name, replace it with the one supported candidate, or drop it

The name model is trained to copy a name from dictionary_hits, not to free-write one. A positive marker supports a type when its log fold change is above 0.5 and it is detected in at least 25% of the cluster. A negative marker blocks a type only when it is that common and its log fold change is at least 1. The proposal stays when at least two markers support it and none block it. It is replaced only when it is not supported and exactly one other candidate is. Otherwise it is dropped, and the marker score can still name the cluster. A name with no marker that passes expression and specificity validation is flagged (no_marker_passed) instead of being trusted silently.

The weights are on the Hugging Face Hub: lieberlee/annotune-qwen3.5-4b-gguf (preview). Inference is local: no cluster data leaves the machine.

Pipeline

raw counts ─ prepare ─▶ QC, doublets, normalization, batch correction, Leiden
           ─ run ─────▶ per cluster:
                          1. marker score        (built-in human / mouse dictionary)
                          2. name model          (one GGUF, copies from dictionary_hits)
                          3. check rule          (keeps, replaces, or drops that name)
                          ▼
                        title + status + reason + hint
                          ▼
                        validated marker panels, dotplot, report, annotated h5ad
  • A rule, not a second model. The check reads the measurements. It does not call another adapter. Mixed programs and unvalidated names stay flagged (mixed_programs, near_clear_cluster, subcluster_labels, no_marker_passed, check_rule) so you can review them.
  • Marker evidence is checked, not quoted. Panels are selected from cited dictionary markers and validated against measured expression and specificity in your data.
  • Every title is traceable. The report records the name-model answer, the check result, the panel, and the reason a cluster was or was not settled.

The name model runs when models is passed (or --name-adapter / --name-url is given). Without it, run uses the marker score alone.

Install

Python 3.10–3.13.

pip install annotuneagent

Local GGUF models need pip install 'annotuneagent[models]', which installs the tokenizer stack (transformers and jinja2). Optional methods: AmbiDose (denoise=True, install), scVI and SOLO (annotuneagent[scvi]), scFair (annotuneagent[scfair]), Harmony, and Scanorama. If you select one that is missing, prepare prints the install command and leaves the matrix unchanged. See Installation.

From a checkout:

git clone https://github.com/leelieber2025/AnnoTuneAgent.git
cd AnnoTuneAgent
pip install -e ".[dev]"

First run

prepare expects raw integer counts. run expects finite, nonnegative, library-size-normalized natural log1p expression with Scanpy's adata.uns["log1p"], which prepare writes.

import annotuneagent as ata

adata = ata.read_10x("outs", ["sample_a", "sample_b"])
adata = ata.prepare(adata, species="human", batch_key="sample")
report = ata.run(adata, "leiden", species="human", subcluster=False)

read_10x takes one filtered matrix per sample folder (*.h5, or the mtx directory when there is no h5). Scrublet and SOLO run per sample on those filtered counts. doublet_chip="10k" (default) uses 0.8% multiplets per 1,000 recovered cells, and "20k" uses 0.4%.

geo_info("GSE341410") lists the samples in a GEO series. read_geo then downloads the ones you name. groups sets obs["group"]. Characteristics such as day and treatment are stored on obs, and obs={...} adds columns the record does not name. docs/tutorials/gse266598_annotation.ipynb follows one series from the GEO page through annotation.

To score a caller-supplied list instead of the built-in dictionary:

records = ata.annotate(
    adata,
    cluster_key="leiden",
    hypotheses=[
        ata.Hypothesis(
            "CD4-positive, alpha-beta T cell",
            positive=("CD3E", "CD4"),
            negative=("CD8A",),
        ),
        ata.Hypothesis(
            "CD8-positive, alpha-beta T cell",
            positive=("CD3E", "CD8A"),
            negative=("CD4",),
        ),
    ],
)

A label needs positive marker enrichment. A negative marker counts against a hypothesis only when the cluster is enriched for it relative to the other cells. Scores are operational, not probabilities.

The built-in table is markers.tsv: human and mouse, each with a tissue-agnostic core and organ pages. Tissue rows stay hidden until tissue matches. Symbols are not translated across species. evaluate compares records with a per-cell author label: the reference for a cluster is the majority label, a tied majority is left unmatched, and a parent name counts as a coarse match.

annotuneagent \
  --input clustered.h5ad \
  --cluster-key leiden \
  --species human \
  --output result.json

--base with the merged GGUF runs the name model on one local server and requires --output-h5ad. The check rule then reads the marker measurements. The weights are on the Hugging Face Hub: lieberlee/annotune-qwen3.5-4b-gguf. The tokenizer is installed with the package. See docs/tutorials/load_model.ipynb.

Status

0.1.7 (Alpha). Import as import annotuneagent as ata.

Citation

For the software record, cite the Zenodo DOI. Pin the package version used in the analysis, for example annotuneagent==0.1.7.

License

Software: Apache License 2.0.

Author

Zhao Li (李钊) Email: leelieber@gmail.com

Metadata

Release files for annotuneagent 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for annotuneagent 0.1.7
File Size Uploaded Provenance Actions
annotuneagent-0.1.7.tar.gz 10.5 MB With provenance Details for annotuneagent-0.1.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for annotuneagent 0.1.7
File Interpreter ABI Platform Actions
annotuneagent-0.1.7-py3-none-any.whl Python 3 none any Details for annotuneagent-0.1.7-py3-none-any.whl

Total release size: 17.7 MB

Release files / annotuneagent-0.1.7.tar.gz

Download URL annotuneagent-0.1.7.tar.gz
Size 10.5 MB
Tags Source
SHA-256 checksum
How to use checksums
450cd39e53ab7793311dd8e363e432abc8d06e729bec17447d5d0df3cc18970b
BLAKE2b-256 checksum
How to use checksums
fd46c7d5725bac8fb6024aca4d1dd137741ae7530fcc776e67fcee32361d7442
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / annotuneagent-0.1.7-py3-none-any.whl

Download URL annotuneagent-0.1.7-py3-none-any.whl
Size 7.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
7457bf2f0fd0f4944bcda23985cecc17f9733b014041c70e328b48681ed58cef
BLAKE2b-256 checksum
How to use checksums
d4158ce5433ee9fb5ac3e003f083bb3ab52aa8f99a41c6e3ee9b663fa58fe915
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for annotuneagent 0.1.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for annotuneagent-0.1.7.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page