Skip to contents

One function for all beta diversity visualizations.

Usage

plot_beta(
  data.obj,
  plot.type = c("ordination", "boxplot", "spaghettiplot", "dotplot"),
  dist.name = c("BC", "Jaccard"),
  dist.obj = NULL,
  pc.obj = NULL,
  subject.var = NULL,
  time.var = NULL,
  group.var = NULL,
  strata.var = NULL,
  time.points = NULL,
  change.type = c("none", "relative"),
  theme = "bw",
  ...
)

Arguments

data.obj

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

plot.type

Type of visualization: - "ordination": PCoA/MDS ordination plot - "boxplot": Box plots of beta diversity distances - "spaghettiplot": Individual distance trajectories - "dotplot": Dot plot of per-time statistics

dist.name

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

dist.obj

Optional pre-calculated distance object.

pc.obj

Optional pre-calculated PC/MDS object (for ordination).

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

strata.var

Character. Name of the stratification variable for faceting.

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

change.type

For paired/longitudinal comparisons: - "none": show raw values (default) - "relative": relative change (x1-x0)/(x1+x0) - "log_fold": log2 fold change - "absolute": absolute difference

theme

Theme specification. Can be: - Character: preset name ("bw", "classic", "minimal", "prism") - List: list(base.size = 12, choice = "bw", palette = NULL)

...

Additional arguments passed to the underlying function.

Value

A list of ggplot objects.

Examples

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

# Cross-sectional ordination
plot_beta(peerj32.obj, "ordination",
          dist.name = c("BC", "Jaccard"),
          group.var = "group")

# Longitudinal ordination
plot_beta(peerj32.obj, "ordination",
          subject.var = "subject",
          time.var = "time",
          dist.name = "BC",
          group.var = "group")
} # }