Skip to main content

Automated cell annotation from scRNA-seq data using LLMs

Project description

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, and Anthropic Claude models out of the box, with more providers planned for the future.

✨ Key Features

  • 🤖 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.

📦 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.

💸 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.

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, 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.

🙏 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cell_annotator-0.2.1.tar.gz (3.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cell_annotator-0.2.1-py3-none-any.whl (43.7 kB view details)

Uploaded Python 3

File details

Details for the file cell_annotator-0.2.1.tar.gz.

File metadata

  • Download URL: cell_annotator-0.2.1.tar.gz
  • Upload date:
  • Size: 3.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cell_annotator-0.2.1.tar.gz
Algorithm Hash digest
SHA256 8adb48ff3e5aa268c27c3af2b3d6c27496cd4311110bff66ce5c5a6a0b8f721f
MD5 46a08b272896d441680cbde128f88031
BLAKE2b-256 ed3239989f8ad791906f8bde029897d6a5e16155849414811e33cdd94d80d70d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cell_annotator-0.2.1.tar.gz:

Publisher: release.yaml on quadbio/cell-annotator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cell_annotator-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: cell_annotator-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 43.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cell_annotator-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b848eef5ad0c8cd82637a39b7adb11dae1bcdd2861cd7e7e1b19513d192877ef
MD5 e68255bb603b35a82635f43ee2623b29
BLAKE2b-256 3cce38f1759f4167e18978845a27b47641cb8ba3d8dad89575bf7c0e48cb372f

See more details on using hashes here.

Provenance

The following attestation bundles were made for cell_annotator-0.2.1-py3-none-any.whl:

Publisher: release.yaml on quadbio/cell-annotator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page