Last updated: 2020-08-14

Checks: 6 1

Knit directory: causal-TWAS/

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.


The R Markdown file has unstaged changes. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

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(20191103) 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 7f24341. 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:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    code/workflow/.ipynb_checkpoints/
    Ignored:    data/

Untracked files:
    Untracked:  analysis/simulation-susieI-ukbchr17to22-gtex.adipose.Rmd
    Untracked:  code/ld.R
    Untracked:  code/workflow/workflow-susieI-20200813.ipynb

Unstaged changes:
    Modified:   analysis/simulation-multi-ukbchr17to22-gtex.adipose.Rmd
    Modified:   analysis/simulation-multi-ukbchr17to22-gtex.adipose_sa2_v2.Rmd
    Modified:   code/gen_mr.ash2_output.R
    Modified:   code/run_ld.R
    Modified:   code/run_test_mr.ash_gene.R
    Modified:   code/run_test_susieI.R

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/simulation-multi-ukbchr17to22-gtex.adipose.Rmd) and HTML (docs/simulation-multi-ukbchr17to22-gtex.adipose.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
html 1d3e1ed simingz 2020-08-10 clean
Rmd 9783727 simingz 2020-08-06 susie names
html 9783727 simingz 2020-08-06 susie names
Rmd 2216650 simingz 2020-08-06 Remove ignored files
html 2216650 simingz 2020-08-06 Remove ignored files
Rmd b6132ab simingz 2020-08-05 visual chr17to22
html b6132ab simingz 2020-08-05 visual chr17to22
Rmd 958f794 simingz 2020-08-05 move code- plot functions
html 958f794 simingz 2020-08-05 move code- plot functions
Rmd 86e42c2 simingz 2020-08-04 website hide code
html 86e42c2 simingz 2020-08-04 website hide code
Rmd f6ea15c simingz 2020-08-04 change sa2 grid
html f6ea15c simingz 2020-08-04 change sa2 grid
Rmd dff432c simingz 2020-07-31 workflow and susie
html dff432c simingz 2020-07-31 workflow and susie
Rmd e0835ef simingz 2020-07-24 chr17:22
html e0835ef simingz 2020-07-24 chr17:22

Run simulation 8 times for ukb chr 17 to chr 22 combined. SNPs are downsampled to 1/10, eQTLs defined by FUSION-TWAS (Adipose/GTEx) lasso effect size > 0 were kept, p= 86k, n = 20k.

library(mr.ash.alpha)
library(data.table)
suppressMessages({library(plotly)})
library(tidyr)
library(plyr)
library(stringr)
library(kableExtra)
source("analysis/summarize_twas_plots.R")
simdatadir <- "~/causalTWAS/simulations/simulation_ashtest_20200721/"
outputdir <- "~/causalTWAS/simulations/simulation_ashtest_20200721/sa2_default/"
susiedir <- "~/causalTWAS/simulations/simulation_susietest_20200721/sa2_default/"
tags <- paste0('20200721-1-', c(2, 4:9))
tagglob <- '20200721-1-*'
tagextr <- '20200721-1-\\d+'
tag2s <- c('zeroes-es', 'zerose-es', 'lassoes-es','lassoes-se')

Mr.ash2 parameter estimation

Results for 10 simulations runs, using different initialize and update strategy

NULL; expr-snp; expr-snp

show_param(tags, tag2s[1])
Gene.pi1
Gene.PVE
SNP.pi1
SNP.PVE
Simulation# Truth Est. Truth Est. Truth Est. Truth Est.
1 0.0502117 0.0038203 0.0091963 0.0077097 0.0024981 0.0004988 0.0437056 0.0493777
2 0.0502117 0.0127840 0.0114605 0.0251959 0.0024981 0.0004663 0.0548585 0.0461038
3 0.0502117 0.0128614 0.0110859 0.0250191 0.0024981 0.0002822 0.0478479 0.0281643
4 0.0502117 0.0097879 0.0097170 0.0194024 0.0024981 0.0004053 0.0580372 0.0403293
5 0.0502117 0.0118048 0.0111216 0.0235006 0.0024981 0.0005047 0.0491958 0.0501203
6 0.0502117 0.0116464 0.0110024 0.0226369 0.0024981 0.0003257 0.0477211 0.0322025
7 0.0502117 0.0068140 0.0114627 0.0136486 0.0024981 0.0003761 0.0513712 0.0377470

NULL; snp-expr; expr-snp

show_param(tags, tag2s[2])
Gene.pi1
Gene.PVE
SNP.pi1
SNP.PVE
Simulation# Truth Est. Truth Est. Truth Est. Truth Est.
1 0.0502117 0.0038203 0.0091963 0.0077097 0.0024981 0.0004988 0.0437056 0.0493777
2 0.0502117 0.0121765 0.0114605 0.0240500 0.0024981 0.0005029 0.0548585 0.0495821
3 0.0502117 0.0128614 0.0110859 0.0250191 0.0024981 0.0002822 0.0478479 0.0281643
4 0.0502117 0.0097879 0.0097170 0.0194024 0.0024981 0.0004053 0.0580372 0.0403293
5 0.0502117 0.0118048 0.0111216 0.0235006 0.0024981 0.0005047 0.0491958 0.0501203
6 0.0502117 0.0116464 0.0110024 0.0226369 0.0024981 0.0003257 0.0477211 0.0322025
7 0.0502117 0.0068140 0.0114627 0.0136486 0.0024981 0.0003761 0.0513712 0.0377470

lasso; expr-snp; expr-snp

show_param(tags, tag2s[3])
Gene.pi1
Gene.PVE
SNP.pi1
SNP.PVE
Simulation# Truth Est. Truth Est. Truth Est. Truth Est.
1 0.0502117 0.0025035 0.0091963 0.0050747 0.0024981 0.0005317 0.0437056 0.0525218
2 0.0502117 0.0096839 0.0114605 0.0192560 0.0024981 0.0005430 0.0548585 0.0533743
3 0.0502117 0.0125445 0.0110859 0.0244517 0.0024981 0.0002905 0.0478479 0.0290015
4 0.0502117 0.0053686 0.0097170 0.0107749 0.0024981 0.0005126 0.0580372 0.0505513
5 0.0502117 0.0110461 0.0111216 0.0220645 0.0024981 0.0005172 0.0491958 0.0513885
6 0.0502117 0.0068421 0.0110024 0.0134577 0.0024981 0.0004223 0.0477211 0.0413592
7 0.0502117 0.0061398 0.0114627 0.0123350 0.0024981 0.0003996 0.0513712 0.0400672

lasso; expr-snp; snp-expr

show_param(tags, tag2s[4])
Gene.pi1
Gene.PVE
SNP.pi1
SNP.PVE
Simulation# Truth Est. Truth Est. Truth Est. Truth Est.
1 0.0502117 0.0025035 0.0091963 0.0050747 0.0024981 0.0005317 0.0437056 0.0525218
2 0.0502117 0.0097114 0.0114605 0.0193093 0.0024981 0.0005429 0.0548585 0.0533621
3 0.0502117 0.0125458 0.0110859 0.0244540 0.0024981 0.0002905 0.0478479 0.0290008
4 0.0502117 0.0053687 0.0097170 0.0107750 0.0024981 0.0005126 0.0580372 0.0505513
5 0.0502117 0.0110466 0.0111216 0.0220653 0.0024981 0.0005172 0.0491958 0.0513885
6 0.0502117 0.0068546 0.0110024 0.0134818 0.0024981 0.0004221 0.0477211 0.0413370
7 0.0502117 0.0061805 0.0114627 0.0124158 0.0024981 0.0003996 0.0513712 0.0400624

Regional mr.ash2s PIP overview

Take simulation 1 (NULL; expr-snp; expr-snp) as examples. We use region size 500kb and PIP cut off at 0.2 for SUSIE.

chrom = 17
f <- get_files(tag= "20200721-1-1" , tag2 = tag2s[1])
allchr <- read.table(f[["rpip"]], header = T)
a <- allchr[allchr["chrom"]==chrom,]
print(paste("plot for chr", chrom))
[1] "plot for chr 17"
par(mar=c(5, 4, 4, 6) + 0.1)
with(a, plot(p0, rPIP, col ='salmon', xlab = "position", ylab= "Sum of PIP", type = 'h', lwd = 2))
par(new = T)
with(a, plot(p0, nCausal, pch =19, col = "darkgreen",axes = FALSE, bty = "n", xlab = "", ylab = ""))
axis(side = 4)
mtext(side = 4, line = 3, 'No. causal signals')
legend("topleft",
       legend=c("Mr.ASH PIP", "# Causal"),
       lty=c(1,0), pch=c(NA, 19), col=c("salmon", "darkgreen"))
grid()

Version Author Date
dff432c simingz 2020-07-31
e0835ef simingz 2020-07-24

PIP calibration

We run 50 simulations and combine results.

NULL; expr-snp; expr-snp

tag2 = "zeroes-es"
tags_ext <- Reduce(intersect, get_tags(tagglob, tagextr, tag2 = tag2)['gsusie'])
res <- caliPIP_plot(tags = tags_ext, tag2 = tag2)

Version Author Date
9783727 simingz 2020-08-06
f6ea15c simingz 2020-08-04
dff432c simingz 2020-07-31
tags_ext2 <- Reduce(intersect, get_tags(tagglob, tagextr, tag2 = tag2)['gsusie'])
caliFDR_plot(tags = tags_ext2, tag2 = tag2)

Version Author Date
1d3e1ed simingz 2020-08-10
f6ea15c simingz 2020-08-04
FDR at bonferroni corrected p = 0.05:  0.5846154

Lasso; expr-snp; expr-snp

caliPIP_plot(tags = tags_ext, tag2 = "lassoes-es")

Version Author Date
9783727 simingz 2020-08-06
f6ea15c simingz 2020-08-04
dff432c simingz 2020-07-31
caliFDR_plot(tags = tags_ext2, tag2 = "lassoes-es")

Version Author Date
1d3e1ed simingz 2020-08-10
f6ea15c simingz 2020-08-04
FDR at bonferroni corrected p = 0.05:  0.5858586

PIP scatter plot

mr.ash2s PIP vs. susie PIP.

NULL; expr-snp; expr-snp

scatter_plot_PIP(tags, tag2s[1])

NULL; snp-expr; expr-snp

scatter_plot_PIP(tags, tag2s[2])

lasso; expr-snp; expr-snp

scatter_plot_PIP(tags, tag2s[3])

lasso; expr-snp; snp-expr

scatter_plot_PIP(tags, tag2s[4])

ROC curve

NULL; expr-snp; expr-snp

tags <- paste0('20200721-1-', c(2,4:9))
ROC_plot(tags, tag2s[2])

Version Author Date
9783727 simingz 2020-08-06
f6ea15c simingz 2020-08-04
dff432c simingz 2020-07-31
e0835ef simingz 2020-07-24
AUC for  mr.ash :  0.8062336AUC for  SUSIE.w :  0.7962262AUC for  SUSIE.u :  0.7730684AUC for  SUSIE.w0 :  0.8074635AUC for  TWAS :  0.7968044

NULL; snp-expr; expr-snp

ROC_plot(tags, tag2s[2])

Version Author Date
9783727 simingz 2020-08-06
dff432c simingz 2020-07-31
e0835ef simingz 2020-07-24
AUC for  mr.ash :  0.8062336AUC for  SUSIE.w :  0.7962262AUC for  SUSIE.u :  0.7730684AUC for  SUSIE.w0 :  0.8074635AUC for  TWAS :  0.7968044

lasso; expr-snp; expr-snp

ROC_plot(tags, tag2s[3])

Version Author Date
9783727 simingz 2020-08-06
dff432c simingz 2020-07-31
e0835ef simingz 2020-07-24
AUC for  mr.ash :  0.7866667AUC for  SUSIE.w :  0.797551AUC for  SUSIE.u :  0.7733333AUC for  SUSIE.w0 :  0.8073964AUC for  TWAS :  0.8037353

lasso; expr-snp; snp-expr

ROC_plot(tags, tag2s[4])

Version Author Date
9783727 simingz 2020-08-06
dff432c simingz 2020-07-31
e0835ef simingz 2020-07-24
AUC for  mr.ash :  0.7866667AUC for  SUSIE.w :  0.7975263AUC for  SUSIE.u :  0.7733333AUC for  SUSIE.w0 :  0.8073964AUC for  TWAS :  0.8037353

PIP vs p value

NULL; expr-snp; expr-snp

scatter_plot_PIP_p(tags, tag2s[1])

sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Scientific Linux 7.4 (Nitrogen)

Matrix products: default
BLAS/LAPACK: /software/openblas-0.2.19-el7-x86_64/lib/libopenblas_haswellp-r0.2.19.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] kableExtra_1.1.0    stringr_1.4.0       plyr_1.8.6         
[4] tidyr_0.8.3         plotly_4.9.2.9000   ggplot2_3.3.1      
[7] data.table_1.12.7   mr.ash.alpha_0.1-34

