alifestd_calc_distance_matrix_polars
- alifestd_calc_distance_matrix_polars(phylogeny_df: ~polars.dataframe.frame.DataFrame, *, criterion: str | ~polars.expr.expr.Expr = 'origin_time', progress_wrap: ~typing.Callable = <function <lambda>>) ndarray
Calculate pairwise distances between all taxa via their MRCAs.
The distance between two taxa is computed as the sum of criterion differences between each taxon and their Most Recent Common Ancestor (MRCA):
- distance[i, j] = (criterion[i] - criterion[mrca])
(criterion[j] - criterion[mrca])
Taxa sharing no common ancestor will have distance NaN.
Pass tqdm or equivalent as progress_wrap to display a progress bar.
Parameters
- phylogeny_dfpolars.DataFrame or polars.LazyFrame
The phylogeny as a dataframe in alife standard format.
Must represent an asexual phylogeny in working format (i.e., topologically sorted with contiguous ids and an ancestor_id column, or an ancestor_list column from which ancestor_id can be derived).
- criterionstr or polars.Expr, default “origin_time”
Column name or polars expression used to measure distance between taxa and their MRCA.
- progress_wrapcallable, optional
Wrapper for progress display (e.g., tqdm).
Returns
- numpy.ndarray
Array of shape (n, n) with dtype float64, containing pairwise distances. Entries are NaN where organisms share no common ancestor.
See Also
- alifestd_calc_distance_matrix_asexual :
Pandas-based implementation.
- alifestd_calc_mrca_id_matrix_asexual_polars :
Computes the underlying MRCA id matrix.
- alifestd_find_pair_distance_polars :
Computes distance for a single pair of taxa.