Uncertainty analysis - Pancreas#

Library imports#

import os
import sys

import numpy as np
import pandas as pd
import torch

import matplotlib.pyplot as plt
import mplscience
import seaborn as sns

import scanpy as sc
import scvelo as scv
import scvi
from scvelo.plotting.simulation import compute_dynamics
from velovi import preprocess_data, VELOVI
from velovi._model import _compute_directional_statistics_tensor

sys.path.append("../..")
from paths import DATA_DIR, FIG_DIR
Global seed set to 0

General settings#

scvi.settings.dl_pin_memory_gpu_training = False
sns.reset_defaults()
sns.reset_orig()
scv.settings.set_figure_params('scvelo', dpi_save=400, dpi=80, transparent=True, fontsize=20, color_map='viridis')
SAVE_FIGURES = True
if SAVE_FIGURES:
    os.makedirs(FIG_DIR / 'uncertainty' / 'pancreas', exist_ok=True)

Function definition#

def fit_velovi(bdata):
    VELOVI.setup_anndata(bdata, spliced_layer="Ms", unspliced_layer="Mu")

    vae = VELOVI(bdata)

    vae.train()

    df = vae.history["elbo_train"].iloc[20:].reset_index().rename(columns={'elbo_train': 'elbo'})
    df['set'] = 'train'

    _df = vae.history["elbo_validation"].iloc[20:].reset_index().rename(columns={'elbo_validation': 'elbo'})
    _df['set'] = 'validation'

    df = pd.concat([df, _df], axis=0).reset_index(drop=True)

    with mplscience.style_context():
        sns.set_style(style="whitegrid")
        fig, ax = plt.subplots(figsize=(6, 4))
        sns.lineplot(data=df, x='epoch', y='elbo', hue='set', palette=['#0173B2', '#DE8F05'], ax=ax)

    latent_time = vae.get_latent_time(n_samples=25)
    velocities = vae.get_velocity(n_samples=25, velo_statistic="mean")

    t = latent_time
    scaling = 20 / t.max(0)

    bdata.layers["velocities_velovi"] = velocities / scaling
    bdata.layers["latent_time_velovi"] = latent_time

    bdata.var["fit_alpha"] = vae.get_rates()["alpha"] / scaling
    bdata.var["fit_beta"] = vae.get_rates()["beta"] / scaling
    bdata.var["fit_gamma"] = vae.get_rates()["gamma"] / scaling
    bdata.var["fit_t_"] = (
        torch.nn.functional.softplus(vae.module.switch_time_unconstr)
        .detach()
        .cpu()
        .numpy()
    ) * scaling
    bdata.layers["fit_t"] = latent_time.values * scaling[np.newaxis, :]
    bdata.var['fit_scaling'] = 1.0

    return vae
def compute_sign_variance(adata, vae):
    v_stack = vae.get_velocity(n_samples=50, velo_statistic="mean", return_mean=False)
    pos_freq = (v_stack >= 0).mean(0)
    # neg_freq = (v_stack < 0).mean(0)

    adata.layers["velocity"] = v_stack.mean(0)

    var_freq = pos_freq * (1 - pos_freq)
    adata.obs["sign_var"] = var_freq.mean(1)

    adata.layers["sign_var"] = var_freq
    adata.layers["variance"] = v_stack.var(0)
def compute_sign_var_score(adata, labels_key, vae):
    compute_sign_variance(adata, vae)

    sign_var_df = adata.to_df("sign_var")
    expr_df = adata.to_df("Ms")

    prod_df = sign_var_df * np.abs(expr_df)
    prod_df[labels_key] = adata.obs[labels_key]
    prod_df = prod_df.groupby(labels_key).mean()

    sign_var_df[labels_key] = adata.obs[labels_key]
    sign_var_df = sign_var_df.groupby(labels_key).mean()

    # max over clusters for a gene
    return sign_var_df.mean(0)
def gene_rank(adata, vkey="velocities_velovi"):
    from scipy.stats import rankdata
    scv.tl.velocity_graph(adata, vkey=vkey)
    tm = scv.utils.get_transition_matrix(
        adata, vkey=vkey, use_negative_cosines=True, self_transitions=True
    )
    tm.setdiag(0)
    adata.layers["Ms_extrap"] = tm @ adata.layers["Ms"]
    adata.layers["Ms_delta"] = adata.layers["Ms_extrap"] - adata.layers["Ms"]

    prod = adata.layers["Ms_delta"] * adata.layers[vkey]
    ranked = rankdata(prod, axis=1)
    adata.layers["product_score"] = prod
    adata.layers["ranked_score"] = ranked
def plot_phase_portrait(adata, gene, color, figsize=(6, 6)):
    fig, ax = plt.subplots(figsize=figsize)

    df = pd.DataFrame(
        {
            'unspliced': adata[:, gene].layers['Mu'].squeeze().copy(),
            'spliced': adata[:, gene].layers['Ms'].squeeze().copy(),
            'color': color
        }
    )

    with mplscience.style_context():
        sns.scatterplot(data=df, x='spliced', y='unspliced', c=color, s=25, ax=ax);

        _, unspliced, spliced = compute_dynamics(adata, basis=gene, extrapolate=True, sort=True)
        df = pd.DataFrame(
            {
                'unspliced': unspliced.squeeze(),
                'spliced': spliced.squeeze(),
            }
        )

        ax.plot(spliced, unspliced, color="purple", linewidth=2)

        spliced_steady_state = np.linspace(np.min(spliced), np.max(spliced))
        unspliced_steady_state = adata.var.loc[gene, 'fit_gamma'] / adata.var.loc[gene, 'fit_beta'] * (spliced_steady_state - np.min(spliced_steady_state)) + np.min(unspliced)
        ax.plot(spliced_steady_state, unspliced_steady_state, color='purple', linestyle="--", linewidth=2);

    ax.axis('off')
    if SAVE_FIGURES:
        fig.savefig(
            FIG_DIR / 'uncertainty' / 'pancreas' / f'phase_portrait_{gene}.svg',
            format="svg",
            transparent=True,
            bbox_inches='tight'
        )

Data loading#

adata = scv.datasets.pancreas(DATA_DIR / "pancreas" / "endocrinogenesis_day15.h5ad")
adata
AnnData object with n_obs × n_vars = 3696 × 27998
    obs: 'clusters_coarse', 'clusters', 'S_score', 'G2M_score'
    var: 'highly_variable_genes'
    uns: 'clusters_coarse_colors', 'clusters_colors', 'day_colors', 'neighbors', 'pca'
    obsm: 'X_pca', 'X_umap'
    layers: 'spliced', 'unspliced'
    obsp: 'distances', 'connectivities'
scv.pl.scatter(adata, basis='umap', c='clusters', dpi=200)
../_images/865b0b624b3b38fc9f21fce40f6e04a6afb90c2e7d077d23bf9687b3056feadc.png

Data preprocessing#

scv.pp.filter_and_normalize(adata, min_shared_counts=20, n_top_genes=2000)
scv.pp.moments(adata, n_pcs=30, n_neighbors=30)
adata = preprocess_data(adata)
Filtered out 20801 genes that are detected 20 counts (shared).
Normalized count data: X, spliced, unspliced.
Extracted 2000 highly variable genes.
Logarithmized X.
computing neighbors
    finished (0:00:11) --> added 
    'distances' and 'connectivities', weighted adjacency matrices (adata.obsp)
computing moments based on connectivities
    finished (0:00:00) --> added 
    'Ms' and 'Mu', moments of un/spliced abundances (adata.layers)
computing velocities
    finished (0:00:00) --> added 
    'velocity', velocity vectors for each individual cell (adata.layers)

Model training#

