Skip to content

Commit 08c3cd4

Browse files
authored
Merge pull request #53 from quadbio/feat/backend
Add generic LLM backend
2 parents 683b981 + a7c4bb8 commit 08c3cd4

29 files changed

+3421
-829
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ __pycache__/
1818
# docs
1919
/docs/generated/
2020
/docs/_build/
21+
/docs/notebooks/tests/
2122

2223
# Jupyter
2324
.ipynb_checkpoints

README.md

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,54 @@
1616
[badge-downloads]: https://static.pepy.tech/badge/cell-annotator
1717
[badge-zenodo]: https://zenodo.org/badge/899554552.svg
1818

19-
CellAnnotator is an [scverse ecosystem package](https://scverse.org/packages/#ecosystem), designed to annotate cell types in scRNA-seq data based on marker genes using OpenAI models.
2019

21-
## Key features
20+
🧬 CellAnnotator is an [scverse ecosystem package](https://scverse.org/packages/#ecosystem), 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.
2221

23-
- Automatically annotate cells including type, state and confidence fields.
24-
- Generate consistent annotations across samples of your study.
25-
- Optionally infuse prior knowledge by providing information about your biological system.
26-
- Retrieve reliable results thanks to [OpenAI structured outputs](https://platform.openai.com/docs/guides/structured-outputs)
27-
- Use this tool to quickly generate pre-integration cell type labels to either score your integration quality (e.g. [scIB metrics](https://scib-metrics.readthedocs.io/en/stable/)) or to guide your integration effort (e.g. [scPoli](https://docs.scarches.org/en/latest/), [scANVI](https://docs.scvi-tools.org/en/stable/api/reference/scvi.model.SCANVI.html)).
2822

29-
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.
23+
## ✨ Key Features
3024

31-
## Installation
25+
- 🤖 **LLM-agnostic backend**: Seamlessly use models from OpenAI, Anthropic (Claude), and Gemini (Google) — just set your provider and API key.
26+
- 🧬 **Automatically annotate cells** including type, state, and confidence fields.
27+
- 🔄 **Consistent annotations** across all samples in your study.
28+
- 🧠 **Infuse prior knowledge** by providing information about your biological system.
29+
- 📦 **Structured outputs** for reliable results (see e.g. [OpenAI structured outputs](https://platform.openai.com/docs/guides/structured-outputs)).
30+
- 🧩 **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.
31+
-**Quickly generate pre-integration cell type labels** to score or guide your integration (e.g. [scIB metrics](https://scib-metrics.readthedocs.io/en/stable/), [scPoli](https://docs.scarches.org/en/latest/), [scANVI](https://docs.scvi-tools.org/en/stable/api/reference/scvi.model.SCANVI.html)).
3232

33-
You need to have Python 3.10 or newer installed on your system.
33+
> ℹ️ **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.
34+
35+
36+
## 📦 Installation
37+
You need to have 🐍 Python 3.10 or newer installed on your system.
3438
If you don't have Python installed, we recommend installing [Mambaforge][].
3539

36-
### PyPI
3740

41+
### 🚀 PyPI
3842
Install by running:
3943

4044
```bash
4145
pip install cell-annotator
4246
```
4347

44-
### Development version
4548

49+
### 🛠️ Development version
4650
To install the latest development version from [GitHub](https://github.com/quadbio/cell-annotator), run
4751

4852
```bash
4953
pip install git+https://github.com/quadbio/cell-annotator.git@main
5054
```
5155

52-
## Getting started
5356

54-
After installation, head over to OpenAI to generate your [API key](https://help.openai.com/en/articles/4936850-where-do-i-find-my-openai-api-key)
57+
## 🏁 Getting started
58+
After installation, head over to the LLM provider of your choice to generate an API key 🔑. For example:
59+
60+
- OpenAI: [API key](https://help.openai.com/en/articles/4936850-where-do-i-find-my-openai-api-key)
61+
- Google (Gemini): [API key](https://ai.google.dev/gemini-api/docs/api-key)
62+
- Anthropic (Claude): [API key](https://docs.anthropic.com/en/docs/get-started)
63+
64+
65+
🔒 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](https://pypi.org/project/python-dotenv/) to export the key from the `env` file as an environmental variable.
5566

56-
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](https://pypi.org/project/python-dotenv/) to export the key from the `env` file as an environmental variable.
5767

5868
Here's the simplest way to annotate your data:
5969

@@ -65,25 +75,39 @@ cell_ann = CellAnnotator(
6575
).annotate_clusters()
6676
```
6777

68-
By default, this will store annotations in `adata.obs['cell_type_predicted']`. Head over to our [tutorials](https://cell-annotator.readthedocs.io/en/latest/notebooks/tutorials/index.html) 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.
6978

70-
## Costs and models
79+
By default, this will store annotations in `adata.obs['cell_type_predicted']`. Head over to our 📚 [tutorials](https://cell-annotator.readthedocs.io/en/latest/notebooks/tutorials/index.html) 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.
80+
81+
7182

72-
The default model is currently `gpt-4o-mini`, which is included in [OpenAI's Free Usage Tier](https://platform.openai.com/docs/guides/rate-limits). Thus, you can get started for free and experiment with our [tutorials](https://cell-annotator.readthedocs.io/en/latest/notebooks/tutorials/index.html) 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`, `gpt-4.1`, etc, 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. Take a look at the [OpenAI API docs](https://platform.openai.com/docs/models) to learn more about the different available models.
83+
## 💸 Costs and models
84+
CellAnnotator is LLM-agnostic and works with multiple providers:
7385

74-
## Data privacy
86+
- **OpenAI (GPT models):** The default model is currently `gpt-4o-mini`, which is included in [OpenAI's Free Usage Tier](https://platform.openai.com/docs/guides/rate-limits). You can get started for free and experiment with our 📚 [tutorials](https://cell-annotator.readthedocs.io/en/latest/notebooks/tutorials/index.html) 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](https://platform.openai.com/docs/models) for details.
7587

76-
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.
88+
- **Google Gemini:** Gemini models are supported and have their own free tier and pricing. See the [Gemini API docs](https://ai.google.dev/gemini-api/docs/models) for available models and costs.
7789

78-
## Credits
90+
- **Anthropic Claude:** Claude models are supported. See the [Anthropic pricing page](https://docs.anthropic.com/claude/docs/pricing) for details.
7991

92+
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.
93+
94+
95+
96+
## 🔐 Data privacy
97+
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.**
98+
99+
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.
100+
101+
102+
## 🙏 Credits
80103
This tool was inspired by [Hou et al., Nature Methods 2024](https://www.nature.com/articles/s41592-024-02235-4) and [https://github.com/VPetukhov/GPTCellAnnotator](https://github.com/VPetukhov/GPTCellAnnotator).
81104

82-
## Contact
83105

106+
## 📬 Contact
84107
If you found a bug, please use the [issue tracker][].
85108

86-
## Citation
109+
110+
## 📖 Citation
87111
Please use our [zenodo][] entry to cite this software.
88112

89113
[mambaforge]: https://github.com/conda-forge/miniforge#mambaforge

0 commit comments

Comments
 (0)