Last updated: 2021-04-09

Checks: 7 0

Knit directory: mmbr-rss-dsc/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20200227) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 2c8eae7. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .DS_Store
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/figure/
    Ignored:    data/.DS_Store
    Ignored:    output/.DS_Store

Untracked files:
    Untracked:  data/ENSG00000140265.12.Multi_Tissues.rds
    Untracked:  data/FastQTLSumStats.mash.FL_PC3.rds
    Untracked:  data/Multi_Tissues.ENSG00000089486.RDS
    Untracked:  data/mmbr_ukb_simulation/
    Untracked:  data/mmbr_ukb_simulation_problem/
    Untracked:  data/ukb_rss_naive_lfsr_problem.rds
    Untracked:  data/ukb_rss_naive_pip_problem.rds
    Untracked:  output/GTExprofile_res.rds
    Untracked:  output/GTExprofile_resL1.rds
    Untracked:  output/GTExprofile_resL1_elbo.rds
    Untracked:  output/GTExprofile_resL3.rds
    Untracked:  output/GTExprofile_resL3_elbo.rds
    Untracked:  output/GTExprofile_res_elbo.rds
    Untracked:  output/GTExprofile_resapprox.rds
    Untracked:  output/GTExprofile_resapproxL1.rds
    Untracked:  output/GTExprofile_resapproxL1_elbo.rds
    Untracked:  output/GTExprofile_resapproxL3.rds
    Untracked:  output/GTExprofile_resapproxL3_elbo.rds
    Untracked:  output/GTExprofile_resapprox_elbo.rds
    Untracked:  output/GTExprofile_resapproxdiag.rds
    Untracked:  output/GTExprofile_resapproxdiagL1.rds
    Untracked:  output/GTExprofile_resapproxdiagL1_elbo.rds
    Untracked:  output/GTExprofile_resapproxdiagL3.rds
    Untracked:  output/GTExprofile_resapproxdiagL3_elbo.rds
    Untracked:  output/GTExprofile_resapproxdiag_elbo.rds
    Untracked:  output/GTExprofile_resdiag.rds
    Untracked:  output/mmbr_gtex_res.Rprof
    Untracked:  output/mmbr_gtex_res_approx.Rprof
    Untracked:  output/mmbr_gtex_res_approx_diag.Rprof
    Untracked:  output/mmbr_gtex_res_diag.Rprof
    Untracked:  output/mnm_missing_output.20200527.rds
    Untracked:  output/test
    Untracked:  output/tiny_data_211_cond2L2.gif
    Untracked:  output/tiny_data_211_cond2L2.pdf
    Untracked:  output/tiny_data_211_cond2L3.gif
    Untracked:  output/tiny_data_211_cond2L3.pdf
    Untracked:  output/tiny_data_211_cond2initL3.gif
    Untracked:  output/tiny_data_211_cond2initL3.pdf
    Untracked:  output/ukb_rss_20200107/
    Untracked:  output/ukb_rss_20210313/