vae = fit_velovi(adata)
GPU available: True, used: True
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
HPU available: False, using: 0 HPUs
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]
Epoch 500/500: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 500/500 [04:32<00:00,  1.83it/s, loss=-2.65e+03, v_num=1]
../_images/fa9950c689005b43b9f9eb2d1ef23e19f127821d1c85927357ffe5b73bc93f29.png
scv.tl.velocity_graph(adata, vkey="velocities_velovi", sqrt_transform=False)
scv.tl.velocity_embedding(
    adata, vkey="velocities_velovi", use_negative_cosines=True, self_transitions=True
)
computing velocity graph (using 1/14 cores)
    finished (0:00:08) --> added 
    'velocities_velovi_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity embedding
    finished (0:00:00) --> added
    'velocities_velovi_umap', embedded velocity vectors (adata.obsm)
with mplscience.style_context():
    fig, ax = plt.subplots(figsize=(6, 4))
    scv.pl.velocity_embedding_stream(
        adata, vkey="velocities_velovi", color=["clusters"], cmap="viridis", legend_loc=False, title='', ax=ax
    )

if SAVE_FIGURES:
    fig.savefig(
        FIG_DIR / 'uncertainty' / 'pancreas' / 'velocity_stream.svg',
        format="svg",
        transparent=True,
        bbox_inches='tight'
    )
../_images/ffc911b1bfda5965e59152ff662e985451fd896918701c19386a601fcfec4c8a.png

Uncertainty#

Intrinsic#

udf, _ = vae.get_directional_uncertainty(n_samples=100)
INFO     velovi: Sampling from model...                                                      
INFO     velovi: Computing the uncertainties...                                              
[Parallel(n_jobs=-1)]: Using backend LokyBackend with 14 concurrent workers.
Global seed set to 0
Global seed set to 0
Global seed set to 0
Global seed set to 0
Global seed set to 0
Global seed set to 0
Global seed set to 0
Global seed set to 0
Global seed set to 0
Global seed set to 0
Global seed set to 0
Global seed set to 0
Global seed set to 0
Global seed set to 0
[Parallel(n_jobs=-1)]: Done   4 tasks      | elapsed:    3.5s
[Parallel(n_jobs=-1)]: Done 152 tasks      | elapsed:    4.0s
[Parallel(n_jobs=-1)]: Done 2158 tasks      | elapsed:    6.6s
[Parallel(n_jobs=-1)]: Done 3696 out of 3696 | elapsed:    8.5s finished
for c in udf.columns:
    adata.obs[c] = np.log10(udf[c].values)
with mplscience.style_context():
    fig, ax = plt.subplots(figsize=(6, 4))
    scv.pl.umap(adata, color='directional_cosine_sim_variance', perc=[5, 95], title='', cmap="Greys", ax=ax)

if SAVE_FIGURES:
    fig.savefig(
        FIG_DIR / 'uncertainty' / 'pancreas' / 'directional_cosine_sim_variance_initrinsic.svg',
        format="svg",
        transparent=True,
        bbox_inches='tight'
    )
../_images/168da51c060cf486d120a715e94247f86e0b8820b1d8e18eb0b1e02934c6a8e6.png

Extrinsic#

extrapolated_cells_list = []
for i in range(25):
    vkey = "velocities_velovi_{i}".format(i=i)
    v = vae.get_velocity(n_samples=1, velo_statistic="mean")
    adata.layers[vkey] = v
    scv.tl.velocity_graph(adata, vkey=vkey, sqrt_transform=False, approx=True)
    t_mat = scv.utils.get_transition_matrix(
        adata, vkey=vkey, self_transitions=True, use_negative_cosines=True
    )
    extrapolated_cells = np.asarray(t_mat @ adata.layers["Ms"])
    extrapolated_cells_list.append(extrapolated_cells)
extrapolated_cells = np.stack(extrapolated_cells_list)
computing velocity graph (using 1/14 cores)
    finished (0:00:03) --> added 
    'velocities_velovi_0_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_1_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_2_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_3_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_4_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_5_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_6_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_7_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_8_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_9_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_10_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_11_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_12_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_13_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_14_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_15_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_16_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_17_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_18_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_19_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_20_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_21_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_22_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_23_graph', sparse matrix with cosine correlations (adata.uns)
