Plot circular embedding

This example shows how to plot absorption probabilities using circular a posteriori projection as used in [Velten17].

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 compute the absorption probabilities.

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

Out:

  0%|          | 0/90 [00:00<?, ?/s]
  7%|6         | 6/90 [00:00<00:01, 46.83/s]
 16%|#5        | 14/90 [00:00<00:01, 53.72/s]
 24%|##4       | 22/90 [00:00<00:01, 56.05/s]
 33%|###3      | 30/90 [00:00<00:01, 57.44/s]
 42%|####2     | 38/90 [00:00<00:00, 58.28/s]
 51%|#####1    | 46/90 [00:00<00:00, 58.62/s]
 60%|######    | 54/90 [00:00<00:00, 58.56/s]
 69%|######8   | 62/90 [00:01<00:00, 57.10/s]
 78%|#######7  | 70/90 [00:01<00:00, 51.97/s]
 86%|########5 | 77/90 [00:01<00:00, 49.73/s]
 93%|#########3| 84/90 [00:01<00:00, 47.95/s]
100%|##########| 90/90 [00:01<00:00, 52.22/s]

We can now visualize the absorption probabilities by projecting them onto a unit circle. The tips of the simplex indicate the probability of 1.0 for the lineages and the midpoints of the edges of the edges mark where the probabilities of the lineages connected by an edge are equal.

cr.pl.circular_projection(
    adata, keys=["clusters", "kl_divergence"], legend_loc="upper right"
)
clusters, to terminal states kl divergence

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

Estimated memory usage: 550 MB

Gallery generated by Sphinx-Gallery