User

Import dynamo as:

import dynamo as dyn

Data IO

read

Read .h5ad-formatted hdf5 file.

read_h5ad

Read .h5ad-formatted hdf5 file.

read_loom

Read .loom-formatted hdf5 file.

Preprocessing (pp)

Preprocessor class and recipe functions

pp.recipe_monocle

pp.recipe_velocyto

pp.Preprocessor

pp.filter_cells_by_outliers

Select valid cells based on a collection of filters including spliced, unspliced and protein min/max vals.

pp.filter_cells_by_highly_variable_genes

Filter cells based on the expression of highly variable genes.

Basic preprocessing functions

pp.filter_cells

Select valid cells based on a collection of filters including spliced, unspliced and protein min/max vals.

pp.filter_cells_by_outliers

Select valid cells based on a collection of filters including spliced, unspliced and protein min/max vals.

pp.filter_cells_by_highly_variable_genes

Filter cells based on the expression of highly variable genes.

pp.filter_cells_by_outliers

Select valid cells based on a collection of filters including spliced, unspliced and protein min/max vals.

pp.filter_genes_by_clusters

Prepare filtering genes on the basis of cluster-wise expression threshold.

pp.filter_genes_by_outliers

Basic filter of genes based a collection of expression filters.

pp.filter_genes_by_pattern

Utility function to filter mitochondria, ribsome protein and ERCC spike-in genes, etc.

pp.filter_genes

Basic filter of genes based a collection of expression filters.

pp.normalize_cell_expr_by_size_factors

pp.scale

Scale layers to a particular total expression value, similar to normalize_expr_data function.

pp.log1p

Perform log1p transform on selected adata layers

pp.pca

Perform PCA reduction for monocle recipe.

Gene selection

pp.highest_frac_genes

Compute top genes df and store results in adata.uns

pp.select_genes_monocle

Select genes based on monocle recipe.

pp.select_genes_by_pearson_residuals

Gene selection and normalization based on [Lause21].

Tools (tl)

kNN and moments of expressions

tl.neighbors

Search nearest neighbors of the adata object.

tl.mnn

Calculate mutual nearest neighbor graph across specific data layers.

tl.moments

Calculate kNN based first and second moments (including uncentered covariance) for different layers of data.

Kinetic parameters and RNA/protein velocity

tl.dynamics

Inclusive model of expression dynamics considers splicing, metabolic labeling and protein translation.

Labeling Velocity recipes

tl.recipe_deg_data

An analysis recipe that properly pre-processes different layers for a degradation experiment with both labeling and splicing data or only labeling.

tl.recipe_kin_data

An analysis recipe that properly pre-processes different layers for an kinetics experiment with both labeling and splicing or only labeling data.

tl.recipe_mix_kin_deg_data

An analysis recipe that properly pre-processes different layers for a mixture kinetics and degradation experiment with both labeling and splicing or only labeling data.

tl.recipe_one_shot_data

An analysis recipe that properly pre-processes different layers for a one-shot experiment with both labeling and splicing data.

tl.velocity_N

Use new RNA based pca, umap, for velocity calculation and projection for kinetics or one-shot experiment.

Labeling Velocity recipes

tl.reduceDimension

Compute a low dimension reduction projection of an AnnData object first with PCA, followed by non-linear dimension reduction methods

tl.DDRTree

Provides an implementation of the framework of reversed graph embedding (RGE).

tl.psl

This function is a pure Python implementation of the PSL algorithm.

Clustering

tl.hdbscan

Apply hdbscan to cluster cells in the space defined by basis.

tl.leiden

Apply leiden clustering to the input adata.

tl.louvain

Apply louvain clustering to adata.

tl.scc

Spatially constrained clustering (scc) to identify continuous tissue domains.

Velocity projection

tl.cell_velocities

Project high dimensional velocity vectors onto given low dimensional embeddings, and/or compute cell transition

tl.confident_cell_velocities

Compute transition probability and perform velocity projection

Velocity metrics

tl.cell_wise_confidence

Calculate the cell-wise velocity confidence metric.

tl.gene_wise_confidence

Diagnostic measure to identify genes contributed to "wrong" directionality of the vector flow.

tl.pseudotime_velocity

Embrace RNA velocity and velocity vector field analysis for pseudotime.

Markov chain

tl.generalized_diffusion_map

Apply the diffusion map algorithm on the transition matrix build from Itô kernel.

tl.stationary_distribution

Compute stationary distribution of cells using the transition matrix.

tl.diffusion

Find the state distribution of a Markov process.

tl.expected_return_time

Find the expected returning time.

Markers and differential expressions

tl.moran_i

Identify genes with strong spatial autocorrelation with Moran's I test.

tl.find_group_markers

Find marker genes for each group of cells based on gene expression or velocity values as specified by the layer.

