cellrank.tl.kernels.CytoTRACEKernel

class cellrank.tl.kernels.CytoTRACEKernel(adata, backward=False, layer='Ms', aggregation='mean', use_raw=False, compute_cond_num=False, check_connectivity=False)[source]

Kernel which computes directed transition probabilities based on a KNN graph and the CytoTRACE score [Cyto20].

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. This kernel internally uses the cellrank.tl.kernels.PseudotimeKernel to direct the KNN graph on the basis of the CytoTRACE-derived pseudotime.

Optionally, we apply a density correction as described in [Coifman05], where we use the implementation of [Haghverdi16].

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

  • backward (bool) – Direction of the process.

  • layer (str) – Key in anndata.AnnData.layers or ‘X’ for anndata.AnnData.X from where to get the expression.

  • aggregation (Literal[‘mean’, ‘median’, ‘hmean’, ‘gmean’]) –

    How to aggregate expression of the top-correlating genes. Valid options are:

    • ’mean’: arithmetic mean.

    • ’median’: median.

    • ’gmean’: geometric mean.

    • ’hmean’: harmonic mean.

  • compute_cond_num (bool) – Whether to compute condition number of the transition matrix. Note that this might be costly, since it does not use sparse implementation.

Examples

Workflow:

import scvelo as scv
import cellrank as cr

adata = cr.datasets.pancreas()

sc.pp.filter_genes(adata, min_cells=10)
adata.raw = adata.copy()
sc.pp.normalize_total(adata)
sc.pp.log1p(adata)
sc.pp.highly_variable_genes(adata)

if 'spliced' not in adata.layers or 'unspliced' not in adata.layers:
    # use the following trick to get scvelo's moments function working
    adata.layers['spliced'] = adata.X
    adata.layers['unspliced'] = adata.X

scv.pp.moments(adata, n_pcs=None, n_neighbors=None)

Attributes

adata

Annotated data object.

backward

Direction of the process.

condition_number

Condition number of the transition matrix.

kernels

Get the kernels of the kernel expression, except for constants.

params

Parameters which are used to compute the transition matrix.

pseudotime

Pseudotemporal ordering of cells.

transition_matrix

Return row-normalized transition matrix.

Methods

compute_cytotrace([layer, aggregation, use_raw])

Re-implementation of the CytoTRACE algorithm [Cyto20] to estimate cellular plasticity.

compute_projection([basis, key_added, copy])

Compute a projection of the transition matrix in the embedding.

compute_transition_matrix([…])

Compute transition matrix based on KNN graph and pseudotemporal ordering.

copy()

Return a copy of self.

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

Plot random walks in an embedding.

read(fname)

Deserialize self from a file.

write(fname[, ext])

Serialize self to a file.

write_to_adata([key])

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