plotMediation | R Documentation |
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 signature 'SummarizedExperiment'
plotMediation(x, name = "mediation", ...)
## S4 method for signature 'data.frame'
plotMediation(x, layout = "heatmap", ...)
x |
a
|
... |
Additional parameters for plotting.
|
name |
|
layout |
|
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.
A ggplot2
object.
## Not run:
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")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.