alifestd_mark_colless_index_asexual

alifestd_mark_colless_index_asexual(phylogeny_df: DataFrame, mutate: bool = False, *, mark_as: str = 'colless_index') DataFrame

Add column colless_index with Colless imbalance index for each subtree.

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

Computes the classic Colless index for strictly bifurcating trees. For each internal node with exactly two children, the local contribution is |L - R| where L and R are leaf counts in left and right subtrees. The value at each node represents the total Colless index for the subtree rooted at that node.

Raises ValueError if the tree is not strictly bifurcating. For trees with polytomies, use alifestd_mark_colless_like_index_mdm_asexual for the Colless-like index instead.

Leaf nodes will have Colless index 0 (no imbalance in subtree of size 1). The root node contains the Colless 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 “colless_index” containing the Colless imbalance index for the subtree rooted at each node.

Raises

ValueError

If phylogeny_df is not strictly bifurcating.

See Also

alifestd_mark_colless_index_corrected_asexual :

Normalized Colless index (corrected for tree size).

alifestd_mark_colless_like_index_mdm_asexual :

Colless-like index (MDM) that supports polytomies.

alifestd_mark_colless_like_index_var_asexual :

Colless-like index (variance) that supports polytomies.

alifestd_mark_colless_like_index_sd_asexual :

Colless-like index (std dev) that supports polytomies.