Skip to contents

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,
  ...
)

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 with equal length as the distance matrix.

metadata

A data.table or data.frame as input to the function perm_design (default: NULL).

perm_design

A function that takes the metadata and returns a permutation design with how (default: NULL).

p.adjust.method

A character variable to adjust the p-values, see p.adjust (default: "bonferroni").

perm

A whole number to define the number of permutations in adonis2 (default: 999).

...

Additional arguments passed to adonis2.

Value

A data.frame containing:

pairs

combinations of group comparisons

Df

Degrees of Freedom

SumsOfSqs

The sums of squares (centroid) of the null hypothesis \(H_0\)

F.Model

The F-test of the null hypothesis \(H_0\)

R2

The R squared of the null hypothesis \(H_0\)

p.value

The number of \(F^p\) higher than the null hypothesis divided by the total number of permutations.

p.adj

The adjusted P-value based on the used p.adjust.method

See also

Examples

# 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)