cellrank.external.kernels.WOTKernel

class cellrank.external.kernels.WOTKernel(adata, backward=False, time_key='exp_time', compute_cond_num=False)[source]

Waddington optimal transport kernel from [Schiebinger et al., 2019].

This class requires the wot package, which can be installed as pip install git+https://github.com/broadinstitute/wot.

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

  • backward (bool) – Direction of the process.

  • time_key (str) – Key in adata .obs where experimental time is stored. The experimental time can be of either of a numeric or an ordered categorical type.

  • 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 packages, load data
import scanpy as sc
import cellrank as cr
adata = cr.datasets.lung()

# filter, normalize and annotate highly variable genes
sc.pp.filter_genes(adata, min_cells=10)
sc.pp.normalize_total(adata)
sc.pp.log1p(adata)
sc.pp.highly_variable_genes(adata)

# estimate proliferation and apoptosis from gene sets (see. e.g. WOT tutorial for example lists)
proliferation_genes = ...
apoptosis_genes = ...
sc.tl.score_genes(adata, gene_list=proliferation_genes, score_name='proliferation')
sc.tl.score_genes(adata, gene_list=apoptosis_genes, score_name='apoptosis')

# initialize kernel, estimate initial growth rate based on scores from above
from cellrank.external.kernels import WOTKernel
ot = WOTKernel(adata, time_key='day')
ot.compute_initial_growth_rates(proliferation_key='proliferation',
                                apoptosis_key='apoptosis',
                                key_added='initial_growth_rates')

# compute transport maps, aggregate into one single transition matrix
ot.compute_transition_matrix(growth_rate_key='initial_growth_rates', growth_iters=3)

Attributes

adata

Annotated data object.

backward

Direction of the process.

condition_number

Condition number of the transition matrix.

growth_rates

Estimated cell growth rates for each growth rate iteration.

kernels

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

params

Parameters which are used to compute the transition matrix.

transition_matrix

Return row-normalized transition matrix.

Methods

compute_initial_growth_rates([…])

Estimate initial growth rates using a birth-death process as described in [Schiebinger et al., 2019].

compute_projection([basis, key_added, copy])

Compute a projection of the transition matrix in the embedding.

compute_transition_matrix([cost_matrices, …])

Compute transition matrix using Waddington OT [Schiebinger et al., 2019].

copy()

Return a copy of itself.

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)

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.