Last updated: 2018-11-08
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: e4d4425
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: analysis/.Rhistory
Ignored: docs/.DS_Store
Ignored: docs/figure/Test.Rmd/
Untracked files:
Untracked: analysis/MASH_est_Cor.Rmd
Untracked: analysis/MASHbaselineCode.Rmd
Untracked: analysis/MashMedian.Rmd
Untracked: analysis/mashMean.Rmd
Untracked: code/generateDataV.R
Untracked: code/summary.R
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/mashrEMlk.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(corrplot)
corrplot 0.84 loaded
set.seed(1)
simdata = simple_sims(500,5,1)
data = mash_set_data(simdata$Bhat, simdata$Shat)
U.c = cov_canonical(data)
m = mash(data, U.c, algorithm.version = 'R', posterior_samples = 100)
- Computing 2000 x 151 likelihood matrix.
- Likelihood calculations took 0.09 seconds.
- Fitting model with 151 mixture components.
- Model fitting took 0.27 seconds.
- Computing posterior matrices.
- Computation allocated took 3.03 seconds.
The posterior samples is a \(2000\times 5 \times 100\) array. The get_pairwise_sharing_from_samples
computes the proportion as \[
\begin{align*}
&\text{Proportion of effects have the same sign for condition r, r'} \\
&= \frac{1}{2000} \sum_{j=1}^{2000}\mathbb{E}\left[\mathbb{I}(b_{jr}, b_{jr'} \text{ have same sign}) \right] \\
&\approx \frac{1}{2000} \sum_{j=1}^{2000} \frac{1}{100} \sum_{m=1}^{100} \mathbb{I}(b_{jr}^{(m)}, b_{jr'}^{(m)} \text{ have same sign})
\end{align*}
\]
Pairwise sharing by Sign from get_pairwise_sharing_from_samples
x = get_pairwise_sharing_from_samples(m, factor=0)
corrplot(x, method='color', cl.lim=c(0,1), type='upper', addCoef.col = "black", tl.col="black", tl.srt=45, title = 'Pairwise Sharing by Sign', mar = c(4,0,4,0))
Version | Author | Date |
---|---|---|
7a54901 | zouyuxin | 2018-11-07 |
The diagonal elements are less than 1, because when we compute the probability of sharing for each effect, we don’t count a sample with all 0s as sharing (\(\mathbb{I}(b_{jr}^{(m)} = 0, b_{jr'}^{(m)} = 0 \text{ have same sign}) = 0\)).
Pairwise sharing by Sign from get_pairwise_sharing
x = get_pairwise_sharing(m, factor=0, lfsr_thresh = 1)
corrplot(x, method='color', cl.lim=c(0,1), type='upper', addCoef.col = "black", tl.col="black", tl.srt=45, title = 'Pairwise Sharing by Sign', mar = c(4,0,4,0))
Version | Author | Date |
---|---|---|
7a54901 | zouyuxin | 2018-11-07 |
The diagonal elements are 1, because we include the effects close to 0 as sharing.
sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS 10.14
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] corrplot_0.84 mashr_0.2.18.0476 ashr_2.2-23
loaded via a namespace (and not attached):
[1] Rcpp_0.12.19 compiler_3.5.1 git2r_0.23.0
[4] plyr_1.8.4 workflowr_1.1.1 R.methodsS3_1.7.1
[7] R.utils_2.7.0 iterators_1.0.10 tools_3.5.1
[10] digest_0.6.18 evaluate_0.12 lattice_0.20-35
[13] Matrix_1.2-14 foreach_1.4.4 yaml_2.2.0
[16] parallel_3.5.1 mvtnorm_1.0-8 stringr_1.3.1
[19] knitr_1.20 REBayes_1.3 rprojroot_1.3-2
[22] grid_3.5.1 rmarkdown_1.10 rmeta_3.0
[25] magrittr_1.5 whisker_0.3-2 backports_1.1.2
[28] codetools_0.2-15 htmltools_0.3.6 MASS_7.3-50
[31] abind_1.4-5 assertthat_0.2.0 stringi_1.2.4
[34] Rmosek_8.0.69 doParallel_1.0.14 pscl_1.5.2
[37] truncnorm_1.0-8 SQUAREM_2017.10-1 R.oo_1.22.0
This reproducible R Markdown analysis was created with workflowr 1.1.1