knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
You can install the released version of SMUT from CRAN with:
install.packages("SMUT")
And the development version from GitHub with:
# install.packages("devtools") devtools::install_github("wjzhong/SMUT")
SMUT package has functions to test for mediation effects of multiple SNPs (G) on a continuous, binary, count or time-to-event outcome (Y) through a continuous mediator (M). Besides SNPs data, these functions can also be applied to test mediation effects in other fields. In general, SMUT package has functions to test mediation effects of multiple continuous variables (G) on a continuous, binary, count or time-to-event outcome (Y) through a continuous mediator (M).
The example data has a genotype matrix (G) of 100 individuals with 200 SNPs.
library(SMUT) dim(Genotype_data) Genotype_data[1:3,1:4]
We generate one continuous mediator and one continuous outcome based on this genotype matrix, as well as two covariates.
N_individual = nrow(Genotype_data) N_SNPs = ncol(Genotype_data) set.seed(1) # generate two covariates X1 = rnorm(N_individual, 2, 3) X2 = sample(c(0,1), N_individual, replace = TRUE) X = cbind(X1, X2) # generate coefficients: iota_M, iota_Y, beta, theta and gamma iota_M = c(0.3,0.5) iota_Y = c(0.2,0.6) beta = rnorm(N_SNPs, 1, 2) theta = 1.2 gamma = rnorm(N_SNPs, 0.5, 2) # generate error terms e1 = rnorm(N_individual, 0, 1) e2 = rnorm(N_individual, 0, 1) # generate the mediator mediator = 1 + X %*% iota_M + Genotype_data %*% beta + e1 # generate the outcome outcome = 2 + mediator*theta + X %*% iota_Y + Genotype_data %*% gamma + e2
We apply SMUT function to test the mediation effect.
result_continuous = SMUT(G = Genotype_data, mediator = mediator, outcome = outcome, covariates = X) print( unlist( result_continuous ))
The warning messages are generated by the SKAT function in the R package SKAT. From the result, we can see that the p value of the mediation effect (p_value_IUT) is 0.02595523, which is the maximum of the p value of testing $\beta$ (p_value_beta) and the p value of testing $\theta$ (p_value_theta).
Full details of the SMUT method can be found in the manuscript:
Zhong, W., Spracklen, C.N., Mohlke, K.L., Zheng, X., Fine, J. and Li, Y., 2019. Multi-SNP mediation intersection-union test. Bioinformatics, 35(22), pp.4724-4729.
In the manuscript, GSMUT is referred to as SMUT_GLM for a continuous, binary or count outcome and as SMUT_PH for a time-to-event outcome.
The example data has a genotype matrix (G) of 100 individuals with 200 SNPs.
library(SMUT) dim(Genotype_data) Genotype_data[1:3,1:4]
We generate one continuous mediator, one binary outcome and one time-to-event outcome based on this genotype matrix, as well as two covariates.
N_individual = nrow(Genotype_data) N_SNPs = ncol(Genotype_data) set.seed(1) # generate two covariates X1 = rnorm(N_individual, 2, 3) X2 = sample(c(0,1), N_individual, replace = TRUE) X = cbind(X1, X2) # generate coefficients: iota_M, iota_Y, beta, theta and gamma iota_M = c(0.3,0.5) iota_Y = c(0.2,-0.6) beta = rnorm(N_SNPs, 0, 0.5) theta = 1 gamma = rnorm(N_SNPs, 0, 0.3) # generate error terms e1 = rnorm(N_individual, 0, 1) # generate the mediator mediator = 1 + X %*% iota_M + Genotype_data %*% beta + e1 # generate the binary outcome eta = 2 + mediator*theta + X %*% iota_Y + Genotype_data %*% gamma pi = 1/(1+exp( -(eta ) )) binary_outcome = rbinom(length(pi),size=1,prob=pi) # generate the time-to-event outcome based on Weibull baseline hazard v = runif(N_individual) lambda=0.01; rho=1; rateC=0.01 Tlat = (- log(v) / (lambda * exp( eta )))^(1 / rho) # censoring times C = rexp(N_individual, rate=rateC) # follow-up times and event indicators time = pmin(Tlat, C) status = as.numeric(Tlat <= C) survival_outcome = cbind(time,status) colnames(survival_outcome) = c("time","status")
We apply GSMUT function to test the mediation effect.
result_binary = GSMUT(G = Genotype_data, mediator = mediator, outcome = binary_outcome, covariates = X, outcome_type = "binary") print( unlist( result_binary ) ) result_survival = GSMUT(G = Genotype_data, mediator = mediator, outcome = survival_outcome, covariates = X, outcome_type = "survival") print( unlist( result_survival ))
The warning messages are generated by the SKAT function in the R package SKAT. From the result, we can see that the p value of the mediation effect (p_value_IUT) for the binary outcome is 0.000421673; p value of the mediation effect for the time-to-event outcome is 0.02470066. Here the p value of the mediation effect (p_value_IUT) is the maximum of the p value of testing $\beta$ (p_value_beta) and the p value of testing $\theta$ (p_value_theta). And theta_hat is the point estimate of the $\theta$ in the outcome model.
| Type of outcome | outcome_type | |:------:|:------:| | continuous | "continuous" | | binary | "binary" | | count | "count" | | time-to-event | "survival" |
Full details of the GSMUT method can be found in the manuscript:
Zhong, W., Darville, T., Zheng, X., Fine, J. and Li, Y., 2019. Generalized Multi-SNP Mediation Intersection-Union Test. Submitted
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.