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", ...)
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"
(p-values displayed as symbols), "numeric"
(p-values displayed as
numeric values) and NULL
(p-values not displayed).
(Default: "symbol"
)
Character scalar
value defining which mediation data
to use. (Default: "mediation"
)
Character scalar
Determines the layout of plot. Must be
either "heatmap" or "forest". (Default: "heatmap"
)
A ggplot2
object.
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.
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")
} # }