Skip to main content

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:

  1. grid_search: Makes a search over the hyperparameters of the model, evaluates the best model and retrains it on the whole dataset using 'train'.
  2. train: Trains the model with the given hyperparameters.
  3. 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.
  4. 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. GridSearch
print("\n1. grid_search")
classifier.grid_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:

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

clacell-1.0.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

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

clacell-1.0.0-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: clacell-1.0.0.tar.gz
  • Upload date:
  • Size: 17.0 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

Hashes for clacell-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7e4a000ff6eb759552117cfea7721468f3afb2a846bf0261109d18f28fad41e6
MD5 95b7b12a94e8d0c0dac494d5512789ee
BLAKE2b-256 097b20f9ff6b63431aeb024adf3a31c9a3a10cf4170af3a6aabd921580060e60

See more details on using hashes here.

File details

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

File metadata

  • Download URL: clacell-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 23.0 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

Hashes for clacell-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 178646e5c8b7c1317b50c6298fc8b226ccb4e5d0f1356bfb72a3391d1c929b02
MD5 520b99e7e578eb9a9e855a6b7145b76f
BLAKE2b-256 0ad4e86e888c88429b58a43c2766573da372860216bb83c358cfaee444e7037f

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