Last updated: 2020-06-14

Checks: 6 1

Knit directory: causal-TWAS/

This reproducible R Markdown analysis was created with workflowr (version 1.6.0). 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 version displayed above was the version of the Git repository at the time these results were generated.

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:    code/.ipynb_checkpoints/
    Ignored:    data/

Untracked files:
    Untracked:  code/run_simulate_data.R

Unstaged changes:
    Modified:   analysis/simulation-susie-ukbchr22.Rmd
    Modified:   code/workflow-ashtest.ipynb

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 R Markdown and HTML files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view them.

File Version Author Date Message
Rmd 8708f04 simingz 2020-06-11 SUSIE
html 8708f04 simingz 2020-06-11 SUSIE

library(mr.ash.alpha)
library(data.table)
suppressMessages({library(plotly)})

plot_pip <- function(dt){
  pal <- c("salmon", "darkgreen")
  pal <- setNames(pal, c("Causal", "Non causal"))
  
  fig <- plot_ly(dt, x = ~ pos, y = ~ pip, type = 'scatter', mode = 'markers', color = ~ ifcausal, colors = pal, text = ~paste("Name: ", name))

  fig <- fig %>% layout(yaxis = list(title = "PIP"))
  return(fig)
}

plot_all <- function(susieres, mrashres.gene, mrashres.snp){
  dt <- read.table(susieres , header =T)
  
  a <- read.table(mrashres.gene , header =T)
  a[a$ifcausal == 1, "ifcausal"] = "Causal"
  a[a$ifcausal == 0, "ifcausal"] = "Non causal"
  
  dt.gene <- merge(dt, a, by= "name")

  a <- read.table(mrashres.snp , header =T)
  a[a$ifcausal == 1, "ifcausal"] = "Causal"
  a[a$ifcausal == 0, "ifcausal"] = "Non causal"
  
  dt.snp <- merge(dt, a, by= "name")
  
  fig1 <- plot_pip(dt.gene)
  fig2 <- plot_pip(dt.snp)

  fig <- subplot(fig1, fig2, nrows= 2, shareX = T, titleY = T)
  
  fig <- fig %>% layout(autosize = F, width = 600, height = 600, margin = 0.02,
    xaxis = list(title = "Genomic position"))
  
  fig <- fig %>% toWebGL()
  fig
}
simdatadir <- "~/causalTWAS/simulations/simulation_ashtest_20200503/"
outputdir <- "~/causalTWAS/simulations/simulation_susietest_20200604/"
mr.ash2dir <-  "~/causalTWAS/simulations/simulation_ashtest_20200527/"

Simulation 1

Priors:

readLines(paste0(outputdir, "prior-1.R"))
[1] ""                                                                   
[2] "# this is the parameter estimated by mr.ash2 in simulation+20200503"
[3] ""                                                                   
[4] "prior.SNP <- 0.0003892186 "                                         
[5] "prior.gene <- 0.103"                                                

SUSIE results:

mrashtag <- "20200527-1"
susietag <- "20200604-1"
mrashres.gene <- paste0(mr.ash2dir, mrashtag, "-mr.ash2s.expr-res.expr.txt")
mrashres.snp <- paste0(mr.ash2dir, mrashtag, "-mr.ash2s.expr-res.snp.txt")

FALSE positives in mr.ash2

name <- "DGCR14"
susieres <- paste0(outputdir, susietag,"-", name, "-susieres.txt")
print(paste0("SUISE results for regions around ", name))
[1] "SUISE results for regions around DGCR14"
plot_all(susieres, mrashres.gene, mrashres.snp)
Warning: `arrange_()` is deprecated as of dplyr 0.7.0.
Please use `arrange()` instead.
See vignette('programming') for more help
This warning is displayed once every 8 hours.
Call `lifecycle::last_warnings()` to see where this warning was generated.
Warning: Specifying width/height in layout() is now deprecated.
Please specify in ggplotly() or plot_ly()
name <- "VPREB3"
susieres <- paste0(outputdir, susietag,"-", name, "-susieres.txt")
print(paste0("SUISE results for regions around ", name))
[1] "SUISE results for regions around VPREB3"
plot_all(susieres, mrashres.gene, mrashres.snp)
Warning: Specifying width/height in layout() is now deprecated.
Please specify in ggplotly() or plot_ly()
name <- "TCN2"
susieres <- paste0(outputdir, susietag,"-", name, "-susieres.txt")
print(paste0("SUISE results for regions around ", name))
[1] "SUISE results for regions around TCN2"
plot_all(susieres, mrashres.gene, mrashres.snp)
Warning: Specifying width/height in layout() is now deprecated.
Please specify in ggplotly() or plot_ly()

