skbio.diversity.alpha_diversity#
- skbio.diversity.alpha_diversity(metric, counts, ids=None, validate=True, **kwargs)[source]#
Compute alpha diversity for one or more samples.
- Parameters:
- metricstr or callable
The alpha diversity metric to apply to the sample(s). See
alphafor available metrics. Passing metric as a string is preferable as this often results in an optimized version of the metric being used.- countstable_like of shape (n_samples, n_taxa) or (n_taxa,)
Vector or matrix containing count/abundance data of one or multiple samples. See supported formats.
- idsarray_like of shape (n_samples,), optional
Identifiers for each sample in
counts. If not provided, will extract sample IDs fromcounts, if available, or assign integer identifiers in the order that samples were provided.- validate: bool, optional
If True (default), validate the input data before applying the alpha diversity metric. See
skbio.diversityfor the details of validation.- kwargsdict, optional
Metric-specific parameters. Refer to the documentation of the chosen metric. A special parameter is
taxa, needed by some phylogenetic metrics. If not provided, will extract taxa (feature IDs) fromcounts, if available, and pass to the metric.
- Returns:
- pd.Series
Values of
metricfor all samples provided incounts. The index will beids, if provided.
- Raises:
- ValueError, MissingNodeError, DuplicateNodeError
If validation fails. Exact error will depend on what was invalid.
- TypeError
If invalid method-specific parameters are provided.