This package provides a way to estimate and test marginal mediation effects for zero-inflated compositional mediators.
## From GitHub:
::install_github("quranwu/MarZIC") devtools
Detailed instructions can be found in the vignette file.
The example data was built from scratch, with 200 observations and 10 taxon.
library(MarZIC)
## A make up example with 1 taxon and 100 subjects.
set.seed(1)
<- 200
nSub <- 10
nTaxa ## generate covariate of interest X
<- rbinom(nSub, 1, 0.5)
X ## generate mean of each taxon. All taxon are having the same mean for simplicity.
<- exp(-5 + X) / (1 + exp(-5 + X))
mu <- 10
phi
## generate true RA
<-t(sapply(mu,function(x) dirmult::rdirichlet(n=1,rep(x*phi,nTaxa))))
M_taxon
<- exp(-3 + 0.3 * X) / (1 + exp(-3 + 0.3 * X))
P_zero
<- t(sapply(P_zero,function(x) 1-rbinom(nTaxa,1,rep(x,nTaxa))))
non_zero_ind
<-t(apply(M_taxon*non_zero_ind,1,function(x) x/sum(x)))
True_RA
## generate outcome Y based on true RA
<- 1 + 100 * True_RA[,1] + 5 * (True_RA[,1] > 0) + X + rnorm(nSub)
Y
## library size was set to 10,000 for all subjects for simplicity.
<- 10000
libsize
## generate observed RA
<- floor(M_taxon*libsize*non_zero_ind)
observed_AA
<- t(apply(observed_AA,1,function(x) x/sum(x)))
observed_RA colnames(observed_RA)<-paste0("rawCount",seq_len(nTaxa))
## Construct SummerizedExperiment object
<- cbind(Y = Y, X = X, libsize = libsize)
CovData <-
test_dat ::SummarizedExperiment(assays = list(MicrobData = t(observed_RA)), colData = CovData)
SummarizedExperiment
## run the analysis
<- MarZIC(
res Experiment_dat = test_dat,
lib_name = "libsize",
y_name = "Y",
x_name = "X",
num_cores = 1,
mediator_mix_range = 1
)
Once the analysis is done, res
is a list with four
elements, each for NIE\(_1\), NIE\(_2\), NDE, NIE, respectively. The NIE\(_1\), for example, could be extracted
as:
<- res$NIE1_save NIE1
And the significant result could be extracted as:
subset(NIE1,significance == TRUE)
Wu et al.(2022) MarZIC: A Marginal Mediation Model for Zero-Inflated Compositional Mediators with Applications to Microbiome Data. Genes 2022, 13, 1049.