plotEnrichment {benchdamic}R Documentation

plotEnrichment

Description

Summary plot for the number of differentially abundant (DA) features and their association with enrichment variable. If some features are UP-Abundant or DOWN-Abundant (or just DA), several bars will be represented in the corresponding direction. Significance thresholds are reported over/under each bar, according to the Fisher exact tests.

Usage

plotEnrichment(enrichment, enrichmentCol, levels_to_plot)

Arguments

enrichment

enrichment object produced by createEnrichment function.

enrichmentCol

name of the column containing information for enrichment analysis.

levels_to_plot

A character vector containing the levels of the enrichment variable to plot.

Value

a ggplot2 object.

See Also

createEnrichment, plotContingency, and plotMutualFindings.

Examples

data("ps_plaque_16S")
data("microbial_metabolism")

# Extract genera from the phyloseq tax_table slot
genera <- phyloseq::tax_table(ps_plaque_16S)[, "GENUS"]
# Genera as rownames of microbial_metabolism data.frame
rownames(microbial_metabolism) <- microbial_metabolism$Genus
# Match OTUs to their metabolism
priorInfo <- data.frame(genera,
    "Type" = microbial_metabolism[genera, "Type"]
)
# Unmatched genera becomes "Unknown"
unknown_metabolism <- is.na(priorInfo$Type)
priorInfo[unknown_metabolism, "Type"] <- "Unknown"
priorInfo$Type <- factor(priorInfo$Type)
# Add a more informative names column
priorInfo[, "newNames"] <- paste0(rownames(priorInfo), priorInfo[, "GENUS"])

# DA analysis
# Add scaling factors
ps_plaque_16S <- norm_edgeR(object = ps_plaque_16S, method = "TMM")
ps_plaque_16S <- norm_CSS(object = ps_plaque_16S, method = "median")

# Perform DA analysis
Plaque_16S_DA <- list()
Plaque_16S_DA <- within(Plaque_16S_DA, {
    # DA analysis
    da.limma <- DA_limma(
        object = ps_plaque_16S,
        design = ~ 1 + HMP_BODY_SUBSITE,
        coef = 2,
        norm = "TMM"
    )
    da.limma.css <- DA_limma(
        object = ps_plaque_16S,
        design = ~ 1 + HMP_BODY_SUBSITE,
        coef = 2,
        norm = "CSSmedian"
    )
})

enrichment <- createEnrichment(
    object = Plaque_16S_DA,
    priorKnowledge = priorInfo, enrichmentCol = "Type", namesCol = "GENUS",
    slot = "pValMat", colName = "adjP", type = "pvalue", direction = "logFC",
    threshold_pvalue = 0.1, threshold_logfc = 1, top = 10, verbose = TRUE
)
# Contingency tables
plotContingency(enrichment = enrichment, method = "limma.TMM")
# Barplots
plotEnrichment(enrichment, enrichmentCol = "Type")
# Mutual findings
plotMutualFindings(
    enrichment = enrichment, enrichmentCol = "Type",
    n_methods = 1
)

[Package benchdamic version 1.0.0 Index]