alifestd_mask_descendants_polars

alifestd_mask_descendants_polars(phylogeny_df: DataFrame, *, ancestor_mask: ndarray) DataFrame

For given ancestor nodes, create a mask identifying those nodes and all descendants.

Ancestral nodes are identified by ancestor_mask corresponding to rows in phylogeny_df.

The mask is returned as a new column alifestd_mask_descendants_polars in the output DataFrame.

Only supports asexual phylogenies.

Parameters

phylogeny_dfpolars.DataFrame

The phylogeny as a dataframe in alife standard format.

Must represent an asexual phylogeny with contiguous, topologically sorted ids and an ancestor_id column.

ancestor_masknumpy.ndarray

Boolean array indicating ancestor nodes to propagate from.

Raises

NotImplementedError

If phylogeny_df has no “ancestor_id” column or if ids are non-contiguous or not topologically sorted.

Returns

polars.DataFrame

The input DataFrame with an additional boolean column alifestd_mask_descendants_polars.