cassiopeia.sim.UniformLeafSubsampler

class cassiopeia.sim.UniformLeafSubsampler(ratio=None, number_of_leaves=None)[source]

Methods

subsample_leaves(tree, collapse_source=None)[source]

Uniformly subsample leaf samples of a given tree.

Generates a uniform random sample on the leaves of the given CassiopeiaTree and returns a tree pruned to contain lineages relevant to only leaves in the sample (the “induced subtree” on the sample). All fields on the original character matrix persist, but maintains character states, meta data, and the dissimilarity map for the sampled cells only.

Parameters
tree : CassiopeiaTreeCassiopeiaTree

The CassiopeiaTree for which to subsample leaves

collapse_source : str, NoneOptional[str] (default: None)

The source node from which to collapse unifurcations

Return type

CassiopeiaTreeCassiopeiaTree

Returns

A new CassiopeiaTree that is the induced subtree on a sample of the leaves in the given tree.