AICAT: AI-based Cell-type Annotation Tool
AICAT (AI-based Cell-type Annotation Tool) is a computational method for automatic cell type annotation of single-cell RNA-seq data. It leverages the model via OpenAI's API to generate deep and context-aware cell type predictions based on cluster-level expression profiles.
Installation
To install the package in development mode:
git clone https://github.com/RavenGan/AICAT.git
cd AICAT
pip install -e .
To install the package through pip:
pip install aicat-annotator==0.0.2
API Key Requirement
AICAT requires access to the OpenAI GPT model. Users need to provide their own OpenAI API key. To avoid the risk of exposing the API key or committing the key to browsers, users need to set up the API key as a system environment variable before running AICAT.
Users can generate the API key in the OpenAI account webpage: log in to OpenAI. In the pop-up windows, click on “->” next to “API”; next, click on the left-hand-side icon of “API key”; then click on “Create new secret key” to create your key which directs you to the API key page. Copy the key and paste it on a note for further use. Avoid sharing your API key with others or uploading it to public spaces. Make sure it’s not visible in browsers or any client-side scripts. Finally, on the left bar, click “Settings”; on the break-down list click on “Billing”, and make sure you have non-zero credit balance.
With the API key, there are two options to setup the key:
Option 1: Using .env file
OPENAI_API_KEY=your-api-key-here
Option 2: Using terminal (temporary)
export OPENAI_API_KEY=your-api-key-here
Supported Input
The main input is a clustered .h5ad file containing single-cell gene expression data.
Required Structure
- The
.obsDataFrame should contain a cluster label column. - The expression matrix should be preprocessed (e.g., log-normalized) to allow differential gene calculation later in the program.
- The
.h5adfile can be generated via the python packageScanpy.
Usage
CLI Usage
Indepth annotation CLI
Run the following from your terminal. Here a small test data is used as an example. This data can also be found under the folder ./tests/data.
aicat-indepth \
--openai_api_key "OPENAI_API_KEY" \
--adata_path "tests/data/CRC_SMC05-T_processed.h5ad" \
--species "human" \
--tissue "primary colorectal cancer" \
--cluster_col_name "Cell_type" \
--data_name "CRC_SMC05-T" \
--save_path "tests/res/CRC_SMC05-T"
Display CLI options with
aicat-indepth --help
Subcluster CLI (optional)
To perform subclustering annotation, run the following from the terminal. The argument --AnnoSingle_res_path requires the output from the previous command aicat-indepth.
aicat-subcluster \
--openai_api_key "OPENAI_API_KEY" \
--adata_path "tests/data/CRC_SMC05-T_processed.h5ad" \
--tissue "primary colorectal cancer" \
--cluster_col_name 'Cell_type' \
--chosen_cluster "B cells" \
--AnnoSingle_res_path "tests/res/CRC_SMC05-T/AnnoSingle_primary colorectal cancer_res_dict.json" \
--save_path "tests/res/CRC_SMC05-T_subcluster"
Display CLI options with
aicat-subcluster --help
Programmatic Usage
Users can also call aicat from python:
from aicat.main_indepth import indepth_annotation
# Indepth annotation
indepth_annotation(api_key,
adata_path,
species,
tissue,
cluster_col_name)
# subclustering annotation
subcluster_annotation(api_key,
adata_path,
tissue,
cluster_col_name,
chosen_cluster,
AnnoSingle_res_path)
Output
AICAT will output the following:
- A
.jsonfile with predicted cell types - The full conversation history including the prompts and GPT response content
- A log of the full running progress
Testing
Users can also run unit tests using
pytest tests/
To test a specific function manually:
python tests/test_indepth.py
Make sure OPENAI_API_KEY is set in your environment.
Dependencies
Major dependencies used in this package:
langchain,langchain-openai,langchain-corepydantic,pydantic-settingsscanpy,pandas,dotenv,requestsargparse,json,os,re,subprocessSeepyproject.tomlfor full details about the package versions.
License
This project is licensed under the MIT License.
Contributions
Contributions are welcome! If you’d like to add features or fix bugs, feel free to fork the repository and open a pull request.
Metadata
Release files for aicat-annotator 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| aicat_annotator-0.0.2.tar.gz | 287.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aicat_annotator-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 315.4 kB
Release files / aicat_annotator-0.0.2.tar.gz
| Download URL | aicat_annotator-0.0.2.tar.gz |
|---|---|
| Size | 287.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1c6ae822f6cfcff7d3c1542d8e6ca81ef69f398c16b1d1f6b13b5d7f8bbfb005
|
|
BLAKE2b-256 checksum How to use checksums |
677ba76dfbdb4936d33adc8232c8b816a2ec3f8a0d101849dbe2c3bad9a49611
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Release files / aicat_annotator-0.0.2-py3-none-any.whl
| Download URL | aicat_annotator-0.0.2-py3-none-any.whl |
|---|---|
| Size | 27.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
502c622426786ea8e5a9cfd94af104570416963021ecc7bb63f1eeaf2a4b965e
|
|
BLAKE2b-256 checksum How to use checksums |
d37edece2b382cbcb58de6e57c3096266c7222552371756006ab3b179a4c1c5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Security for aicat-annotator 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.