plotMediation() generates a heatmap from the results of mediation analysis produced with mia:getMediation() or mia:addMediation(). It displays effect size and significance of the Actual Causal Mediation Effect (ACME) and the Actual Direct Effect (ADE) for each mediator included in the object x.

plotMediation(x, ...)

# S4 method for class 'SummarizedExperiment'
plotMediation(x, name = "mediation", ...)

# S4 method for class 'data.frame'
plotMediation(x, layout = "heatmap", ...)

Arguments

x

a SummarizedExperiment object or a data.frame, returned as output from addMediation or getMediation, respectively.

...

Additional parameters for plotting.

  • add.significance: Character scalar. Controls how p-values are displayed in the heatmap. Options include "symbol" (adjusted p-values displayed as stars: * < 0.05, ** < 0.01, *** < 0.001), "numeric" (adjusted p-values displayed as numbers, e.g. "p=0.012" or "p<0.001") and NULL (p-values not displayed). (Default: "symbol")

  • add.estimate: Logical scalar. Should the effect estimate be printed in each tile of the heatmap? The significance symbol or p-value is shown after it. (Default: TRUE)

name

Character scalar value defining which mediation data to use. (Default: "mediation")

layout

Character scalar Determines the layout of plot. Must be either "heatmap" or "forest". (Default: "heatmap")

Value

A ggplot2 object.

Details

plotMediation creates a heatmap starting from the output of the mediation functions, which are mia wrappers for the basic mediate function. Either a SummarizedExperiment or a data.frame object is supported as input. When the input is a SummarizedExperiment, this should contain the output of addMediation in the metadata slot and the argument name needs to be defined. When the input is a data.frame, this should be returned as output from getMediation.

In the heatmap, ACME, ADE and the total effect share one colour scale, centred at zero, so that colours can be compared between the columns. Because the ACME is often much smaller than the total effect, its tiles can be pale; the printed estimates show their size. The total effect does not depend on the mediator, so it is the same in every row. It is the sum of ACME and ADE and serves as their reference.

Examples

if (FALSE) { # \dontrun{
library(mia)
library(scater)

# Load dataset
data(hitchip1006, package = "miaTime")
tse <- hitchip1006

# Agglomerate features by family (merely to speed up execution)
tse <- agglomerateByRank(tse, rank = "Phylum")
# Convert BMI variable to numeric
tse[["bmi_group"]] <- as.numeric(tse[["bmi_group"]])

# Apply clr transformation to counts assay
tse <- transformAssay(tse, method = "clr", pseudocount = 1)

# Analyse mediated effect of nationality on BMI via clr-transformed features
# 100 permutations were done to speed up execution, but ~1000 are recommended
tse <- addMediation(
    tse, name = "assay_mediation",
    outcome = "bmi_group",
    treatment = "nationality",
    assay.type = "clr",
    covariates = c("sex", "age"),
    treat.value = "Scandinavia",
    control.value = "CentralEurope",
    boot = TRUE, sims = 100,
    p.adj.method = "fdr"
    )

# Visualise results as heatmap
plotMediation(tse, "assay_mediation")

# Visualise results as forest plot
plotMediation(tse, "assay_mediation", layout = "forest")
} # }