IRanges causes bug in complete.cases
2
0
Entering edit mode
@kasper-daniel-hansen-2979
Last seen 17 months ago
United States
After loading IRanges, complete.cases ceases to work (see below). Test via example("complete.cases", package = "stats") To avoid stuff like this in the future, perhaps it would make sense to think of some kind of testing for packages making an S4 generic out of a "base" function. Kasper compute-0-5:~/> R-devel R version 2.11.0 Under development (unstable) (2009-12-08 r50689) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > example(complete.cases) cmplt.> x <- airquality[, -1] # x is a regression design matrix cmplt.> y <- airquality[, 1] # y is the corresponding response cmplt.> stopifnot(complete.cases(y) != is.na(y)) cmplt.> ok <- complete.cases(x,y) cmplt.> sum(!ok) # how many are not "ok" ? [1] 42 cmplt.> x <- x[ok,] cmplt.> y <- y[ok] > library(IRanges) Attaching package: 'IRanges' The following object(s) are masked from package:base : cbind, Map, mapply, order, pmax, pmax.int, pmin, pmin.int, rbind, rep.int, table > example(complete.cases, package = "stats") cmplt.> x <- airquality[, -1] # x is a regression design matrix cmplt.> y <- airquality[, 1] # y is the corresponding response cmplt.> stopifnot(complete.cases(y) != is.na(y)) Error: '...' used in an incorrect context Error in complete.cases(y) : error in evaluating the argument '...' in selecting a method for function 'complete.cases' > sessionInfo() R version 2.11.0 Under development (unstable) (2009-12-08 r50689) x86_64-unknown-linux-gnu locale: [1] LC_CTYPE=en_US.iso885915 LC_NUMERIC=C [3] LC_TIME=en_US.iso885915 LC_COLLATE=en_US.iso885915 [5] LC_MONETARY=C LC_MESSAGES=en_US.iso885915 [7] LC_PAPER=en_US.iso885915 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.iso885915 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] IRanges_1.5.16 loaded via a namespace (and not attached): [1] tools_2.11.0
Regression IRanges Regression IRanges • 1.4k views
ADD COMMENT
0
Entering edit mode
@michael-lawrence-3846
Last seen 3.0 years ago
United States
Thanks for pointing this out. Haven't encountered this S4 ... behavior.. before. Worked around it by forcing our own generic, rather than relying on the implicit one. Could this be a bug in S4? Annoyingly, the IRanges start up message is now longer, due to the masking of package stats. Somebody needs to remove the newlines from that message. On Thu, Dec 10, 2009 at 12:17 PM, Kasper Daniel Hansen < khansen@stat.berkeley.edu> wrote: > After loading IRanges, complete.cases ceases to work (see below). Test via > example("complete.cases", package = "stats") > > To avoid stuff like this in the future, perhaps it would make sense to > think of some kind of testing for packages making an S4 generic out of a > "base" function. > > Kasper > > compute-0-5:~/> R-devel > > R version 2.11.0 Under development (unstable) (2009-12-08 r50689) > Copyright (C) 2009 The R Foundation for Statistical Computing > ISBN 3-900051-07-0 > > R is free software and comes with ABSOLUTELY NO WARRANTY. > You are welcome to redistribute it under certain conditions. > Type 'license()' or 'licence()' for distribution details. > > Natural language support but running in an English locale > > R is a collaborative project with many contributors. > Type 'contributors()' for more information and > 'citation()' on how to cite R or R packages in publications. > > Type 'demo()' for some demos, 'help()' for on-line help, or > 'help.start()' for an HTML browser interface to help. > Type 'q()' to quit R. > > > example(complete.cases) > > cmplt.> x <- airquality[, -1] # x is a regression design matrix > > cmplt.> y <- airquality[, 1] # y is the corresponding response > > cmplt.> stopifnot(complete.cases(y) != is.na(y)) > > cmplt.> ok <- complete.cases(x,y) > > cmplt.> sum(!ok) # how many are not "ok" ? > [1] 42 > > cmplt.> x <- x[ok,] > > cmplt.> y <- y[ok] > > library(IRanges) > > Attaching package: 'IRanges' > > > The following object(s) are masked from package:base : > > cbind, > Map, > mapply, > order, > pmax, > pmax.int, > pmin, > pmin.int, > rbind, > rep.int, > table > > > example(complete.cases, package = "stats") > > cmplt.> x <- airquality[, -1] # x is a regression design matrix > > cmplt.> y <- airquality[, 1] # y is the corresponding response > > cmplt.> stopifnot(complete.cases(y) != is.na(y)) > Error: '...' used in an incorrect context > Error in complete.cases(y) : > error in evaluating the argument '...' in selecting a method for function > 'complete.cases' > > sessionInfo() > R version 2.11.0 Under development (unstable) (2009-12-08 r50689) > x86_64-unknown-linux-gnu > > locale: > [1] LC_CTYPE=en_US.iso885915 LC_NUMERIC=C > [3] LC_TIME=en_US.iso885915 LC_COLLATE=en_US.iso885915 > [5] LC_MONETARY=C LC_MESSAGES=en_US.iso885915 > [7] LC_PAPER=en_US.iso885915 LC_NAME=C > [9] LC_ADDRESS=C LC_TELEPHONE=C > [11] LC_MEASUREMENT=en_US.iso885915 LC_IDENTIFICATION=C > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > other attached packages: > [1] IRanges_1.5.16 > > loaded via a namespace (and not attached): > [1] tools_2.11.0 > > _______________________________________________ > Bioconductor mailing list > Bioconductor@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor > [[alternative HTML version deleted]]
ADD COMMENT
0
Entering edit mode
Seth Falcon ★ 7.4k
@seth-falcon-992
Last seen 10.2 years ago
On 12/10/09 12:17 PM, Kasper Daniel Hansen wrote: > After loading IRanges, complete.cases ceases to work (see below). > Test via example("complete.cases", package = "stats") I can reproduce this on R-devel, but not on R-patched and am not certain yet where the problem lies. There have been some non-trivial fixes to some methods package code in recent R-devel. This is likely related and will take some more looking to understand if the bug is in the IRanges method def or in R. I expect an update next week. > To avoid stuff like this in the future, perhaps it would make sense > to think of some kind of testing for packages making an S4 generic > out of a "base" function. Do you have a specific idea of how we could achieve this? Adding a sanity test, like running the example, for a base function within a package that promotes the function into a generic would have helped this case, but might not catch other issues? + seth -- Seth Falcon Program in Computational Biology | Fred Hutchinson Cancer Research Center
ADD COMMENT
0
Entering edit mode
On Fri, Dec 11, 2009 at 2:10 PM, Seth Falcon <sfalcon@fhcrc.org> wrote: > On 12/10/09 12:17 PM, Kasper Daniel Hansen wrote: > >> After loading IRanges, complete.cases ceases to work (see below). >> Test via example("complete.cases", package = "stats") >> > > I can reproduce this on R-devel, but not on R-patched and am not certain > yet where the problem lies. There have been some non-trivial fixes to some > methods package code in recent R-devel. This is likely related and will > take some more looking to understand if the bug is in the IRanges method def > or in R. > > Just in case this didn't get through, I did work around this by forcing IRanges to provide the generic (package = "IRanges"), rather than relying on the implicit generic. I don't see from the S4 documentation how this could be required of IRanges. The code shouldn't be coming anywhere near the actual IRanges method (on DataTable). > I expect an update next week. > > > To avoid stuff like this in the future, perhaps it would make sense >> to think of some kind of testing for packages making an S4 generic >> out of a "base" function. >> > > Do you have a specific idea of how we could achieve this? Adding a sanity > test, like running the example, for a base function within a package that > promotes the function into a generic would have helped this case, but might > not catch other issues? > > + seth > > -- > Seth Falcon > Program in Computational Biology | Fred Hutchinson Cancer Research Center > > > _______________________________________________ > Bioconductor mailing list > Bioconductor@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor > [[alternative HTML version deleted]]
ADD REPLY
0
Entering edit mode
On 12/11/09 4:54 PM, Michael Lawrence wrote: > On Fri, Dec 11, 2009 at 2:10 PM, Seth Falcon<sfalcon at="" fhcrc.org=""> wrote: > >> On 12/10/09 12:17 PM, Kasper Daniel Hansen wrote: >> >>> After loading IRanges, complete.cases ceases to work (see below). >>> Test via example("complete.cases", package = "stats") >>> >> >> I can reproduce this on R-devel, but not on R-patched and am not certain >> yet where the problem lies. There have been some non-trivial fixes to some >> methods package code in recent R-devel. This is likely related and will >> take some more looking to understand if the bug is in the IRanges method def >> or in R. >> >> > Just in case this didn't get through, I did work around this by forcing > IRanges to provide the generic (package = "IRanges"), rather than relying on > the implicit generic. I don't see from the S4 documentation how this could > be required of IRanges. The code shouldn't be coming anywhere near the > actual IRanges method (on DataTable). Yes, I see your workaround in IRanges (and it works around for me too). I agree that IRanges should not have to do this. I think for this case, IRanges should be able to simply call setMethod with no setGeneric call and the right thing should happen. I'll look into it more. + seth -- Seth Falcon | @sfalcon | http://userprimary.net/users
ADD REPLY
0
Entering edit mode
On Dec 11, 2009, at 17:10 PM, Seth Falcon wrote: > On 12/10/09 12:17 PM, Kasper Daniel Hansen wrote: >> To avoid stuff like this in the future, perhaps it would make sense >> to think of some kind of testing for packages making an S4 generic >> out of a "base" function. > > Do you have a specific idea of how we could achieve this? Adding a sanity test, like running the example, for a base function within a package that promotes the function into a generic would have helped this case, but might not catch other issues? It seems that this issue was caused by some recent changes to the methods package, in which case it is not too strange things break (irritating, but that's life :) There are now a number of core Bioconductor packages that promotes many functions to generics. I would suggest seeing if R passes make check with these packages loaded. For example Biostrings and IRanges. But yes, I think it would a lot of sense if - in general - R CMD check makes sure that if a package promotes a function from base/utils/... into a generic, that the examples connected to that function still runs. There may be variants not caught by this check, but I don't think it hurts to have as many unit tests as we can think of. There may be some implications of this that I have not thought through. Kasper
ADD REPLY

Login before adding your answer.

Traffic: 625 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6