Skip to main content

ConvexGating is a Python tool to infer optimal gating strategies for flow cytometry and cyTOF data.

Project description

overview

PyPI Python Version License Read the documentation at https://convexgating.readthedocs.io/ Build Package Status Run Tests Status Codecov pre-commit Black

Features

ConvexGating is a Python package to infer an optimal gating strategy from flow, cyTOF or Ab/CITE-seq data. Convex gating expects a labelled input (for instance, from clustering) and returns a gating panel to separate the selected group of events (e.g. a cluster) from all other events (see Fig. 1a). For each cluster, it reports the purity (precision), yield (recall) and the harmonic mean of both metrics (F1 score) for each gate hierarchy and the entire gating strategy. It relies on the scanpy/anndata for the data format and data pre-processing and further on PyTorch for stochastic gradient descent. Therefore, resulting gates may slightly vary.

overview

The iterative procedure to find a suitable gate before applying the convex hull is illustrated in the following graphic.

Update

Installation

We recommend using Python 3.9 and setting up a new conda environment.

conda create -n ConvexGating_env python=3.9
conda activate ConvexGating_env

Then, install ConvexGating the following way.

git clone https://github.com/buettnerlab/convexgating.git
cd convexgating
pip install -e .

Installation time should not exceed 5 minutes. Installation has been successfully tested on Windows and Linux operating systems. We experienced issues with MacOS with Apple Silicon M1/M2 CPUs.

Usage

Single Target Population

Generating gating strategy for cells or events labeled ‘cluster_A’ from an AnnData object (adata) using labels found in adata.obs[cluster_string].

import convexgating as cg
import scanpy as sc

adata = sc.read_h5ad(adata_path)
cluster_string = 'clustering'                                       #column in adata.obs
target_cluster = 'cluster_A'                                        #category in adata.obs[cluster_string]
save = save_path
cg.tools.CONVEX_GATING(adata=adata,
          cluster_numbers = [target_cluster],
          cluster_string = cluster_string,
          save_path=save)

Multiple Target Population

Generating a series of gating strategies for cells or events labeled ‘cluster_A’,’cluster_B’,’cluster_C’ from an AnnData object (adata) using labels found in adata.obs[cluster_string].

import convexgating as cg
import scanpy as sc

adata = sc.read_h5ad(adata_path)
cluster_string = 'clustering'                                          #column in adata.obs
target_clusters = ['cluster_A','cluster_B','cluster_C']                #categories in adata.obs[cluster_string]
save = save_path
cg.tools.CONVEX_GATING(adata=adata,
          cluster_numbers = target_clusters,
          cluster_string = cluster_string,
          save_path=save)

Example

A usage example is available in the docs/tutorials/tutorial_01.ipynb file located in this repository.

Further Details

Please see the Command-line Reference for further details.

Credits

This package was created with cookietemple using Cookiecutter based on Hypermodern_Python_Cookiecutter.

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

convexgating-1.0.0.tar.gz (27.4 kB view details)

Uploaded Source

Built Distribution

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

convexgating-1.0.0-py3-none-any.whl (30.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: convexgating-1.0.0.tar.gz
  • Upload date:
  • Size: 27.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.10.11 Windows/10

File hashes

Hashes for convexgating-1.0.0.tar.gz
Algorithm Hash digest
SHA256 474742902ad148ee35190165262b9ed6615eba0d34d2a4b0b84ac37a054f03bb
MD5 6df8b164048462da62c8b7443ed2f818
BLAKE2b-256 e84cff8d2d190e9630e73fd42d64da15cc1137c931b6ef9ee9541e837470db84

See more details on using hashes here.

File details

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

File metadata

  • Download URL: convexgating-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 30.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.10.11 Windows/10

File hashes

Hashes for convexgating-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ce37233f5fafed4818bbca2f1c2c255a03107f7b16342e356a4c1ef8f588b5d8
MD5 355c8bed7e610392859f815a8bf22fb9
BLAKE2b-256 b01c6a4e13a6e51a58146ae8eae89b6e1f664e4255ddd5d9d9f6de3b113da7d3

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