qdiv.diversity.naive_alpha

qdiv.diversity.naive_alpha(tab, *, q=1, use_values_in_tab=False)[source]

Compute naive alpha diversity of order q for all samples.

Accepts:
  • DataFrame: features x samples

  • MicrobiomeData-like object: must expose a DataFrame in .tab / .table / .counts / .abundance

  • dict-of-dicts: either {feature: {sample: count}} or {sample: {feature: count}}

Parameters:
  • tab (DataFrame | MicrobiomeData-like | dict) – Abundance table (features x samples) or convertible structure.

  • q (float, default=1) – Diversity order: - q = 0 : species richness - q = 1 : exponential of Shannon entropy - q = 2 : inverse Simpson - general q : Hill number of order q

  • use_values_in_tab (bool, default=False) – If False (default), values are converted to relative abundances. If True, values in tab are assumed to already be relative abundances.

Returns:

Hill numbers for each sample. If input has one sample/column, returns a float.

Return type:

pandas.Series or float

Notes

  • For q = 1, the limit definition is used:

    H₁ = exp( - Σ pᵢ ln pᵢ )

  • For q ≠ 1:

    H_q = ( Σ pᵢ^q )^( 1 / (1 - q) )

  • Zero abundances are ignored safely.