Skip to main content
`Ctrl`+`K`

# skbio.diversity.alpha_diversity

skbio.diversity.alpha_diversity(metric, counts, ids=None, validate=True, **kwargs)

  Compute alpha diversity for one or more samples.

  Parameters:
    metric str 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.

    counts table_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.

    ids array_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.

    kwargs dict, 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.

  See also

  `alpha`
  `get_alpha_diversity_metrics`
  `beta_diversity`