
Generate MA Plots for Taxa Differential Test for a Single Time Point
Source:R/generate_taxa_ma_plot_single.R
generate_taxa_ma_plot_single.RdThis function creates MA plots to visualize differential abundance analysis results. MA plots display the log2 fold change (M) against the average abundance (A) for each taxon, helping to identify taxa with significant abundance differences between groups.
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 list object in a format specific to MicrobiomeStat, which can include components such as feature.tab (matrix), feature.ann (matrix), meta.dat (data.frame), tree, and feature.agg.list (list). The data.obj can be converted from other formats using several functions from the MicrobiomeStat package, including: 'mStat_convert_DGEList_to_data_obj', 'mStat_convert_DESeqDataSet_to_data_obj', 'mStat_convert_phyloseq_to_data_obj', 'mStat_convert_SummarizedExperiment_to_data_obj', 'mStat_import_qiime2_as_data_obj', 'mStat_import_mothur_as_data_obj', 'mStat_import_dada2_as_data_obj', and 'mStat_import_biom_as_data_obj'. Alternatively, users can construct their own data.obj. Note that not all components of data.obj may be required for all functions in the MicrobiomeStat package.
- group.var
The grouping variable tested, found in metadata.
- 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 will be plotted.
- palette
An optional parameter specifying the color palette to be used for the plot. It can be either a character string specifying the name of a predefined palette or a vector of color codes in a format accepted by ggplot2 (e.g., hexadecimal color codes). Available predefined palettes include 'npg', 'aaas', 'nejm', 'lancet', 'jama', 'jco', and 'ucscgb', inspired by various scientific publications and the `ggsci` package. If `palette` is not provided or an unrecognized palette name is given, a default color palette will be used. Ensure the number of colors in the palette is at least as large as the number of groups being plotted.
Boolean; whether to save the plot as a PDF file.
- pdf.wid
Numeric; width of the saved PDF file.
- pdf.hei
Numeric; height of the saved PDF file.
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",
time.point = "1",
group.var = "subject_race",
adj.vars = "sample_body_site",
feature.level = c("Genus","Family"),
feature.dat.type = c("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"
)
} # }