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

Error in rowVars(p) : could not find function "rowVars" #14

Open
alexw-gsct opened this issue Oct 26, 2020 · 6 comments
Open

Error in rowVars(p) : could not find function "rowVars" #14

alexw-gsct opened this issue Oct 26, 2020 · 6 comments

Comments

@alexw-gsct
Copy link

I am getting the following error:

dmlt = DSS::DMLtest(bs, group1, group2, equal.disp = FALSE, smoothing = FALSE, BPPARAM = BiocParallel::SnowParam(2))
Estimating dispersion for each CpG site, this will take a while ...
Error in rowVars(p) : could not find function "rowVars"

This error means I cannot use DMLtest without loading library(DSS) (which itself loads many other downstream packages). Perhaps specify the namespace e.g. calling MatrixGenerics::rowVars(p) ?

@haowulab
Copy link
Owner

rowVars is a function from matrixStats package, which should be automatically loaded into R. Maybe your R version is old. Please update to the latest one.

@alexw-gsct
Copy link
Author

I am running R 4.0.3 and using Bioconductor devel 3.12.

I also use matrixStats for its row statistics functions and can confirm it does not automatically load.

See below reprex:
path = file.path(system.file(package="DSS"), "extdata")

dat1.1 = read.table(file.path(path, "cond1_1.txt"), header=TRUE)
dat1.2 = read.table(file.path(path, "cond1_2.txt"), header=TRUE)
dat2.1 = read.table(file.path(path, "cond2_1.txt"), header=TRUE)
dat2.2 = read.table(file.path(path, "cond2_2.txt"), header=TRUE)
BSobj = DSS::makeBSseqData( list(dat1.1, dat1.2, dat2.1, dat2.2),

  •                    c("C1","C2", "N1", "N2") )[1:1000,]
    

dmlTest = DSS::DMLtest(BSobj, group1=c("C1", "C2"), group2=c("N1", "N2"))
Estimating dispersion for each CpG site, this will take a while ...
Error in rowVars(p) : could not find function "rowVars"
sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252 LC_MONETARY=English_Australia.1252
[4] LC_NUMERIC=C LC_TIME=English_Australia.1252

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

loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 compiler_4.0.3 GenomeInfoDb_1.25.11 XVector_0.29.3
[5] R.methodsS3_1.8.1 R.utils_2.10.1 MatrixGenerics_1.1.8 bitops_1.0-6
[9] rhdf5filters_1.1.3 DSS_2.37.0 tools_4.0.3 DelayedMatrixStats_1.11.5
[13] zlibbioc_1.35.0 BSgenome_1.57.7 lifecycle_0.2.0 rhdf5_2.33.11
[17] lattice_0.20-41 rlang_0.4.8 Matrix_1.2-18 rstudioapi_0.11
[21] DelayedArray_0.15.16 parallel_4.0.3 GenomeInfoDbData_1.2.4 bsseq_1.25.7
[25] rtracklayer_1.49.5 Biostrings_2.57.2 S4Vectors_0.27.14 gtools_3.8.2
[29] IRanges_2.23.10 stats4_4.0.3 locfit_1.5-9.4 grid_4.0.3
[33] Biobase_2.49.1 data.table_1.13.2 R6_2.4.1 HDF5Array_1.17.14
[37] XML_3.99-0.5 BiocParallel_1.23.3 limma_3.45.19 Rhdf5lib_1.11.3
[41] GenomicAlignments_1.25.3 Rsamtools_2.5.3 scales_1.1.1 matrixStats_0.57.0
[45] sparseMatrixStats_1.1.11 splines_4.0.3 BiocGenerics_0.35.4 GenomicRanges_1.41.6
[49] SummarizedExperiment_1.19.9 permute_0.9-5 colorspace_1.4-1 RCurl_1.98-1.2
[53] munsell_0.5.0 crayon_1.3.4 R.oo_1.24.0

The function works after DSS is loaded; presumably rowVars using namespace MatrixGenerics is used.

suppressPackageStartupMessages(library(DSS))
dmlTest = DSS::DMLtest(BSobj, group1=c("C1", "C2"), group2=c("N1", "N2"))
Estimating dispersion for each CpG site, this will take a while ...
|===============================================================================================================| 100%

|===============================================================================================================| 100%

@haowulab
Copy link
Owner

Yeah you are right. I have library(matrixStats) in my .Rprofile. My bad. I'll update the package to use matrixStats::rowVars.

I never used MatrixGenerics, seems like a new package. And I don't even have it installed in my R. I guess some other packages load matrixStats.

BTW, is there particular reason why you don't want to load DSS?

@alexw-gsct
Copy link
Author

Thanks Haowu.

I am developing a package and it's just my habit of loading as few packages as possible so I know their namespace dependencies when I finalise the functions.

Your package imports bsseq, which imports DelayedMatrixStats, which depends MatrixGenerics and imports matrixStats. bsseq also imports a whole bunch of other packages, which I try to avoid as it helps in debugging which package is breaking the code.

@haowulab
Copy link
Owner

I've modified the package and committed the changes. Do you want a copy of the package? It'll take some time until the changes appear on bioc. Or you can just modify that yourself.

@alexw-gsct
Copy link
Author

Thanks. I have installed using devtools::install_github. Can now confirm the above example now works without loading library

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

2 participants