Last updated: 2019-01-10
workflowr checks: (Click a bullet for more information) ✔ R Markdown file: up-to-date
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.
✔ Environment: empty
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.
✔ Seed:
set.seed(20180529)
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.
✔ Session information: recorded
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
✔ Repository version: df40371
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
Ignored: docs/.DS_Store
Ignored: docs/figure/Test.Rmd/
Untracked files:
Untracked: analysis/MASH_est_Cor.Rmd
Untracked: analysis/MashEstCorProblem.Rmd
Untracked: analysis/MashMedian.Rmd
Untracked: analysis/mashMean.Rmd
Untracked: code/EstCorV.R
Untracked: docs/Estimate_Null_Cor_New.pdf
Untracked: docs/Estimate_Null_Cor_Old.pdf
Untracked: output/MASH.result.1.rds
Untracked: output/MASH.result.10.rds
Untracked: output/MASH.result.2.rds
Untracked: output/MASH.result.3.rds
Untracked: output/MASH.result.4.rds
Untracked: output/MASH.result.5.rds
Untracked: output/MASH.result.6.rds
Untracked: output/MASH.result.7.rds
Untracked: output/MASH.result.8.rds
Untracked: output/MASH.result.9.rds
Unstaged changes:
Modified: analysis/susieProblem2.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.
library(mashr)
Loading required package: ashr
library(magic)
Loading required package: abind
library(mvtnorm)
library(knitr)
library(kableExtra)
ROC.table = function(data, model){
sign.test = data*model$result$PosteriorMean
thresh.seq = seq(0, 1, by=0.005)[-1]
m.seq = matrix(0,length(thresh.seq), 2)
colnames(m.seq) = c('TPR', 'FPR')
for(t in 1:length(thresh.seq)){
m.seq[t,] = c(sum(sign.test>0 & model$result$lfsr <= thresh.seq[t])/sum(data!=0),
sum(data==0 & model$result$lfsr <=thresh.seq[t])/sum(data==0))
}
return(m.seq)
}
V1 = matrix(0.75, 20,20)
diag(V1) = 1
V2 = matrix(0.75, 30,30)
diag(V2) = 1
V = adiag(V1, V2)
set.seed(1)
n = 10000
B1 = matrix(0, n/2, 50)
effect = rnorm(n/2)
B2 = matrix(effect, n/2, 50)
B = rbind(B1, B2)
Ehat = rmvnorm(n, sigma = V)
Bhat = B + Ehat
data = mash_set_data(Bhat = Bhat, Shat = 1)
U.c = cov_canonical(data)
m.1by1 = mash_1by1(data)
strong = get_significant_results(m.1by1)
U.pca = cov_pca(data, 3, subset = strong)
U.ed = cov_ed(data, U.pca, subset = strong)
V.simple = estimate_null_correlation_simple(data)
data.simple = mash_update_data(data, V = V.simple)
m.simple = mash(data.simple, c(U.c, U.ed))
- Computing 10000 x 945 likelihood matrix.
- Likelihood calculations took 17.50 seconds.
- Fitting model with 945 mixture components.
- Model fitting took 93.12 seconds.
- Computing posterior matrices.
- Computation allocated took 0.90 seconds.
V.current = estimate_null_correlation(data, c(U.c, U.ed))
m.current = V.current$mash.model
data.true = mash_update_data(data, V = V)
m.true = mash(data.true, c(U.c, U.ed))
- Computing 10000 x 945 likelihood matrix.
- Likelihood calculations took 22.17 seconds.
- Fitting model with 945 mixture components.
- Model fitting took 123.75 seconds.
- Computing posterior matrices.
- Computation allocated took 1.81 seconds.
corrplot::corrplot(V.simple, method='color', type='upper', tl.col="black", tl.srt=45, tl.cex = 0.5, diag = TRUE, col=colorRampPalette(c("blue", "white", "red"))(200), cl.lim = c(-1,1), title = 'Simple', mar=c(0,0,5,0))
corrplot::corrplot(V.current$V, method='color', type='upper', tl.col="black", tl.srt=45, tl.cex = 0.5, diag = TRUE, col=colorRampPalette(c("blue", "white", "red"))(200), cl.lim = c(-1,1), title = 'Current EZ', mar=c(0,0,5,0))
loglike = c(get_loglik(m.simple), get_loglik(m.current), get_loglik(m.true))
sig = c(length(get_significant_results(m.simple)), length(get_significant_results(m.current)), length(get_significant_results(m.true)))
fd = c(sum(get_significant_results(m.simple)<=5000), sum(get_significant_results(m.current)<=5000), sum(get_significant_results(m.true)<=5000))
rrmse = c(sqrt(mean((B - m.simple$result$PosteriorMean)^2)/mean((B - Bhat)^2)),
sqrt(mean((B - m.current$result$PosteriorMean)^2)/mean((B - Bhat)^2)),
sqrt(mean((B - m.true$result$PosteriorMean)^2)/mean((B - Bhat)^2)))
tmp = cbind(loglike, sig, fd, rrmse)
colnames(tmp) = c('logliklihood', '#sig', 'false pos','RRMSE')
rownames(tmp) = c('simple', 'current', 'true')
tmp %>% kable() %>% kable_styling()
logliklihood | #sig | false pos | RRMSE | |
---|---|---|---|---|
simple | -441847.3 | 1058 | 65 | 0.4879696 |
current | -409465.6 | 480 | 6 | 0.4503394 |
true | -410051.5 | 560 | 13 | 0.4478056 |
roc.seq = ROC.table(B, m.true)
plot(roc.seq[,'FPR'], roc.seq[,'TPR'], type='l', xlab = 'FPR', ylab='TPR',
main=paste0(' True Pos vs False Pos'), cex=1.5, lwd = 1.5, col = 'cyan')
roc.seq = ROC.table(B, m.current)
lines(roc.seq[,'FPR'], roc.seq[,'TPR'], col='purple', lwd = 1.5)
roc.seq = ROC.table(B, m.simple)
lines(roc.seq[,'FPR'], roc.seq[,'TPR'], col='red', lwd = 1.5)
legend('bottomright', c('true','current', 'simple'), col=c('cyan','purple', 'red'),
lty=c(1,1,1), lwd=c(1.5,1.5, 1.5))
Version | Author | Date |
---|---|---|
8809dc7 | zouyuxin | 2018-12-20 |
barplot(get_estimated_pi(m.simple), las=2, main='simple')
Version | Author | Date |
---|---|---|
8809dc7 | zouyuxin | 2018-12-20 |
barplot(get_estimated_pi(m.current), las=2, main='current')
Version | Author | Date |
---|---|---|
8809dc7 | zouyuxin | 2018-12-20 |
barplot(get_estimated_pi(m.true), las=2, main='true')
Version | Author | Date |
---|---|---|
8809dc7 | zouyuxin | 2018-12-20 |
sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS 10.14.2
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] kableExtra_0.9.0 knitr_1.20 mvtnorm_1.0-8 magic_1.5-9
[5] abind_1.4-5 mashr_0.2.19.0555 ashr_2.2-26
loaded via a namespace (and not attached):
[1] corrplot_0.84 lattice_0.20-35 colorspace_1.3-2
[4] htmltools_0.3.6 viridisLite_0.3.0 yaml_2.2.0
[7] rlang_0.3.0.1 R.oo_1.22.0 mixsqp_0.1-93
[10] pillar_1.3.1 R.utils_2.7.0 foreach_1.4.4
[13] plyr_1.8.4 stringr_1.3.1 munsell_0.5.0
[16] workflowr_1.1.1 rvest_0.3.2 R.methodsS3_1.7.1
[19] codetools_0.2-15 evaluate_0.12 pscl_1.5.2
[22] doParallel_1.0.14 parallel_3.5.1 highr_0.7
[25] Rcpp_1.0.0 readr_1.1.1 backports_1.1.2
[28] scales_1.0.0 rmeta_3.0 truncnorm_1.0-8
[31] hms_0.4.2 digest_0.6.18 stringi_1.2.4
[34] grid_3.5.1 rprojroot_1.3-2 tools_3.5.1
[37] magrittr_1.5 tibble_1.4.2 crayon_1.3.4
[40] whisker_0.3-2 pkgconfig_2.0.2 MASS_7.3-50
[43] Matrix_1.2-14 SQUAREM_2017.10-1 xml2_1.2.0
[46] assertthat_0.2.0 rmarkdown_1.10 httr_1.3.1
[49] rstudioapi_0.8 iterators_1.0.10 R6_2.3.0
[52] git2r_0.23.0 compiler_3.5.1
This reproducible R Markdown analysis was created with workflowr 1.1.1