loaded via a namespace (and not attached):
 [1] tidyselect_1.1.0  purrr_0.3.4       lattice_0.20-38  
 [4] colorspace_1.3-2  vctrs_0.3.1       generics_0.0.2   
 [7] htmltools_0.3.6   viridisLite_0.3.0 yaml_2.2.0       
[10] rlang_0.4.6       later_0.7.5       pillar_1.4.4     
[13] glue_1.4.1        withr_2.1.2       lifecycle_0.2.0  
[16] munsell_0.5.0     gtable_0.2.0      workflowr_1.6.2  
[19] rvest_0.3.2       htmlwidgets_1.3   evaluate_0.12    
[22] knitr_1.20        crosstalk_1.0.0   httpuv_1.4.5     
[25] highr_0.7         Rcpp_1.0.4.6      xtable_1.8-3     
[28] readr_1.3.1       promises_1.0.1    scales_1.0.0     
[31] backports_1.1.2   webshot_0.5.1     jsonlite_1.6.1   
[34] mime_0.6          fs_1.3.1          hms_0.4.2        
[37] digest_0.6.25     stringi_1.3.1     shiny_1.2.0      
[40] dplyr_1.0.0       grid_3.5.1        rprojroot_1.3-2  
[43] tools_3.5.1       magrittr_1.5      lazyeval_0.2.1   
[46] tibble_3.0.1      crayon_1.3.4      whisker_0.3-2    
[49] pkgconfig_2.0.2   ellipsis_0.3.1    Matrix_1.2-15    
[52] xml2_1.2.0        rmarkdown_1.10    httr_1.4.1       
[55] rstudioapi_0.11   R6_2.3.0          git2r_0.26.1     
[58] compiler_3.5.1