tl.two_groups_degs

Find marker genes between two groups of cells based on gene expression or velocity as specified by the layer.

tl.top_n_markers

Filter cluster deg (Moran's I test) results and retrieve top markers for each cluster.

tl.glm_degs

Differential genes expression tests using generalized linear regressions.

Cell proliferation and apoptosis

tl.score_cells

Score cells based on a set of genes.

tl.cell_growth_rate

Estimate the growth rate via clone information or logistic equation of population dynamics.

Converter and helper

tl.converter

Convert adata to loom object or vice versa.

tl.run_scvelo

Run Scvelo over the AnnData.

tl.run_velocyto

Run velocyto over the AnnData object.

tl.vlm_to_adata

Conversion function from the velocyto world to the dynamo world.

Vector field (vf)

Vector field reconstruction

Note

Vector field class is internally to vf.VectorField. See our vector field classes here: [vector field](https://dynamo-release.readthedocs.io/en/latest/Class.html#vector-field)

vf.VectorField

Learn a function of high dimensional vector field from sparse single cell samples in the entire space robustly.

vf.SparseVFC

Apply sparseVFC (vector field consensus) algorithm to learn a functional form of the vector field from random samples with outlier on the entire space robustly and efficiently.

vf.BaseVectorField

The BaseVectorField class is a base class for storing and manipulating vector fields.

vf.SvcVectorField

vf.graphize_vecfld

vf.vector_field_function

Vector field topology

vf.cluster_field

Cluster cells based on vector field features.

vf.topography

Map the topography of the single cell vector field in (first) two or three dimensions.

vf.FixedPoints

The FixedPoints class stores a list of fixed points and their corresponding Jacobian matrices, and provides methods for computing the eigenvalues of the Jacobian matrices, determining the stability of the fixed points, and identifying saddle/stable fixed points.

vf.assign_fixedpoints

Assign each cell in our data to a fixed point.

Beyond RNA velocity

vf.velocities

Calculate the velocities for any cell state with the reconstructed vector field function.

vf.speed

Calculate the speed for each cell with the reconstructed vector field function.

vf.jacobian

Calculate Jacobian for each cell with the reconstructed vector field.

vf.divergence

Calculate divergence for each cell with the reconstructed vector field function.

vf.curl

Calculate Curl for each cell with the reconstructed vector field function.

vf.acceleration

Calculate acceleration for each cell with the reconstructed vector field function.

vf.curvature

Calculate curvature for each cell with the reconstructed vector field function.

vf.torsion

Calculate torsion for each cell with the reconstructed vector field function.

vf.sensitivity

Calculate Sensitivity matrix for each cell with the reconstructed vector field.

Beyond velocity vector field

vf.cell_accelerations

Compute RNA acceleration field via reconstructed vector field and project it to low dimensional embeddings.

vf.cell_curvatures

Compute RNA curvature field via reconstructed vector field and project it to low dimensional embeddings.

Vector field ranking

vf.rank_genes

Rank gene's absolute, positive, negative vector field metrics by different cell groups.

vf.rank_expression_genes

Rank genes based on their expression values for each cell group.

vf.rank_velocity_genes

Rank genes based on their raw and absolute velocities for each cell group.

vf.rank_divergence_genes

Rank genes based on their diagonal Jacobian for each cell group.

vf.rank_acceleration_genes

Rank genes based on their absolute, positive, negative accelerations for each cell group.

vf.rank_curvature_genes

Rank gene's absolute, positive, negative curvature by different cell groups.

vf.rank_jacobian_genes

Rank genes or gene-gene interactions based on their Jacobian elements for each cell group.

vf.rank_s_divergence_genes

Rank genes based on their diagonal Sensitivity for each cell group.

vf.rank_sensitivity_genes

Rank genes or gene-gene interactions based on their sensitivity elements for each cell group.

Single cell potential: three approaches

vf.gen_fixed_points

Calculate the fixed points of (learned) vector field function .

vf.gen_gradient

Calculate the gradient of the (learned) vector field function for the least action path (LAP) symbolically

vf.IntGrad

Calculate the action of the path based on the (reconstructed) vector field function and diffusion matrix (Eq.

vf.DiffusionMatrix

Diffusion matrix can be variable dependent

vf.action

It calculates the minimized action value given an initial path, ODE, and diffusion matrix.

vf.Potential

Function to map out the pseudo-potential landscape.

vf.path_integral

A deterministic map of Waddington’s epigenetic landscape for cell fate specification Sudin Bhattacharya, Qiang Zhang and Melvin E.

vf.alignment

Align potential values so all path-potentials end up at same global min and then generate potential surface with interpolation on a grid.

vf.Wang_action

Calculate action by path integral by Wang's method.

vf.Wang_LAP

Calculating least action path based methods from Jin Wang and colleagues (http://www.pnas.org/cgi/doi/10.1073/pnas.1017017108)

vf.transition_rate

Calculate the rate to convert from one cell state to another cell state by taking the optimal path.

vf.MFPT

Calculate the MFPT (mean first passage time) to convert from one cell state to another cell state by taking the optimal path.

vf.Ao_pot_map

Mapping potential landscape with the algorithm developed by Ao method. References: Potential in stochastic differential equations: novel construction. Journal of physics A: mathematical and general, Ao Ping, 2004.

vf.solveQ

Stochastic processes

vf.diffusionMatrix

Calculate the diffusion matrix from the estimated velocity vector and the reconstructed vector field.

Vector field clustering and graph

vf.cluster_field

Cluster cells based on vector field features.

vf.streamline_clusters

Cluster 2D streamlines based on vector field features.

vf.vfGraph

A class for manipulating the graph creating from the transition matrix, built from the (reconstructed) vector field.

Prediction (pd)

pd.andecestor

Predict the ancestors or descendants of a group of initial cells (states) with the given vector field function.

pd.fate

Predict the historical and future cell transcriptomic states over arbitrary time scales.

pd.fate_bias

Calculate the lineage (fate) bias of states whose trajectory are predicted.

pd.get_init_path

Get the initial path for the least action path calculation.

pd.least_action

Calculate the optimal paths between any two cell states.

pd.perturbation

In silico perturbation of single-cells and prediction of cell fate after perturbation.

pd.state_graph

Estimate the transition probability between cell types using method of vector field integrations or Markov chain lumping.

pd.KO

In silico knockout genes (and thus the vector field function) and prediction of cell fate after knockout.

pd.rank_perturbation_cell_clusters

Rank cells based on their raw and absolute perturbation for each cell group.

pd.rank_perturbation_cells

Rank cells based on their raw and absolute perturbation for each cell group.

pd.rank_perturbation_genes

Rank genes based on their raw and absolute perturbation effects for each cell group.

pd.tree_model

This function learns a tree model of cell states (types).

Plotting (pl)

Preprocessing

pl.basic_stats

Plot the basic statics (nGenes, nCounts and pMito) of each category of adata.

pl.show_fraction

Plot the fraction of each category of data used in the velocity estimation.

pl.feature_genes

Plot selected feature genes on top of the mean vs.

pl.biplot

A biplot overlays a score plot and a loadings plot in a single graph.

pl.loading

Plot the top absolute pca loading genes.

pl.variance_explained

Plot the accumulative variance explained by the principal components.

pl.highest_frac_genes

Plot the top genes.

pl.exp_by_groups

Plot the (labeled) expression values of genes across different groups (time points).

pl.bubble

Bubble plots generalized to velocity, acceleration, curvature.

Cell cycle staging

pl.cell_cycle_scores

Plot a heatmap of cells ordered by cell cycle position.

Scatter base

pl.scatters

Plot an embedding as points.

Space plot

pl.space

Scatter plot for physical coordinates of each cell.

Phase diagram: conventional scRNA-seq

pl.phase_portraits

Draw the phase portrait, expression values, velocity on the low dimensional embedding.

Kinetic models: labeling based scRNA-seq

pl.dynamics

Plot the data and fitting of different metabolic labeling experiments.

Kinetics

pl.kinetic_curves

Plot the gene expression dynamics over time (pseudotime or inferred real time) as kinetic curves.

pl.kinetic_heatmap

Plot the gene expression dynamics over time (pseudotime or inferred real time) in a heatmap.

pl.jacobian_kinetics

Plot the Jacobian dynamics over time (pseudotime or inferred real time) in a heatmap.

pl.sensitivity_kinetics

Plot the Sensitivity dynamics over time (pseudotime or inferred real time) in a heatmap.

Dimension reduction

pl.pca

Scatter plot with pca basis.

pl.tsne

Scatter plot with tsne basis.

pl.umap

Scatter plot with umap basis.

pl.trimap

Scatter plot with trimap basis.

Clustering

pl.leiden

Scatter plot for leiden community detection in selected basis.

pl.louvain

Scatter plot for louvain community detection in selected basis.

pl.infomap

Scatter plot for infomap community detection in selected basis.

pl.streamline_clusters

Scatter plot for visualizing streamline clusters in selected basis.

Neighbor graph

pl.nneighbors

Plot nearest neighbor graph of cells used to embed data into low dimension space.

pl.state_graph

Plot a summarized cell type (state) transition graph.

Vector field plots: velocities and accelerations

pl.cell_wise_vectors

Plot the velocity or acceleration vector of each cell.

pl.cell_wise_vectors_3d

Plot the velocity or acceleration vector of each cell.

pl.grid_vectors

Plot the velocity or acceleration vector of each cell on a grid.

pl.streamline_plot

Plot the velocity vector of each cell.

pl.line_integral_conv

Visualize vector field with quiver, streamline and line integral convolution (LIC), using velocity estimates on a

pl.plot_energy

Plot the energy and energy change rate over each optimization iteration.

pl.plot_3d_streamtube

Plot an interative 3d streamtube plot via plotly.

Vector field topology

pl.plot_flow_field

Plots the flow field with line thickness proportional to speed.

pl.plot_fixed_points

Plot fixed points stored in the VectorField class.

pl.plot_fixed_points_2d

Plot fixed points stored in the VectorField2D class.

pl.plot_nullclines

Plot nullclines stored in the VectorField2D class.

pl.plot_separatrix

Plot separatrix on phase portrait.

pl.plot_traj

Plots a trajectory on a phase portrait.

pl.topography

Plot the streamline, fixed points (attractor / saddles), nullcline, separatrices of a recovered dynamic system for single cells.

pl.response

Plot the lagged DREVI plot pairs of genes across pseudotime.

Beyond RNA velocity

pl.speed

Scatter plot with cells colored by the estimated velocity speed (and other information if provided).

pl.divergence

Scatter plot with cells colored by the estimated divergence (and other information if provided).

pl.acceleration

Scatter plot with cells colored by the estimated acceleration (and other information if provided).

pl.curl

Scatter plot with cells colored by the estimated curl (and other information if provided).

pl.curvature

Scatter plot with cells colored by the estimated curvature (and other information if provided).

pl.jacobian

Scatter plot of Jacobian values across cells.

pl.jacobian_heatmap

Plot the Jacobian matrix for each cell or the average Jacobian matrix of the cells from input indices as a heatmap.

pl.sensitivity

Scatter plot of Sensitivity value across cells.

pl.sensitivity_heatmap

Plot the Jacobian matrix for each cell as a heatmap.

Regulatory network

pl.arcPlot

Arc plot of gene regulatory network for a particular cell cluster.

pl.circosPlot

wrapper for drawing circos plot via nxviz >= 0.7.3

pl.circosPlotDeprecated

Deprecated.

pl.hivePlot

Hive plot of cell cluster specific gene regulatory networks.

Potential landscape

pl.show_landscape

Plot the quasi-potential landscape.

Cell fate

pl.fate

Draw the predicted integration paths on the low-dimensional embedding.

pl.fate_bias

Plot the lineage (fate) bias of cells states whose vector field trajectories are predicted.

Heatmaps

pl.causality

Plot the heatmap for the expected value z(t) given x and y data.

pl.comb_logic

Plot the combinatorial influence of two genes x, y to the target z.

pl.plot_hill_function

Plot the hill function curve generated by dynamo.pl.response.

pl.response

Plot the lagged DREVI plot pairs of genes across pseudotime.

Predictions

pl.lap_min_time

Plot minimum time of the least action paths.

Save figures

pl.save_fig

Save a figure from pyplot.

Movie (mv)

Note

animation class is internally to mv.animate_fates. See our animation classes here: [animation](https://dynamo-release.readthedocs.io/en/latest/Class.html#movie)

mv.animate_fates

Animating cell fate commitment prediction via reconstructed vector field function.

Simulation (sim)

Simple ODE vector field simulation

sim.toggle

Calculates the right-hand side (RHS) of the differential equations for the toggle switch system.

sim.Ying_model

Solve the equation from the network used in the potential landscape paper from Ying, et. al:

Gillespie simulation

sim.Gillespie

A simulator of RNA dynamics that includes RNA bursting, transcription, metabolic labeling, splicing, transcription, RNA/protein degradation.

sim.Simulator

Simulate the gene expression dynamics via deterministic ODE model

sim.state_space_sampler

Sample N points from the dim dimension gene expression space while restricting the values to be between min_val and max_val.

sim.evaluate

Function to evaluate the vector field related reference quantities vs.

External (ext)

ext.ddhodge

Modeling Latent Flow Structure using Hodge Decomposition based on the creation of sparse diffusion graph from the reconstructed vector field function.

ext.enrichr

Perform gene list enrichment with gseapy.

ext.scribe

Apply Scribe to calculate causal network from spliced/unspliced, metabolic labeling based and other "real" time series datasets.

ext.coexp_measure

Calculate co-expression measures, including mutual information (MI), pearson correlation, etc.

ext.scifate_glmnet

Perform scifate analysis using glmnet.

Utilities

Package versions

get_all_dependencies_version

Get the version of all dependencies of Dynamo.

Clean up adata

cleanup

Clean up adata before saving it to a file.

Figures configuration

configuration.set_figure_params

Set resolution/size, styling and format of figures.

configuration.set_pub_style

Formatting helper function that can be used to save publishable figures.