Mapping Vector Field of Single Cells
API
Import dynamo as:
import dynamo as dyn
Data IO
(See more at anndata-docs)
|
Read .h5ad-formatted hdf5 file. |
|
Read .h5ad-formatted hdf5 file. |
|
Read .loom-formatted hdf5 file. |
Preprocessing (pp)
|
This helper function converts unofficial gene names to official gene names. |
|
Basic filter of genes based a collection of expression filters. |
|
Utility function to filter mitochondria, ribsome protein and ERCC spike-in genes, etc. |
|
scale layers to a particular total expression value, similar to normalize_expr_data function. |
|
perform log1p transform on selected adata layers |
|
|
|
|
|
This function is partly based on Monocle R package (https://github.com/cole-trapnell-lab/monocle3). |
|
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
|
Function to search nearest neighbors of the adata object. |
|
Function to calculate mutual nearest neighbor graph across specific data layers. |
|
Calculate kNN based first and second moments (including uncentered covariance) for |
Kinetic parameters and RNA/protein velocity
|
Inclusive model of expression dynamics considers splicing, metabolic labeling and protein translation. |
Labeling Velocity recipes
|
An analysis recipe that properly pre-processes different layers for a degradation experiment with both labeling and splicing data or only labeling . |
|
An analysis recipe that properly pre-processes different layers for an kinetics experiment with both labeling and splicing or only labeling data. |
|
An analysis recipe that properly pre-processes different layers for an mixture kinetics and degradation experiment with both labeling and splicing or only labeling data. |
|
An analysis recipe that properly pre-processes different layers for an one-shot experiment with both labeling and splicing data. |
|
use new RNA based pca, umap, for velocity calculation and projection for kinetics or one-shot experiment. |
Dimension reduction
|
Compute a low dimension reduction projection of an annodata object first with PCA, followed by non-linear dimension reduction methods |
|
This function is a pure Python implementation of the DDRTree algorithm. |
|
This function is a pure Python implementation of the PSL algorithm. |
Clustering
|
Apply hdbscan to cluster cells in the space defined by basis. |
|
|
|
|
|
|
|
Spatially constrained clustering (scc) to identify continuous tissue domains. |
Velocity projection
|
Project high dimensional velocity vectors onto given low dimensional embeddings, and/or compute cell transition probabilities. |
|
Confidently compute transition probability and project high dimension velocity vector to existing low dimension embeddings using progenitors and mature cell groups priors. |
Velocity metrics
|
Calculate the cell-wise velocity confidence metric. |
|
Diagnostic measure to identify genes contributed to "wrong" directionality of the vector flow. |
Markov chain
|
Apply the diffusion map algorithm on the transition matrix build from Itô kernel. |
|
Compute stationary distribution of cells using the transition matrix. |
|
Find the state distribution of a Markov process. |
|
Find the expected returning time. |
Markers and differential expressions
|
Identify genes with strong spatial autocorrelation with Moran's I test. |
|
Find marker genes for each group of cells based on gene expression or velocity values as specified by the layer. |
|
Find marker genes between two groups of cells based on gene expression or velocity values as specified by the layer. |
|
Filter cluster deg (Moran's I test) results and retrieve top markers for each cluster. |
|
Differential genes expression tests using generalized linear regressions. |
Cell proliferation and apoptosis
|
Score cells based on a set of genes. |
|
Estimate the growth rate via clone information or logistic equation of population dynamics. |
*Converter and helper *
|
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 |
|
|
|
|
|
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
|
Learn a function of high dimensional vector field from sparse single cell samples in the entire space robustly. |
|
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. |
|
|
|
Initialize the VectorField class. |
|
|
|
Vector field topology
|
Cluster cells based on vector field features. |
|
Map the topography of the single cell vector field in (first) two dimensions. |
|
|
|
|
|
Assign each cell in our data to a fixed point. |
Beyond RNA velocity
|
Calculate the velocities for any cell state with the reconstructed vector field function. |
|
Calculate the speed for each cell with the reconstructed vector field function. |
|
Calculate Jacobian for each cell with the reconstructed vector field. |
|
Calculate divergence for each cell with the reconstructed vector field function. |
|
Calculate Curl for each cell with the reconstructed vector field function. |
|
Calculate acceleration for each cell with the reconstructed vector field function. |
|
Calculate curvature for each cell with the reconstructed vector field function. |
|
Calculate torsion for each cell with the reconstructed vector field function. |
|
Calculate Sensitivity matrix for each cell with the reconstructed vector field. |
Beyond velocity vector field
|
Compute RNA acceleration field via reconstructed vector field and project it to low dimensional embeddings. |
|
Compute RNA curvature field via reconstructed vector field and project it to low dimensional embeddings. |
Vector field ranking
|
Rank cell's absolute, positive, negative vector field metrics by different gene groups. |
|
Rank gene's absolute, positive, negative vector field metrics by different cell groups. |
|
Rank genes based on their expression values for each cell group. |
|
Rank genes based on their raw and absolute velocities for each cell group. |
|
Rank genes based on their diagonal Jacobian for each cell group. |
|
Rank genes based on their absolute, positive, negative accelerations for each cell group. |
|
Rank gene's absolute, positive, negative curvature by different cell groups. |
|
Rank genes or gene-gene interactions based on their Jacobian elements for each cell group. |
|
Rank genes based on their diagonal Sensitivity for each cell group. |
|
Rank genes or gene-gene interactions based on their sensitivity elements for each cell group. |
Single cell potential: three approaches
|
Calculate the fixed points of (learned) vector field function . |
|
Calculate the gradient of the (learned) vector field function for the least action path (LAP) symbolically |
|
Calculate the action of the path based on the (reconstructed) vector field function and diffusion matrix (Eq. |
Diffusion matrix can be variable dependent |
|
|
It calculates the minimized action value given an initial path, ODE, and diffusion matrix. |
|
Function to map out the pseudo-potential landscape. |
|
A deterministic map of Waddington’s epigenetic landscape for cell fate specification Sudin Bhattacharya, Qiang Zhang and Melvin E. |
|
Align potential values so all path-potentials end up at same global min and then generate potential surface with interpolation on a grid. |
|
Calculate action by path integral by Wang's method. |
|
Calculating least action path based methods from Jin Wang and colleagues (http://www.pnas.org/cgi/doi/10.1073/pnas.1017017108) |
|
Calculate the rate to convert from one cell state to another cell state by taking the optimal path. |
|
Calculate the MFPT (mean first passage time) to convert from one cell state to another cell state by taking the optimal path. |
|
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. |
|
Stochastic processes
|
"Calculate the diffusion matrix from the estimated velocity vector and the reconstructed vector field. |
Vector field clustering and graph
|
Cluster cells based on vector field features. |
|
|
|
A class for manipulating the graph creating from the transition matrix, built from the (reconstructed) vector field. |
Prediction (pd)
- toctree
_autosummary
pd.andecestor pd.fate pd.fate_bias pd.get_init_path pd.least_action pd.perturbation pd.state_graph pd.KO pd.rank_perturbation_cell_clusters pd.rank_perturbation_cells pd.rank_perturbation_genes pd.state_graph pd.tree_model
Plotting (pl)
Preprocessing
|
Plot the basic statics (nGenes, nCounts and pMito) of each category of adata. |
|
Plot the fraction of each category of data used in the velocity estimation. |
|
Plot selected feature genes on top of the mean vs. |
|
A biplot overlays a score plot and a loadings plot in a single graph. |
|
Plot the top absolute pca loading genes. |
|
Plot the accumulative variance explained by the principal components. |
|
[summary] |
|
Plot the (labeled) expression values of genes across different groups (time points). |
|
Bubble plots generalized to velocity, acceleration, curvature. |
Cell cycle staging
|
Plot a heatmap of cells ordered by cell cycle position |
Scatter base
|
Plot an embedding as points. |
Space plot
|
Scatter plot for physical coordinates of each cell. |
Phase diagram: conventional scRNA-seq
|
Draw the phase portrait, expression values , velocity on the low dimensional embedding. |
Kinetic models: labeling based scRNA-seq
|
Plot the data and fitting of different metabolic labeling experiments. |
Kinetics
|
Plot the gene expression dynamics over time (pseudotime or inferred real time) as kinetic curves. |
|
Plot the gene expression dynamics over time (pseudotime or inferred real time) in a heatmap. |
|
Plot the Jacobian dynamics over time (pseudotime or inferred real time) in a heatmap. |
|
Plot the Sensitivity dynamics over time (pseudotime or inferred real time) in a heatmap. |
Dimension reduction
|
Scatter plot with pca basis. |
|
Scatter plot with tsne basis. |
|
Scatter plot with umap basis. |
|
Scatter plot with trimap basis. |
Clustering
|
Scatter plot for leiden community detection in selected basis. |
|
Scatter plot for louvain community detection in selected basis. |
|
Scatter plot for infomap community detection in selected basis. |
|
Scatter plot for infomap community detection in selected basis. |
Neighbor graph
|
Plot nearest neighbor graph of cells used to embed data into low dimension space. |
|
Plot a summarized cell type (state) transition graph. |
Vector field plots: velocities and accelerations
|
Plot the velocity or acceleration vector of each cell. |
|
Plot the velocity or acceleration vector of each cell. |
|
Plot the velocity or acceleration vector of each cell on a grid. |
|
Plot the velocity vector of each cell. |
|
Visualize vector field with quiver, streamline and line integral convolution (LIC), using velocity estimates on a |
|
Plot the energy and energy change rate over each optimization iteration. |
|
Plot a interative 3d streamtube plot via plotly. |
Vector field topology
|
Plots the flow field with line thickness proportional to speed. |
|
Plot fixed points stored in the VectorField2D class. |
|
Plot fixed points stored in the VectorField2D class. |
|
Plot nullclines stored in the VectorField2D class. |
|
Plot separatrix on phase portrait. |
|
Plots a trajectory on a phase portrait. |
|
Plot the streamline, fixed points (attractor / saddles), nullcline, separatrices of a recovered dynamic system for single cells. |
|
Plot the lagged DREVI plot pairs of genes across pseudotime. |
Beyond RNA velocity
|
Scatter plot with cells colored by the estimated velocity speed (and other information if provided). |
|
Scatter plot with cells colored by the estimated divergence (and other information if provided). |
|
Scatter plot with cells colored by the estimated curl (and other information if provided). |
|
Scatter plot with cells colored by the estimated curvature (and other information if provided). |
|
Scatter plot of Jacobian values across cells. |
|
Plot the Jacobian matrix for each cell as a heatmap. |
|
Scatter plot of Sensitivity value across cells. |
|
Plot the Jacobian matrix for each cell as a heatmap. |
Regulatory network
|
Arc plot of gene regulatory network for a particular cell cluster. |
|
wrapper for drawing circos plot via nxviz >= 0.7.3 |
|
Note: this function is written with nxviz old version (<=0.3.x, or higher) API for the latest nxviz version compatibility, please refer to dyn.pl.circos_plot. |
|
Hive plot of cell cluster specific gene regulatory networks. |
Potential landscape
|
Plot the quasi-potential landscape. |
Cell fate
|
Draw the predicted integration paths on the low-dimensional embedding. |
|
Plot the lineage (fate) bias of cells states whose vector field trajectories are predicted. |
Heatmaps
|
Plot the heatmap for the expected value \(y(t)\) given \(x(t - d)\) and \(y(t - 1)\). |
|
Plot the combinatorial influence of two genes \(x\), \(y\) to the target \(z\). |
|
|
|
Plot the lagged DREVI plot pairs of genes across pseudotime. |
Predictions
|
Save figures
|
Save a figure from pyplot. |
Moive (mv)
Note
animation class is internally to mv.animate_fates. See our animation classes here: animation
|
Animating cell fate commitment prediction via reconstructed vector field function. |
Simulation (sim)
Simple ODE vector field simulation
|
The ODE model for the neurogenesis system that used in benchmarking Monocle 2, Scribe and dynamo (here), original from Xiaojie Qiu, et. |
|
Right hand side (rhs) for toggle ODEs. |
|
network used in the potential landscape paper from Ying, et. |
Gillespie simulation
|
A simulator of RNA dynamics that includes RNA bursting, transcription, metabolic labeling, splicing, transcription, RNA/protein degradation |
|
Simulate the gene expression dynamics via deterministic ODE model |
|
Sample N points from the dim dimension gene expression space while restricting the values to be between min_val and max_val. |
|
Function to evaluate the vector field related reference quantities vs. |
External (ext)
|
Modeling Latent Flow Structure using Hodge Decomposition based on the creation of sparse diffusion graph from the reconstructed vector field function. |
|
Perform gene list enrichment with gseapy. |
|
Apply Scribe to calculate causal network from spliced/unspliced, metabolic labeling based and other "real" time series datasets. |
|
Calculate co-expression measures, including mutual information (MI), pearson correlation, etc. |
Utilities
Package versions
|
Adapted from answer 2 in https://stackoverflow.com/questions/40428931/package-for-listing-version-of-packages-used-in-a-jupyter-notebook |
Clean up adata
|
clean up adata before saving it to a file |
Figures configuration
|
Set resolution/size, styling and format of figures. |
|
formatting helper function that can be used to save publishable figures |