Learn R Programming

Nematode (version 0.2.0)

runPCoA: Principal Coordinates Analysis (PCoA) Analysis

Description

This function performs PCoA analysis on a dataset using the specified distance metric, and optionally runs PERMANOVA (adonis2) and ANOSIM tests for group differences. It supports both data.frame and matrix inputs.

Usage

runPCoA(
  data,
  group,
  k = 2,
  distance = "bray",
  adonis2 = TRUE,
  anosim = TRUE,
  simper = TRUE,
  ...
)

# S3 method for data.frame runPCoA( data, group, k = 2, distance = "bray", adonis2 = TRUE, anosim = TRUE, simper = TRUE, ... )

# S3 method for matrix runPCoA( data, group, k = 2, distance = "bray", adonis2 = TRUE, anosim = TRUE, simper = TRUE, ... )

# S3 method for default runPCoA( data, group, k = 2, distance = "bray", adonis2 = TRUE, anosim = TRUE, simper = TRUE, ... )

Value

An object of class "PCoA" containing:

  • data - List containing the input data and group information

  • call - The function call

  • Points - Sample coordinates in the reduced space.

  • Eigenvalues - Variance explained by each principal coordinate axis.

  • adonis2 - PERMANOVA results (if adonis2 = TRUE)

  • anosim - ANOSIM results (if anosim = TRUE)

  • SIMPER - SIMPER results (if simper = TRUE)

Arguments

data

data.frame or matrix. The nematode abundance table where rows represent samples and columns represent nematode genera. Each element indicates the count of a specific nematode genus in the corresponding sample. Row names must be sample names.

group

data.frame. A data frame with sample names as row names and a single column containing group information for each sample.

k

Number of dimensions for PCoA (default: 2).

distance

Distance metric to use (default: "bray"). See vegdist for all available options.

adonis2

Logical; whether to perform PERMANOVA test using adonis2 (default: TRUE).

anosim

Logical; whether to perform ANOSIM test using anosim (default: TRUE).

simper

Logical; whether to perform SIMPER test using simper (default: TRUE).

...

Additional arguments passed to cmdscale, decostand, adonis2, anosim, or simper.

See Also

  • cmdscale for details on cmdscale implementation

  • vegdist for available distance metrics

  • adonis2 for PERMANOVA

  • anosim for ANOSIM

  • simper for SIMPER

Examples

Run this code
# Example with default Bray-Curtis distance
data <- data.frame(
  Cephalobus = c(10, 20, 30, 1, 6, 5),
  Eucephalobus = c(5, 10, 12, 30, 1, 6),
  Acrobeloides = c(1, 2, 3, 12, 30, 1),
  Caenorhabditis = c(5, 8, 15, 2, 3, 12),
  Aphelenchus = c(5, 13, 11, 15, 2, 3),
  Leptonchus = c(3, 10, 15, 0, 15, 11),
  Pratylenchus = c(9, 2, 15, 15, 0, 15),
  Tylenchus = c(5, 0, 15, 11, 15, 2),
  Mesodorylaimus = c(7, 10, 18, 3, 12, 30),
  Discolaimus = c(1, 10, 25, 10, 18, 3),
  row.names = c("Sample1", "Sample2", "Sample3", "Sample4", "Sample5", "Sample6")
)
group_df <- data.frame(
  group = c("A", "A", "B", "B", "C", "C"),
  row.names = c("Sample1", "Sample2", "Sample3", "Sample4", "Sample5", "Sample6")
)

pcoa <- runPCoA(data, group = group_df)

Run the code above in your browser using DataLab