Last updated: 2018-01-07
Code version: e92eeac
# Load required packages
library(mashr); library(ExtremeDeconvolution); library(flashr2)
Loading required package: ashr
# read data
data = readRDS('../data/ImmuneQTLSummary.4MASH.rds')
data$max$se = data$max$beta/data$max$z
data$null$se = data$null$beta / data$null$z
# set parameters
K = 10
P = 5
vhat = 1
mash
modelUsing a random null set, the cell below computes the weights for input covariance matrices (Covariance matrices plus loading) in MASH mixture. The output contains matrix of log-likelihoods as well as weights learned from the hierarchical model.
if (vhat == 1) {
V = cor(data$null$z[which(apply(abs(data$null$z),1, max) < 2),])
} else {
V = diag(ncol(data$null$z))
}
mash_data = mashr::set_mash_data(Bhat = as.matrix(data$null$beta),
Shat = as.matrix(data$null$se),
V=as.matrix(V), alpha=1)
Ulist = readRDS('../output/ImmuneEZ.U.center.xtx.Load.K10.P5.rds')$Ulist
saveRDS(mashr::mash(mash_data, Ulist, outputlevel = 1),
paste0('../output/ImmuneEZ.V',vhat,'.center.mash_model.Load.K',K,'.P',P,'.rds'))
- Computing 193301 x 1008 likelihood matrix.
- Likelihood calculations took 26.05 seconds.
- Fitting model with 1008 mixture components.
Warning in REBayes::KWDual(A, rep(1, k), normalize(w), control = control): estimated mixing distribution has some negative values:
consider reducing rtol
Warning in mixIP(matrix_lik = structure(c(0.256254290186069,
0.750668812603541, : Optimization step yields mixture weights that are
either too small, or negative; weights have been corrected and renormalized
after the optimization.
- Model fitting took 1142.36 seconds.
Applying hyperparameters learned from the training (the null) set to the test (the top eQTL) set, the cell below computes posterior quantities.
U.m = readRDS('../output/ImmuneEZ.V1.center.mash_model.Load.K10.P5.rds')
if (vhat == 1) {
V = cor(data$null$z[which(apply(abs(data$null$z),1, max) < 2),])
} else {
V = diag(ncol(data$null$z))
}
mash_data = mashr::set_mash_data(Bhat = as.matrix(data$max$beta),
Shat = as.matrix(data$max$se),
V = as.matrix(V),
alpha = 1)
saveRDS(mash_compute_posterior_matrices(U.m, mash_data),
paste0('../output/ImmuneEZ.V',vhat,'.center.mash_posterior.Load.K',K,'.P',P,'.rds'))
FIXME: 'compute_posterior_matrices' in Rcpp does not transfer EZ to EE
sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.2
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] flashr2_0.4-0 ExtremeDeconvolution_1.3
[3] mashr_0.2-4 ashr_2.1-27
loaded via a namespace (and not attached):
[1] Rcpp_0.12.14 knitr_1.17 magrittr_1.5
[4] REBayes_1.2 MASS_7.3-47 doParallel_1.0.11
[7] pscl_1.5.2 SQUAREM_2017.10-1 lattice_0.20-35
[10] foreach_1.4.4 plyr_1.8.4 stringr_1.2.0
[13] tools_3.4.3 parallel_3.4.3 grid_3.4.3
[16] rmeta_2.16 git2r_0.20.0 htmltools_0.3.6
[19] iterators_1.0.9 assertthat_0.2.0 yaml_2.1.16
[22] rprojroot_1.2 digest_0.6.13 Matrix_1.2-12
[25] codetools_0.2-15 evaluate_0.10.1 rmarkdown_1.8
[28] stringi_1.1.6 compiler_3.4.3 Rmosek_8.0.69
[31] backports_1.1.2 mvtnorm_1.0-6 truncnorm_1.0-7
This R Markdown site was created with workflowr