stephens999 / ashr

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

Mode estimation fails in utils::modifyList #103

Closed aksarkar closed 5 years ago

aksarkar commented 5 years ago

Minimal example:

> train = readRDS("train.Rds")
> c = ashr:::ash.estmode(rep(0, nrow(train)), sebetahat=1, modemin=0, modemax=2, lik=ashr::lik_pois(y=train$x, scale=train$scale, link="identity"))
Error in is.list(x) : invalid 'times' argument
> traceback()
13: stop(e)
12: value[[3L]](cond)
11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
10: tryCatchList(expr, classes, parentenv, handlers)
9: tryCatch(if (missE) ...elt(i) else eval(cl.i, envir = envir),
       error = function(e) {
           e$call <- cl.i
           stop(e)
       })
8: withCallingHandlers(tryCatch(if (missE) ...elt(i) else eval(cl.i,
       envir = envir), error = function(e) {
       e$call <- cl.i
       stop(e)
   }), warning = function(w) {
       w$call <- cl.i
       w
   })
7: stopifnot(is.list(x), is.list(val))
6: utils::modifyList(ash.workhorse(betahat, sebetahat, mixcompdist = mixcompdist,
       df = df, ...), list(call = match.call()))
5: ash(betahat = betahat, mode = c, outputlevel = "loglik", ...)
4: f(arg, ...)
3: (function (arg)
   f(arg, ...))(1.23606797749979)
2: stats::optimize(test.op, interval = c(modemin, modemax))
1: ashr:::ash.estmode(rep(0, nrow(train)), sebetahat = 1, modemin = 0,
       modemax = 2, lik = ashr::lik_pois(y = train$x, scale = train$scale,
           link = "identity"))
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-conda_cos6-linux-gnu (64-bit)
Running under: Scientific Linux 7.4 (Nitrogen)

Matrix products: default
BLAS/LAPACK: /scratch/midway2/aksarkar/miniconda3/envs/scmodes/lib/R/lib/libRblas.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

loaded via a namespace (and not attached):
 [1] MASS_7.3-50       compiler_3.5.1    Matrix_1.2-14     parallel_3.5.1
 [5] mixsqp_0.1-97     Rcpp_0.12.18      codetools_0.2-15  SQUAREM_2017.10-1
 [9] pscl_1.5.2        doParallel_1.0.11 grid_3.5.1        iterators_1.0.10
[13] foreach_1.4.4     truncnorm_1.0-8   ashr_2.2-32       lattice_0.20-35

Data is available here https://users.rcc.uchicago.edu/~aksarkar/singlecell-ideas/train.Rds

stephens999 commented 5 years ago

aksarkar can you try this again with recent push?

stephens999 commented 5 years ago

Sorry closed by accident. please Close if it works!

aksarkar commented 5 years ago

646154b did fix it.

It might be helpful to add a test case with this example dataset to make sure nothing else breaks in tricky places.