Learn R Programming

OmicFlow (version 1.5.0)

pairwise_adonis: Pairwise adonis2 (PERMANOVA) computation

Description

Computes pairwise adonis2, given a distance matrix and a vector of labels. This function is built into the class omics with method ordination() and inherited by other omics classes, such as; metagenomics and proteomics.

Usage

pairwise_adonis(
  x,
  groups,
  metadata = NULL,
  perm_design = NULL,
  p.adjust.method = "bonferroni",
  perm = 999
)

Value

A data.frame of

  • pairs that are used

  • Degrees of freedom (Df)

  • Sums of Squares of H_0

  • F.Model of H_0

  • R2 of H_0

  • p value of F^p > F

  • p adjusted

Arguments

x

A distance matrix in the form of dist. Obtained from a dissimilarity metric, in the case of similarity metric please use 1-dist

groups

A character vector (column from a table) of labels.

metadata

A data.table or data.frame of extra metadata for perm_design (default: NULL).

perm_design

A function that takes a data.frame and constructs a permutation design with how (default: NULL).

p.adjust.method

P adjust method see p.adjust.

perm

Number of permutations to compare against the null hypothesis of adonis2 (default: perm=999).

See Also

adonis2

Examples

Run this code
# Create random data
set.seed(42)
mock_data <- matrix(rnorm(15 * 10), nrow = 15, ncol = 10)

# Create euclidean dissimilarity matrix
mock_dist <- dist(mock_data, method = "euclidean")

# Define group labels, should be equal to number of columns and rows to dist
mock_groups <- rep(c("A", "B", "C"), each = 5)

# Compute pairwise adonis (PERMANOVA)
result <- pairwise_adonis(x = mock_dist, 
                          groups = mock_groups, 
                          p.adjust.method = "bonferroni", 
                          perm = 99)

Run the code above in your browser using DataLab