Skip to contents

One function for all taxa/feature visualizations. Automatically detects study design (cross-sectional, longitudinal, or paired) and routes to the appropriate underlying function.

Usage

plot_taxa(
  data.obj,
  plot.type = c("barplot", "boxplot", "heatmap", "dotplot", "areaplot", "spaghettiplot",
    "cladogram"),
  subject.var = NULL,
  time.var = NULL,
  group.var = NULL,
  strata.var = NULL,
  time.points = NULL,
  feature.level = "original",
  feature.select = 20,
  feature.dat.type = c("count", "proportion", "other"),
  change.type = c("none", "relative", "log_fold", "absolute"),
  prev.filter = 0,
  abund.filter = 0,
  transform = c("identity", "sqrt", "log"),
  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: - "barplot": Stacked bar plot of relative abundances - "boxplot": Box plots comparing groups/time points - "heatmap": Heatmap of feature abundances - "dotplot": Dot plot with effect sizes - "areaplot": Stacked area plot (longitudinal only) - "spaghettiplot": Individual trajectories (longitudinal only) - "cladogram": Phylogenetic cladogram (single time point only)

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

feature.level

Character vector. Taxonomic level(s) for aggregation. Options include column names from feature.ann or "original" for no aggregation.

feature.select

Feature selection. Can be: - Integer: top N features by mean abundance (default: 20) - Character vector: specific feature names to display - NULL: use function defaults

feature.dat.type

Data type: "count", "proportion", or "other".

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

prev.filter

Numeric. Minimum prevalence threshold (0-1) for filtering.

abund.filter

Numeric. Minimum abundance threshold for filtering.

transform

Transformation for visualization: "identity", "sqrt", or "log".

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, one per feature.level.

Examples

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

# Cross-sectional barplot
plot_taxa(peerj32.obj, "barplot",
          group.var = "group",
          feature.level = "Phylum")

# Longitudinal boxplot with change
plot_taxa(peerj32.obj, "boxplot",
          subject.var = "subject",
          time.var = "time",
          group.var = "group",
          change.type = "relative")

# Paired heatmap
plot_taxa(peerj32.obj, "heatmap",
          subject.var = "subject",
          time.var = "time",
          time.points = c("1", "2"),
          feature.level = "Genus")
} # }