alifestd_reroot_at_id_polars

alifestd_reroot_at_id_polars(phylogeny_df: DataFrame, new_root_id: int) DataFrame

Reroot phylogeny at specified node id, preserving topology.

Reverses the descendant-to-ancestor relationships of all ancestors of the new root. Does not update branch_lengths or edge_lengths columns if present.

Parameters

phylogeny_dfpolars.DataFrame

The phylogeny as a dataframe in alife standard format.

Must represent an asexual phylogeny.

new_root_idint

The ID of the node to use as the new root of the phylogeny.

Returns

polars.DataFrame

The rerooted phylogeny in alife standard format.