🧬 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, and Anthropic Claude models out of the box, with more providers planned for the future.
- 🤖 LLM-agnostic backend: Seamlessly use models from OpenAI, Anthropic (Claude), and Gemini (Google) — 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.
You need to have 🐍 Python 3.10 or newer installed on your system. If you don't have Python installed, we recommend installing Mambaforge.
Install by running:
pip install cell-annotator
To install the latest development version from GitHub, run
pip install git+https://github.com/quadbio/cell-annotator.git@main
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.
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 likegpt-4o
,gpt-4.1
, or reasoning models likeo3-mini
(these may incur a small fee; e.g., running both tutorials witho3-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.
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.
This package sends cluster marker genes, and the species
and tissue
you define, to the selected LLM provider (e.g., OpenAI, Google, or Anthropic). 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.
This tool was inspired by Hou et al., Nature Methods 2024 and https://github.com/VPetukhov/GPTCellAnnotator.
If you found a bug, please use the issue tracker.
Please use our zenodo entry to cite this software.