Last updated: 2019-10-06

Checks: 4 3

Knit directory: lipids_mvp/

This reproducible R Markdown analysis was created with workflowr (version 1.4.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(20190925) 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.

The following chunks had caches available:
  • load.data
  • session-info-chunk-inserted-by-workflowr
  • unnamed-chunk-1
  • unnamed-chunk-2

To ensure reproducibility of the results, delete the cache directory looking_at_significance_cache and re-run the analysis. To have workflowr automatically delete the cache directory prior to building the file, set delete_cache = TRUE when running wflow_build() or wflow_publish().

Using absolute paths to the files within your workflowr project makes it difficult for you and others to run your code on a different machine. Change the absolute path(s) below to the suggested relative path(s) to make your code more reproducible.

absolute relative
~/lipids_mvp/analysis/ analysis

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:    .DS_Store
    Ignored:    .Rhistory
    Ignored:    analysis/.DS_Store
    Ignored:    analysis/.RData
    Ignored:    analysis/.Rhistory
    Ignored:    analysis/looking_at_significance_cache/
    Ignored:    analysis/workingwithdata_cache/
    Ignored:    data/.DS_Store
    Ignored:    data/Archive.zip.gz
    Ignored:    data/EDcov.Rds
    Ignored:    data/ash.rds
    Ignored:    data/gtexcolors.txt
    Ignored:    data/mashcomplete.rds
    Ignored:    data/mashcomplete.rds.zip
    Ignored:    data/max_ld_block.txt
    Ignored:    data/merged_betas.txt
    Ignored:    data/merged_se.txt
    Ignored:    data/merged_z.txt
    Ignored:    data/znew.txt
    Ignored:    docs/.DS_Store

Untracked files:
    Untracked:  analysis/looking_at_significance.knit.md
    Untracked:  analysis/looking_at_significance.utf8.md

Unstaged changes:
    Modified:   analysis/looking_at_significance.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 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 079589b Sarah Urbut 2019-10-07 Update
html 079589b Sarah Urbut 2019-10-07 Update

Introduction

setwd('~/lipids_mvp/analysis/')
mash=readRDS("../data/mashcomplete.rds")
ash=readRDS("../data/ash.rds")
bf=read.table('../data/merged_betas.txt')
sf=read.table('../data/merged_se.txt')
z=read.table("../data/merged_z.txt")
pm=mash$result$PosteriorMean
pv=mash$result$PosteriorSD
lfsr=mash$result$lfsr

betas=bf[1:2437099,c("hdl","ldl","tg","tc")];rownames(betas)=bf$SNP_hg18[1:2437099]
se=sf[1:2437099,c("hdl","ldl","tg","tc")];rownames(se)=sf$SNP_hg18[1:2437099]

shrunk.beta=se*pm;colnames(shrunk.beta)=colnames(pm);rownames(shrunk.beta)=rownames(betas)
shrunk.se=pv*se;colnames(shrunk.se)=colnames(pm);rownames(shrunk.se)=rownames(betas)

Let’s print the maximum by hdl and then triglyceride:

b=betas[order(abs(betas$hdl),decreasing=T),][1:100,]
tg=b[order(abs(b$tg),decreasing=T),][1:100,]

head(tg)
                 hdl     ldl      tg      tc
chr8:19850911 0.2186 -0.0310 -0.1911 -0.0141
chr8:19819463 0.2228  0.0112 -0.1825  0.0287
chr8:19849775 0.2230  0.0062 -0.1792  0.0260
chr8:19821159 0.2005 -0.0224 -0.1756 -0.0071
chr8:19848082 0.1994 -0.0206 -0.1753 -0.0049
chr8:19820855 0.1966 -0.0249 -0.1731 -0.0084
j=which(rownames(betas)==rownames(tg)[1])

# title=paste("MLE",bf[j,"rsid"])
# par(mfrow=c(1,2))
# metaplot(as.numeric(betas[j,]),as.numeric(se[j,]),colors=meta.colors(box=c("red","blue","green","yellow"),lines="blue", zero="red", summary="orange",text="forestgreen"),xlim=c(-0.4,0.4),labels = colnames(shrunk.beta),xlab = "",ylab="")
# title(title)


title=paste("Mash",bf[j,"rsid"])
sd=as.numeric(shrunk.se[j,])##to transform to posterior sd of beta
x=as.numeric(shrunk.beta[j,])
metaplot(x,sd,xlab = "",ylab="",colors=meta.colors(box=c("red","blue","green","yellow"),lines="blue", zero="red", summary="orange",text="forestgreen"),xlim=c(-0.4,0.4),labels = colnames(shrunk.beta))
title(title)

Version Author Date
079589b Sarah Urbut 2019-10-07
print("LFSR of SNP")
[1] "LFSR of SNP"
lfsr[j,]
         hdl          ldl           tg           tc 
1.433870e-58 9.639228e-03 1.110223e-16 2.812616e-01 

We can do the same for LDL and TG, sorting first by LDL and then by TG

b=betas[order(abs(betas$ldl),decreasing=T),][1:100,]
tg=b[order(abs(b$tg),decreasing=T),][1:100,]

head(tg)
                  hdl     ldl      tg      tc
chr2:21240579  0.1653 -0.1563 -0.1245 -0.0242
chr19:50081436 0.0528 -0.4853  0.1235 -0.3050
chr19:50103919 0.0978 -0.5898  0.1119 -0.3736
chr12:88544876 0.0560 -0.1631 -0.1105 -0.0957
chr7:14231090  0.0075  0.1367  0.1098  0.1617
chr19:50091184 0.0942 -0.1735 -0.1095 -0.1592
j=which(rownames(betas)==rownames(tg)[1])

# title=paste("MLE",bf[j,"rsid"])
# par(mfrow=c(1,2))
# metaplot(as.numeric(betas[j,]),as.numeric(se[j,]),colors=meta.colors(box=c("red","blue","green","yellow"),lines="blue", zero="red", summary="orange",text="forestgreen"),xlim=c(-0.4,0.4),labels = colnames(shrunk.beta),xlab = "",ylab="")
# title(title)


title=paste("Mash",bf[j,"rsid"])
sd=as.numeric(shrunk.se[j,])##to transform to posterior sd of beta
x=as.numeric(shrunk.beta[j,])
metaplot(x,sd,xlab = "",ylab="",colors=meta.colors(box=c("red","blue","green","yellow"),lines="blue", zero="red", summary="orange",text="forestgreen"),xlim=c(-0.4,0.4),labels = colnames(shrunk.beta))
title(title)

Version Author Date
079589b Sarah Urbut 2019-10-07
print("LFSR of SNP")
[1] "LFSR of SNP"
lfsr[j,]
         hdl          ldl           tg           tc 
4.298489e-16 6.291464e-07 1.624161e-04 8.468237e-02 

sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6

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

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1        knitr_1.23        magrittr_1.5     
 [4] workflowr_1.4.0   MASS_7.3-51.4     pscl_1.5.2       
 [7] doParallel_1.0.14 SQUAREM_2017.10-1 lattice_0.20-38  
[10] foreach_1.4.4     ashr_2.2-37       stringr_1.4.0    
[13] highr_0.8         tools_3.5.2       parallel_3.5.2   
[16] grid_3.5.2        xfun_0.8          git2r_0.26.1     
[19] htmltools_0.3.6   iterators_1.0.10  yaml_2.2.0       
[22] rprojroot_1.3-2   digest_0.6.20     mixsqp_0.1-97    
[25] Matrix_1.2-17     codetools_0.2-16  fs_1.3.1         
[28] glue_1.3.1        evaluate_0.14     rmarkdown_1.14   
[31] stringi_1.4.3     compiler_3.5.2    backports_1.1.4  
[34] truncnorm_1.0-8