Skip to main content

A tool to annotate cell types

Project description

CellAnnotator

Tests Coverage Documentation Pre-commit.ci PyPI

A tool 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 gpu-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 a more powerful model, like gpt-4o, for which you will have to pay a small fee to OpenAI. As an orientation, running our tutorials with gpt-4o will cost around 0.20 USD.

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.3.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.3-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cell_annotator-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e25e380c0dde81af752b7e3202f6c714bfb197af9f675c6459f8c3389ce84585
MD5 2c91f00db01d7563bc37e14e30242ab8
BLAKE2b-256 25f172ecb32943f306f761a6612e6318caf1446306d5d091965934fc13e408d7

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for cell_annotator-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e88e703eca1224ddd56f2a40a8795e4c9bb4ba6126a75fbb26d8d3f91925d2de
MD5 0bd031fc499f734453da6c9c30ffe64b
BLAKE2b-256 d1669b2f36bb72e0034d0fabcb58afe5e971a17ac083fb669871e0e32dcdda3a

See more details on using hashes here.

Provenance

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