Skip to main content

CellAnnotator

Tests Coverage Documentation Pre-commit.ci PyPI Downloads Zenodo

🧬 CellAnnotator is an scverse ecosystem package, designed to annotate cell types in scRNA-seq data based on marker genes using large language models (LLMs). It supports OpenAI, Google Gemini, Anthropic Claude, and OpenRouter models out of the box.

✨ Key Features

  • 🤖 LLM-agnostic backend: Seamlessly use models from OpenAI, Anthropic (Claude), Gemini (Google), or OpenRouter — just set your provider and API key.
  • 🧬 Automatically annotate cells including type, state, and confidence fields.
  • 🔄 Consistent annotations across all samples in your study.
  • 🧠 Infuse prior knowledge by providing information about your biological system.
  • 📦 Structured outputs for reliable results (see e.g. OpenAI structured outputs).
  • 🧩 Supports datasets with limited feature sets (e.g., imaging-based spatial transcriptomics): marker gene lists are filtered to the actual gene set in your data.
  • ⚡ Quickly generate pre-integration cell type labels to score or guide your integration (e.g. scIB metrics, scPoli, scANVI).

ℹ️ Note: This package is based on output generated by large language models and might sometimes make mistakes. We use some safeguards, like anchoring the tool in a multi-step process, and using structured output predictions, but mistakes are still possible. We recommend using this tool as a first step in an annotation workflow to generate an initial, coarse set of annotations that must be further refined.

📦 Installation

You need to have 🐍 Python 3.11 or newer installed on your system. If you don't have Python installed, we recommend installing Mambaforge.

🚀 PyPI

Install by running:

pip install cell-annotator

🛠️ Development version

To install the latest development version from GitHub, run

pip install git+https://github.com/quadbio/cell-annotator.git@main

🏁 Getting started

After installation, head over to the LLM provider of your choice to generate an API key 🔑. For example:

🔒 Keep this key private and don't share it with anyone. CellAnnotator will try to read the key as an environmental variable - either expose it to the environment yourself, or store it as an .env file anywhere within the repository where you conduct your analysis and plan to run CellAnnotator. The package will then use dotenv to export the key from the env file as an environmental variable.

Here's the simplest way to annotate your data:

from cell_annotator import CellAnnotator

cell_ann = CellAnnotator(
    adata, species="human", tissue="heart", cluster_key="leiden", sample_key="samples",
).annotate_clusters()

By default, this will store annotations in adata.obs['cell_type_predicted']. Head over to our 📚 tutorials to see more advanced use cases, and learn how to adapt this to your own data. You can run CellAnnotator for just a single sample of data, or across multiple samples. In the latter case, it will attempt to harmonize annotations across samples.

Advanced provider options

CellAnnotator can also be used in single-sample mode by setting sample_key=None.

Example:

from cell_annotator import CellAnnotator

cell_ann = CellAnnotator(
    adata=adata,
    species="human",
    tissue="pancreas",
    cluster_key="leiden_1",
    sample_key=None,  # single-sample mode
    provider="openrouter",
    model="openai/gpt-4o-mini",
    api_key="YOUR_OPENROUTER_API_KEY",
)

cell_ann.get_expected_cell_type_markers(n_markers=3)
cell_ann.get_cluster_markers()
cell_ann.annotate_clusters(key_added="cell_type_predicted")

💸 Costs and models

CellAnnotator is LLM-agnostic and works with multiple providers:

  • OpenAI (GPT models): The default model is currently gpt-4o-mini, which is included in OpenAI's Free Usage Tier. You can get started for free and experiment with our 📚 tutorials and your own data. For more accurate cell type labels in complex tissues, we recommend more powerful models like gpt-4o, gpt-4.1, or reasoning models like o3-mini (these may incur a small fee; e.g., running both tutorials with o3-mini costs around 1 USD). See the OpenAI API docs for details.

  • Google Gemini: Gemini models are supported and have their own free tier and pricing. See the Gemini API docs for available models and costs.

  • Anthropic Claude: Claude models are supported. See the Anthropic pricing page for details.

  • OpenRouter: OpenRouter routes requests to many model families (including OpenAI, Anthropic, and others) behind a single API key. Use provider="openrouter" and pass a model slug such as openai/gpt-4o-mini or anthropic/claude-3.5-sonnet.

You can select your provider and model by setting the appropriate parameters. More providers may be supported in the future as the LLM ecosystem evolves.

🔐 Data privacy

This package sends cluster marker genes, and the species and tissue you define, to the selected LLM provider (e.g., OpenAI, Google, Anthropic, or OpenRouter routes). No actual gene expression values are sent.

Please ensure your usage of this package aligns with your institution's guidelines on data privacy and the use of external AI models. Each provider has its own privacy policy and terms of service. Review these carefully before using CellAnnotator with sensitive or regulated data.

When using OpenRouter, requests are forwarded to the upstream provider implied by your model slug (e.g. openai/..., anthropic/...). Review both OpenRouter's privacy policy and the upstream provider's. Some OpenRouter model tiers may log prompts by default; users who need privacy guarantees should configure this via their OpenRouter account settings.

🙏 Credits

This tool was inspired by Hou et al., Nature Methods 2024 and https://github.com/VPetukhov/GPTCellAnnotator.

📬 Contact

If you found a bug, please use the issue tracker.

📖 Citation

Please use our zenodo entry to cite this software.

Metadata

Release files for cell-annotator 0.3.0

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

Source distribution (sdist)

Source distribution for cell-annotator 0.3.0
File Size Uploaded
cell_annotator-0.3.0.tar.gz 3.8 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for cell-annotator 0.3.0
File Interpreter ABI Platform
cell_annotator-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 3.9 MB

Release files / cell_annotator-0.3.0.tar.gz

Download URL cell_annotator-0.3.0.tar.gz
Size 3.8 MB
Tags Source
SHA-256 checksum
How to use checksums
eee70b826e297f6b91d3fd8de1621e8182ebbf6bc83449d25054d3b07ff36f22
BLAKE2b-256 checksum
How to use checksums
9ef65a98dd32e1e70b319d9d33f9c114b6723369eda018620046a729659d90e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 9, 2026.

Transparency log

Release files / cell_annotator-0.3.0-py3-none-any.whl

Download URL cell_annotator-0.3.0-py3-none-any.whl
Size 48.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
04c5ba7f7d98c615447b3d799c36dbbef5896a6170860924742251012532b8a1
BLAKE2b-256 checksum
How to use checksums
08501d39aa90f0437ae1de362019d902b6dbf438cd9c09eabc618bba310ed3f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

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