Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

design is not imported into package namespace #17

Closed
karawoo opened this issue Jul 22, 2020 · 3 comments
Closed

design is not imported into package namespace #17

karawoo opened this issue Jul 22, 2020 · 3 comments

Comments

@karawoo
Copy link

karawoo commented Jul 22, 2020

This has previously come up in #15 and #14, however I think it is not resolved. voomWithDreamWeights throws an error if it's called using variancePartition::voomWithDreamWeights() and variancePartition hasn't been loaded/attached to the search path. See the following reprex:

metadata <- data.frame(
  batch = c("1", "2", "1", "2"),
  diagnosis = c("dx", "dx", "ct", "ct"),
  stringsAsFactors = FALSE,
  row.names = c("S1", "S2", "S3", "S4")
)

counts <- matrix(
  sample(0:100, size = 12),
  ncol = 4,
  dimnames = list(c("ENSG1", "ENSG2", "ENSG5"), c("S1", "S2", "S3", "S4"))
)

DGE <- edgeR::DGEList(counts)
gene_expression <- edgeR::calcNormFactors(DGE)

output <- variancePartition::voomWithDreamWeights(
  counts = gene_expression,
  formula =  ~ diagnosis + (1|batch),
  data = metadata,
  quiet = TRUE
)
#> Error in variancePartition::voomWithDreamWeights(counts = gene_expression, : object 'design' not found

## Load and attach variancePartition
suppressPackageStartupMessages(library("variancePartition"))

output <- voomWithDreamWeights(
  counts = gene_expression,
  formula =  ~ diagnosis + (1|batch),
  data = metadata,
  quiet = TRUE
) # no error
#> Memory usage to store result: >2.7 Kb
#> Dividing work into 3 chunks...
#> 
#> Total:1 s

