CellTypist

raw JSON →
1.7.1 verified Fri May 01 auth: no python

A Python tool for semi-automatic cell type classification from single-cell RNA-seq data. It uses logistic regression models trained on diverse cell atlases. Current version is 1.7.1, with regular updates on GitHub.

pip install celltypist
error ModuleNotFoundError: No module named 'celltypist'
cause Package not installed.
fix
Run pip install celltypist.
error ValueError: Unknown model 'Immune_All_Low.pkl'. Available models: ...
cause Model name typo or not downloaded.
fix
Check list of available models with celltypist.models.models_description() and use exact name.
gotcha CellTypist models are downloaded to a cache directory (~/.celltypist/) on first use. Ensure you have write permissions.
fix Set environment variable CELLTYPIST_CACHE_DIR to a writable path.
breaking In version 1.6.0, the internal model loading API changed. Old code using `models.Model.load` with version string may break.
fix Update to newer version and use `models.Model.load(model='model_name')` without explicit version. Check model naming.
deprecated Using `CellTypist().predict()` without specifying model name may fall back to a default. This behavior is deprecated.
fix Always supply a `model` argument explicitly.

Load a pre-trained model and predict cell types from an AnnData file. Replace the file path with your own data.

from celltypist import CellTypist
from celltypist import models
# Download model if not present (first time)
model = models.Model.load(model='Immune_All_Low.pkl')
# Predict cell types
transcriptome_data = 'path/to/your/data.h5ad'  # replace with your file
predictions = CellTypist().predict(transcriptome_data, model=model)
print(predictions.cell_type.value_counts())