robust cell type classifier for immune cells
Project description
CLACELL
Robust cell type classifier for immune cells
Usage
MarkerAnnotator
The MarkerAnnotator can be used to annotate an Anndata dataset. It uses a marker based annotation strategy to annotate the dataset. It takes only a dictionary with markers as an input.
from clacell import MarkerAnnotator
annotator = MarkerAnnotator(marker_dict=marker_dict)
adata = annotator.annotate(adata)
# Now adata.obs['scumi-annotation'] contains the annotations
Preprocessing
You should preprocess your data before you give it to the CellClassifier. A sample Preprocessing can be applied with the provided method preprocess_data.
from clacell import preprocess_data
adata_preprocessed = preprocess_data(adata)
CellClassifier
The cell type classifier has four different methods:
- random_search: Makes a search over the hyperparameters of the model, evaluates the best model and retrains it on the whole dataset using 'train'.
- train: Trains the model with the given hyperparameters.
- evaluate: Evaluates the current model with robustness tests. The model needs to be trained before this method is called. The logs can be printed in the console as well as in a log file. The results will be returned in a dataframe with a multi index for easier access.
- predict: Predicts new samples. The model needs to be trained before this method is called.
All methods can be called with Dataframes or with an Anndata object. Either way the data has to be processed. We recommend to use Dataframes so you can choose the train test split yourself for more realistic results. If an Anndata object is provided, the train test split will be random and won't consider batches.
from clacell import CellClassifier
classifier = CellClassifier()
# 1. RandomSearch
print("\n1. random_search")
classifier.random_search(X_train, y_train, X_test, y_test, n_jobs=3)
# 2. Train
print("\n2. train")
classifier.train(X_train, y_train, C=0.001)
# 3. Evaluate
print("\n3. evaluate")
classifier.evaluate(X_test, y_test, log_to_console=True, log_to_file=True)
# 4. Predict
print("\n4. predict")
predictions = classifier.predict(X_test)
print(f"Macro F1: {f1_score(y_test, predictions, average="macro")}")
Acknowledgments & Data Sources
The marker based annotation strategy is a reimplementation of the existing R package scumi-dev (licensed under BSD 3-Clause License). Link to the repository: https://bitbucket.org/jerry00/scumi-dev/src/master/
- Citation: Ding, J., Adiconis, X., Simmons, S.K. et al. Systematic comparison of single-cell and single-nucleus RNA-sequencing methods. Nat Biotechnol 38, 737–746 (2020). https://doi.org/10.1038/s41587-020-0465-8
This repository contains reference datasets used for training and validation:
- CellTypist: The Cross-tissue Immune Cell Atlas was provided by the Teichmann Group at the Wellcome Sanger Institute and were hosted by Genome Research Limited (licensed under CC BY-NC-ND 4.0). Link: https://www.tissueimmunecellatlas.org/
- Citation: C. Domínguez Conde et al., Cross-tissue immune cell analysis reveals tissue-specific features in humans. Science376, eabl5197(2022).DOI: 10.1126/science.abl5197
- Human Cell Atlas (HCA): HematopoieticImmuneCellAtlas (licensed under CC-BY 4.0). Project Link: https://explore.data.humancellatlas.org/projects/cc95ff89-2e68-4a08-a234-480eca21ce79
- Citation: Li, B., Kowalczyk, M.S. et al. Hematopoietic Immune Cell Atlas. Human Cell Atlas Data Portal (2026).
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clacell-2.1.1.tar.gz.
File metadata
- Download URL: clacell-2.1.1.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64c3e6170c420cebec47265415e2a4ac37f1d40511d07ec845070c2ccf7a3107
|
|
| MD5 |
45a60b8532e2c9ac02fbfee279058b7b
|
|
| BLAKE2b-256 |
bc4a395286525b6cbae04662934388094227fbcac390de823de37316be5b1345
|
File details
Details for the file clacell-2.1.1-py3-none-any.whl.
File metadata
- Download URL: clacell-2.1.1-py3-none-any.whl
- Upload date:
- Size: 21.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a812b03a4ae7094fd0a78fa9bf7d9ded5c9f17bdb7bbd54067ef4261dd67aa7
|
|
| MD5 |
56f628946bf69c520c7c013774c2f1d1
|
|
| BLAKE2b-256 |
eb46bc65ec82c60377988f220a5ce2fa9b40f42e5bf20e327b8be6a40ab108bb
|