cassiopeia.tl.compute_expansion_pvalues#

cassiopeia.tl.compute_expansion_pvalues(tree, min_clade_size=10, min_depth=1, copy=False)[source]#

Call expansion pvalues on a tree.

Uses the methodology described in Yang, Jones et al, BioRxiv (2021) to assess the expansion probability of a given subclade of a phylogeny. Mathematical treatment of the coalescent probability is described in Griffiths and Tavare, Stochastic Models (1998).

The probability computed corresponds to the probability that, under a simple neutral coalescent model, a given subclade contains the observed number of cells; in other words, a one-sided p-value. Often, if the probability is less than some threshold (e.g., 0.05), this might indicate that there exists some subclade under this node that to which this expansion probability can be attributed (i.e. the null hypothesis that the subclade is undergoing neutral drift can be rejected).

This function will add an attribute “expansion_pvalue” to the tree, and return None unless :param:`copy` is set to True.

On a typical balanced tree, this function will perform in O(n log n) time, but can be up to O(n^3) on highly unbalanced trees. A future endeavor may be to impelement the function in O(n) time.

Parameters:
tree CassiopeiaTree

CassiopeiaTree

min_clade_size int (default: 10)

Minimum number of leaves in a subtree to be considered.

min_depth int (default: 1)

Minimum depth of clade to be considered. Depth is measured in number of nodes from the root, not branch lengths.

copy bool (default: False)

Return copy.

Return type:

Optional[CassiopeiaTree]

Returns:

If copy is set to False, returns the tree with attributes added

in place. Else, returns a new CassiopeiaTree.