Mapping Vector Field of Single Cells

API

Import dynamo as:

import dynamo as dyn

Data IO

(See more at anndata-docs)

read(filename[, backed, as_sparse, ...])

Read .h5ad-formatted hdf5 file.

read_h5ad(filename[, backed, as_sparse, ...])

Read .h5ad-formatted hdf5 file.

read_loom(filename[, sparse, cleanup, ...])

Read .loom-formatted hdf5 file.

Preprocessing (pp)

pp.recipe_monocle(adata[, reset_X, tkey, ...])

This function is partly based on Monocle R package (https://github.com/cole-trapnell-lab/monocle3).

pp.cell_cycle_scores(adata[, layer, ...])

Call cell cycle positions for cells within the population.

Estimation (est)

Note

Classes in est are internally to Tools. See our estimation classes here: estimation

Tools (tl)

kNN and moments of expressions

tl.neighbors(adata[, X_data, genes, basis, ...])

Function to search nearest neighbors of the adata object.

tl.mnn(adata[, n_pca_components, ...])

Function to calculate mutual nearest neighbor graph across specific data layers.

tl.moments(adata[, X_data, genes, group, ...])

Calculate kNN based first and second moments (including uncentered covariance) for

Kinetic parameters and RNA/protein velocity

tl.dynamics(adata[, filter_gene_mode, ...])

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

Dimension reduction

tl.reduceDimension(adata[, X_data, genes, ...])

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

tl.DDRTree(X, maxIter, sigma, gamma[, eps, ...])

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

tl.psl(Y[, sG, dist, K, C, param_gamma, d, ...])

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

Clustering

tl.hdbscan(adata[, X_data, genes, layer, ...])

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

Velocity projection

tl.cell_velocities(adata[, ekey, vkey, X, ...])

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

tl.confident_cell_velocities(adata, group, ...)

Confidently compute transition probability and project high dimension velocity vector to existing low dimension embeddings using progenitors and mature cell groups priors.

Velocity metrics

tl.cell_wise_confidence(adata[, X_data, ...])

Calculate the cell-wise velocity confidence metric.

tl.gene_wise_confidence(adata, group[, ...])

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

Markov chain

tl.generalized_diffusion_map(adata, **kwargs)

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

tl.stationary_distribution(adata[, method, ...])

Compute stationary distribution of cells using the transition matrix.

tl.diffusion(M[, P0, steps, backward])

Find the state distribution of a Markov process.

tl.expected_return_time(M[, backward])

Find the expected returning time.

Markers and differential expressions

tl.moran_i(adata[, X_data, genes, layer, ...])

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

tl.find_group_markers(adata, group[, genes, ...])

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

tl.two_groups_degs(adata, genes, layer, ...)

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

tl.top_n_markers(adata[, with_moran_i, ...])

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

tl.glm_degs(adata[, X_data, genes, layer, ...])

Differential genes expression tests using generalized linear regressions.

Cell proliferation and apoptosis

tl.score_cells(adata[, genes, layer, basis, ...])

Score cells based on a set of genes.

tl.cell_growth_rate(adata, group, source, target)

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

Converter

tl.converter(data_in[, from_type, to_type, dir])

convert adata to loom object - we may save_fig to a temp directory automatically - we may write a on-the-fly converter which doesn't involve saving and reading files

Vector field (vf)

Vector field reconstruction

Note

Vector field class is internally to vf.VectorField. See our vector field classes here: vector field

vf.SparseVFC(X, Y, Grid[, M, a, beta, ecr, ...])

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.

Vector field topology

vf.topography(adata[, basis, layer, X, ...])

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

Beyond RNA velocity

vf.velocities(adata, init_cells[, ...])

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

vf.speed(adata[, basis, vector_field_class, ...])

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

vf.divergence(adata[, cell_idx, sampling, ...])

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

vf.curl(adata[, basis, vector_field_class, ...])

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

vf.acceleration(adata[, basis, ...])

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

vf.curvature(adata[, basis, ...])

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

vf.torsion(adata[, basis, vector_field_class])

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

Beyond velocity vector field

vf.cell_accelerations(adata[, vf_basis, ...])

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

vf.cell_curvatures(adata[, vf_basis, basis, ...])

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

Vector field ranking

vf.rank_velocity_genes(adata[, vkey, ...])

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

vf.rank_divergence_genes(adata[, jkey, ...])

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

vf.rank_acceleration_genes(adata[, akey, ...])

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

vf.rank_curvature_genes(adata[, ckey, ...])

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

Single cell potential: three approaches

vf.gen_fixed_points(func, auto_func, ...[, ...])

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

vf.gen_gradient(dim, N, Function, ...)

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

vf.IntGrad(points, Function, DiffusionMatrix, dt)

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

vf.DiffusionMatrix(x)

Diffusion matrix can be variable dependent

vf.action(n_points, tmax, point_start, ...)

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

vf.Potential(adata[, DiffMat, method])

Function to map out the pseudo-potential landscape.

vf.path_integral(VecFnc, x_lim, y_lim, ...)

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

vf.alignment(numPaths, numTimeSteps, ...[, ...])

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(X_input, F, D, dim, N[, lamada_])

Calculate action by path integral by Wang's method.

vf.Wang_LAP(F, n_points, point_start, point_end)

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

vf.transition_rate(X_input, F[, D, lambda_])

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

vf.MFPT(X_input, F[, D, lambda_])

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(vecFunc, X[, D])

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(*args, **kw)

Stochastic processes

vf.diffusionMatrix(adata[, X_data, V_data, ...])

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

Vector field graph

vf.vfGraph(*args, **kwds)

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

Prediction (pd)

pd.fate(adata, init_cells[, init_states, ...])

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

pd.fate_bias(adata, group[, basis, inds, ...])

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

pd.state_graph(adata, group[, method, ...])

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

Plotting (pl)

Preprocessing

pl.basic_stats(adata[, group, figsize, ...])

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

pl.show_fraction(adata[, genes, group, ...])

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

pl.feature_genes(adata[, layer, mode, ...])

Plot selected feature genes on top of the mean vs.

pl.variance_explained(adata[, threshold, ...])

Plot the accumulative variance explained by the principal components.

pl.exp_by_groups(adata, genes[, layer, ...])

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

Cell cycle staging

pl.cell_cycle_scores(adata[, cells, ...])

Plot a heatmap of cells ordered by cell cycle position

Scatter base

pl.scatters(adata[, basis, x, y, color, ...])

Plot an embedding as points.

Phase diagram: conventional scRNA-seq

pl.phase_portraits(adata, genes[, x, y, ...])

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

Kinetic models: labeling based scRNA-seq

pl.dynamics(adata, genes[, unit, ...])

Plot the data and fitting of different metabolic labeling experiments.

Kinetics

pl.kinetic_curves(adata, genes[, mode, ...])

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

pl.kinetic_heatmap(adata, genes[, mode, ...])

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

pl.jacobian_kinetics(adata[, basis, ...])

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

Dimension reduction

pl.pca(adata, *args, **kwargs)

Scatter plot with pca basis.

pl.tsne(adata, *args, **kwargs)

Scatter plot with tsne basis.

pl.umap(adata, *args, **kwargs)

Scatter plot with umap basis.

pl.trimap(adata, *args, **kwargs)

Scatter plot with trimap basis.

Neighbor graph

pl.nneighbors(adata[, x, y, color, basis, ...])

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

pl.state_graph(adata[, group, ...])

Plot a summarized cell type (state) transition graph.

Vector field plots: velocities and accelerations

pl.cell_wise_vectors(adata[, basis, x, y, ...])

Plot the velocity or acceleration vector of each cell.

pl.grid_vectors(adata[, basis, x, y, ekey, ...])

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

pl.streamline_plot(adata[, basis, x, y, ...])

Plot the velocity vector of each cell.

pl.line_integral_conv(adata[, basis, ...])

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

pl.plot_energy(adata[, basis, vecfld_dict, ...])

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

Vector field topology

pl.plot_flow_field(vecfld, x_range, y_range)

Plots the flow field with line thickness proportional to speed.

pl.plot_fixed_points(vecfld[, vecfld_dict, ...])

Plot fixed points stored in the VectorField2D class.

pl.plot_nullclines(vecfld[, vecfld_dict, ...])

Plot nullclines stored in the VectorField2D class.

pl.plot_separatrix(vecfld, x_range, y_range, t)

Plot separatrix on phase portrait.

pl.plot_traj(f, y0, t[, args, lw, ...])

Plots a trajectory on a phase portrait.

pl.topography(adata[, basis, fps_basis, x, ...])

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

Beyond RNA velocity

pl.speed(adata[, basis, color, frontier])

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

pl.divergence(adata[, basis, color, cmap, ...])

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

pl.curl(adata[, basis, color, cmap, ...])

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

pl.curvature(adata[, basis, color, frontier])

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

pl.jacobian(adata[, regulators, effectors, ...])

Scatter plot of Jacobian values across cells.

pl.jacobian_heatmap(adata, cell_idx[, jkey, ...])

Plot the Jacobian matrix for each cell as a heatmap.

Potential landscape

pl.show_landscape(adata, Xgrid, Ygrid, Zgrid)

Plot the quasi-potential landscape.

Cell fate

pl.fate_bias(adata, group[, basis, ...])

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

Save figures

pl.save_fig([path, prefix, dpi, ext, ...])

Save a figure from pyplot.

Moive (mv)

Note

animation class is internally to mv.animate_fates. See our animation classes here: animation

mv.animate_fates(adata[, basis, dims, ...])

Animating cell fate commitment prediction via reconstructed vector field function.

Simulation (sim)

Simple ODE vector field simulation

sim.two_genes_motif(x[, t, a1, a2, b1, b2, ...])

The ODE model for the famous Pu.1-Gata.1 like network motif with self-activation and mutual inhibition.

sim.neurogenesis(x[, t, mature_mu, n, k, a, ...])

The ODE model for the neurogenesis system that used in benchmarking Monocle 2, Scribe and dynamo (here), original from Xiaojie Qiu, et.

sim.toggle(ab[, t, beta, gamma, n])

Right hand side (rhs) for toggle ODEs.

sim.Ying_model(x[, t])

network used in the potential landscape paper from Ying, et.

Gillespie simulation

sim.Gillespie([a, b, la, aa, ai, si, be, ...])

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

sim.Simulator([motif, seed_num, clip, cell_num])

Simulate the gene expression dynamics via deterministic ODE model

sim.state_space_sampler(ode, dim[, ...])

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

sim.evaluate(reference, prediction[, metric])

Function to evaluate the vector field related reference quantities vs.

External (ext)

ext.ddhodge(adata[, X_data, layer, basis, ...])

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

ext.enrichr(genes, organism[, background, ...])

Perform gene list enrichment with gseapy.

ext.scribe(adata[, genes, TFs, Targets, ...])

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

ext.coexp_measure(adata, genes, layer_x, layer_y)

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

Utilities

Package versions

get_all_dependencies_version([display])

Adapted from answer 2 in https://stackoverflow.com/questions/40428931/package-for-listing-version-of-packages-used-in-a-jupyter-notebook

Clean up adata

cleanup(adata[, del_prediction, del_2nd_moments])

clean up adata before saving it to a file

Figures configuration

configuration.set_figure_params([dynamo, ...])

Set resolution/size, styling and format of figures.

configuration.set_pub_style([scaler])

formatting helper function that can be used to save publishable figures