Skip to contents

One function for all alpha diversity visualizations.

Usage

plot_alpha(
  data.obj,
  plot.type = c("boxplot", "spaghettiplot", "dotplot"),
  alpha.name = c("shannon", "observed_species"),
  alpha.obj = NULL,
  depth = NULL,
  subject.var = NULL,
  time.var = NULL,
  group.var = NULL,
  strata.var = NULL,
  time.points = NULL,
  change.type = c("none", "relative", "log_fold", "absolute"),
  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: - "boxplot": Box plots comparing groups/time points - "spaghettiplot": Individual trajectories (longitudinal) - "dotplot": Dot plot of per-time statistics (longitudinal)

alpha.name

Character vector. Alpha diversity indices to calculate. Options: "shannon", "simpson", "observed_species", "chao1", "ace", "pielou".

alpha.obj

Optional pre-calculated alpha diversity object.

depth

Rarefaction depth. NULL for no rarefaction.

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 alpha boxplot
plot_alpha(peerj32.obj, "boxplot",
           alpha.name = c("shannon", "observed_species"),
           group.var = "group")

# Longitudinal spaghettiplot
plot_alpha(peerj32.obj, "spaghettiplot",
           subject.var = "subject",
           time.var = "time",
           alpha.name = "shannon",
           group.var = "group")
} # }