FACSPy.ml.unsupervisedGating#
- class FACSPy.ml.unsupervisedGating(adata, gating_strategy, layer, clustering_algorithm='leiden', cluster_key=None, sensitivity=1, intervals=[0.33, 0.66])#
Class for semi-supervised gating. This class allows to identify cell populations based on their marker expression. Cells are first clustered using one of the four implemented algorithms (parc, leiden, phenograph and FlowSOM). The clusters are then analyzed and compared to a user-defined gating strategy.
Gating strategies are dicts with the following naming convention: gating_strategy = {population_name: [parent_population, [marker1+, marker2-]]} where the population name is the population that is identified, the parent population states which cell population is used to derive the population from and the marker specify the population characteristics.
- Parameters:
adata (
AnnData) – The anndata object of shape n_obs x n_vars where rows correspond to cells and columns to the channels.gating_strategy (
dict) – The gating strategy with the above mentioned format.layer (
str) – The layer corresponding to the data matrix.clustering_algorithm (
Literal['leiden','FlowSOM','phenograph','parc']) – The clustering algorithm used for community detection. One of parc, leiden, phenograph or FlowSOM.cluster_key (
Optional[str]) – The cluster key to be added to the dataset.sensitivity (
float) – Parameter to control the sensitivity of the marker detection. The value will be log-transformed so that a sensitivity of 1 leads to cutoff of np.arcsinh(1) (~0.88). For every log there will be the addition of 0.1. Sensitivity of 0.1 therefore leads to np.arcsinh(1) + 0.1*-np.log10(0.1) which is np.arcsinh(1) + 0.1. To increase the sensitivity, choose higher values (100 will result in a decrease of 0.2).intervals (
list[float]) – gives the intervals for lo, int and hi so that the first two numbers denote the lo quantile. Defaults to the 33rd and 66th percentile.
- Return type:
A
AnnDataobject where the identified populations are stored in adata.obsm[“gating”].
Examples
>>> import FACSPy as fp >>> dataset = fp.dt.create_dataset(...) >>> gating_strategy = {"T_cells": ["CD45+", ["CD3+"]]} >>> clf = fp.ml.unsupervisedGating( ... dataset, ... gating_strategy = gating_strategy, ... layer = "transformed", ... clustering_algorithm = "parc" ... ) >>> clf.identify_populations()
Methods
Returns a
AnnDataobjectidentify_populations([cluster_kwargs])