Created on 2020-07-21 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                                      
#>  version  R version 4.0.2 Patched (2020-07-13 r78838)
#>  os       macOS Mojave 10.14.6                       
#>  system   x86_64, darwin17.0                         
#>  ui       X11                                        
#>  language (EN)                                       
#>  collate  en_US.UTF-8                                
#>  ctype    en_US.UTF-8                                
#>  tz       America/Los_Angeles                        
#>  date     2020-07-21                                 
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package           * version    date       lib
#>  assertthat          0.2.1      2019-03-21 [1]
#>  backports           1.1.8      2020-06-17 [1]
#>  Biobase           * 2.48.0     2020-04-27 [1]
#>  BiocGenerics      * 0.34.0     2020-04-27 [1]
#>  BiocParallel        1.22.0     2020-04-27 [1]
#>  bitops              1.0-6      2013-08-17 [1]
#>  boot                1.3-25     2020-04-26 [1]
#>  callr               3.4.3      2020-03-28 [1]
#>  caTools             1.18.0     2020-01-17 [1]
#>  cli                 2.0.2      2020-02-28 [1]
#>  codetools           0.2-16     2018-12-24 [1]
#>  colorRamps          2.3        2012-10-29 [1]
#>  colorspace          1.4-1      2019-03-18 [1]
#>  crayon              1.3.4      2017-09-16 [1]
#>  desc                1.2.0      2018-05-01 [1]
#>  devtools            2.3.0      2020-04-10 [1]
#>  digest              0.6.25     2020-02-23 [1]
#>  doParallel          1.0.15     2019-08-02 [1]
#>  dplyr               1.0.0      2020-05-29 [1]
#>  edgeR               3.30.3     2020-06-02 [1]
#>  ellipsis            0.3.1      2020-05-15 [1]
#>  evaluate            0.14       2019-05-28 [1]
#>  fansi               0.4.1      2020-01-08 [1]
#>  foreach           * 1.5.0      2020-03-30 [1]
#>  fs                  1.4.2      2020-06-30 [1]
#>  gdata               2.18.0     2017-06-06 [1]
#>  generics            0.0.2      2018-11-29 [1]
#>  ggplot2           * 3.3.2.9000 2020-07-21 [1]
#>  glue                1.4.1      2020-05-13 [1]
#>  gplots              3.0.4      2020-07-05 [1]
#>  gtable              0.3.0      2019-03-25 [1]
#>  gtools              3.8.2      2020-03-31 [1]
#>  highr               0.8        2019-03-20 [1]
#>  hms                 0.5.3      2020-01-08 [1]
#>  htmltools           0.5.0      2020-06-16 [1]
#>  iterators           1.0.12     2019-07-26 [1]
#>  KernSmooth          2.23-17    2020-04-26 [1]
#>  knitr               1.29       2020-06-23 [1]
#>  lattice             0.20-41    2020-04-02 [1]
#>  lifecycle           0.2.0      2020-03-06 [1]
#>  limma             * 3.44.3     2020-06-12 [1]
#>  lme4                1.1-23     2020-04-07 [1]
#>  locfit              1.5-9.4    2020-03-25 [1]
#>  magrittr            1.5        2014-11-22 [1]
#>  MASS                7.3-51.6   2020-04-26 [1]
#>  Matrix              1.2-18     2019-11-27 [1]
#>  memoise             1.1.0      2017-04-21 [1]
#>  minqa               1.2.4      2014-10-09 [1]
#>  munsell             0.5.0      2018-06-12 [1]
#>  nlme                3.1-148    2020-05-24 [1]
#>  nloptr              1.2.2.2    2020-07-02 [1]
#>  pbkrtest            0.4-8.6    2020-02-20 [1]
#>  pillar              1.4.6      2020-07-10 [1]
#>  pkgbuild            1.1.0      2020-07-13 [1]
#>  pkgconfig           2.0.3      2019-09-22 [1]
#>  pkgload             1.1.0      2020-05-29 [1]
#>  plyr                1.8.6      2020-03-03 [1]
#>  prettyunits         1.1.1      2020-01-24 [1]
#>  processx            3.4.3      2020-07-05 [1]
#>  progress            1.2.2      2019-05-16 [1]
#>  ps                  1.3.3      2020-05-08 [1]
#>  purrr               0.3.4      2020-04-17 [1]
#>  R6                  2.4.1      2019-11-12 [1]
#>  Rcpp                1.0.5      2020-07-06 [1]
#>  remotes             2.1.1      2020-02-15 [1]
#>  reshape2            1.4.4      2020-04-09 [1]
#>  rlang               0.4.7      2020-07-09 [1]
#>  rmarkdown           2.3        2020-06-18 [1]
#>  rprojroot           1.3-2      2018-01-03 [1]
#>  scales            * 1.1.1      2020-05-11 [1]
#>  sessioninfo         1.1.1      2018-11-05 [1]
#>  statmod             1.4.34     2020-02-17 [1]
#>  stringi             1.4.6      2020-02-17 [1]
#>  stringr             1.4.0      2019-02-10 [1]
#>  testthat            2.3.2      2020-03-02 [1]
#>  tibble              3.0.3      2020-07-10 [1]
#>  tidyselect          1.1.0      2020-05-11 [1]
#>  usethis             1.6.1      2020-04-29 [1]
#>  variancePartition * 1.19.10    2020-07-22 [1]
#>  vctrs               0.3.2      2020-07-15 [1]
#>  withr               2.2.0      2020-04-20 [1]
#>  xfun                0.15       2020-06-21 [1]
#>  yaml                2.2.1      2020-02-01 [1]
#>  source                                           
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.1)                                   
#>  Bioconductor                                     
#>  Bioconductor                                     
#>  Bioconductor                                     
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.2)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.2)                                   
#>  CRAN (R 4.0.2)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.2)                                   
#>  CRAN (R 4.0.0)                                   
#>  Bioconductor                                     
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.1)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  Github (tidyverse/ggplot2@a3019f9)               
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.1)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.1)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.2)                                   
#>  CRAN (R 4.0.1)                                   
#>  CRAN (R 4.0.2)                                   
#>  CRAN (R 4.0.0)                                   
#>  Bioconductor                                     
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.2)                                   
#>  CRAN (R 4.0.2)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.2)                                   
#>  CRAN (R 4.0.1)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.2)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.1)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.2)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.2)                                   
#>  CRAN (R 4.0.1)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.2)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.0)                                   
#>  Github (GabrielHoffman/variancePartition@e61a3de)
#>  CRAN (R 4.0.2)                                   
#>  CRAN (R 4.0.0)                                   
#>  CRAN (R 4.0.1)                                   
#>  CRAN (R 4.0.0)                                   
#> 
#> [1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library

The first call fails at this line. design isn't defined anywhere in the function. After calling library("variancePartition"), BiocGenerics gets loaded and attached as well, and since it exports design, the code works.

If the design function from BiocGenerics is what's meant to be referenced here, this issue should be fixable by either replacing design with BiocGenerics::design at that line or adding this roxygen comment #' @importFrom BiocGenerics design. Though then I'm not sure then why the code tests if design is NULL, if it's a function from another package.

@GabrielHoffman
Copy link
Owner

Thanks for the bug report. This was a simple mistake on my end that led to #15. Because design wasn't initialized, it looked in the above scope and found BiocGenerics::design, which led to some very confusing errors.

I have now initialized design = NULL at the beginning of the function in v1.19.11.

I can push this as a patch to the Bioconductor release once you confirm it works.

@kelshmo, can you confirm that this addresses #14 and #15?

Gabriel

@karawoo
Copy link
Author

karawoo commented Jul 22, 2020

Confirmed that that fixes the error 👍

@kelshmo
Copy link

kelshmo commented Jul 22, 2020

Yes - error resolved!

@karawoo karawoo closed this as completed Jul 22, 2020
MattPM added a commit to MattPM/scglmmr that referenced this issue Jan 17, 2021
MattPM added a commit to MattPM/scglmmr that referenced this issue Jan 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants