Skip to main content

CellTypeAI: local LLM driven cell type annotation of scRNA-seq data

Project description

CellTypeAI: Automated cell identification for scRNA-seq using local generative-AI

CellTypeAI, a streamlined, scalable program developed to perform context-dependent cell identification in scRNA-seq datasets, which leverages locally-run LLMs with enhanced RAG methods and optional ensemble methods.

CellTypeAI builds upon local LLM hosting technol-ogies and integrates directly into scanpy-based scRNA-seq analysis pipelines to enable accurate cell type identification of pre-clustered scRNA-seq data

Table of Contents

Installation

Dev version:

#Using pip:
pip install git+https://github.com/rhdaw/celltypeai

#Using uv: 
uv add git+https://github.com/rhdaw/celltypeai

# Navigate into the directory to install requirements from .toml
cd CellTypeAI
pip install .

# Or using uv:
uv pip install -r pyproject.toml

pip installation (to be confirmed)

pip install celltypeai
#or
uv add celltypeai

Usage

Ollama Requirements:

ollama pull phi4:14b
  • Initialise ollama server via ollama serve in terminal / powershell
ollama serve

Running CellTypeAI

Following standard scRNA-seq processing with leiden OR louvain clustering.

import celltypeai as cta

cta.cell_annotator(
                "Human",
                "Intestine",
                adata,
                model="qwen3:32b",
                num_genes=200,
                n_iterations=3,
            )

On completion, annotations are stored in adata.obs["cell_type_ai"]

cell_annotator(adata, species, tissue, ...)

Takes a processed .h5ad object, extracts Differentially Expressed Genes (DEGs) from each cluster, and utilizes a local LLM via Ollama to define and annotate cell types.

Parameter Type Default Description
adata AnnData Required Annotated data matrix containing cell clusters (Leiden or Louvain).
species str Required The biological species (e.g., "Human", "Mouse").
tissue str Required The tissue type being analyzed. Must be one of: Adrenal, Brain, Eye, Heart, Immune system, Intestine, Kidney, Liver, Lung, Muscle, Pancreas, Placenta, Spleen, Stomach, Thymus, Skin.
model str "phi4:14b" The Ollama model to use. Recommended: "phi4:14b", "qwen3:32b", "qwen3:235b".
num_genes int 200 Number of top marker genes to provide to the LLM for each cluster.
n_iterations int 3 Ensemble size. The model prompts n times and selects the mode (most frequent) annotation.
verbose bool False If True, outputs detailed logs and saves the engineered prompt to the working directory for inspection.

Returns:

  • adata (AnnData): The input object with a new .obs column containing the predicted cell types.

Contributing

Fork the repo, create a feature branch, and submit a pull request. Please add tests and update documentation for new features.

License

GNU GPL-2.0 license - see LICENSE file

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

celltypeai-1.0.0.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

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

celltypeai-1.0.0-py3-none-any.whl (26.8 kB view details)

Uploaded Python 3

File details

Details for the file celltypeai-1.0.0.tar.gz.

File metadata

  • Download URL: celltypeai-1.0.0.tar.gz
  • Upload date:
  • Size: 26.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for celltypeai-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c41dc87a4bb408c2eb96bd508edccdeab62765bb2222f1c3d3d5344f02b9a49a
MD5 b77c5cf4f4d8a051a0992053fbdb21ec
BLAKE2b-256 793ab9ee53c647571964895f28aeb77d27c00260cea38ed614192f5b1ea211d2

See more details on using hashes here.

File details

Details for the file celltypeai-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: celltypeai-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 26.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for celltypeai-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0c0b59115e821c000de7a804c97fa331e3cad4621872724b0d9ae1ec1bed768
MD5 554587039501c137433a297b46896dec
BLAKE2b-256 3ccf8dfc2fc000c384190c341cc427b18dd5353608b21d8c41aed0913f215e98

See more details on using hashes here.

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