Skip to content

Commit

Permalink
Finalise draft of mediation chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
RiboRings committed Feb 8, 2025
1 parent 834b011 commit a80be6b
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 27 deletions.
40 changes: 40 additions & 0 deletions inst/assets/bibliography.bib
Original file line number Diff line number Diff line change
Expand Up @@ -2321,3 +2321,43 @@ @article{mangiola2023
eprint = {https://www.pnas.org/doi/pdf/10.1073/pnas.2203828120},
}

@Article{Tingley2014mediation,
title = {{mediation}: {R} Package for Causal Mediation Analysis},
author = {Dustin Tingley and Teppei Yamamoto and Kentaro Hirose and Luke Keele and Kosuke Imai},
journal = {Journal of Statistical Software},
year = {2014},
volume = {59},
number = {5},
pages = {1--38},
url = {http://www.jstatsoft.org/v59/i05/},
}

@article{Xia2021mediation,
title={Mediation Analysis of Microbiome Data and Detection of Causality in Microbiome Studies},
author={Xia, Yinglin},
journal={Inflammation, Infection, and Microbiome in Cancers: Evidence, Mechanisms, and Implications},
pages={457--509},
year={2021},
publisher={Springer}
}

@article{Dinan2022antibiotics,
title={Antibiotics and mental health: The good, the bad and the ugly},
author={Dinan, Katherine and Dinan, Timothy},
journal={Journal of Internal Medicine},
volume={292},
number={6},
pages={858--869},
year={2022},
publisher={Wiley Online Library}
}

@article{Logan2014nutritional,
title={Nutritional psychiatry research: an emerging discipline and its intersection with global urbanization, environmental challenges and the evolutionary mismatch},
author={Logan, Alan C and Jacka, Felice N},
journal={Journal of Physiological Anthropology},
volume={33},
pages={1--16},
year={2014},
publisher={Springer}
}
146 changes: 119 additions & 27 deletions inst/pages/mediation.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,64 @@ chapterPreamble()
```

Mediation analysis is used to study the effect of an independent variable (X) on
the outcome variable (Y) through a third variable, known as mediator (M). Mathematically, this relationship is described as follows:
the outcome (Y) through a third factor, known as mediator (M). Mathematically,
this relationship can be described as follows:

Y ~ X * M
$$
Y \thicksim X * M
$$

The significance of a mediator is typically quantified in terms of the mediated
effect, that is, the portion of the association between X and Y that can be
explained through M. This corresponds to the difference between the total effect
and the direct effect and is called Average Causal Mediated Effect (ACME):
The contribution of a mediator is typically quantified in terms of Average
Causal Mediated Effect (ACME), that is, the portion of the association between X
and Y that is explained by M. In practice, this corresponds to the difference
between the Total Effect (TE) and the Average Direct Effect (ADE):

ACME = Total Effect - Average Direct Effect
$$
ACME = TE - ADE
$$

Put nice illustration of mediation, use a DAG.
The microbiome can mediate the effects of multiple environmental stimuli on
human health. However, the importance of its role as a mediator depends on the
nature of the stimulus. For example, the effect of dietary fiber intake on host behaviour is largely mediated by the gut microbiome [@Logan2014nutritional]. On
the other hand, the indirect impact of antibiotic use on mental health through
an altered microbiome represents a more subtle phenomenon [@Dinan2022antibiotics].

The microbiome has the potential to mediate the effects of multiple environmental
stimuli on human health. For example, the impact of antibiotics on humour largely
depends on microbiome depletion. In this case, we talk about complete mediation.
On the other hand, diet affects the organism directly via nutrition and
metabolism, but in part also delivered through the microbiome. In this case, we
talk about partial mediation.
In general, the wide range of mediation effects can be divided into two classes:
- complete mediation, where the mediator conveys the full effect of the the
treatment variable on the outcome
- partial mediation, where the mediator only assists the treatment variable in
conveying the effect on the outcome

We demonstrate a basic mediation analysis and visualisation with the hitchip1006
dataset from miaTime package.
Put nice illustration of mediation as a DAG.

We demonstrate a standard mediation analysis with the `hitchip1006` dataset
from the `miaTime` package, which contains a genus-level assay for 1006 western
adults of 6 different nationalities.

```{r}
#| label: mediation1
#| message: false
# Import libraries
library(mia)
library(miaViz)
library(scater)
library(patchwork)
# Load dataset
data(hitchip1006, package = "miaTime")
tse <- hitchip1006
```

In our analyses, nationality and BMI group will represent the independent (X)
and outcome (Y) variables, respectively. We make the broad assumption that
nationality reflects differences in the living environment between subjects.

```{r}
#| label: mediation2
# Convert BMI variable to numeric
tse$bmi_group <- as.numeric(tse$bmi_group)
# Agglomerate features by family (merely to speed up execution)
# Agglomerate features by phylum
tse <- agglomerateByRank(tse, rank = "Phylum")
# Apply clr transformation to counts assay
Expand All @@ -51,14 +72,29 @@ tse <- transformAssay(tse,
pseudocount = 1)
```

## Feature mediation
In the following examples, the effect of living environment on BMI mediated
by the microbiome is investigated in 3 different steps:

1. global contribution by alpha diversity
2. individual contributions by assay features
3. combined contributions by reduced dimensions

## Alpha diversity as mediator

First, we ask whether alpha diversity mediates the effect of living environment
on BMI. Using the `getMediation` function, the variables X, Y and M are
specified with the arguments `treatment`, `outcome` and `mediator`, respectively.
We control for sex and age and limit comparisons to two nationality groups,
Central Europeans (control) vs. Scandinavians (treatment).

```{r}
#| label: mediation3
#| message: false
# Analyse mediated effect of nationality on BMI via alpha diversity
# 100 permutations were done to speed up execution, but ~1000 are recommended
med_df <- getMediation(tse,
outcome = "bmi_group",
treatment = "nationality",
outcome = "bmi_group",
mediator = "diversity",
covariates = c("sex", "age"),
treat.value = "Scandinavia",
Expand All @@ -69,11 +105,21 @@ med_df <- getMediation(tse,
plotMediation(med_df, layout = "forest")
```

what is the meaning of ACME, ADE and total effect?
The forest plot above shows significance for both ACME and ADE, which suggests
that alpha diversity is a partial mediator of living environment on BMI. In
contrast, if ACME but not ADE were significant, complete mediation would be
inferred.

## Assay mediation
## Assay features as mediators

If we suspect that only certain features of the microbiome act as mediators,
we can estimate their individual contributions by fitting one model for each
feature in a selected assay. As multiple tests are performed, it is good
practice to correct the significance of the findings with a method of choice.

```{r}
#| label: mediation4
#| message: false
# 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",
Expand All @@ -87,17 +133,39 @@ tse <- addMediation(tse, name = "assay_mediation",
p.adj.method = "fdr")
# Show results for first 5 mediators
head(metadata(tse)$assay_mediation, 5)
knitr::kable(metadata(tse)$assay_mediation)
```

For convenience, results can be visualized with a heatmap, where rows represent
features and columns correspond to the coefficients for TE, ADE and ACME.
Significant findings can be marked with p-values or stars.

```{r}
plotMediation(tse, "assay_mediation", layout = "heatmap")
#| label: mediation5
plotMediation(tse, "assay_mediation", layout = "heatmap",
add.significance = "symbol")
```

Results suggest that only four out of eight features (Bacteroidetes, Firmicutes,
Proteobacteria and Verrucomicrobia) partially mediate the effect of living
environment on BMI.

While analyses were conducted at the phylum level to simplify results, using
original assays without agglomeration also represents a valid option. However,
the increase in phylogenetic resolution also implies a higher probability of
spurious findings, which in turn necessitates a stronger correction for multiple
comparisons. A solution to this issue is proposed in the following section.

## Reduced dimensions as mediators

## Mediation of reduced dimensions
Performing mediation analysis for each feature provides insight into individual
contributions. However, this approach greatly increases the number of drawn comparisons and thus it reduces statistical power. To overcome this issue, it is
possible to assess the combined contributions of subset of features by means of
dimensionality reduction.

```{r}
#| label: mediation6
#| message: false
# Perform ordination
tse <- runPCA(tse, name = "PCA",
assay.type = "clr",
Expand All @@ -116,15 +184,39 @@ tse <- addMediation(tse, name = "reddim_mediation",
p.adj.method = "fdr")
# Show results for first 5 mediators
head(metadata(tse)$reddim_mediation, 5)
knitr::kable(metadata(tse)$reddim_mediation)
```

Results can be displayed as one forest plot for each reduced dimension. When
combined with a heatmap of the feature loadings for each dimension, we can
deduce whether certain groups of features act as mediators.

```{r}
#| label: mediation7
p1 <- plotMediation(tse, "reddim_mediation", layout = "forest")
p2 <- plotLoadings(tse, "PCA", ncomponents = 3, n = 8, layout = "heatmap")
library(patchwork)
p1 / p2
```

The plot above suggests that only PC1 partially mediates the effect of living
environment on BMI. Within this dimension, Bacteroidetes and Actinobacteria are
the largest contributors.

## Final remarks

This chapter introduced the concept of mediation and demonstrated a standard
analysis of the microbiome as mediator at 3 different levels (global, individual
and combined contributions). Importantly, the provided method is based on the `mediation` package and is limited to univariate comparisons and binary
treatment conditions [@Tingley2014mediation]. Therefore, it is recommended to
reduce the number of mediators under study by means of a knowledge-based
strategy to preserve statistical power.

A few methods for multivariate mediation analysis of high-dimensional omic
data also exist [@Xia2021mediation]. However, no one solution has emerged to
become the golden standard in microbiome data analysis, mainly because the
available approaches can only partially accommodate for the specific properties
of microbiome data, such as compositionality, sparsity and its hierarchical
structure. While this chapter proposed a standard approach to mediation analysis,
in the future fine-tuned solutions for the microbiome may also become common.

0 comments on commit a80be6b

Please sign in to comment.