calc_beta_div: beta-diversity calculation

View source: R/multivar.R

calc_beta_divR Documentation

beta-diversity calculation

Description

A wrapper around vegan::vegdist and rbiom (rbiom used for UniFrac calculations). For unifrac: "wunifrac" = weighted unifrac, "unifrac" = unweighted unifrac. The function returns a tidy dataframe of PCoA axes (PC1 & PC2), percent variance explained for each PC.

Usage

calc_beta_div(
  df,
  tree = NULL,
  method = c("wunifrac", "unifrac", "manhattan", "euclidean", "canberra", "clark",
    "bray", "kulczynski", "jaccard", "gower", "altGower", "morisita", "horn",
    "mountford", "raup", "binomial", "chao", "cao", "mahalanobis"),
  threads = 1
)

Arguments

df

sample x taxon dataframe. Colnames (taxa) must match the tree tip labels if the tree is provided

tree

phylogeny with tips matching the df colnames (only needed for wunifrac & unifrac methods)

method

distance method (vegdist distances; wunifrac=Weighted Unifrac; unifrac=Unweighted Unifrac)

threads

threads used for UniFrac calculations with rbiom

Details

Unifrac is calculated with the https://github.com/cmmr/rbiom package (requires bioconductor packages).

If the goal is PCoA, then see the "tidy_PCoA" function.

Value

data.frame


leylabmpi/LeyLabRMisc documentation built on Nov. 3, 2022, 3:45 p.m.