pycea.tl.expansion_test

Contents

pycea.tl.expansion_test#

pycea.tl.expansion_test(tdata, tree=None, min_clade_size=10, min_depth=1, key_added='expansion_pvalue', copy=False)#
Overloads:
  • tdata (td.TreeData), tree (str | Sequence[str] | None), min_clade_size (int), min_depth (int), key_added (str), copy (Literal[True, False]) → pd.DataFrame

  • tdata (td.TreeData), tree (str | Sequence[str] | None), min_clade_size (int), min_depth (int), key_added (str), copy (Literal[True, False]) → None

Compute expansion p-values on a tree.

Uses the methodology described in [YJN+22] to assess the expansion probability of a given subclade of a phylogeny. Mathematical treatment of the coalescent probability is described in [GT98].

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 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 to tree nodes storing the expansion p-value.

On a typical balanced tree, this function performs in O(n) time.

Parameters:
  • tdata (TreeData) – TreeData object containing a phylogenetic tree.

  • min_clade_size (int (default: 10)) – Minimum number of leaves in a subtree to be considered. Default is 10.

  • 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. Default is 1.

  • tree (str | Sequence[str] | None (default: None)) – The obst key or keys of the trees to use. If None, all trees are used.

  • key_added (str (default: 'expansion_pvalue')) – Attribute key where expansion p-values will be stored in tree nodes. Default is “expansion_pvalue”.

  • copy (Literal[True, False] (default: False)) – If True, return a pandas.DataFrame with attributes added. If False, modify in place and return None. Default is False.

Returns:

Returns None if copy=False, otherwise returns a pandas.DataFrame with expansion pvalues.

Sets the following fields:

  • tdata.obst[tree].nodes[key_added]float
    • Expansion pvalue for each node.