alifestd_find_pair_distance_polars

alifestd_find_pair_distance_polars(phylogeny_df: DataFrame, first: int, second: int, *, criterion: str | Expr = 'origin_time') float | None

Find the pairwise distance between two taxa via their MRCA.

The distance is computed as the sum of criterion differences between each taxon and their Most Recent Common Ancestor (MRCA):

distance = (criterion[first] - criterion[mrca])
  • (criterion[second] - criterion[mrca])

Parameters

phylogeny_dfpolars.DataFrame or polars.LazyFrame

The phylogeny as a dataframe in alife standard format.

Must represent an asexual phylogeny with contiguous ids and topologically sorted rows.

firstint

First taxon id.

secondint

Second taxon id.

criterionstr or polars.Expr, default “origin_time”

Column name or polars expression used to measure distance between taxa and their MRCA.

Returns

float or None

The pairwise distance between the two taxa, or None if they have no common ancestor.

See Also

alifestd_find_pair_mrca_id_polars :

Finds the MRCA id used internally by this function.

alifestd_find_pair_distance_asexual :

Pandas-based implementation.