Skip to main content

A tool to annotate cell types

Project description

CellAnnotator

Tests Coverage Documentation Pre-commit.ci PyPI

CellAnnotator is an scverse ecosystem package, designed to annotate cell types in scRNA-seq data based on marker genes using OpenAI models.

Key features

  • Automatically annotate cells including type, state and confidence fields.
  • Generate consistent annotations across samples of your study.
  • Optionally infuse prior knowledge by providing information about your biological system.
  • Retrieve reliable results thanks to OpenAI structured outputs
  • Use this tool to quickly generate pre-integration cell type labels to either score your integration quality (e.g. scIB metrics) or to guide your integration effort (e.g. scPoli, scANVI).

Note that 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.10 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 OpenAI to generate your API key

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

The default model is currently gpt-4o-mini, which is included in OpenAI's Free Usage Tier. Thus, you can get started for free and experiment with our tutorials and with your own data. If you want to get accurate cell type labels for complex tissues, we strongly recommend using more powerful models, like gpt-4o, or reasoning models like o3-mini, for which you will have to pay a small fee to OpenAI. As an orientation, running both tutorials with o3-mini will cost around 1 USD.

Data privacy

This package sends cluster marker genes to OpenAI, but no actual gene expression values. In addition, it sends the species and tissue you define. Make sure your usage of this package aligns with your institutions guidelines on data privacy and AI models.

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.

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.1.4.tar.gz (1.7 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.1.4-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cell_annotator-0.1.4.tar.gz
Algorithm Hash digest
SHA256 68d00097633ae62db3123b401013d8f573902429c54841188c65ffaf8b6e3c22
MD5 ce901f203534b44bfb315431f19bf098
BLAKE2b-256 6e726330125bea4f24bece431c469b017402ca84f9185ba55e1fdd5bdcbdaa38

See more details on using hashes here.

Provenance

The following attestation bundles were made for cell_annotator-0.1.4.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.1.4-py3-none-any.whl.

File metadata

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

File hashes

Hashes for cell_annotator-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0e719d670ffd5ff7d191a0b25abba13a3116983250f01e5bae0798c0b0dc6dcd
MD5 ed24b1b2e0d19736432dea15d0b760b9
BLAKE2b-256 901311113fa5ccd5f0a7d6e2d24c97b58c70ad6441b4ae6833e7e09b076c89c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for cell_annotator-0.1.4-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