computing velocity graph (using 1/14 cores)
    finished (0:00:02) --> added 
    'velocities_velovi_24_graph', sparse matrix with cosine correlations (adata.uns)
df, _ = _compute_directional_statistics_tensor(extrapolated_cells, n_jobs=4, n_cells=adata.n_obs)
INFO     velovi: Computing the uncertainties...                                              
[Parallel(n_jobs=4)]: Using backend LokyBackend with 4 concurrent workers.
Global seed set to 0
Global seed set to 0
Global seed set to 0
Global seed set to 0
[Parallel(n_jobs=4)]: Done  24 tasks      | elapsed:    3.2s
[Parallel(n_jobs=4)]: Done 3480 tasks      | elapsed:    5.6s
[Parallel(n_jobs=4)]: Done 3696 out of 3696 | elapsed:    5.7s finished
for c in df.columns:
    adata.obs[c + "_extrinsic"] = np.log10(df[c].values)
with mplscience.style_context():
    fig, ax = plt.subplots(figsize=(6, 4))
    scv.pl.umap(adata, color='directional_cosine_sim_variance_extrinsic', perc=[5, 95], cmap='viridis', ax=ax)

if SAVE_FIGURES:
    fig.savefig(
        FIG_DIR / 'uncertainty' / 'pancreas' / 'directional_cosine_sim_variance_extrinsic.svg',
        format="svg",
        transparent=True,
        bbox_inches='tight'
    )
../_images/778ce1b349b1d9b0bc2b4f9d19ad7d7ffd47277be6cc9680b111a073c3042ff1.png

Velocity coherence#

sign_score = compute_sign_var_score(adata, 'clusters', vae)
gene_rank(adata)
computing velocity graph (using 1/14 cores)
    finished (0:00:08) --> added 
    'velocities_velovi_graph', sparse matrix with cosine correlations (adata.uns)
alpha_cells = adata.obs.query("clusters == 'Alpha'").index
alpha_cluster_data = adata[alpha_cells]
alpha_cluster_data.obs['mean_product_score_per_cell_alpha'] = alpha_cluster_data.layers['product_score'].mean(axis=1)
alpha_cluster_data.var['mean_product_score_per_gene_alpha'] = alpha_cluster_data.layers['product_score'].mean(axis=0)
ngn3_high_cells = adata.obs.query("clusters == 'Ngn3 high EP'").index
ngn3_high_cluster_data = adata[ngn3_high_cells]
ngn3_high_cluster_data.obs['mean_product_score_per_cell_ngn3_high_ep'] = ngn3_high_cluster_data.layers['product_score'].mean(axis=1)
ngn3_high_cluster_data.var['mean_product_score_per_gene_ngn3_high_ep'] = ngn3_high_cluster_data.layers['product_score'].mean(axis=0)
sorted_alpha_data = alpha_cluster_data.var['mean_product_score_per_gene_alpha'].sort_values().values
sorted_ngn3_high_data = ngn3_high_cluster_data.var['mean_product_score_per_gene_ngn3_high_ep'].sort_values().values

cdf_alpha = 1. * np.arange(len(sorted_alpha_data)) / (len(sorted_alpha_data) - 1)
cdf_ngn3_high = 1. * np.arange(len(sorted_ngn3_high_data)) / (len(sorted_ngn3_high_data) - 1)

df = pd.concat(
    [
        pd.DataFrame(
            {
                'Velocity coherence': sorted_alpha_data,
                'CDF': cdf_alpha,
                'Cell type': 'Alpha'
            }
        ),
        pd.DataFrame(
            {
                'Velocity coherence': sorted_ngn3_high_data,
                'CDF': cdf_ngn3_high,
                'Cell type': 'Ngn3 high EP'
            }
        ),
    ],
    axis=0
).reset_index(drop=True)

