Plot lineages

This example shows how to plot the absorption probabilities of the process.

CellRank computes absorption probabilities to estimate how likely each individual cell is to transition into each of the identified terminal or intermediate states. Absorption probabilities refer to the probability of a random walk starting in cell \(i\) to reach terminal state \(j\) before reaching any other terminal state.

Throughout CellRank, we use the terms lineage probabilities, fate probabilities and absorption probabilities interchangeably to describe the same set of probabilities.

import cellrank as cr

adata = cr.datasets.pancreas_preprocessed("../example.h5ad")
adata

Out:

AnnData object with n_obs × n_vars = 2531 × 2000
    obs: 'day', 'proliferation', 'G2M_score', 'S_score', 'phase', 'clusters_coarse', 'clusters', 'clusters_fine', 'louvain_Alpha', 'louvain_Beta', 'initial_size_unspliced', 'initial_size_spliced', 'initial_size', 'n_counts', 'velocity_self_transition', 'dpt_pseudotime'
    var: 'highly_variable_genes', 'gene_count_corr', 'means', 'dispersions', 'dispersions_norm', 'fit_r2', 'fit_alpha', 'fit_beta', 'fit_gamma', 'fit_t_', 'fit_scaling', 'fit_std_u', 'fit_std_s', 'fit_likelihood', 'fit_u0', 'fit_s0', 'fit_pval_steady', 'fit_steady_u', 'fit_steady_s', 'fit_variance', 'fit_alignment_scaling', 'velocity_genes'
    uns: 'clusters_colors', 'clusters_fine_colors', 'diffmap_evals', 'iroot', 'louvain_Alpha_colors', 'louvain_Beta_colors', 'neighbors', 'pca', 'recover_dynamics', 'velocity_graph', 'velocity_graph_neg', 'velocity_params'
    obsm: 'X_diffmap', 'X_pca', 'X_umap', 'velocity_umap'
    varm: 'PCs', 'loss'
    layers: 'Ms', 'Mu', 'fit_t', 'fit_tau', 'fit_tau_', 'spliced', 'unspliced', 'velocity', 'velocity_u'
    obsp: 'connectivities', 'distances'

First, we need to compute the terminal states and the absorption probabilities towards them.

cr.tl.terminal_states(
    adata,
    cluster_key="clusters",
    n_cells=30,
    n_states=3,
    softmax_scale=4,
    show_progress_bar=False,
)
cr.tl.lineages(adata)

Out:

INFO: Using pre-computed schur decomposition

We can now plot the terminal states. By default, we plot the degree of membership, which is available only to the cellrank.tl.estimators.GPCCA estimator.

cr.pl.lineages(adata)
absorption probabilities (fwd)

We can also plot only a subset of these lineages or plot the most likely cells.

cr.pl.lineages(adata, ["Alpha", "Beta"], discrete=True)
terminal states (fwd)

Lastly, we can also plot the absorption probabilities separately, one plot for each lineage. By default this also shows the differentiation potential, defined in [Setty19] as the entropy over the absorption probabilities.

cr.pl.lineages(adata, same_plot=False)
to Epsilon, to Alpha, to Beta, differentiation potential

To see how to compute and plot the lineage driver genes, refer to Plot potential lineage drivers.

Total running time of the script: ( 0 minutes 23.324 seconds)

Estimated memory usage: 591 MB

Gallery generated by Sphinx-Gallery