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

pp.initialize_adata_object([adata, X_state, …])

Initialized the AnnData object.

pp.get_highly_variable_genes(adata[, …])

Get highly variable genes.

pp.remove_cell_cycle_correlated_genes(adata)

Remove cell-cycle correlated genes.

pp.get_X_pca(adata[, n_pca_comp])

Get X_pca.

pp.get_X_emb(adata[, n_neighbors, umap_min_dist])

Get X_emb using scanpy.tl.umap()

pp.get_X_clone(adata, clone_data_cell_id, …)

Build the X_clone matrix from data.

pp.get_state_info(adata[, n_neighbors, …])

Update state_info using scanpy.tl.leiden()

pp.refine_state_info_by_marker_genes(adata, …)

Refine state info according to marker gene expression.

pp.refine_state_info_by_leiden_clustering(adata)

Refine state info by clustering states at given time points.

Transition map inference

tmap.infer_Tmap_from_multitime_clones(adata_orig)

Infer transition map for clonal data with multiple time points.

tmap.infer_Tmap_from_one_time_clones(adata_orig)

Infer transition map from clones with a single time point

tmap.infer_Tmap_from_state_info_alone(adata_orig)

Infer transition map from state information alone.

tmap.infer_Tmap_from_clonal_info_alone(…)

Compute transition map using only the lineage information.

Analysis

tl.clonal_fate_bias(adata[, selected_fate, …])

Compute clonal fate bias towards a cluster.

tl.fate_biased_clones(adata, selected_fate)

Find clones that significantly biased towards a given fate

tl.fate_coupling(adata[, selected_fates, …])

Compute fate coupling determined by the transition map.

tl.fate_hierarchy(adata[, selected_fates, …])

Build fate hierarchy or lineage trees

tl.fate_map(adata[, selected_fates, source, …])

Compute transition probability to given fate/ancestor clusters.

tl.fate_potency(adata[, selected_fates, …])

Quantify how multi-potent a cell state is.

tl.fate_bias(adata[, selected_fates, …])

Compute fate bias to given two fate clusters (A, B).

tl.progenitor(adata[, selected_fates, …])

Identify trajectories towards/from two given clusters.

tl.iterative_differentiation(adata[, …])

Infer trajectory towards/from a cluster

tl.differential_genes(adata[, cell_group_A, …])

Perform differential gene expression analysis and plot top DGE genes.

Plotting

Clone analysis (clone visualization, clustering etc.)

pl.clones_on_manifold(adata[, …])

Plot clones on top of state embedding.

pl.barcode_heatmap(adata[, selected_times, …])

Plot barcode heatmap among different fate clusters.

pl.clonal_fate_bias(adata[, show_histogram, FDR])

Plot clonal fate bias towards a cluster.

pl.fate_coupling(adata[, source, color_bar, …])

Plot fate coupling determined by the transition map.

pl.fate_hierarchy(adata[, source, …])

Plot fate hierarchy determined by the transition map.

pl.clonal_fates_across_time(adata, …)

Scatter plot for clonal fate number across time point

pl.clonal_reports(adata[, selected_times])

Report the statistics of the clonal data.

pl.visualize_tree(input_tree[, …])

Visualize a tree structured in ete3 style.

Transition map analysis (fate bias etc.)

pl.single_cell_transition(adata, …[, …])

Plot transition probability from given initial cell states.

pl.fate_map(adata[, selected_fates, source, …])

Plot transition probability to given fate/ancestor clusters.

pl.fate_potency(adata[, source, …])

Plot fate potency.

pl.fate_bias(adata[, selected_fates, …])

Plot fate bias.

pl.progenitor(adata[, selected_fates, …])

Plot the progenitors of given fate clusters.

pl.iterative_differentiation(adata[, …])

Plot the progenitors of given fates across time points

pl.gene_expression_dynamics(adata, …[, …])

Plot gene trend along the inferred dynamic trajectory.

pl.fate_coupling(adata[, source, color_bar, …])

Plot fate coupling determined by the transition map.

pl.fate_hierarchy(adata[, source, …])

Plot fate hierarchy determined by the transition map.

General

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

Scatter plot for user-specified embedding basis.

pl.embedding_genes(adata[, basis, color, …])

A test embedding method for plotting genes

pl.gene_expression_on_manifold(adata, …[, …])

Plot gene expression on the state manifold.

pl.gene_expression_heatmap(adata[, …])

Plot heatmap of gene expression within given clusters.

settings.set_figure_params([style, dpi, …])

Set resolution/size, styling and format of figures.

Datasets

datasets.hematopoiesis([data_des])

The hematopoiesis data set from

datasets.hematopoiesis_130K([data_des])

The hematopoiesis data set from

datasets.hematopoiesis_subsampled([data_des])

Top 15% most heterogeneous clones of the hematopoiesis data set from

datasets.hematopoiesis_Gata1_states([data_des])

All of the hematopoiesis data set from

datasets.lung([data_des])

The direct lung differentiation dataset from

datasets.reprogramming([data_des])

The reprogramming dataset from

datasets.reprogramming_Day0_3_28([data_des])

The reprogramming dataset from

datasets.synthetic_bifurcation([data_des])

Synthetic clonal dataset with static barcoding.

Help functions

hf.read(filename[, backed, sheet, ext, …])

Read file and return AnnData object.

hf.save_map(adata)

Save the adata and print the filename prefix.

hf.save_preprocessed_adata(adata[, data_des])

Save preprocessed adata.

hf.check_adata_structure(adata)

Check whether the adata has the right structure.

hf.check_available_choices(adata)

Check available parameter choices.

hf.update_time_ordering(adata[, …])

Update the ordering of time points at adata.uns[‘time_ordering’]

hf.update_data_description(adata[, …])

Update data_des, a string to distinguish different datasets

tl.get_normalized_covariance(data[, method])

Compute the normalized correlation of the data matrix.

hf.get_X_clone_with_reference_ordering(…)

Build the X_clone matrix from data.

Simulations

simulate.linear_differentiation_model([Nt1, …])

Simulate linear differentiation corrupted with barcode collision (See Fig.

simulate.bifurcation_model([progeny_N, t1, …])

Simulate bifurcation corrupted with clonal dispersion (See Fig.

simulate.quantify_correlation_with_ground_truth_fate_bias_BifurcationModel(…)

Quantify the correlation of an inferred fate bias with the actual one, using a map from the Bifurcation Model.

simulate.quantify_transition_peak_TPR_LinearDifferentiation(…)

Quantify the True positive rate of a transition map for linear differentiation model.