plotMediation: Visualize mediation

plotMediationR Documentation

Visualize mediation

Description

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.

Usage

plotMediation(x, ...)

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

## S4 method for signature '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" (p-values displayed as symbols), "numeric" (p-values displayed as numeric values) and NULL (p-values not displayed). (Default: "symbol")

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")

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.

Value

A ggplot2 object.

Examples

## 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)


microbiome/miaViz documentation built on Feb. 3, 2025, 12:15 a.m.