alpha_95_percentile = np.percentile(alpha_cluster_data.var['mean_product_score_per_gene_alpha'], 95)

sns.set_style("whitegrid")
with mplscience.style_context():
    fig, ax = plt.subplots(figsize=(6, 4))
    sns.lineplot(data=df, x='Velocity coherence', y='CDF', hue='Cell type', ax=ax)
    plt.vlines(x=alpha_95_percentile, ymin=0, ymax=1, colors='black', linestyles='dashed')

if SAVE_FIGURES:
    fig.savefig(
        FIG_DIR / 'uncertainty' / 'pancreas' / 'mean_product_score_per_gene_cdf.svg',
        format="svg",
        transparent=True,
        bbox_inches='tight'
    )
../_images/60a43c9ae53ef786dda1fa211895997f4aa32a6fb3b51b694966f6b9835a6ce5.png
sns.set_style("whitegrid")
with mplscience.style_context():
    fig, ax = plt.subplots(figsize=(6, 4))
    sns.lineplot(data=df, x='Velocity coherence', y='CDF', hue='Cell type', ax=ax)

    ax.set_xlim(
        [alpha_95_percentile, 0.007]
    );
    ax.set_ylim([0.875, 1])

if SAVE_FIGURES:
    fig.savefig(
        FIG_DIR / 'uncertainty' / 'pancreas' / 'mean_product_score_per_gene_cdf_zoom.svg',
        format="svg",
        transparent=True,
        bbox_inches='tight'
    )
../_images/833cf35ae18396aa4b8e5f9d8b78887448f7b5665e59ad8bcda3f5a426d79cd6.png
df = pd.concat(
    [
        pd.DataFrame(
            {
                'Velocity coherence': alpha_cluster_data.var['mean_product_score_per_gene_alpha'],
                'Cell type': 'Alpha'
            }
        ),
        
        pd.DataFrame(
            {
                'Velocity coherence': ngn3_high_cluster_data.var['mean_product_score_per_gene_ngn3_high_ep'],
                'Cell type': 'Ngn3 high EP'
            }
        ),
    ],
    axis=0
)
df['Dataset'] = 'Pancreas'

sns.set_style("whitegrid")
with mplscience.style_context():
    fig, ax = plt.subplots(figsize=(6, 4))
    sns.violinplot(data=df, x='Dataset', y='Velocity coherence', hue='Cell type', split=True, palette='colorblind');
    ax.set_ylim([-0.003, 0.005]);

if SAVE_FIGURES:
    fig.savefig(
        FIG_DIR / 'uncertainty' / 'pancreas' / 'mean_product_score_per_gene.svg',
        format="svg",
        transparent=True,
        bbox_inches='tight'
    )
    fig.savefig(
        FIG_DIR / 'uncertainty' / 'pancreas' / 'mean_product_score_per_gene.pdf',
        transparent=True,
        bbox_inches='tight'
    )
/vol/storage/miniconda3/envs/velovi-py39/lib/python3.9/site-packages/seaborn/categorical.py:381: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if LooseVersion(mpl.__version__) < "3.0":
/vol/storage/miniconda3/envs/velovi-py39/lib/python3.9/site-packages/setuptools/_distutils/version.py:346: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  other = LooseVersion(other)
../_images/4b03137016fe2213ae213d2514ce1099e3b56fca8c2f2f19a80a2f335240d968.png

Alpha cells#

lb, ub = np.percentile(alpha_cluster_data.var['mean_product_score_per_gene_alpha'], [5, 95])

n_genes_above_upper_percentile = (alpha_cluster_data.var['mean_product_score_per_gene_alpha'] > ub).sum()
n_genes_below_lower_percentile = (alpha_cluster_data.var['mean_product_score_per_gene_alpha'] < lb).sum()

print(f'Number of genes above percentile: {n_genes_above_upper_percentile}')
Number of genes above percentile: 54

