In [1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as pl
import scanpy as sc

import scvelo as scv
scv.logging.print_version()
Running scvelo 0.1.24 (python 3.7.3) on 2019-10-28 18:44.
In [2]:
scv.settings.set_figure_params('scvelo', dpi_save=200, dpi=80, transparent=True)
scv.settings.plot_prefix = 'scvelo_fig3_'
scv.settings.verbosity = 2
In [3]:
adata = scv.datasets.pancreatic_endocrinogenesis()

Velocity Analysis of pancreatic endocrinogenesis - day 15

In [4]:
scv.pp.filter_and_normalize(adata, min_shared_counts=20, n_top_genes=2000)
scv.pp.moments(adata, n_neighbors=30, n_pcs=30)
Filtered out 20801 genes that are detected in less than 20 counts (shared).
Normalized count data: X, spliced, unspliced.
Logarithmized X.
computing neighbors
    finished (0:00:04)
computing moments based on connectivities
    finished (0:00:00)
In [5]:
scv.tl.velocity(adata, vkey='steady_state_velocity', mode='steady_state')
scv.tl.velocity_graph(adata, vkey='steady_state_velocity')

scv.tl.velocity(adata, vkey='stochastic_velocity', mode='stochastic')
scv.tl.velocity_graph(adata, vkey='stochastic_velocity')
computing velocities
    finished (0:00:00)
computing velocity graph
    finished (0:00:07)
computing velocities
    finished (0:00:01)
computing velocity graph
    finished (0:00:11)
In [6]:
scv.tl.recover_dynamics(adata)
recovering dynamics
    finished (0:13:41)
In [7]:
# adata.write('data/pancreas/endoDM.h5ad', compression='gzip')
# adata = scv.read('data/pancreas/endoDM.h5ad', cache=True)
In [8]:
scv.tl.velocity(adata, vkey='dynamical_velocity', mode='dynamical')
scv.tl.velocity_graph(adata, vkey='dynamical_velocity')
computing velocities
    finished (0:00:05)
computing velocity graph
    finished (0:00:07)
In [9]:
scv.pl.velocity_embedding_stream(adata, vkey='dynamical_velocity', title='', legend_fontsize=14, dpi=120)
computing velocity embedding
    finished (0:00:00)
In [10]:
scv.pl.velocity_embedding(adata, vkey='dynamical_velocity', arrow_length=3, arrow_size=1.4, dpi=200)