Warning in as.POSIXlt.POSIXct(Sys.time()): unknown timezone 'default/
America/Chicago'
Last updated: 2017-11-17
Code version: 703c629
# 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
We estimate the covariance using column-centered Z scores
D.center = apply(as.matrix(data$max$z), 2, function(x) x - mean(x))
mash_data_center = mashr::set_mash_data(Bhat = as.matrix(D.center))
Here we create 3 type of data-driven covariance matrices:
and apply Extreme Deconvolution
to refine these matrices. We observed that Extreme Deconvolution perserves rank.
Additionally we include 2 other types of covariance matrices:
canonical configurations (aka bmalite
)
simple heterogeneity models
FlashResult = readRDS('../output/Immune.flash2.center.greedy.K10.rds')
Flash_res = flash_get_lf(FlashResult$f)
U.flash = c(mashr::cov_from_factors(t(as.matrix(FlashResult$F_flash[,1:5])), "Flash"),
list("tFlash" = t(Flash_res) %*% Flash_res / nrow(data$max$z)))
# PCA matrices
U.pca = cov_pca(mash_data_center, P)
# Emperical data matrices
# Denoised data-driven matrices
U.dd = c(U.flash, U.pca, list("XX" = t(D.center) %*% D.center / nrow(data$max$z)))
mash_data = mashr::set_mash_data(Bhat = as.matrix(data$max$beta),
Shat = as.matrix(data$max$se), alpha=0)
U.ed = cov_ed(mash_data, U.dd)
# Canonical
U.can = cov_canonical(mash_data)
# save Covariance matrix
saveRDS(list(Ulist = c(U.ed, U.can), DD_raw = U.dd),
paste0('../output/ImmuneEE.U.center.xtx.K',K,'.P',P,'.rds'))
sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.1
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.2-3 ExtremeDeconvolution_1.3
[3] mashr_0.2-4 ashr_2.1-27
loaded via a namespace (and not attached):
[1] Rcpp_0.12.13 compiler_3.4.2 git2r_0.19.0
[4] plyr_1.8.4 iterators_1.0.8 tools_3.4.2
[7] digest_0.6.12 evaluate_0.10.1 tibble_1.3.4
[10] gtable_0.2.0 lattice_0.20-35 rlang_0.1.2
[13] Matrix_1.2-11 foreach_1.4.3 yaml_2.1.14
[16] parallel_3.4.2 mvtnorm_1.0-6 stringr_1.2.0
[19] knitr_1.17 rprojroot_1.2 grid_3.4.2
[22] rmarkdown_1.7 rmeta_2.16 ggplot2_2.2.1
[25] magrittr_1.5 backports_1.1.1 scales_0.5.0
[28] codetools_0.2-15 htmltools_0.3.6 MASS_7.3-47
[31] assertthat_0.2.0 colorspace_1.3-2 stringi_1.1.5
[34] lazyeval_0.2.1 pscl_1.5.2 doParallel_1.0.11
[37] munsell_0.4.3 truncnorm_1.0-7 SQUAREM_2017.10-1
This R Markdown site was created with workflowr