Ngn3 high EP cells#

n_genes_above_upper_percentile = (ngn3_high_cluster_data.var['mean_product_score_per_gene_ngn3_high_ep'] > ub).sum()
n_genes_below_lower_percentile = (ngn3_high_cluster_data.var['mean_product_score_per_gene_ngn3_high_ep'] < lb).sum()

print(f'Number of genes above percentile: {n_genes_above_upper_percentile}')
Number of genes above percentile: 135

Phase portraits - Alpha cells#

color = adata.obs['clusters'].astype(str).replace(
    dict(zip(adata.obs['clusters'].cat.categories, adata.uns['clusters_colors']))
).tolist()

Highest velocity coherence

for gene in alpha_cluster_data.var['mean_product_score_per_gene_alpha'].sort_values().index[:5]:
    plot_phase_portrait(adata, gene, color)
../_images/89334ba3c41a5b69643655c09cae78b37ff44302a5cb317e8d78226f46097b51.png ../_images/6b07fe35bfc31df60283fc88e681f094edaed703e90b6a977ecafe56738e5ce7.png ../_images/a15c5483e3e5f1ec68ed84578f7457369fee8a3d4ee3b60573ef2d64843131b2.png ../_images/99514bf27eac3f339f01eea56635becbc878af38cf8589b1097d0df3abf438dc.png ../_images/fd00f1487be86c3fb20117130ac83324cd1259f9eca1d87b0efdeaa0b009157e.png

Lowest velocity coherence

for gene in alpha_cluster_data.var['mean_product_score_per_gene_alpha'].sort_values().index[-5:]:
    plot_phase_portrait(adata, gene, color)
../_images/501d106cdf4e6fc2a059d1c687b2aee99b22a26c931038adc9baba7bd0919411.png ../_images/8b023867157046a080ac1429a073a71da1e68497126e4349d6ec83e0212002be.png ../_images/4b60edfd8dd08a56bdef6c070c1d9415ba4d0872935fc3cc4af0d2060c05c5d2.png ../_images/d929eb2580f4a396d7952de2e8c0d0a22c365ee06bfd8bea7e70b68306eb21fe.png ../_images/52990cf38448e036ec8346b291b30523d5f4adeb17d413978128848904ee6c2c.png

Phase portraits - Ngn3 high EP cells#

Highest velocity coherence

for gene in ngn3_high_cluster_data.var['mean_product_score_per_gene_ngn3_high_ep'].sort_values().index[:5]:
    plot_phase_portrait(adata, gene, color)
../_images/36aeca5cee7ac050ef48de66fed2cb1a2baff7129c5da470dc80b5544140748a.png ../_images/e8195b2e847f82d98ad2dcaddd1e424ea6e0cb537a168b6509d2b0d5e70c3752.png ../_images/9fe754c2bcd5d2acdbc0f77cb6007784ac04b3a9fae7e31f6b34f0fd6318ed13.png ../_images/2f52f3470697ed14308cb81dac854811a8e4dd4df4b9ef4d559b77bae418672c.png ../_images/8ebaae42e332348e38352e9e44c1cfffba64ab23457521b58ee808dc06844b8b.png

Lowest velocity coherence

for gene in ngn3_high_cluster_data.var['mean_product_score_per_gene_ngn3_high_ep'].sort_values().index[-5:]:
    plot_phase_portrait(adata, gene, color)
../_images/91af519eb94b50330f57a7961ca28086433d193af21927746c8782cd6a244aef.png ../_images/37f508e46aba77bde272778e752f517880cd96f61099ba4242b279397f035810.png ../_images/92e61d62f03fa15817ca54ada7d6727c0d2d145f2890d2454fa5c85b414cff15.png ../_images/9418a3b9c7519ede0b1c70f3b5a0a34eb139fd1582ee3427a5ddb16acb7de6f7.png ../_images/b6130e219926ba929df8743e88d4dfdc033da6865d9d4b20413af92f8b398b47.png