skbio.diversity.alpha.kempton_taylor_q#
- skbio.diversity.alpha.kempton_taylor_q(counts, lower_quantile=0.25, upper_quantile=0.75)[source]#
Calculate Kempton-Taylor Q index of alpha diversity.
Kempton-Taylor Q index measures diversity based on the middle-ranking taxa in the abundance distribution. Specifically, it estimates the slope of the cumulative abundance curve in the interquantile range. It is defined as:
\[Q = \frac{S_{lower..upper}}{\ln n_{lower} - \ln n_{upper}}\]where “lower” and “upper” are the taxa at the lower and upper quantiles of the abundance distribution, \(S\) is the number of taxa, and \(n\) is the number of individuals.
By default, the lower and upper quartiles are used. Therefore:
\[Q = \frac{S}{2(\ln n_{0.25} - \ln n_{0.75})}\]The quantiles are rounded inwards in this implementation.
- Parameters:
- counts1-D array-like, int
Vector of counts.
- lower_quantilefloat, optional
Lower bound of the interquantile range. Must be greater than or equal to 0, and smaller than 1. Defaults to lower quartile (0.25).
- upper_quantilefloat, optional
Upper bound of the interquantile range. Must be greater than
lower_quantile, and smaller than or equal to 1. Defaults to upper quartile (0.75).
- Returns:
- float
Kempton-Taylor Q index of alpha diversity.
- Raises:
- ValueError
If the quantiles do not satisfy
0 <= lower_quantile < upper_quantile <= 1.
Notes
This function returns NaN if the interquantile range is empty or constant.
The index is defined in [1]. The implementation here is based on the description given in the SDR-IV online manual [2].
The implementation provided here differs slightly from the results given in Magurran 1998. Specifically, we have 14 in the numerator rather than 15. Magurran recommends counting half of the taxa with the same # counts as the point where the UQ falls and the point where the LQ falls, but the justification for this is unclear (e.g. if there were a very large # taxa that just overlapped one of the quantiles, the results would be considerably off). Leaving the calculation as-is for now, but consider changing.
References
[1]Kempton, R. A. and Taylor, L. R. (1976) Models and statistics for species diversity. Nature, 262, 818-820.