Skip to contents

Programmatic access to the lists of available metrics, and their associated functions.

Usage

metrics

as_alpha_metric(metric, multiple = FALSE, evar = "metric")

as_beta_metric(metric, multiple = FALSE, evar = "metric")

Format

An object of class list of length 2.

Arguments

metric

The name, partial name, alternate name, or partial alternate name of an alpha/beta diversity metric.

multiple

If TRUE, allow length(metric) to be longer than 1.

evar

The name of the variable to display in an error message.

Value

metrics is a nested list of functions for alpha and beta diversity. as_alpha_metric() and as_beta_metric() return a validated metric name or throws an error.

Examples

    names(metrics)
#> [1] "alpha" "beta" 
    
    names(metrics$alpha)
#> [1] "observed"    "chao1"       "shannon"     "simpson"     "inv_simpson"
#> [6] "faith"      
    
    names(formals(metrics$alpha$faith))
#> [1] "counts" "tree"   "cpus"  
    
    metrics$alpha$faith(ex_counts, ex_tree)
#> Saliva   Gums   Nose  Stool 
#>    180    191    215    202 
    
    as_alpha_metric('otus')
#> [1] "observed"
    
    as_beta_metric('guni')
#> [1] "generalized_unifrac"