Here we analyze an example of GTEx V7 cis-gene data-set.
raw_data = readRDS('Multi_Tissues.ENSG00000145214.RDS')
names(raw_data)
dim(raw_data$X)
dim(raw_data$y_res)
head(raw_data$y_res)
data = mvsusieR:::DenseData$new(raw_data$X, raw_data$y_res)
residual_covar = diag(apply(raw_data$y_res, 2, function(x) var(x, na.rm=T)))
prior_mats = mvsusieR:::create_cov_canonical(ncol(raw_data$y_res), singletons=F)
scaling = c(0.05,0.15,0.25,0.4) # FIXME: use auto-grid
str(prior_mats)
str(data)
Now using EE model,
mash_init = mvsusieR:::MashInitializer$new(prior_mats, scaling, alpha = 0)
mash_init$precompute_cov_matrices(data, residual_covar)
The line above currently takes 3m40s. It is 2.5GB on disk in RDS format. This is to compute for $R = 49, J = 7962, P = 21$. $P$ is 21 for null weight plus at most 20 other components. I saved it to disk,
saveRDS(mash_init, 'mash_init.rds')
-rw-r--r-- 1 gaow gaow 2.5G May 12 07:41 mash_init.rds
And test the memory it takes to keep it -- 7.42GB.
python ~/GIT/github/misc/monitor/monitor.py Rscript -e "mash_init = readRDS('mash_init.rds')"
time elapsed: 25.18s
peak first occurred: 15.40s
peak last occurred: 24.65s
max vms_memory: 7.42GB
max rss_memory: 7.23GB
memory check interval: 1s
return code: 0
mvsusie_obj = mvsusieR:::MashRegression$new(ncol(raw_data$X), residual_covar, mash_init)
mvsusie_obj$fit(data)
The step above now take 2 min. This is for one iteration. MV-SuSiE
computation time will depend on how many iterations there are, as we will find out next.
#mash_init = readRDS('mash_init.rds')
res = mvsusieR::susie(raw_data$X,raw_data$y_res,
L=10,prior_variance=mash_init,
compute_objective=FALSE)
Code above takes 25 minutes to complete for L=5, >1hr for L=10.
saveRDS(res, "mvsusie_res_10.rds")
p = mvsusieR::mvsusie_plot(res)
pdf('mvsusie_plot_ENSG00000145214.pdf', width = 20, height = 20)
print(p$plot)
dev.off()
pdf('susie_plot_ENSG00000145214.pdf', width=9, height=5)
susieR::susie_plot(res,y='PIP', main = 'Default SuSiE plot for cross-condition PIP', xlab = 'SNP positions', add_legend = T)
dev.off()
%preview susie_plot_ENSG00000145214.pdf -s png --dpi 150
%preview mvsusie_plot_ENSG00000145214.pdf -s png --dpi 150