scvelo - RNA velocity generalized through dynamical modeling


Import scVelo as:

import scvelo as scv

After reading the data ( or loading an in-built dataset (scv.datasets.*), the typical workflow consists of subsequent calls of preprocessing (scv.pp.*), analysis tools (*) and plotting (*). Further, several utilities (scv.utils.*) are provided to facilitate data analysis.

Read / Load

read(filename[, backed, sheet, ext, …]) Read file and return AnnData object.
read_loom(filename, *[, sparse, cleanup, …]) Read .loom-formatted hdf5 file.

Preprocessing (pp)

Basic preprocessing (gene selection and normalization)

pp.filter_genes(data[, min_counts, …]) Filter genes based on number of cells or counts.
pp.filter_genes_dispersion(data[, flavor, …]) Extract highly variable genes.
pp.normalize_per_cell(data[, …]) Normalize each cell by total counts over all genes.
pp.log1p(data[, copy]) Logarithmize the data matrix.
pp.filter_and_normalize(data[, min_counts, …]) Filtering, normalization and log transform

Moments (across nearest neighbors in PCA space)

pp.pca(data[, n_comps, zero_center, …]) Principal component analysis [Pedregosa11].
pp.neighbors(adata[, n_neighbors, n_pcs, …]) Compute a neighborhood graph of observations.
pp.moments(data[, n_neighbors, n_pcs, mode, …]) Computes moments for velocity estimation.

Tools (tl)

Clustering and embedding (more at scanpy-docs)

tl.louvain(adata[, resolution, …]) Cluster cells into subgroups [Blondel08] [Levine15] [Traag17].
tl.umap(adata[, min_dist, spread, …]) Embed the neighborhood graph using UMAP [McInnes18].

Velocity estimation

tl.velocity(data[, vkey, mode, fit_offset, …]) Estimates velocities in a gene-specific manner.
tl.velocity_graph(data[, vkey, xkey, tkey, …]) Computes velocity graph based on cosine similarities.
tl.velocity_embedding(data[, basis, vkey, …]) Projects the single cell velocities into any embedding.

Dynamical modeling

tl.recover_dynamics(data[, var_names, …]) Recovers the full splicing kinetics of specified genes.
tl.differential_kinetic_test(data[, …]) Test to detect cell types / lineages with different kinetics.

Dynamical genes

tl.rank_velocity_genes(data[, vkey, …]) Rank genes for velocity characterizing groups.
tl.rank_dynamical_genes(data[, n_genes, …]) Rank genes by likelihoods per cluster/regime.

Pseudotime and trajectory inference

tl.terminal_states(data[, vkey, modality, …]) Computes terminal states (root and end points).
tl.velocity_pseudotime(adata[, vkey, …]) Computes a pseudotime based on the velocity graph.
tl.latent_time(data[, vkey, min_likelihood, …]) Computes a gene-shared latent time.
tl.paga(adata[, groups, vkey, …]) PAGA graph with velocity-directed edges.

Further tools

tl.velocity_clusters(data[, vkey, …]) Computes velocity clusters via louvain on velocities.
tl.velocity_confidence(data[, vkey, copy]) Computes confidences of velocities.
tl.score_genes_cell_cycle(adata[, s_genes, …]) Score cell cycle genes.

Plotting (pl)

Base scatter plot

pl.scatter([adata, basis, x, y, vkey, …]) Scatter plot along observations or variables axes.

Velocity embeddings

pl.velocity_embedding(adata[, basis, vkey, …]) Scatter plot of velocities on the embedding.
pl.velocity_embedding_grid(adata[, basis, …]) Scatter plot of velocities on a grid.
pl.velocity_embedding_stream(adata[, basis, …]) Stream plot of velocities on the embedding.

Velocity graph

pl.velocity(adata[, var_names, basis, vkey, …]) Phase and velocity plot for set of genes.
pl.velocity_graph(adata[, basis, vkey, …]) Plot of the velocity graph.
pl.paga(adata[, basis, vkey, color, layer, …]) Plot PAGA graph with velocity-directed edges.

Further plotting

pl.proportions(adata[, groupby, layers, …]) Plot pie chart of spliced/unspliced proprtions.
pl.heatmap(adata, var_names[, sortby, …]) Plot time series for genes as heatmap.
pl.hist(arrays[, alpha, bins, color, …]) Plot a histogram.


datasets.pancreas([file_path]) Pancreatic endocrinogenesis
datasets.dentategyrus([file_path, adjusted]) Dentate Gyrus neurogenesis.
datasets.forebrain([file_path]) Developing human forebrain.
datasets.dentategyrus_lamanno([file_path]) Dentate Gyrus neurogenesis.
datasets.gastrulation([file_path]) Mouse gastrulation.
datasets.gastrulation_e75([file_path]) Mouse gastrulation subset to E7.5.
datasets.gastrulation_erythroid([file_path]) Mouse gastrulation subset to erythroid lineage.
datasets.bonemarrow([file_path]) Human bone marrow.
datasets.pbmc68k([file_path]) Peripheral blood mononuclear cells.
datasets.simulation([n_obs, n_vars, alpha, …]) Simulation of mRNA splicing kinetics.


Get data by key

get_df(data[, keys, layer, index, columns, …]) Get dataframe for a specified adata key.

Get gene info

utils.gene_info(name[, fields]) Retrieve gene information from biothings client.

Data preparation

utils.cleanup(adata[, clean, keep, inplace]) Delete not needed attributes.
utils.clean_obs_names(adata[, alphabet, …]) Clean up the obs_names.
utils.merge(adata, ldata[, copy]) Merge two annotated data matrices.
utils.show_proportions(adata[, layers, use_raw]) Proportions of abundances of modalities in layers.


utils.get_moments(adata[, layer, …]) Computes moments for a specified layer.
utils.get_transition_matrix(adata[, vkey, …]) Computes cell-to-cell transition probabilities
utils.get_cell_transitions(adata[, …]) Simulate cell transitions
utils.get_extrapolated_state(adata[, vkey, …]) Get extrapolated cell state.


utils.convert_to_ensembl([gene_names]) Retrieve ensembl IDs from a list of gene names.
utils.convert_to_gene_names([ensembl_names]) Retrieve gene names from ensembl IDs.

Least squares and correlation

utils.leastsq(x, y[, fit_offset, perc, …]) Solves least squares X*b=Y for b.
utils.vcorrcoef(X, y[, mode, axis]) Pearsons/Spearmans correlation coefficients.
utils.test_bimodality(x[, bins, kde, plot]) Test for bimodal distribution.


set_figure_params([style, dpi, dpi_save, …]) Set resolution/size, styling and format of figures.