alifestd_mark_sample_tips_lineage_polars

alifestd_mark_sample_tips_lineage_polars(phylogeny_df: ~polars.dataframe.frame.DataFrame, n_sample: int, seed: int | None = None, *, criterion_delta: str | ~polars.expr.expr.Expr = 'origin_time', criterion_target: str | ~polars.expr.expr.Expr = 'origin_time', progress_wrap: ~typing.Callable = <function <lambda>>, mark_as: str = 'alifestd_mark_sample_tips_lineage_polars') DataFrame

Mark the n_sample leaves closest to the lineage of a target leaf.

Adds a boolean column mark_as indicating retained tips.

Parameters

phylogeny_dfpolars.DataFrame or polars.LazyFrame

The phylogeny as a dataframe in alife standard format.

Must represent an asexual phylogeny.

n_sampleint

Number of tips to mark.

seedint, optional

Random seed for reproducible target-leaf selection.

criterion_deltastr or polars.Expr, default “origin_time”

Column name or polars expression used to compute the off-lineage delta for each leaf.

criterion_targetstr or polars.Expr, default “origin_time”

Column name or polars expression used to select the target leaf.

progress_wrapCallable, optional

Pass tqdm or equivalent to display a progress bar.

mark_asstr, default “alifestd_mark_sample_tips_lineage_polars”

Column name for the boolean mark.

Raises

NotImplementedError

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

ValueError

If criterion_delta or criterion_target is not a column in phylogeny_df.

Returns

polars.DataFrame

The phylogeny with an added boolean mark column.

See Also

alifestd_mark_sample_tips_lineage_asexual :

Pandas-based implementation.