alifestd_mark_sackin_index_asexual

alifestd_mark_sackin_index_asexual(phylogeny_df: DataFrame, mutate: bool = False, *, mark_as: str = 'sackin_index') DataFrame

Add column sackin_index with Sackin index for each subtree.

The output column name can be changed via the mark_as parameter.

Computes the Sackin imbalance index, which is the sum of the depths of all leaves in the subtree. For each internal node, the contribution is the sum of leaf depths in its subtree.

For a node with children c_1, c_2, …, c_k:

sackin[node] = sum_{i} (sackin[c_i] + num_leaves[c_i])

This formula naturally supports both bifurcating trees and trees with polytomies.

Leaf nodes will have Sackin index 0. The root node contains the Sackin index for the entire tree.

A topological sort will be applied if phylogeny_df is not topologically sorted. Dataframe reindexing (e.g., df.index) may be applied.

Input dataframe is not mutated by this operation unless mutate set True. If mutate set True, operation does not occur in place; still use return value to get transformed phylogeny dataframe.

Parameters

phylogeny_dfpd.DataFrame

Alife standard DataFrame containing the phylogenetic relationships.

mutatebool, optional

If True, modify the input DataFrame in place. Default is False.

Returns

pd.DataFrame

Phylogeny DataFrame with an additional column “sackin_index” containing the Sackin imbalance index for the subtree rooted at each node.

See Also

alifestd_mark_colless_index_asexual :

Colless index for strictly bifurcating trees.

alifestd_mark_colless_like_index_mdm_asexual :

Colless-like index that supports polytomies.