Last updated: 2018-12-13
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(1)
The command set.seed(1)
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: 00713c7
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/.DS_Store
Ignored: analysis/.Rhistory
Ignored: analysis/include/.DS_Store
Ignored: code/.DS_Store
Ignored: data/.DS_Store
Ignored: docs/.DS_Store
Ignored: output/.DS_Store
Ignored: output/.sos/
Untracked files:
Untracked: analysis/Classify.Rmd
Untracked: analysis/EstimateCorMash.Rmd
Untracked: analysis/EstimateCorMaxGD.Rmd
Untracked: analysis/EstimateCorMaxMCMash.Rmd
Untracked: analysis/HierarchicalFlashSim.Rmd
Untracked: analysis/MashLowSignalGTEx4.Rmd
Untracked: analysis/Mash_GTEx.Rmd
Untracked: analysis/MeanAsh.Rmd
Untracked: analysis/OutlierDetection.Rmd
Untracked: analysis/OutlierDetection2.Rmd
Untracked: analysis/OutlierDetection3.Rmd
Untracked: analysis/OutlierDetection4.Rmd
Untracked: analysis/mash_missing_row.Rmd
Untracked: code/GTExNullModel.R
Untracked: code/MashClassify.R
Untracked: code/MashCorResult.R
Untracked: code/MashCormVResult.R
Untracked: code/MashNULLCorResult.R
Untracked: code/MashSource.R
Untracked: code/Weight_plot.R
Untracked: code/addemV.R
Untracked: code/dsc-differentV/
Untracked: code/dsc-differentV_signal/
Untracked: code/estimate_cor.R
Untracked: code/generateDataV.R
Untracked: code/johnprocess.R
Untracked: code/mV.R
Untracked: code/sim_mean_sig.R
Untracked: code/summary.R
Untracked: data/Blischak_et_al_2015/
Untracked: data/scale_data.rds
Untracked: docs/figure/Classify.Rmd/
Untracked: docs/figure/OutlierDetection.Rmd/
Untracked: docs/figure/OutlierDetection2.Rmd/
Untracked: docs/figure/OutlierDetection3.Rmd/
Untracked: docs/figure/Test.Rmd/
Untracked: docs/figure/mash_missing_whole_row_5.Rmd/
Untracked: docs/include/
Untracked: output/AddEMV/
Untracked: output/CovED_UKBio_strong.rds
Untracked: output/CovED_UKBio_strong_Z.rds
Untracked: output/EstCorMLECompare/
Untracked: output/Flash_UKBio_strong.rds
Untracked: output/GTExNULLres/
Untracked: output/GTEx_2.5_nullData.rds
Untracked: output/GTEx_2.5_nullModel.rds
Untracked: output/GTEx_2.5_nullPermData.rds
Untracked: output/GTEx_2.5_nullPermModel.rds
Untracked: output/GTEx_3.5_nullData.rds
Untracked: output/GTEx_3.5_nullModel.rds
Untracked: output/GTEx_3.5_nullPermData.rds
Untracked: output/GTEx_3.5_nullPermModel.rds
Untracked: output/GTEx_3_nullData.rds
Untracked: output/GTEx_3_nullModel.rds
Untracked: output/GTEx_3_nullPermData.rds
Untracked: output/GTEx_3_nullPermModel.rds
Untracked: output/GTEx_4.5_nullData.rds
Untracked: output/GTEx_4.5_nullModel.rds
Untracked: output/GTEx_4.5_nullPermData.rds
Untracked: output/GTEx_4.5_nullPermModel.rds
Untracked: output/GTEx_4_nullData.rds
Untracked: output/GTEx_4_nullModel.rds
Untracked: output/GTEx_4_nullPermData.rds
Untracked: output/GTEx_4_nullPermModel.rds
Untracked: output/MASH.10.em2.result.rds
Untracked: output/MASH.10.mle.result.rds
Untracked: output/MashCorSim--midway/
Untracked: output/Mash_EE_Cov_0_plusR1.rds
Untracked: output/UKBio_mash_model.rds
Untracked: output/diff_v/
Untracked: output/diff_v_signal/
Untracked: output/dsc-mashr-est_v/
Untracked: output/mVIterations/
Untracked: output/mVMLEsubset/
Untracked: output/mVUlist/
Untracked: output/result.em.rds
Unstaged changes:
Modified: analysis/EstimateCorHeterR50.Rmd
Modified: analysis/EstimateCorMaxMVSample.Rmd
Modified: analysis/Mash_UKBio.Rmd
Modified: analysis/mash_missing_samplesize.Rmd
Modified: output/Flash_T2_0.rds
Modified: output/Flash_T2_0_mclust.rds
Modified: output/Mash_model_0_plusR1.rds
Modified: output/PresiAddVarCol.rds
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.
File | Version | Author | Date | Message |
---|---|---|---|---|
Rmd | 00713c7 | zouyuxin | 2018-12-13 | wflow_publish(“analysis/EstimateCorHeter.Rmd”) |
html | e475e2e | zouyuxin | 2018-12-13 | Build site. |
Rmd | fe6e6f8 | zouyuxin | 2018-12-13 | wflow_publish(“analysis/EstimateCorHeter.Rmd”) |
html | 27b0d6d | zouyuxin | 2018-12-09 | Build site. |
Rmd | f33b26f | zouyuxin | 2018-12-09 | wflow_publish(“analysis/EstimateCorHeter.Rmd”) |
html | 66be60b | zouyuxin | 2018-12-07 | Build site. |
Rmd | af556c8 | zouyuxin | 2018-12-07 | wflow_publish(“analysis/EstimateCorHeter.Rmd”) |
rrmse = function(data, model){
sqrt(mean((data$B - model$result$PosteriorMean)^2)/mean((data$B - data$Bhat)^2))
}
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)
}
library(knitr)
library(kableExtra)
We simulate null data which has common noise correlation structure. We fit mash model without and with the estimated correlation structure. There are lots of false positives in the model without the correlation structure. The posterior mean is far from the truth.
library(mvtnorm)
library(mashr)
Loading required package: ashr
set.seed(1)
n = 10000; p = 5
B = matrix(0,n,p)
V = matrix(0.75, p, p); diag(V) = 1
Bhat = rmvnorm(n, sigma = V)
simdata = list(B = B, Bhat = Bhat, Shat = 1)
data = mash_set_data(Bhat, Shat=1)
U.c = cov_canonical(data)
m.ignore = mash(data, U.c, verbose = FALSE, optmethod = 'mixSQP')
V.current = estimate_null_correlation(data, U.c, optmethod = 'mixSQP')
m.current = V.current$mash.model
data.true = mash_update_data(data, V = V)
m.true = mash(data.true, U.c, verbose = FALSE, optmethod = 'mixSQP')
ign = c(get_loglik(m.ignore), length(get_significant_results(m.ignore)))
current = c(get_loglik(m.current), length(get_significant_results(m.current)))
true = c(get_loglik(m.true), length(get_significant_results(m.true)))
tmp = rbind(ign, current, true)
row.names(tmp) = c('ignore', 'current', 'true')
colnames(tmp) = c('loglik', '# signif')
tmp %>% kable() %>% kable_styling()
loglik | # signif | |
---|---|---|
ignore | -62970.95 | 2930 |
current | -50426.34 | 0 |
true | -50432.45 | 0 |
RRMSE:
tmp = c(rrmse(simdata, m.ignore), rrmse(simdata, m.current), rrmse(simdata, m.true))
barplot(tmp, names.arg = c('ignore', 'current', 'true'))
Now, we simulate data with 2 noise correlation structures. Half of the null data have no noise correlation, the other half have noise correlation.
Bhat1 = rmvnorm(n/2, sigma = diag(p))
Bhat2 = rmvnorm(n/2, sigma = V)
Bhat = rbind(Bhat1, Bhat2)
simdata = list(B = B, Bhat = Bhat, Shat = 1)
data = mash_set_data(Bhat, Shat=1)
U.c = cov_canonical(data)
m.I = mash(data, U.c, verbose = FALSE, optmethod = 'mixSQP')
data.V = mash_update_data(data, V = V)
m.V = mash(data.V, U.c, verbose = FALSE, optmethod = 'mixSQP')
V.current = estimate_null_correlation(data, U.c, optmethod = 'mixSQP')
m.current = V.current$mash.model
Vtrue = array(0,dim=c(p,p,n))
Vtrue[,,1:(n/2)] = diag(p)
Vtrue[,,(n/2+1): n] = V
data.true = mash_update_data(data, V = Vtrue)
m.true = mash(data.true, U.c, verbose = FALSE, algorithm.version = 'R', optmethod = 'mixSQP')
The estimated V is
V.current$V
[,1] [,2] [,3] [,4] [,5]
[1,] 1.0000000 0.3866503 0.4018459 0.3783972 0.3990992
[2,] 0.3866503 1.0000000 0.3913344 0.3688567 0.3936947
[3,] 0.4018459 0.3913344 1.0000000 0.4172121 0.3878398
[4,] 0.3783972 0.3688567 0.4172121 1.0000000 0.3830626
[5,] 0.3990992 0.3936947 0.3878398 0.3830626 1.0000000
Ionly = c(get_loglik(m.I), length(get_significant_results(m.I)))
Vonly = c(get_loglik(m.V), length(get_significant_results(m.V)))
current = c(get_loglik(m.current), length(get_significant_results(m.current)))
true = c(get_loglik(m.true), length(get_significant_results(m.true)))
tmp = rbind(Ionly, Vonly, current, true)
row.names(tmp) = c('I only', 'V only', 'current', 'true')
colnames(tmp) = c('loglik', '# signif')
tmp %>% kable() %>% kable_styling()
loglik | # signif | |
---|---|---|
I only | -67844.31 | 597 |
V only | -65457.36 | 1904 |
current | -65793.60 | 28 |
true | -60618.08 | 0 |
RRMSE:
tmp = c(rrmse(simdata, m.I), rrmse(simdata, m.V), rrmse(simdata, m.current), rrmse(simdata, m.true))
barplot(tmp, names.arg = c('I only', 'V only', 'current', 'true'))
set.seed(2018)
B1 = matrix(0, n/2, p)
V.1 = matrix(0,p,p); V.1[1,1] = 1
B2 = rmvnorm(n/2, sigma = V.1)
B = rbind(B1, B2)
V.random = array(0, dim=c(p,p,n))
ind = sample(1:n, n/2)
V.random[,,ind] = V
V.random[,,-ind] = diag(p)
Ehat = matrix(0, n, p)
Ehat[ind,] = rmvnorm(n/2, sigma = V)
Ehat[-ind,] = rmvnorm(n/2, sigma = diag(p))
Bhat = B + Ehat
simdata = list(B = B, Bhat=Bhat, Shat = 1)
data = mash_set_data(Bhat, Shat=1)
U.c = cov_canonical(data)
m.I = mash(data, U.c, verbose = FALSE, optmethod = 'mixSQP')
data.V = mash_update_data(data, V = V)
m.V = mash(data.V, U.c, verbose = FALSE, optmethod = 'mixSQP')
V.current = estimate_null_correlation(data, U.c, optmethod = 'mixSQP')
m.current = V.current$mash.model
data.true = mash_update_data(data, V = V.random)
m.true = mash(data.true, U.c, verbose = FALSE, algorithm.version = 'R', optmethod = 'mixSQP')
The estimated V is
V.current$V
[,1] [,2] [,3] [,4] [,5]
[1,] 1.0000000 0.3546900 0.3429763 0.3490958 0.3441626
[2,] 0.3546900 1.0000000 0.3990044 0.3829695 0.3814801
[3,] 0.3429763 0.3990044 1.0000000 0.3706123 0.3784721
[4,] 0.3490958 0.3829695 0.3706123 1.0000000 0.3832406
[5,] 0.3441626 0.3814801 0.3784721 0.3832406 1.0000000
Ionly = c(get_loglik(m.I), length(get_significant_results(m.I)), sum(get_significant_results(m.I) <= n/2))
Vonly = c(get_loglik(m.V), length(get_significant_results(m.V)), sum(get_significant_results(m.V) <= n/2))
current = c(get_loglik(m.current), length(get_significant_results(m.current)), sum(get_significant_results(m.current) <= n/2))
true = c(get_loglik(m.true), length(get_significant_results(m.true)), sum(get_significant_results(m.true) <= n/2))
tmp = rbind(Ionly, Vonly, current, true)
row.names(tmp) = c('I only', 'V only', 'current', 'true')
colnames(tmp) = c('loglik', '# signif', 'false positive')
tmp %>% kable() %>% kable_styling()
loglik | # signif | false positive | |
---|---|---|---|
I only | -70068.62 | 741 | 344 |
V only | -68333.69 | 2588 | 999 |
current | -68468.47 | 114 | 16 |
true | -63908.32 | 340 | 5 |
RRMSE:
tmp = c(rrmse(simdata, m.I), rrmse(simdata, m.V), rrmse(simdata, m.current), rrmse(simdata, m.true))
barplot(tmp, names.arg = c('I only', 'V only', 'current', 'true'))
Version | Author | Date |
---|---|---|
e475e2e | zouyuxin | 2018-12-13 |
66be60b | zouyuxin | 2018-12-07 |
ROC:
roc.seq = ROC.table(simdata$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(simdata$B, m.current)
lines(roc.seq[,'FPR'], roc.seq[,'TPR'], col='purple', lwd = 1.5)
roc.seq = ROC.table(simdata$B, m.I)
lines(roc.seq[,'FPR'], roc.seq[,'TPR'], col='red', lwd = 1.5)
roc.seq = ROC.table(simdata$B, m.V)
lines(roc.seq[,'FPR'], roc.seq[,'TPR'], col='darkolivegreen4', lwd = 1.5)
legend('bottomright', c('oracle','current', 'I only', 'V only'), col=c('cyan','purple','red','darkolivegreen4'),
lty=c(1,1,1,1), lwd=c(1.5,1.5,1.5,1.5))
sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS 10.14.1
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] mashr_0.2.19.0555 ashr_2.2-23 mvtnorm_1.0-8 kableExtra_0.9.0
[5] knitr_1.20
loaded via a namespace (and not attached):
[1] lattice_0.20-35 colorspace_1.3-2 htmltools_0.3.6
[4] viridisLite_0.3.0 yaml_2.2.0 rlang_0.3.0.1
[7] R.oo_1.22.0 mixsqp_0.1-92 pillar_1.3.0
[10] R.utils_2.7.0 foreach_1.4.4 plyr_1.8.4
[13] stringr_1.3.1 munsell_0.5.0 workflowr_1.1.1
[16] rvest_0.3.2 R.methodsS3_1.7.1 codetools_0.2-15
[19] evaluate_0.12 doParallel_1.0.14 pscl_1.5.2
[22] parallel_3.5.1 highr_0.7 Rcpp_1.0.0
[25] readr_1.1.1 scales_1.0.0 backports_1.1.2
[28] rmeta_3.0 truncnorm_1.0-8 abind_1.4-5
[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