class: title background-image: url("figures/interactive-screenshot.png") background-size: cover `\(\def\Gsn{\mathcal{N}}\)` `\(\def\Mult{\text{Mult}}\)` `\(\def\diag{\text{diag}}\)` `\(\def\*#1{\mathbf{#1}}\)` `\(\def\Scal{\mathcal{S}}\)` `\(\def\exp#1{\text{exp}\left(#1\right)}\)` `\(\def\logit#1{\text{logit}\left(#1\right)}\)` `\(\def\absarg#1{\left|#1\right|}\)` `\(\def\E{\mathbb{E}} % Expectation symbol\)` `\(\def\Earg#1{\E\left[{#1}\right]}\)` `\(\def\P{\mathbb{P}} % Expectation symbol\)` `\(\def\Parg#1{\P\left[{#1}\right]}\)` .center[ <br/> # Generative Models for Microbiome <br/> Mediation Analysis <br/> <br/> <br/> <br/> ] <div id="links"> Slides: https://go.wisc.edu/77q6rs Package: https://go.wisc.edu/pf72p4 </div> #### EcoSta 2023 | Topics in Microbiome Data Analysis .large[ Kris Sankaran | [krisrs1128.github.io/LSLab](krisrs1128.github.io/LSLab) | 01 August 2023 <br/> ] --- ### Psychometric & Genomic Integration 1. What is the relationship between mindfulness and the microbiome? 1. The [Handelsman](https://handelsmanlab.discovery.wisc.edu/) and [Davidson groups](https://www.richardjdavidson.com/) designed a study where volunteers' gut microbiomes were sampled before and after meditation training. * This generates joint psychometric, behavioral, and microbiome data 1. Changes in one assay might be associated with effects across all. To approach this, we use the language of graphical modeling. .center[ <img src="figures/microbe-mind.svg" width=420/> ] --- ### Mediation Analysis Mediation models are a type of graphical model where a treatment `\(T\)` can influence a response `\(Y\)` either directly or indirectly through a mediator `\(M\)`. This is formalized through a series of chained regression models, `\begin{align*} M &= \alpha_{0} + \alpha_{T}T + \alpha_{X}^{T}X + \varepsilon^{M} \text{ (mediation model)}\\ Y &= \beta_{0} + \beta_{T}T + \beta_{X}^{T}X + \beta_{M}^{T}M + \varepsilon^{Y} \text{ (outcome model) }. \end{align*}` <img src="figures/mediation-dag.svg" width="300" style="display: block; margin: auto;" /> --- ### Counterfactual Perspective * Typically the direct and indirect effects are read off `\(\alpha_{T}\)`, `\(\beta_{M}\)`, and `\(\beta_{T}\)`. * A more general approach considers the counterfactual difference in potential outcomes [1; 2], `\begin{align} \tau\left(t\right) &= \Earg{Y\left(X, 1, M\left(X, t\right)\right) - Y\left(X,0, M\left(X, t\right)\right)},\\ \delta\left(t\right) &= \Earg{Y\left(X, t, M\left(X, 1\right)\right) - Y\left(X, t, M\left(X, 0\right)\right)}, \end{align}` where the expectation is over draws `\(X\)`, `\(\varepsilon^{M}\)`, and `\(\varepsilon^{Y}\)` from the population. * `\(\tau\)` and `\(\delta\)` intervene on the treatment and mediator, respectively --- ### Counterfactual Perspective For example, if there is no mediation effect, `\(M\)` is unaffected by the treatment. Nonetheless, there can still be a large direct effect. <img src="figures/counterfactual-mediation2.svg" width="540" style="display: block; margin: auto;" /> --- ### Counterfactual Perspective Alternatively, the treatment can influence the response entirely by changing the typical value of the mediator. <img src="figures/counterfactual-mediation3.svg" width="600" style="display: block; margin: auto;" /> --- ### Counterfactual Perspective Both types of effects can exist simultaneously. <img src="figures/counterfactual-mediation4.svg" width="700" style="display: block; margin: auto;" /> --- ### Logistic Normal Multinomial We developed a suite of mediation models based on the Logistic Normal Multinomial (LNM), .pull-left[ `\begin{align*} Y \vert \beta &\sim \Mult\left(n, \varphi^{-1}\left(X^{T}\beta\right)\right) \\ \beta &\sim \Gsn\left(0, \diag\left(\sigma_{k}^{2}\right)\right) \end{align*}` where `\(\varphi^{-1}\left(z\right) \propto\left(\exp{z_{1}}, \dots, \exp{z_{K-1}}, 1\right)\)` and `\(n\)` denotes sequencing depth. ] .pull-right[ <img src="figures/lnm.svg" style="display: block; margin: auto;" /> ] --- ### Logistic Normal Multinomial Mediation We incorporate the mediator path in an LNM model. `\begin{align*} Y \vert \mu, M &\sim \Mult\left(n, \varphi^{-1}\left(\mu\right)\right) \\ \mu \vert M &= \beta_0 + \beta_T T + \beta_X^T X + \beta_M^T M + \varepsilon^{\mu} \\ M &= \alpha_0 + \alpha_T T + \alpha_X^T X + \varepsilon^m\\ \end{align*}` <img src="figures/lnm_med_model_causal.png" width="700" style="display: block; margin: auto;" /> --- ### Semisynthetic Model Comparison * Let's see how semisynthetic simulations can improve over more naive approaches. * Consider the problem of evaluating an LNM model. We will compare estimation quality when we simulate from, - The LNM itself - A simulator based on a pilot dataset --- ### Synthetic Setup In the first simulation, we simulate from a version of the LNM, `\begin{align*} Y &\sim \Mult\left(n, \varphi^{-1}\left(\xi_{0} + \xi_{T}T\right)\right) \\ \xi_{T} &:= \text{HardThreshold}\left(\tilde{\xi}_{T}, \text{keep 25%}\right) \\ \xi_{0}, \tilde{\xi}_{T} &\sim \Gsn\left(0, I_{K}\right) \\ \end{align*}` .center[ <img src="figures/lnm-spherical.png" width=500/> ] --- ### Semisynthetic Setup In the second, we use the exact same `\(\xi_{T}\)`, but now to exponentially tilt samples from treatment, `\begin{align*} Y \sim \Mult\left(n, \exp{\xi_{T}T}\odot \hat{p}^{\ast}\right) \end{align*}` Here, `\(\hat{p}^{\ast}\)` is drawn randomly with replacement from compositions in an observed pilot dataset (the meditation study data, in this case). --- ### Simulation Comparison The purely synthetic simulation setup leads to overoptimistic power and FSR estimates, compared to the semisynthetic setup. .center[ <img src="figures/semisynthetic_comparison.png" width=950/> ] --- ### Graphical ZINQ 1. We can adapt this to the graphical model setting by estimating nonparametric relationships across edges. 2. We can estimate ground truth direct and indirect effects by simulating from prespecified edge relationships. .center[ <img src="figures/mediation-assumptions.svg" width=570/> ] --- ### ZINQ-based Model Comparison 1. We design a semisynthetic simulator following [3]. 2. This approach estimates a CDF for each species using, `\begin{align*} \logit{\Parg{Y > 0 \vert X}} = \gamma_{0} + \gamma^{T}X \\ Q_{Y}\left(\tau \vert X, Y > 0\right) =\xi_{0}\left(\tau\right) + \xi\left(\tau\right)^{T}X \end{align*}` where `\(Q_{Y}\left(\tau \vert X, Y > 0\right)\)` is the conditional `\(\tau^{th}\)` quantile of a nonzero count. .center[ <img src="figures/zinq.png" width=400/> ] --- ### Graphical ZINQ Our package provides utilities for ZINQ estimation, simulation, and model comparison utilities. ```r simulator <- dataset_generator(x, m, trt, y) # covariates, mediators, treatment, abundances params <- expand.grid(sparsity = 0.5, scale = seq(0.1, 5, length.out = 10)) metrics <- power_analysis(simulator, params) ``` --- ### Meditation Study Results .pull-left[ * Based on the simulation results, we use a diff-in-diff model from our LNM-mediation suite. * We consider diet and sleep related variables as potential mediators in the mindfulness intervention. - Lack of significance in indirect effects suggests that behavior change alone does not explain microbiome composition shifts ] .pull-right[ <img src="figures/data_analysis_effects.png" width=500/> ] --- ### R Package We have prepared a package to support these modeling and evaluation techniques. .center[ <img src="figures/lnm_mediation_docs.png" width=900/> ] --- ### R Package We have prepared a package to support these modeling and evaluation techniques. ```r library(LNMmediation) library(phyloseq) data(mindfulness) var_names <- colnames(sample_data(mindfulness)) mediator_ix <- grepl("mediator", var_names) id_vars <- c("subject", "timepoint") input_data <- phyloseq_mediators(mindfulness, var_names[mediator_ix], id_vars) ``` --- ```r fit <- lnm_mediation(model_conf(baseline = TRUE), input_data, raw_output = TRUE) ``` ``` ## ------------------------------------------------------------ ## EXPERIMENTAL ALGORITHM: ## This procedure has not been thoroughly tested and may be unstable ## or buggy. The interface is subject to change. ## ------------------------------------------------------------ ## Gradient evaluation took 0.006494 seconds ## 1000 transitions using 10 leapfrog steps per transition would take 64.94 seconds. ## Adjust your expectations accordingly! ## Begin eta adaptation. ## Iteration: 1 / 250 [ 0%] (Adaptation) ## Iteration: 50 / 250 [ 20%] (Adaptation) ## Iteration: 100 / 250 [ 40%] (Adaptation) ## Iteration: 150 / 250 [ 60%] (Adaptation) ## Iteration: 200 / 250 [ 80%] (Adaptation) ## Success! Found best value [eta = 1] earlier than expected. ## Begin stochastic gradient ascent. ## iter ELBO delta_ELBO_mean delta_ELBO_med notes ## 100 -843671.889 1.000 1.000 ## 200 -393450.360 1.072 1.144 ## 300 -383892.804 0.723 1.000 ## 400 -382984.228 0.543 1.000 ## 500 -382466.111 0.435 0.025 ## 600 -381775.350 0.362 0.025 ## 700 -381793.603 0.311 0.002 MEDIAN ELBO CONVERGED ## Drawing a sample of size 1000 from the approximate posterior... ## COMPLETED. ## Finished in 92.5 seconds. ``` ```r plot_predictive(fit, max_taxa = 10) + labs(x = "Replicate", y = "Relative Abundance") + scale_fill_brewer(palette = "Set3") ``` <img src="20230801_files/figure-html/unnamed-chunk-10-1.png" width="850" style="display: block; margin: auto;" /> --- ### Interactive Visualization ```r plot_interactive(fit) ```
--- ### Thank you! This work has been a collaboration across several teams: .pull-left[ #### Department of Statistics * **Hanying Jiang** (Co-First Author) * **Xinran Miao** (Co-First Author) * Kris Sankaran #### Wisconsin Institute for Discovery * Margaret W. Thairu * Mara Beebe * Jo Handelsman ] .pull-right[ #### Center for Healthy Minds * Dan W. Grupe * Richard J. Davidson ] <img src="figures/uw-logo-flush-web.svg" class="logo"/> --- ### References [1] K. Imai, L. Keele, and D. Tingley. "A general approach to causal mediation analysis." In: _Psychological methods_ 15.4 (2010), p. 309. [2] M. B. Sohn and H. Li. "Compositional mediation analysis for microbiome studies". In: _The Annals of Applied Statistics_ 13.1 (2019), pp. 661-681. [3] W. Ling, N. Zhao, A. M. Plantinga, et al. "Powerful and robust non-parametric association testing for microbiome data via a zero-inflated quantile approach (ZINQ)". In: _Microbiome_ 9.1 (2021), pp. 1-19. --- ### Simulation Comparison To compare strategies, we compute the false sign rate (FSR) and power across species with increasingly large estimated effect sizes, analogous to an ROC curve. .center[ <img src="figures/threshold_ci.png" width=500/> ] --- ### Simulation Comparison To compare strategies, we compute the false sign rate (FSR) and power across species with increasingly large estimated effect sizes, analogous to an ROC curve. .center[ <img src="figures/threshold_ci-2.png" width=500/> ] --- ### ZINQ Simulation Fidelity This model generates fairly realistic data. .center[ <img src="figures/comparison.png" width=700/> ] --- ### ZINQ Simulation Fidelity This is the same plot, but restricting to nonnegative counts. .center[ <img src="figures/comparison_no_zeros.png" width=700/> ] --- ### LNM Goodness-of-Fit .center[ <img src="figures/lnm_bar.png" width=700/> ] --- ### Comparison across Models .center[ <img src="figures/realdata_conclusion_direct.png" width=850/> ] --- ### Comparison across Models .center[ <img src="figures/realdata_conclusion_direct-2.png" width=850/> ]