qdiv.diversity.phyl_alpha
- qdiv.diversity.phyl_alpha(obj, *, q=1, index='D', use_values_in_tab=False)[source]
Compute phylogenetic alpha diversity based on Hill numbers.
This function implements the abundance-weighted phylogenetic diversity framework of Chao et al. (2010, Phil. Trans. R. Soc. B). Diversity is computed at the level of tree branches, where each branch is weighted by its length and by the total relative abundance of all descendant features.
The primary quantity returned is the mean phylogenetic diversity D̄_q(T), which is a true Hill number (dimensionless, continuous, and monotone in q). A branch-length–scaled quantity (phylogenetic diversity, PD_q) can optionally be returned as a derived measure.
- Parameters:
obj (MicrobiomeData-like | dict) –
Object containing an abundance table (tab) and a tree dataframe (tree). The tree dataframe must include:
’leaves’ : list of descendant leaves for each branch
’branchL’ : branch length
q (float, default=1) – Diversity order: - q = 0 : presence/absence weighting (Faith’s PD when index=’PD’) - q = 1 : exponential phylogenetic Shannon diversity - q = 2 : phylogenetic inverse Simpson diversity - general q : phylogenetic Hill number
index ({'D', 'PD', 'H'}, default='D') –
Quantity to return: - ‘D’ : mean phylogenetic diversity D̄_q(T) (dimensionless; Hill number) - ‘PD’ : branch diversity PD_q(T) = T · D̄_q(T) - ‘H’ : entropy-like intermediate quantity:
q = 1 : phylogenetic entropy divided by T
q ≠ 1 : power-sum moment Σ_b (L_b/T) a_b^q
use_values_in_tab (bool, default=False) – If False, abundances are converted to relative abundances per sample. If True, the abundance table is assumed to already contain relative abundances.
- Returns:
A vector of diversity values, one per sample.
- Return type:
pandas.Series
Notes
- For each sample j, the mean tree height is computed as:
T_j = Σ_b L_b · a_{b,j}
- Mean phylogenetic diversity is defined as:
D̄_q(T) = ( Σ_b (L_b / T_j) · a_{b,j}^q )^(1 / (1 − q)), q ≠ 1 D̄_1(T) = exp( − Σ_b (L_b / T_j) · a_{b,j} · log a_{b,j} )
where a_{b,j} is the total relative abundance descending from branch b.
The branch diversity PD_q(T) = T_j · D̄_q(T) has units of branch length (or evolutionary time) and represents effective evolutionary work. Unlike D̄_q(T), PD_q(T) is not a Hill number for q ≠ 0, 1 and is not guaranteed to be monotone in q.