CoSpar - dynamic inference by integrating transcriptome and lineage information
API¶
Import CoSpar as:
import cospar as cs
CoSpar is built around the AnnData
object (usually called adata). For each cell, we store its RNA count matrix at adata.X
, the gene names at adata.var_names
,time information at adata.obs['time_info']
, state annotation at adata.obs['state_info']
, clonal information at adata.obsm['X_clone']
, and 2-d embedding at adata.obsm['X_emb']
.
Once the AnnData
object is initialized via cs.pp.initialize_adata_object()
, the typical flow of analysis is to 1) perform preprocessing and dimension reduction (cs.pp.*
); 2) visualize and analyze clonal data alone (cs.pl.*
); 3) infer transition map (cs.tmap.*
); and 4) analyze inferred map (cs.tl.*
) and then visualize the results with the plotting functions (cs.pl.*
). Typically, each cs.tl.*
function has a corresponding cs.pl.*
function. We also provide several built-in datasets (cs.datasets.*
) and miscellaneous functions to assist with the analysis (cs.hf.*
). See tutorial for details.
Preprocessing¶
|
Initialized the |
|
Get highly variable genes. |
Remove cell-cycle correlated genes. |
|
|
Get X_pca. |
|
Get X_emb using |
|
Build the X_clone matrix from data. |
|
Update state_info using |
|
Refine state info according to marker gene expression. |
Refine state info by clustering states at given time points. |
Transition map inference¶
|
Infer transition map for clonal data with multiple time points. |
|
Infer transition map from clones with a single time point |
|
Infer transition map from state information alone. |
Compute transition map using only the lineage information. |
Analysis¶
|
Compute clonal fate bias towards a cluster. |
|
Find clones that significantly biased towards a given fate |
|
Compute fate coupling determined by the transition map. |
|
Build fate hierarchy or lineage trees |
|
Compute transition probability to given fate/ancestor clusters. |
|
Quantify how multi-potent a cell state is. |
|
Compute fate bias to given two fate clusters (A, B). |
|
Identify trajectories towards/from two given clusters. |
|
Infer trajectory towards/from a cluster |
|
Perform differential gene expression analysis and plot top DGE genes. |
Plotting¶
Clone analysis (clone visualization, clustering etc.)
|
Plot clones on top of state embedding. |
|
Plot barcode heatmap among different fate clusters. |
|
Plot clonal fate bias towards a cluster. |
|
Plot fate coupling determined by the transition map. |
|
Plot fate coupling determined by the transition map. |
|
Scatter plot for clonal fate number across time point |
|
Report the statistics of the clonal data. |
|
Visualize a tree structured in ete3 style. |
Transition map analysis (fate bias etc.)
|
Plot transition probability from given initial cell states. |
|
Plot transition probability to given fate/ancestor clusters. |
|
Plot fate potency. |
|
Plot fate bias. |
|
Plot the progenitors of given fate clusters. |
|
Plot the progenitors of given fates across time points |
|
Plot gene trend along the inferred dynamic trajectory. |
|
Plot fate coupling determined by the transition map. |
|
Plot fate coupling determined by the transition map. |
General
|
Scatter plot for user-specified embedding basis. |
|
A test embedding method for plotting genes |
|
Plot gene expression on the state manifold. |
|
Plot heatmap of gene expression within given clusters. |
|
Set resolution/size, styling and format of figures. |
Datasets¶
|
The hematopoiesis data set from |
|
The hematopoiesis data set from |
|
Top 15% most heterogeneous clones of the hematopoiesis data set from |
|
All of the hematopoiesis data set from |
|
The direct lung differentiation dataset from |
|
The reprogramming dataset from |
|
The reprogramming dataset from |
|
Synthetic clonal dataset with static barcoding. |
Help functions¶
|
Read file and return |
|
Save the adata and print the filename prefix. |
|
Save preprocessed adata. |
|
Check whether the adata has the right structure. |
|
Check available parameter choices. |
|
Update the ordering of time points at adata.uns[‘time_ordering’] |
|
Update data_des, a string to distinguish different datasets |
|
Compute the normalized correlation of the data matrix. |
Build the X_clone matrix from data. |
Simulations¶
|
Simulate linear differentiation corrupted with barcode collision (See Fig. |
|
Simulate bifurcation corrupted with clonal dispersion (See Fig. |
|
Quantify the correlation of an inferred fate bias with the actual one, using a map from the Bifurcation Model. |
|
Quantify the True positive rate of a transition map for linear differentiation model. |