Skip to contents

Generates dot plots visualizing longitudinal taxa test results, showing abundance and significance changes over time across groups.

Usage

generate_taxa_per_time_dotplot_long(
  data.obj,
  test.list,
  group.var,
  time.var,
  t0.level = NULL,
  ts.levels = NULL,
  feature.level,
  feature.mt.method = "none",
  feature.sig.level = 0.05,
  features.plot = NULL,
  filter_significant = TRUE,
  base.size = 16,
  theme.choice = "bw",
  custom.theme = NULL,
  palette = NULL,
  pdf = FALSE,
  pdf.wid = 7,
  pdf.hei = 5
)

Arguments

data.obj

A MicrobiomeStat data object, which is a list containing at minimum the following components:

  • feature.tab: A matrix of feature abundances (taxa/genes as rows, samples as columns)

  • meta.dat: A data frame of sample metadata (samples as rows)

Optional components include:

  • feature.ann: A matrix/data frame of feature annotations (e.g., taxonomy)

  • tree: A phylogenetic tree object (class "phylo")

  • feature.agg.list: Pre-aggregated feature tables by taxonomy

Data objects can be created using converters like mStat_convert_phyloseq_to_data_obj or importers like mStat_import_qiime2_as_data_obj.

test.list

List of test results from generate_taxa_per_time_test_long.

group.var

Character string specifying the column name in meta.dat containing the grouping variable (e.g., treatment, condition, phenotype). Used for between-group comparisons.

time.var

Character string specifying the column name in meta.dat containing the time variable. Required for longitudinal and paired analyses. Supports character/factor labels (e.g., "baseline", "week4") and numeric values. Some trend/volatility methods require numeric or coercible-to-numeric time values.

t0.level

Character or numeric value specifying the baseline time point for longitudinal or paired analyses. Should match a value in the time.var column.

ts.levels

Character vector specifying the follow-up time points for longitudinal or paired analyses. Should match values in the time.var column.

feature.level

Character vector specifying the taxonomic or annotation level(s) for analysis. Should match column names in feature.ann, such as "Phylum", "Family", "Genus", etc. Use "original" to analyze at the original feature level without aggregation.

feature.mt.method

Character; multiple testing method ("fdr" or "none").

feature.sig.level

Numeric; significance level cutoff for highlighting taxa.

features.plot

Character vector of features to plot. Overrides filter_significant.

filter_significant

Logical; whether to show only significant features. Default TRUE.

base.size

Numeric value specifying the base font size for plot text elements. Default is typically 16.

theme.choice

Character string specifying the ggplot2 theme to use. Options include:

  • "bw": Black and white theme (theme_bw)

  • "classic": Classic theme (theme_classic)

  • "gray": Gray theme (theme_gray)

  • "light": Light theme (theme_light)

  • "dark": Dark theme (theme_dark)

  • "minimal": Minimal theme (theme_minimal)

  • "void": Void theme (theme_void)

  • "prism": GraphPad Prism-like theme

Can also use a custom ggplot2 theme object via custom.theme.

custom.theme

A custom ggplot2 theme object to override theme.choice. Should be created using ggplot2::theme() or a complete theme function.

palette

Character vector of colors or a named palette for the plot. If NULL, uses default MicrobiomeStat color scheme. Can be:

  • A vector of color codes (e.g., c("#E41A1C", "#377EB8"))

  • A palette name recognized by the plotting function

pdf

Logical. If TRUE, saves the plot(s) to PDF file(s) in the current working directory. Default is TRUE.

pdf.wid

Numeric value specifying the width of PDF output in inches. Default is typically 11.

pdf.hei

Numeric value specifying the height of PDF output in inches. Default is typically 8.5.

Value

A list of ggplot objects for each taxonomic level and group.

Examples

if (FALSE) { # \dontrun{
# Example 1: Analyzing the ECAM dataset
data("ecam.obj")
# Analyzing the impact of delivery method on microbial composition over months
result1 <- generate_taxa_per_time_test_long(
  data.obj = ecam.obj,
  subject.var = "studyid",
  time.var = "month_num",
  group.var = "delivery",
  adj.vars = "diet",
  feature.level = c("Phylum", "Class", "Family"),
  prev.filter = 0.001,
  abund.filter = 0.01,
  feature.dat.type = "proportion"
)
# Visualizing the results for the ECAM dataset
dotplot_ecam <- generate_taxa_per_time_dotplot_long(
  data.obj = ecam.obj,
  test.list = result1,
  group.var = "delivery",
  time.var = "month_num",
  feature.level = c("Phylum", "Class", "Family"),
  feature.mt.method = "fdr",
  feature.sig.level = 0.1
)

# Example 2: Analyzing the Type 2 Diabetes dataset
data("subset_T2D.obj")
# Longitudinal analysis of microbial changes in different racial groups
result2 <- generate_taxa_per_time_test_long(
  data.obj = subset_T2D.obj,
  subject.var = "subject_id",
  time.var = "visit_number",
  group.var = "subject_race",
  adj.vars = "sample_body_site",
  prev.filter = 0.1,
  abund.filter = 0.001,
  feature.level = c("Genus", "Family"),
  feature.dat.type = "count"
)
# Visualizing the results for the Type 2 Diabetes dataset
dotplot_T2D <- generate_taxa_per_time_dotplot_long(
  data.obj = subset_T2D.obj,
  test.list = result2,
  group.var = "subject_race",
  time.var = "visit_number",
  t0.level = unique(subset_T2D.obj$meta.dat$visit_number)[1],
  ts.levels = unique(subset_T2D.obj$meta.dat$visit_number)[-1],
  feature.level = c("Genus", "Family")
)
} # }