FALSE negatives in mr.ash2

name <- "CBX6"
susieres <- paste0(outputdir, susietag,"-", name, "-susieres.txt")
print(paste0("SUISE results for regions around ", name))
[1] "SUISE results for regions around CBX6"
plot_all(susieres, mrashres.gene, mrashres.snp)
Warning: Specifying width/height in layout() is now deprecated.
Please specify in ggplotly() or plot_ly()
name <- "CHEK2"
susieres <- paste0(outputdir, susietag,"-", name, "-susieres.txt")
print(paste0("SUISE results for regions around ", name))
[1] "SUISE results for regions around CHEK2"
plot_all(susieres, mrashres.gene, mrashres.snp)
Warning: Specifying width/height in layout() is now deprecated.
Please specify in ggplotly() or plot_ly()

True positives in mr.ash2

name <- "LMF2"
susieres <- paste0(outputdir, susietag,"-", name, "-susieres.txt")
print(paste0("SUISE results for regions around ", name))
[1] "SUISE results for regions around LMF2"
plot_all(susieres, mrashres.gene, mrashres.snp)
Warning: Specifying width/height in layout() is now deprecated.
Please specify in ggplotly() or plot_ly()
name <- "DDX17"
susieres <- paste0(outputdir, susietag,"-", name, "-susieres.txt")
print(paste0("SUISE results for regions around ", name))
[1] "SUISE results for regions around DDX17"
plot_all(susieres, mrashres.gene, mrashres.snp)
Warning: Specifying width/height in layout() is now deprecated.
Please specify in ggplotly() or plot_ly()
name <- "MIF"
susieres <- paste0(outputdir, susietag,"-", name, "-susieres.txt")
print(paste0("SUISE results for regions around ", name))
[1] "SUISE results for regions around MIF"
plot_all(susieres, mrashres.gene, mrashres.snp)
Warning: Specifying width/height in layout() is now deprecated.
Please specify in ggplotly() or plot_ly()

Simulation 3

Priors:

readLines(paste0(outputdir, "prior-3.R"))
[1] ""                                                                   
[2] "# this is the parameter estimated by mr.ash2 in simulation+20200503"
[3] ""                                                                   
[4] "prior.SNP <- 0.0001854237 "                                         
[5] "prior.gene <- 0.0525"                                               

SUSIE results:

mrashtag <- "20200527-3"
susietag <- "20200604-3"
mrashres.gene <- paste0(mr.ash2dir, mrashtag, "-mr.ash2s.expr-res.expr.txt")
mrashres.snp <- paste0(mr.ash2dir, mrashtag, "-mr.ash2s.expr-res.snp.txt")
name <- "MCM5"
susieres <- paste0(outputdir, susietag,"-", name, "-susieres.txt")
print(paste0("SUISE results for regions around ", name))
[1] "SUISE results for regions around MCM5"
plot_all(susieres, mrashres.gene, mrashres.snp)
Warning: Specifying width/height in layout() is now deprecated.
Please specify in ggplotly() or plot_ly()
name <- "CBX6"
susieres <- paste0(outputdir, susietag,"-", name, "-susieres.txt")
print(paste0("SUISE results for regions around ", name))
[1] "SUISE results for regions around CBX6"
plot_all(susieres, mrashres.gene, mrashres.snp)
Warning: Specifying width/height in layout() is now deprecated.
Please specify in ggplotly() or plot_ly()

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] plotly_4.9.2.1     ggplot2_3.3.1      data.table_1.12.7 
[4] mr.ash.alpha_0.1-7

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