Skip to main content

A package for generating an embedding space from scRNA-Seq. This space can be used for cell type annotation, novel cell type detection, cell type representations, and visualization.

Project description

CELLULAR: CELLUlar contrastive Learning for Annotation and Representation

Abstract Batch effects are a significant concern in single-cell RNA sequencing (scRNA-Seq) data analysis, where variations in the data can be attributed to factors unrelated to cell types. This can make downstream analysis a challenging task. In this study, we present a novel deep learning approach using contrastive learning and a carefully designed loss function for learning an generalizable embedding space from scRNA-Seq data. We call this model CELLULAR: CELLUlar contrastive Learning for Annotation and Representation. When benchmarked against multiple established methods for scRNA-Seq integration, CELLULAR outperforms existing methods in learning a generalizable embedding space on multiple datasets. Cell annotation was also explored as a downstream application for the learned embedding space. When compared against multiple well-established methods, CELLULAR demonstrates competitive performance with top cell classification methods in terms of accuracy, balanced accuracy, and F1 score. CELLULAR is also capable of performing novel cell type detection. These findings aim to quantify the meaningfulness of the embedding space learned by the model by highlighting the robust performance of our learned cell representations in various applications. The model has been structured into an open-source Python package, specifically designed to simplify and streamline its usage for bioinformaticians and other scientists interested in cell representation learning.

Necessary programming languages

  • Python version >= 3.10.5

Setup

pip install --extra-index-url https://download.pytorch.org/whl/cu118 torch==2.2.1
pip install CELLULAR-CL

Functionality

The following functions have been included:

  • Training function for the embedding space model.
  • Training function for the classifier model.
  • Predict function for generating an embedding space.
  • Predict function for performing cell type annotation.
  • Function for novel cell type detection.
  • Function for creating cell type representation vectors.
  • Function for applying the same normalization strategy as was used in this study, giving the end user the option of using the same strategy or implementing their own.
  • Function for automatic preprocessing, although it is still recommended for end users to use their own preprocessing pipeline to make sure it is appropriate for their data.

Data

Data for the tutorial can be installed from here.

Usage

For making embedding space

import scanpy as sc
import CELLULAR_CL as CELLULAR

adata_train = sc.read("train_data.h5ad", cache=True)
CELLULAR.train(adata=adata_train, target_key="cell_type", batch_key="batch")

adata_test = sc.read("test_data.h5ad", cache=True)
predictions = CELLULAR.predict(adata=adata_test)

For cell type annotation

import scanpy as sc
import CELLULAR_CL as CELLULAR

adata_train = sc.read("train_data.h5ad", cache=True)
CELLULAR.train(adata=adata_train, train_classifier=True, target_key="cell_type", batch_key="batch")

adata_test = sc.read("test_data.h5ad", cache=True)
predictions = CELLULAR.predict(adata=adata_test, use_classifier=True)

For novel cell type detection

import scanpy as sc
import CELLULAR_CL as CELLULAR

adata_train = sc.read("train_data.h5ad", cache=True)
CELLULAR.train(adata=adata_train, target_key="cell_type", batch_key="batch")

adata_test = sc.read("test_data.h5ad", cache=True)
CELLULAR.novel_cell_type_detection(adata=adata_test)

For making cell type representations

import scanpy as sc
import CELLULAR_CL as CELLULAR

adata_train = sc.read("train_data.h5ad", cache=True)
CELLULAR.train(adata=adata_train, target_key="cell_type", batch_key="batch")

adata_test = sc.read("test_data.h5ad", cache=True)
representations = CELLULAR.generate_representations(adata=adata_test, target_key="cell_type")

Tutorials

See Tutorial/embedding_space_tutorial.ipynb, Tutorial/classification_tutorial.ipynb, and Tutorial/pre_process_tutorial.ipynb.

Citation

Coming soon

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

CELLULAR_CL-0.0.2.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

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

CELLULAR_CL-0.0.2-py3-none-any.whl (30.5 kB view details)

Uploaded Python 3

File details

Details for the file CELLULAR_CL-0.0.2.tar.gz.

File metadata

  • Download URL: CELLULAR_CL-0.0.2.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.0 CPython/3.10.5

File hashes

Hashes for CELLULAR_CL-0.0.2.tar.gz
Algorithm Hash digest
SHA256 6bbf8b1cf68cf48ffd69a39bb25a3b54bf45e58ea9383f248313c184efc72ec2
MD5 70986ded5a0d32cfb950f19530aa02b4
BLAKE2b-256 a856ffb2fa7a0d00832376f0751e35ca8b49ce079596d61d40c8bc01f6b013dc

See more details on using hashes here.

File details

Details for the file CELLULAR_CL-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: CELLULAR_CL-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 30.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.0 CPython/3.10.5

File hashes

Hashes for CELLULAR_CL-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 69aa365295f4a3ebef8e75699a8101e667d7295d60cb83d3e37106927a0d451f
MD5 1e4b7d26cea67a0458053940be053a58
BLAKE2b-256 dc0d7070032f1df82e8d3b7d823edd8f80847b0c5c34f9a18619a8a5ccd5600c

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