cellrank.tl.kernels.CytoTRACEKernel

class cellrank.tl.kernels.CytoTRACEKernel(adata, backward=False, **kwargs)[source]

Kernel which computes directed transition probabilities based on a KNN graph and the CytoTRACE score [Gulati et al., 2020].

The KNN graph contains information about the (undirected) connectivities among cells, reflecting their similarity. CytoTRACE can be used to estimate cellular plasticity and in turn, a pseudotemporal ordering of cells from more plastic to less plastic states. It relies on the assumption that differentiated cells express, on average, less genes than naive cells. This kernel internally uses the cellrank.kernels.PseudotimeKernel to direct the kNN graph on the basis of the CytoTRACE-derived pseudotime.

Optionally, we apply a density correction as described in [Coifman et al., 2005], where we use the implementation of [Haghverdi et al., 2016].

Parameters
  • adata (anndata.AnnData) – Annotated data object.

  • backward (bool) – Direction of the process.

  • kwargs (Any) – Keyword arguments for cellrank.kernels.PseudotimeKernel.

Example

Workflow:

# import packages and load data
import scvelo as scv
import cellrank as cr
adata = cr.datasets.pancreas()

# standard pre-processing
sc.pp.filter_genes(adata, min_cells=10)
sc.pp.normalize_total(adata)
sc.pp.log1p(adata)
sc.pp.highly_variable_genes(adata)

# CytoTRACE by default uses imputed data - a simple way to compute kNN-imputed data is to use scVelo's moments
# function. However, note that this function expects `spliced` counts because it's designed for RNA velocity,
# so we're using a simple hack here:
if 'spliced' not in adata.layers or 'unspliced' not in adata.layers:
    adata.layers['spliced'] = adata.X
    adata.layers['unspliced'] = adata.X

# compute kNN-imputation using scVelo's moments function
scv.pp.moments(adata)

# import and initialize the CytoTRACE kernel, compute transition matrix - done!
from cellrank.kernels import CytoTRACEKernel
ctk = CytoTRACEKernel(adata).compute_cytotrace().compute_transition_matrix()

Attributes

adata

Annotated data object.

backward

Direction of the process.

kernels

Underlying base kernels.

params

Parameters which are used to compute the transition matrix.

pseudotime

Pseudotemporal ordering of cells.

shape

(n_cells, n_cells).

transition_matrix

Row-normalized transition matrix.

Methods

compute_cytotrace([layer, aggregation, ...])

Re-implementation of the CytoTRACE algorithm [Gulati et al., 2020] to estimate cellular plasticity.

compute_transition_matrix([...])

Compute transition matrix based on KNN graph and pseudotemporal ordering.

copy(*[, deep])

Return a copy of itself.

plot_projection([basis, key_added, ...])

Plot transition_matrix as a stream or a grid plot.

plot_random_walks([n_sims, max_iter, seed, ...])

Plot random walks in an embedding.

plot_single_flow(cluster, cluster_key, time_key)

Visualize outgoing flow from a cluster of cells [Mittnenzweig et al., 2021].

read(fname[, adata, copy])

Deserialize self from a file.

write(fname[, write_adata, ext])

Serialize self to a file.

write_to_adata([key, copy])

Write the transition matrix and parameters used for computation to the underlying adata object.