alifestd_coarsen_dilate_asexual

alifestd_coarsen_dilate_asexual(phylogeny_df: DataFrame, *, criterion: str = 'origin_time', dilation: int = 1, mutate: bool = False) DataFrame

Coarsen a phylogeny by collapsing inner nodes within dilation windows.

All inner (non-leaf) nodes with criterion values in the half-open interval [n, n + dilation), where n % dilation == 0, are collapsed to a single inner node at n.

Tip nodes are never moved. The MRCA of two tips may only shift backward (never forward), by at most dilation units, and never across a n % dilation == 0 boundary.

Parameters

phylogeny_dfpd.DataFrame

Input phylogeny in alife standard format.

criterionstr, default “origin_time”

Column whose values define the time axis for dilation.

dilationint

Width of the dilation window. Must be a positive integer.

mutatebool, default False

If True, allow in-place mutation of the input dataframe.

Returns

pd.DataFrame

Coarsened phylogeny in alife standard format.

Raises

NotImplementedError

If input is not topologically sorted with contiguous ids.

ValueError

If dilation is not a positive integer, if criterion is not present in phylogeny_df, or if criterion is "id" or "ancestor_id".