scFates.tl.tree

Contents

scFates.tl.tree#

scFates.tl.tree(adata, Nodes=None, use_rep=None, ndims_rep=None, weight_rep=None, method='ppt', init=None, ppt_sigma=0.1, ppt_lambda=1, ppt_metric='euclidean', ppt_nsteps=50, ppt_err_cut=0.005, ppt_gpu_tpb=16, epg_lambda=0.01, epg_mu=0.1, epg_trimmingradius=inf, epg_initnodes=2, epg_extend_leaves=False, epg_verbose=False, device='cpu', plot=False, basis='umap', seed=None, copy=False, **kwargs)#

Generate a principal tree.

Learn a simplified representation on any space, compsed of nodes, approximating the position of the cells on a given space such as gene expression, pca, diffusion maps, … If method==’ppt’, uses simpleppt implementation from [Soldatov19]. If method==’epg’, uses Elastic Principal Graph approach from [Albergante20].

Parameters:
adata AnnData

Annotated data matrix.

Nodes Optional[int] (default: None)

Number of nodes composing the principial tree, use a range of 10 to 100 for ElPiGraph approach and 100 to 2000 for PPT approach.

use_rep Optional[str] (default: None)

Choose the space to be learned by the principal tree.

ndims_rep Optional[int] (default: None)

Number of dimensions to use for the inference.

weight_rep Optional[str] (default: None)

If ppt, use a weight matrix for learning the tree.

method Literal['ppt', 'epg'] (default: 'ppt')

If ppt, uses simpleppt approach, ppt_lambda and ppt_sigma are the parameters controlling the algorithm. If epg, uses ComputeElasticPrincipalTree function from elpigraph python package, epg_lambda epg_mu and epg_trimmingradius are the parameters controlling the algorithm.

init Optional[DataFrame] (default: None)

Initialise the point positions.

ppt_sigma Union[float, int, None] (default: 0.1)

Regularization parameter for simpleppt [Mao15].

ppt_lambda Union[float, int, None] (default: 1)

Parameter for simpleppt, penalty for the tree length [Mao15].

ppt_metric str (default: 'euclidean')

The metric to use to compute distances in high dimensional space. For compatible metrics, check the documentation of sklearn.metrics.pairwise_distances if using cpu or cuml.metrics.pairwise_distances if using gpu.

ppt_nsteps int (default: 50)

Number of steps for the optimisation process of simpleppt.

ppt_err_cut float (default: 0.005)

Stop simpleppt algorithm if proximity of principal points between iterations less than defiend value.

ppt_gpu_tpb int (default: 16)

Threads per block parameter for cuda computations.

epg_lambda Union[float, int, None] (default: 0.01)

Parameter for ElPiGraph, coefficient of ‘stretching’ elasticity [Albergante20].

epg_mu Union[float, int, None] (default: 0.1)

Parameter for ElPiGraph, coefficient of ‘bending’ elasticity [Albergante20].

epg_trimmingradius Optional (default: inf)

Parameter for ElPiGraph, trimming radius for MSE-based data approximation term [Albergante20].

epg_initnodes Optional[int] (default: 2)

numerical 2D matrix, the k-by-m matrix with k m-dimensional positions of the nodes in the initial step

epg_extend_leaves bool (default: False)

Parameter for ElPiGraph, calls elpigraph.ExtendLeaves() after graph learning.

epg_verbose bool (default: False)

show verbose output of epg algorithm

device Literal['cpu', 'gpu'] (default: 'cpu')

Run either mehtod on cpu or on gpu

plot bool (default: False)

Plot the resulting tree.

basis Optional[str] (default: 'umap')

Basis onto which the resulting tree should be projected.

seed Optional[int] (default: None)

A numpy random seed.

copy bool (default: False)

Return a copy instead of writing to adata.

**kwargs

Arguments passsed to elpigraph.computeElasticPrincipalTree()

Returns:

adata : anndata.AnnData if copy=True it returns or else add fields to adata:

.uns[‘ppt’]

dictionnary containing information from simpelppt tree if method=’ppt’

.uns[‘epg’]

dictionnary containing information from elastic principal tree if method=’epg’

.obsm[‘R’]

soft assignment of cells to principal points

.uns[‘graph’][‘B’]

adjacency matrix of the principal points

.uns[‘graph’][‘F’]

coordinates of principal points in representation space