alifestd_ladderize_polars
- alifestd_ladderize_polars(phylogeny_df: DataFrame, reverse: bool = False) DataFrame
Reorder rows so children are sorted by number of descendant leaves, gathering children into contiguous rows.
By default, subtrees with fewer leaves come first (ascending). Set
reverse=Trueto sort descending (more leaves first).Note: after ladderizing, ids will no longer be contiguous with respect to row indices. Call
alifestd_assign_contiguous_ids_polarson the result to reassign contiguous ids if needed.Parameters
- phylogeny_dfpolars.DataFrame
The phylogeny as a dataframe in alife standard format.
Must represent an asexual phylogeny with contiguous ids and topologically sorted rows.
- reversebool, default False
If True, sort descending (more leaves first).
Returns
- polars.DataFrame
The phylogeny with rows reordered in ladderized order.
Raises
- NotImplementedError
If ids are not contiguous or rows are not topologically sorted.
See Also
- alifestd_ladderize_asexual :
Pandas-based implementation.