bdiv_ord_table: Calculate PCoA and other ordinations, including taxa biplots...

bdiv_ord_tableR Documentation

Calculate PCoA and other ordinations, including taxa biplots and statistics.

Description

The biplot parameters (taxa, unc, p.top, and p.adj) only only have an effect when rank is not NULL.

Usage

bdiv_ord_table(
  biom,
  bdiv = "Bray-Curtis",
  ord = "UMAP",
  weighted = TRUE,
  md = NULL,
  k = 2,
  stat.by = NULL,
  split.by = NULL,
  tree = NULL,
  test = "adonis2",
  seed = 0,
  permutations = 999,
  rank = NULL,
  taxa = 6,
  p.top = Inf,
  p.adj = "fdr",
  unc = "singly",
  ...
)

Arguments

biom

An rbiom object, such as from as_rbiom(). Any value accepted by as_rbiom() can also be given here.

bdiv

Beta diversity distance algorithm(s) to use. Options are: "Bray-Curtis", "Manhattan", "Euclidean", "Jaccard", and "UniFrac". For "UniFrac", a phylogenetic tree must be present in biom or explicitly provided via ⁠tree=⁠. Default: "Bray-Curtis"

Multiple/abbreviated values allowed.

ord

Method for reducing dimensionality. Options are:

  • "UMAP" - Uniform manifold approximation and projection; uwot::umap().

  • "PCoA" - Principal coordinate analysis; ape::pcoa().

  • "NMDS" - Nonmetric multidimensional scaling; vegan::metaMDS().

  • "tSNE" - t-distributed stochastic neighbor embedding; tsne::tsne().

Default: "UMAP"

Multiple/abbreviated values allowed.

weighted

Take relative abundances into account. When weighted=FALSE, only presence/absence is considered. Default: TRUE

Multiple values allowed.

md

Dataset field(s) to include in the output data frame, or '.all' to include all metadata fields. Default: '.all'

k

Number of ordination dimensions to return. Either 2L or 3L. Default: 2L

stat.by

The categorical or numeric metadata field over which statistics should be calculated. Required.

split.by

Dataset field(s) that the data should be split by prior to any calculations. Must be categorical. Default: NULL

tree

A phylo object representing the phylogenetic relationships of the taxa in biom. Only required when computing UniFrac distances. Default: biom$tree

test

Permutational test for accessing significance. Options are:

  • "adonis2" - Permutational MANOVA; vegan::adonis2().

  • "mrpp" - Multiple response permutation procedure; vegan::mrpp().

  • "none" - Don't run any statistics.

Default: "adonis2"

Abbreviations are allowed.

seed

Random seed for permutations. Default: 0

permutations

Number of random permutations to use. Default: 999

rank

What rank(s) of taxa to compute biplot coordinates and statistics for, or NULL to disable. E.g. "Phylum", "Genus", ".otu", etc. An integer vector can also be given, where 1 is the highest rank, 2 is the second highest, -1 is the lowest rank, -2 is the second lowest, and 0 is the OTU "rank". Run biom$ranks to see all options for a given rbiom object. Default: NULL.

taxa

Which taxa to display. An integer value will show the top n most abundant taxa. A value 0 <= n < 1 will show any taxa with that mean abundance or greater (e.g. 0.1 implies >= 10%). A character vector of taxa names will show only those named taxa. Default: 6.

p.top

Only display taxa with the most significant differences in abundance. If p.top is >= 1, then the p.top most significant taxa are displayed. If p.top is less than one, all taxa with an adjusted p-value <= p.top are displayed. Recommended to be used in combination with the taxa parameter to set a lower bound on the mean abundance of considered taxa. Default: Inf

p.adj

Method to use for multiple comparisons adjustment of p-values. Run p.adjust.methods for a list of available options. Default: "fdr"

unc

How to handle unclassified, uncultured, and similarly ambiguous taxa names. Options are:

  • "singly" - Replaces them with the OTU name.

  • "grouped" - Replaces them with a higher rank's name.

  • "drop" - Excludes them from the result.

  • "asis" - To not check/modify any taxa names.

Default: "singly"

Abbreviations are allowed.

...

Additional arguments to pass on to uwot::umap(), ape::pcoa(), vegan::metaMDS(), or tsne::tsne().

Value

A data.frame with columns .sample, .weighted, .bdiv, .ord, .x, .y, and (optionally) .z. Any columns given by md, split.by, and stat.by are included as well.
If stat.by is given, then $stats and $stats$code) are set.
If rank is given, then $taxa_coords, $taxa_stats, and $taxa_stats$code are set.

See Also

Other beta_diversity: bdiv_boxplot(), bdiv_corrplot(), bdiv_heatmap(), bdiv_ord_plot(), bdiv_stats(), bdiv_table(), distmat_stats()

Other ordination: bdiv_ord_plot(), distmat_ord_table()

Examples

    library(rbiom)
    
    ord <- bdiv_ord_table(hmp50, "bray", "pcoa", stat.by="Body Site", rank="g")
    head(ord)
    
    ord$stats
    
    ord$taxa_stats
    
    

cmmr/rbiom documentation built on April 28, 2024, 6:38 a.m.