Phylogenetic comparative methods for single-cell gene expression data. scPhyTr implements Brownian Motion, Ornstein-Uhlenbeck and peak-shift model fitting algorithms for single-cell phylogenies and gene expression data to infer evolutionary rates of genes or pathways, evolutionary correlations, and clade-specific rate variation. scPhyTr may also take known covariates to infer covariate-driven rate changes. Additionally, if spatial data is available, scPhyTr can identify niches with different evolutionary rates for any trait de novo.
Comparing to RevBayes, scPhyTr is tailored for the specificities of single-cell data, and extends its functionality to include variation in evolutionary rates in unknown clades, as well as the ability to extract covariates from spatial data to associate with rate variations.
To install scPhyTr and get started, read the documentation.
import scphytr as ph
import anndata
import ete3
adata = anndata.read_h5ad()
tree = ete3.read_tree()
ph.pp.setup_anndata(adata, tree) # adds tree to anndata object
ph.pp.cut_tree(adata, min_cells=10)
ph.tl.estimate_global_rate(adata, character=, model=) # Populates the adata.uns with a global rate for the specified character using the specified model
ph.tl.estimate_paths(adata, character=, model=) # Populates the adata.uns with a trait path for each species. Uses the existing uns.model if available
ph.tl.estimate_lineage_rates(adata, lineage=) # Populates the adata.uns with a rate for each lineage
ph.tl.estimate_state_rates(adata, state=) # Populates the adata.uns with a rate for each state
ph.tl.estimate_evolutionary_correlation(adata, characters=) # Populates the adata.uns with a correlation matrix for the specified characters
ph.tl.estimate_evolutionary_optimum(adata, character=) # Populates the adata.uns with an evolutionary optimal value for the specified character using an OU model
ph.tl.estimate_lineage_evolutionary_optima(adata, character=, lineage=) # Populates the adata.uns with an evolutionary optimal value for the specified character using an OU model in each lineage
ph.pl.trait_value(adata, color=[]) # colors the branches with the value of a trait, one trait per facet
ph.pl.trait_value(adata, color=[], state=) # same as above, but also highlights state changes in the tr
ph.pl.trait_trace(adata, color=[]) # plots the trace of each trait over time
ph.pl.lineage_rates(adata, color=[]) # colors each lineage with the evolutionary rate for each trait
ph.pl.lineage_optima(adata, color=[]) # colors each lineage with the evolutionary optimum for each trait
ph.tl.simulate_traits(adata) # use the fitted model to simulate trait values. put them in obs
ph.tl.simulate_paths(adata) # use the fitted model to simulate trait paths. put them in uns
ph.pl.trait_path(adata)
# Look at the confidence intervals of estimates
ph.pl.violin(adata, color=[])
# And of course usual scanpy plotting functions are available, and can use any of the obs generated by scphytr
sc.pl.umap(adata, color=[]) # color each cell by the evolutionary rate of a given trait