Skip to contents

One function for all beta diversity statistical tests (PERMANOVA, etc.).

Usage

test_beta(
  data.obj,
  test.type = c("difference", "trend", "volatility"),
  dist.name = c("BC", "Jaccard"),
  dist.obj = NULL,
  subject.var = NULL,
  time.var = NULL,
  group.var = NULL,
  adj.vars = NULL,
  time.points = NULL,
  ...
)

Arguments

data.obj

A MicrobiomeStat data object containing feature.tab, meta.dat, and optionally feature.ann, tree, and feature.agg.list.

test.type

Type of test: - "difference": PERMANOVA for group differences - "trend": Test for temporal trends in community structure - "volatility": Test for temporal instability

dist.name

Character vector. Distance metrics to use. Options: "BC" (Bray-Curtis), "Jaccard", "UniFrac", "GUniFrac", "WUniFrac", "JS".

dist.obj

Optional pre-calculated distance object.

subject.var

Character. Name of the subject/sample ID variable in meta.dat. Required for longitudinal and paired designs.

time.var

Character. Name of the time variable in meta.dat. NULL for cross-sectional studies.

group.var

Character. Name of the grouping variable (e.g., treatment, condition).

adj.vars

Character vector. Names of adjustment/covariate variables.

time.points

Time point specification. Can be: - NULL: use all available time points (auto-detect design) - Single value: cross-sectional at that time point - Vector of 2: paired design (baseline, followup) - Vector of >2: longitudinal with specific time points - List: list(baseline = "T0", followup = c("T1", "T2"))

...

Additional arguments passed to the underlying function.

Value

A list containing statistical results.

Examples

if (FALSE) { # \dontrun{
data(peerj32.obj)

# Cross-sectional PERMANOVA
test_beta(peerj32.obj, "difference",
          dist.name = c("BC", "Jaccard"),
          group.var = "group")
} # }