Learn R Programming

Nematode (version 0.2.0)

runNMDS: Non-Metric Multidimensional Scaling (NMDS) Analysis

Description

This function performs NMDS 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

runNMDS(
  data,
  group,
  distance = "bray",
  k = 2,
  decostand.method = "hellinger",
  autotransform = TRUE,
  adonis2 = TRUE,
  anosim = TRUE,
  simper = TRUE,
  ...
)

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

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

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

Value

An object of class "NMDS" containing:

  • data - List containing the input data and group information

  • call - The function call

  • NMDS - NMDS results from metaMDS

  • 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.

distance

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

k

Number of dimensions for NMDS (default: 2).

decostand.method

Standardization methods for community ecology data (default: "hellinger"). Set to NULL for no transformation. See decostand for all available options.

autotransform

Logical; whether to automatically transform the data (default: TRUE). See metaMDS for details.

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 metaMDS, decostand, adonis2, anosim, or simper.

See Also

  • metaMDS for details on NMDS implementation and distance measures

  • decostand for details on standardization methods

  • 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")
)

nmds <- runNMDS(data, group = group_df)

Run the code above in your browser using DataLab