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 alpha for 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 from counts, 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.diversity for 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) from counts, if available, and pass to the metric.

Returns:
pd.Series

Values of metric for all samples provided in counts. The index will be ids, 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.