stephens999 / ashr

An R package for adaptive shrinkage
GNU General Public License v3.0
80 stars 36 forks source link

Error if trace = TRUE in ashci #133

Closed frederikziebell closed 2 years ago

frederikziebell commented 2 years ago

This

beta <-  c(rep(0,20),rnorm(20))
sebetahat <-  abs(rnorm(40,0,1))
betahat <-  rnorm(40,beta,sebetahat)
beta.ash <-  ash(betahat, sebetahat)
res <- ashci(beta.ash,betaindex = 1:10, trace = TRUE)

gives an error

Error in assign(".type", type, envir = baseenv()) : 
cannot add binding of '.type' to the base environment

which does not appear, if trace = FALSE is set

pcarbo commented 2 years ago

@frederikziebell I could not reproduce your error. Which version of the ashr package are you using? Maybe try with library(ashr) rather than, say, loading the package with devtools::load_all()?

frederikziebell commented 2 years ago

I'm using library(ashr), here's my session info:

R version 4.2.0 (2022-04-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.2.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/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] ashr_2.2-54

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.8.3    invgamma_1.1    lattice_0.20-45 digest_0.6.29   truncnorm_1.0-8 grid_4.2.0      evaluate_0.15   rlang_1.0.2     cli_3.3.0       irlba_2.3.5     Matrix_1.4-1    rmarkdown_2.14  tools_4.2.0    
[14] mixsqp_0.3-47   xfun_0.30       yaml_2.3.5      fastmap_1.1.0   compiler_4.2.0  SQUAREM_2021.1  htmltools_0.5.2 knitr_1.39     
stephens999 commented 2 years ago

this appears to be due to a breaking change in R v 4.1.0 which had the following change:

The base environment and its namespace are now locked (so one can no longer add bindings to these or remove from these).

This lead to breaking of the ashr tic and toc functions. I've replaced these functions with the latest commit

stephens999 commented 2 years ago

fixed with 9c5a495