Unstaged changes:
    Modified:   analysis/mmbr_missing_rss_problem1.Rmd

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/mmbr_rss_ukb_simulation_20210313_RandomvsDefault.Rmd) and HTML (docs/mmbr_rss_ukb_simulation_20210313_RandomvsDefault.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 2c8eae7 zouyuxin 2021-04-09 wflow_publish(“analysis/mmbr_rss_ukb_simulation_20210313_RandomvsDefault.Rmd”)

The data is simulated using UKB bloodcells patterns.

dat = readRDS('output/ukb_rss_20210313/data_ukb_14.rds')
simu = readRDS('output/ukb_rss_20210313/data_ukb_14_ukb_bloodcells_mixture_1.rds')
ld <- readRDS('output/ukb_rss_20210313/bloodcells_chr1.36507801.37193916.ld.rds')
meta <- simu$meta
suffstats <- simu$suffstats
sumstats <- simu$sumstats
L <- 10
maxiter <- 1000

The true cofficients are

true_coef = meta$true_coef
beta_idx = which(rowSums(true_coef!=0)>0) #  631 2877
par(mfrow=c(1,2))
barplot(true_coef[beta_idx[1],])
barplot(true_coef[beta_idx[2],])

The z scores for true signals:

resid_Z = meta$residual_variance
Z = as.matrix(sumstats$bhat/sumstats$sbhat)
Z[is.na(Z)] = 0
par(mfrow=c(1,2))
barplot(Z[beta_idx[1],], las=2, cex.names = 0.7)
barplot(Z[beta_idx[2],], las=2, cex.names = 0.7)

Using Default prior,

priorUn = meta$prior[['naive']]
m_initn = mvsusieR::create_mash_prior(mixture_prior = list(matrices=priorUn$xUlist, weights=priorUn$pi),
                                 null_weight=priorUn$null_weight, max_mixture_len=-1)
result = mvsusieR::mvsusie_rss(Z, ld, L=2, prior_variance=m_initn, 
                          residual_variance=resid_Z,compute_objective=T, 
                          estimate_prior_variance=T, estimate_prior_method='EM',
                          precompute_covariances=T, n_thread=1, 
                          max_iter=100, track_fit = T)
Iteration 1 delta = Inf
Iteration 2 delta = 9.57970887208648
Iteration 3 delta = 7.61937417403533
Iteration 4 delta = 2.55643740653613
Iteration 5 delta = 0.485033667078824
Iteration 6 delta = 0.101214589871233
Iteration 7 delta = 0.0354468342775363
Iteration 8 delta = 0.0215204256164725
Iteration 9 delta = 0.0174761971356929
Iteration 10 delta = 0.015664506048779
Iteration 11 delta = 0.0144726800062926
Iteration 12 delta = 0.137843744654674
susieR::susie_plot(result, y='PIP', b=true_coef, main=paste0('ELBO = ', round(susieR::susie_get_objective(result), 2)))

Using identity prior,

priorUi = meta$prior[['identity']]
m_initi = mvsusieR::create_mash_prior(mixture_prior = list(matrices=priorUi$xUlist, weights=priorUi$pi),
                                 null_weight=priorUi$null_weight, max_mixture_len=-1)
result_ide = mvsusieR::mvsusie_rss(Z, ld, L=2, prior_variance=m_initi, residual_variance=resid_Z,
                                   compute_objective=T, estimate_prior_variance=T, estimate_prior_method='EM',
                                   precompute_covariances=T, n_thread=1, max_iter=100, track_fit = T)
Iteration 1 delta = Inf
Iteration 2 delta = 10.086834519534
Iteration 3 delta = 8.64865685154655
Iteration 4 delta = 3.6689518900821
Iteration 5 delta = 1.1973131689374
Iteration 6 delta = 0.425353791688394
Iteration 7 delta = 0.134743233851623
Iteration 8 delta = 0.0360138489340898
Iteration 9 delta = 0.00858377601252869
Iteration 10 delta = 0.00192239973694086
susieR::susie_plot(result_ide, y='PIP', b=true_coef, main=paste0('ELBO = ', round(susieR::susie_get_objective(result_ide), 2)))

I set estimate prior variance = FALSE, and run with 1 iteration.

result1 = mvsusieR::mvsusie_rss(Z, ld, L=2, prior_variance=m_initn, 
                          residual_variance=resid_Z,compute_objective=T, 
                          estimate_prior_variance=F, estimate_prior_method='EM',
                          precompute_covariances=T, n_thread=1, 
                          max_iter=1, track_fit = T)
Warning in SuSiE_model$fit(data, prior_weights, estimate_prior_method,
check_null_threshold, : IBSS failed to converge after 1 iterations. Perhaps you
should increase max_iter and try again.
Iteration 1 delta = Inf
susieR::susie_plot(result1, y='PIP', b=true_coef, main=paste0('ELBO = ', round(susieR::susie_get_objective(result1), 2)))

result_ide1 = mvsusieR::mvsusie_rss(Z, ld, L=2, prior_variance=m_initi, residual_variance=resid_Z,
                                   compute_objective=T, estimate_prior_variance=F, estimate_prior_method='EM',
                                   precompute_covariances=T, n_thread=1, max_iter=1, track_fit = T)
Warning in SuSiE_model$fit(data, prior_weights, estimate_prior_method,
check_null_threshold, : IBSS failed to converge after 1 iterations. Perhaps you
should increase max_iter and try again.
Iteration 1 delta = Inf
susieR::susie_plot(result_ide1, y='PIP', b=true_coef, main=paste0('ELBO = ', round(susieR::susie_get_objective(result_ide1), 2)))


sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/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] workflowr_1.6.2

loaded via a namespace (and not attached):
 [1] progress_1.2.2      softImpute_1.4      tidyselect_1.1.0   
 [4] xfun_0.22           reshape2_1.4.4      purrr_0.3.4        
 [7] ashr_2.2-51         lattice_0.20-41     colorspace_2.0-0   
[10] vctrs_0.3.7         generics_0.1.0      htmltools_0.5.1.1  
[13] yaml_2.2.1          utf8_1.2.1          rlang_0.4.10       
[16] mixsqp_0.3-46       later_1.1.0.1       pillar_1.5.1       
[19] DBI_1.1.1           glue_1.4.2          mashr_0.2.43       
[22] plyr_1.8.6          matrixStats_0.58.0  lifecycle_1.0.0    
[25] stringr_1.4.0       munsell_0.5.0       gtable_0.3.0       
[28] mvtnorm_1.1-1       evaluate_0.14       knitr_1.31         
[31] httpuv_1.5.5        invgamma_1.1        irlba_2.3.3        
[34] fansi_0.4.2         highr_0.8           Rcpp_1.0.6         
[37] promises_1.2.0.1    scales_1.1.1        susieR_0.10.1      
[40] rmeta_3.0           truncnorm_1.0-8     abind_1.4-5        
[43] fs_1.5.0            flashr_0.6-7        ggplot2_3.3.3      
[46] hms_1.0.0           digest_0.6.27       stringi_1.5.3      
[49] dplyr_1.0.5         grid_4.0.3          rprojroot_2.0.2    
[52] tools_4.0.3         magrittr_2.0.1      tibble_3.1.0       
[55] crayon_1.4.1        whisker_0.4         pkgconfig_2.0.3    
[58] ellipsis_0.3.1      Matrix_1.3-2        SQUAREM_2021.1     
[61] prettyunits_1.1.1   reshape_0.8.8       assertthat_0.2.1   
[64] rmarkdown_2.7       R6_2.5.0            mvsusieR_0.0.3.0436
[67] git2r_0.28.0        compiler_4.0.3