alifestd_coarsen_dilate_polars
- alifestd_coarsen_dilate_polars(phylogeny_df: DataFrame | LazyFrame, *, criterion: str = 'origin_time', dilation: int = 1) 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), wheren % dilation == 0, are collapsed to a single inner node atn.Tip nodes are never moved. The MRCA of two tips may only shift backward (never forward), by at most
dilationunits, and never across an % dilation == 0boundary.Parameters
- phylogeny_dfpolars.DataFrame or polars.LazyFrame
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.
Returns
- polars.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".
See Also
- alifestd_coarsen_dilate_asexual :
Pandas-based implementation.