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, callable

The alpha diversity metric to apply to the sample(s). Passing metric as a string is preferable as this often results in an optimized version of the metric being used.

counts1D or 2D array_like of ints or floats, Table

Vector or matrix containing count/abundance data. If a matrix, each row should contain counts of taxa in a given sample.

idsiterable of strs, optional

Identifiers for each sample in counts. By default, samples will be assigned integer identifiers in the order that they were provided.

validate: bool, optional

If False, validation of the input won’t be performed. This step can be slow, so if validation is run elsewhere it can be disabled here. However, invalid input data can lead to invalid results or error messages that are hard to interpret, so this step should not be bypassed if you’re not certain that your input data are valid. See skbio.diversity for the description of what validation entails so you can determine if you can safely disable validation.

kwargskwargs, optional

Metric-specific parameters.

Returns:
pd.Series

Values of metric for all vectors 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.