Last updated: 2022-11-17

Checks: 7 0

Knit directory: gsmash/

This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


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.

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(20220606) 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 results in this page were generated with repository version 8a7af8f. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

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:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    data/poisson_mean_simulation/

Untracked files:
    Untracked:  code/binomial_mean/
    Untracked:  code/poisson_smooth/simulation_summary_smooth.R
    Untracked:  figure/
    Untracked:  output/poisson_mean_simulation/
    Untracked:  output/poisson_smooth_simulation/

Unstaged changes:
    Modified:   analysis/normal_mean_penalty_glm_simplified.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 repository in which changes were made to the R Markdown (analysis/binomial_mean_spliiting.Rmd) and HTML (docs/binomial_mean_spliiting.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 8a7af8f DongyueXie 2022-11-17 wflow_publish("analysis/binomial_mean_spliiting.Rmd")

Introduction

source("code/binomial_mean/binomial_mean_splitting.R")
Loading required package: Rcpp
Loading required package: RcppZiggurat
set.seed(12345)
n = 500
nb = rep(100,n)
w = 0.8
mu = c(rep(0,n*w),rnorm(round(n*(1-w))))
p = sigmoid(mu)
x = rbinom(n,nb,p)
library(ashr)
fit_ash = ashr::ash(rep(0,n),1,lik=lik_binom(x,nb,link='identity'))
fit_split = binomial_mean_splitting(x,nb,printevery = 1,n_gh=10,
                                    b_pm_init = NULL,sigma2_init = NULL,
                                    ebnm_params = list(prior_family='normal_scale_mixture'))
[1] "At iter 1 elbo= -1564.537 sigma2= 0.205"
[1] "At iter 2 elbo= -1505.271 sigma2= 0.159"
[1] "At iter 3 elbo= -1461.715 sigma2= 0.131"
[1] "At iter 4 elbo= -1434.582 sigma2= 0.117"
[1] "At iter 5 elbo= -1419.311 sigma2= 0.11"
[1] "At iter 6 elbo= -1412.213 sigma2= 0.107"
[1] "At iter 7 elbo= -1409.016 sigma2= 0.105"
[1] "At iter 8 elbo= -1407.596 sigma2= 0.105"
[1] "At iter 9 elbo= -1406.97 sigma2= 0.105"
[1] "At iter 10 elbo= -1406.694 sigma2= 0.104"
[1] "At iter 11 elbo= -1406.573 sigma2= 0.104"
[1] "At iter 12 elbo= -1406.519 sigma2= 0.104"
[1] "At iter 13 elbo= -1406.496 sigma2= 0.104"
[1] "At iter 14 elbo= -1406.486 sigma2= 0.104"
[1] "At iter 15 elbo= -1406.481 sigma2= 0.104"
[1] "At iter 16 elbo= -1406.479 sigma2= 0.104"
[1] "At iter 17 elbo= -1406.478 sigma2= 0.104"
[1] "At iter 18 elbo= -1406.478 sigma2= 0.104"
[1] "At iter 19 elbo= -1406.478 sigma2= 0.104"
[1] "At iter 20 elbo= -1406.478 sigma2= 0.104"
[1] "At iter 21 elbo= -1406.478 sigma2= 0.104"
[1] "At iter 22 elbo= -1406.478 sigma2= 0.104"
[1] "At iter 23 elbo= -1406.478 sigma2= 0.104"
fit_GG = binomial_mean_GG(x,nb,printevery = 1,n_gh=10)
[1] "At iter 1 elbo= -1645.672"
[1] "At iter 2 elbo= -1598.219"
[1] "At iter 3 elbo= -1586.716"
[1] "At iter 4 elbo= -1577.111"
[1] "At iter 5 elbo= -1576.244"
[1] "At iter 6 elbo= -1575.846"
[1] "At iter 7 elbo= -1575.346"
[1] "At iter 8 elbo= -1575.346"
plot(x/nb,col='grey80')
lines(p,col='grey80')
lines(fit_ash$result$PosteriorMean,col=2)

plot(x/nb,col='grey80')
lines(p,col='grey80')
lines(fit_split$posterior$mean,col=4)

plot(x/nb,col='grey80')
lines(p,col='grey80')
lines(sigmoid(fit_split$posterior$mean_b),col=4)

plot(x/nb,col='grey80')
lines(p,col='grey80')
lines(fit_GG$posterior$mean,col=3)

set.seed(12345)
n = 500
nb = rep(1,n)
w = 0.8
mu = c(rep(0,n*w),rnorm(round(n*(1-w))))
p = sigmoid(mu)
x = rbinom(n,nb,p)
library(ashr)
fit_ash = ashr::ash(rep(0,n),1,lik=lik_binom(x,nb,link='identity'))
fit_split = binomial_mean_splitting(x,nb,printevery = 1,n_gh=10,
                                    b_pm_init = NULL,sigma2_init = NULL,
                                    ebnm_params = list(prior_family='normal_scale_mixture'))
[1] "At iter 1 elbo= -1072.08 sigma2= 4.761"
[1] "At iter 2 elbo= -1072.08 sigma2= 4.761"
fit_GG = binomial_mean_GG(x,nb,printevery = 1,n_gh=10)
[1] "At iter 1 elbo= -1063.752"
[1] "At iter 2 elbo= -1075.504"
Warning in binomial_mean_GG(x, nb, printevery = 1, n_gh = 10): An iteration
decreases ELBO. This is likely due to numerical issues.
plot(x/nb,col='grey80')
lines(p,col='grey80')
lines(fit_ash$result$PosteriorMean,col=2)

plot(x/nb,col='grey80')
lines(p,col='grey80')
lines(fit_split$posterior$mean,col=4)

plot(x/nb,col='grey80')
lines(p,col='grey80')
lines(sigmoid(fit_split$posterior$mean_b),col=4)

plot(x/nb,col='grey80')
lines(p,col='grey80')
lines(fit_GG$posterior$mean,col=3)


sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.5 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
 [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
 [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
[10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ashr_2.2-54        Rfast_2.0.6        RcppZiggurat_0.1.6 ebnm_1.0-9        
[5] fastGHQuad_1.0.1   Rcpp_1.0.9         vebpm_0.2.1        workflowr_1.7.0   

loaded via a namespace (and not attached):
 [1] horseshoe_0.2.0    invgamma_1.1       lattice_0.20-45    nleqslv_3.3.3     
 [5] getPass_0.2-2      ps_1.7.1           assertthat_0.2.1   rprojroot_2.0.3   
 [9] digest_0.6.29      utf8_1.2.2         truncnorm_1.0-8    R6_2.5.1          
[13] rootSolve_1.8.2.3  evaluate_0.17      highr_0.9          httr_1.4.4        
[17] ggplot2_3.3.6      pillar_1.8.1       rlang_1.0.6        rstudioapi_0.14   
[21] irlba_2.3.5.1      nloptr_2.0.3       whisker_0.4        callr_3.7.2       
[25] jquerylib_0.1.4    Matrix_1.5-1       rmarkdown_2.17     splines_4.2.1     
[29] stringr_1.4.1      munsell_0.5.0      mixsqp_0.3-43      compiler_4.2.1    
[33] httpuv_1.6.6       xfun_0.33          pkgconfig_2.0.3    SQUAREM_2021.1    
[37] htmltools_0.5.3    tidyselect_1.2.0   tibble_3.1.8       matrixStats_0.62.0
[41] fansi_1.0.3        dplyr_1.0.10       later_1.3.0        grid_4.2.1        
[45] jsonlite_1.8.2     gtable_0.3.1       lifecycle_1.0.3    DBI_1.1.3         
[49] git2r_0.30.1       magrittr_2.0.3     scales_1.2.1       ebpm_0.0.1.3      
[53] cli_3.4.1          stringi_1.7.8      cachem_1.0.6       fs_1.5.2          
[57] promises_1.2.0.1   bslib_0.4.0        generics_0.1.3     vctrs_0.4.2       
[61] trust_0.1-8        tools_4.2.1        glue_1.6.2         parallel_4.2.1    
[65] processx_3.7.0     fastmap_1.1.0      yaml_2.3.5         colorspace_2.0-3  
[69] deconvolveR_1.2-1  knitr_1.40         sass_0.4.2