Last updated: 2020-10-05

Checks: 7 0

Knit directory: Note/

This reproducible R Markdown analysis was created with workflowr (version 1.6.1). 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(20180529) 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 fe82bf4. 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/.Rhistory

Untracked files:
    Untracked:  analysis/Li&Stephens.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_missing_implement.Rmd) and HTML (docs/mmbr_missing_implement.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 fe82bf4 zouyuxin 2020-10-05 wflow_publish(“analysis/mmbr_missing_implement.Rmd”)
html 8b93415 zouyuxin 2020-10-05 Build site.
Rmd fde720c zouyuxin 2020-10-05 wflow_publish(“analysis/mmbr_missing_implement.Rmd”)
html 8a3d02e zouyuxin 2020-10-04 Build site.
Rmd f7841a1 zouyuxin 2020-10-04 wflow_publish(“analysis/mmbr_missing_implement.Rmd”)
html bc18167 zouyuxin 2020-10-04 Build site.
Rmd 5be98b5 zouyuxin 2020-10-04 wflow_publish(“analysis/mmbr_missing_implement.Rmd”)

In supplementary of the manuscript, we show the derivation for multivariate SuSiE with missing data. We notice that we only need to compute \(\tilde{\mathbf{X}}_i\) and \(\sum_{i=1}^{N} \tilde{\mathbf{X}}_i \Gamma_i \Sigma_i^\dagger \Gamma_i \tilde{\mathbf{X}}_i\) once before the algorithm begins.

We simulate data with 100 samples, 100 SNPs, 2 conditions, half of the observation is missing.

library(mmbr)
Loading required package: mashr
Loading required package: ashr
Loading required package: susieR
simulate_multivariate = function(n=100,p=100,r=2,center_scale=TRUE,y_missing=0) {
  set.seed(1)
  res = mmbr:::mmbr_sim1(n,p,r,4,center_scale=center_scale,y_missing=y_missing)
  res$L = 10
  return(res)
}
dat = simulate_multivariate(r=2, center_scale = F, y_missing = 0.5)
residual_var = cov(dat$y)
# create data object
data_obj = mmbr:::DenseDataYMissing$new(dat$X, dat$y_missing)
# compute residual variance according to different missing pattern
data_obj$set_residual_variance(residual_var, quantities = 'residual_variance')
# compute \tilde{\mathbf{X}}_i, \tilde{\mathbf{y}}_i
data_obj$standardize(TRUE,FALSE)
# compute svs
data_obj$set_residual_variance(quantities = 'effect_variance')

In Single Effect Model (BayesianSimpleRegression, BayesianMultivariateRegression, MashRegression), we only need bhat and sbhat2. The sbhat2 is precomputed in data object.

data_obj$svs[[1]]
            [,1]        [,2]
[1,] 0.097968791 0.006018362
[2,] 0.006018362 0.136472648
data_obj$svs[[2]]
            [,1]        [,2]
[1,] 0.089531112 0.005459086
[2,] 0.005459086 0.149178188

The bhat can be obtained using get_coef function:

head(data_obj$get_coef(F))
            [,1]         [,2]
[1,]  0.54061432 -0.472094111
[2,]  0.38118760  0.005747207
[3,] -0.01114687  0.383212746
[4,]  0.16990375  0.644584948
[5,] -0.07297641 -0.399183192
[6,] -0.29919993  0.322249929

sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.6

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/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] mmbr_0.0.1.0305 susieR_0.9.26   mashr_0.2.40    ashr_2.2-51    
[5] workflowr_1.6.1

loaded via a namespace (and not attached):
 [1] progress_1.2.2     tidyselect_1.0.0   xfun_0.13          purrr_0.3.4       
 [5] lattice_0.20-41    colorspace_1.4-1   vctrs_0.3.4        htmltools_0.4.0   
 [9] yaml_2.2.1         rlang_0.4.7        mixsqp_0.3-46      later_1.0.0       
[13] pillar_1.4.6       glue_1.4.2         matrixStats_0.57.0 lifecycle_0.2.0   
[17] plyr_1.8.6         stringr_1.4.0      munsell_0.5.0      gtable_0.3.0      
[21] mvtnorm_1.1-1      evaluate_0.14      knitr_1.28         httpuv_1.5.2      
[25] invgamma_1.1       irlba_2.3.3        Rcpp_1.0.5         promises_1.1.0    
[29] backports_1.1.10   scales_1.1.1       rmeta_3.0          truncnorm_1.0-8   
[33] abind_1.4-5        fs_1.4.1           hms_0.5.3          ggplot2_3.3.2     
[37] digest_0.6.25      stringi_1.4.6      dplyr_0.8.5        grid_3.6.3        
[41] rprojroot_1.3-2    tools_3.6.3        magrittr_1.5       tibble_3.0.3      
[45] crayon_1.3.4       whisker_0.4        pkgconfig_2.0.3    ellipsis_0.3.1    
[49] Matrix_1.2-18      prettyunits_1.1.1  SQUAREM_2020.4     assertthat_0.2.1  
[53] rmarkdown_2.1      reshape_0.8.8      R6_2.4.1           git2r_0.26.1      
[57] compiler_3.6.3