Skip to contents

Creates MA plots to visualize differential abundance analysis results, displaying log2 fold change (M) against average abundance (A) for each taxon.

Usage

generate_taxa_ma_plot_single(
  data.obj,
  group.var,
  test.list,
  feature.sig.level = 0.05,
  feature.mt.method = "fdr",
  features.plot = NULL,
  palette = NULL,
  pdf = FALSE,
  pdf.wid = 11,
  pdf.hei = 8.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.

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.

test.list

The list of test results returned by generate_taxa_test_single.

feature.sig.level

The significance level cutoff for highlighting taxa.

feature.mt.method

Multiple testing correction method: "fdr" or "none".

features.plot

A character vector of taxa to be plotted. If NULL, all taxa are plotted.

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 of MA plots for each taxonomic level.

Details

The function generates MA plots for each taxonomic level based on the test results. It visualizes the relationship between average abundance and log2 fold change, highlighting statistically significant changes.

MA plots are useful for identifying abundance-dependent biases in the data and for visualizing which taxa show significant differential abundance between conditions.

Examples

if (FALSE) { # \dontrun{
data("subset_T2D.obj")
test.list <- generate_taxa_test_single(
  data.obj = subset_T2D.obj,
  time.var = "visit_number",
  t.level = unique(subset_T2D.obj$meta.dat$visit_number)[1],
  group.var = "subject_race",
  adj.vars = "sample_body_site",
  feature.level = c("Genus", "Family"),
  feature.dat.type = "count"
)

plot.list <- generate_taxa_ma_plot_single(
  data.obj = subset_T2D.obj,
  group.var = "subject_race",
  test.list = test.list,
  feature.sig.level = 0.05,
  feature.mt.method = "fdr"
)
} # }