Re: [Bioc-devel] conflict rowRanges SummarizedExperiment/matrixStats
Thanks for the explanation and the proposed solution. I was not aware the DelayedArray package was involved as well. Maarten On Fri, Apr 7, 2017 at 6:26 AM, Hervé Pagèswrote: > Hi Maarten, Vince, > > We need to fix this. The plan is to promote rowRanges to an S4 generic > in the DelayedArray package (DelayedArray depends on matrixStats). And > to remove the rowRanges S4 generic defined in SummarizedExperiment > (SummarizedExperiment depends on DelayedArray). So we'll have only 1 > rowRanges generic (defined in DelayedArray). With methods defined in > matrixStats (default method), DelayedArray (method for DelayedMatrix > objects), and SummarizedExperiment (method for RangedSummarizedExperiment > objects). > > Then there won't be anymore conflict. > > Will fix this ASAP. > > H. > > > > On 04/06/2017 03:11 AM, Vincent Carey wrote: > >> I am sure there are better responses to come, but here are a few initial >> comments. >> >> On Thu, Apr 6, 2017 at 5:42 AM, Maarten van Iterson >> wrote: >> >> Dear all, >>> >>> SummarizedExperiment and matrixStats both contain a method/function >>> called >>> rowRanges one operates on a SummarizedExperiment-object the other on a >>> matrix. matrixStats is required by SummarizedExperiment, or a package it >>> is >>> depending on, so rowRanges is masked when loading SummarizedExperiment. >>> >>> I thought a function/method is called depended on the type of the object; >>> >>> >> There are at least two interpretations of this. If a function that is an >> S3 generic is called on an entity whose class corresponds to an existing >> method, that method will be invoked. If a function that is an S4 generic >> is called with (a sequence of) arguments corresponding to a method with >> signature equivalent to the sequence of classes of the arguments, that >> method will be invoked. In matrixStats, rowRanges is just a first level >> function, and will be invoked directly on anything that is passed -- e.g., >> rowRanges(4) is just an error, when matrixStats alone is loaded. >> >> matrix or SummarizedExperiment-object, such that functions/methods with >> the >> >>> same name can coexist. However, this doesn't seems to work for rowRanges. >>> The only way to access rowRanges from matrixStats when >>> SummarizedExperiment >>> is already loaded is using the double colon operator >>> matrixStats::rowRanges. Is this intentional or is there a other way to >>> solve this? >>> >>> Regards, >>> Maarten >>> >>> Here is a small example showing the issue: >>> >>> library(SummarizedExperiment) >>> Loading required package: matrixStats >>> matrixStats v0.51.0 (2016-10-08) successfully loaded. See ?matrixStats >>> for >>> help. >>> Attaching package: ‘matrixStats’ >>> Attaching package: ‘SummarizedExperiment’ >>> The following object is masked from ‘package:matrixStats’: >>> rowRanges >>> nrows <- 200; ncols <- 6 counts <- matrix(runif(nrows * ncols, 1, 1e4), nrows) rowRanges <- GRanges(rep(c("chr1", "chr2"), c(50, 150)), >>> + IRanges(floor(runif(200, 1e5, 1e6)), width=100), >>> + strand=sample(c("+", "-"), 200, TRUE), >>> + feature_id=sprintf("ID%03d", 1:200)) >>> colData <- DataFrame(Treatment=rep(c("ChIP", "Input"), 3), >>> + row.names=LETTERS[1:6]) >>> rse <- SummarizedExperiment(assays=SimpleList(counts=counts), >>> + rowRanges=rowRanges, colData=colData) >>> rowRanges(rse) >>> GRanges object with 200 ranges and 1 metadata column: >>> seqnames ranges strand | feature_id >>> | >>> [1] chr1 [858613, 858712] - | ID001 >>> rowRanges(counts) >>> Error in (function (classes, fdef, mtable) : >>> unable to find an inherited method for function ‘rowRanges’ for >>> signature >>> ‘"matrix"’ >>> library(matrixStats) ##it is already loading so this doesn't alter the >>> >>> >> Actually in this case matrixStats is loaded and attached. Sometimes the >> difference is significant. >> >> >> search path >>> rowRanges(rse) >>> GRanges object with 200 ranges and 1 metadata column: >>> seqnames ranges strand | feature_id >>> | >>> [1] chr1 [858613, 858712] - | ID001 >>> rowRanges(counts) >>> Error in (function (classes, fdef, mtable) : >>> unable to find an inherited method for function ‘rowRanges’ for >>> signature >>> ‘"matrix"’ >>> >>> >> So -- we got a warning when there was a collision in namespaces, when >> SummarizedExperiment was attached, and an indication that rowRanges is an >> S4 generic when we encountered the error. When should we introduce >> the method >> >> setMethod("rowRanges", "matrix", function(x, ...) >> matrixStats::rowRanges(x, >> ...)) >> >> that would foster the behavior I think you are
Re: [Bioc-devel] conflict rowRanges SummarizedExperiment/matrixStats
Hi Maarten, Vince, We need to fix this. The plan is to promote rowRanges to an S4 generic in the DelayedArray package (DelayedArray depends on matrixStats). And to remove the rowRanges S4 generic defined in SummarizedExperiment (SummarizedExperiment depends on DelayedArray). So we'll have only 1 rowRanges generic (defined in DelayedArray). With methods defined in matrixStats (default method), DelayedArray (method for DelayedMatrix objects), and SummarizedExperiment (method for RangedSummarizedExperiment objects). Then there won't be anymore conflict. Will fix this ASAP. H. On 04/06/2017 03:11 AM, Vincent Carey wrote: I am sure there are better responses to come, but here are a few initial comments. On Thu, Apr 6, 2017 at 5:42 AM, Maarten van Itersonwrote: Dear all, SummarizedExperiment and matrixStats both contain a method/function called rowRanges one operates on a SummarizedExperiment-object the other on a matrix. matrixStats is required by SummarizedExperiment, or a package it is depending on, so rowRanges is masked when loading SummarizedExperiment. I thought a function/method is called depended on the type of the object; There are at least two interpretations of this. If a function that is an S3 generic is called on an entity whose class corresponds to an existing method, that method will be invoked. If a function that is an S4 generic is called with (a sequence of) arguments corresponding to a method with signature equivalent to the sequence of classes of the arguments, that method will be invoked. In matrixStats, rowRanges is just a first level function, and will be invoked directly on anything that is passed -- e.g., rowRanges(4) is just an error, when matrixStats alone is loaded. matrix or SummarizedExperiment-object, such that functions/methods with the same name can coexist. However, this doesn't seems to work for rowRanges. The only way to access rowRanges from matrixStats when SummarizedExperiment is already loaded is using the double colon operator matrixStats::rowRanges. Is this intentional or is there a other way to solve this? Regards, Maarten Here is a small example showing the issue: library(SummarizedExperiment) Loading required package: matrixStats matrixStats v0.51.0 (2016-10-08) successfully loaded. See ?matrixStats for help. Attaching package: ‘matrixStats’ Attaching package: ‘SummarizedExperiment’ The following object is masked from ‘package:matrixStats’: rowRanges nrows <- 200; ncols <- 6 counts <- matrix(runif(nrows * ncols, 1, 1e4), nrows) rowRanges <- GRanges(rep(c("chr1", "chr2"), c(50, 150)), + IRanges(floor(runif(200, 1e5, 1e6)), width=100), + strand=sample(c("+", "-"), 200, TRUE), + feature_id=sprintf("ID%03d", 1:200)) colData <- DataFrame(Treatment=rep(c("ChIP", "Input"), 3), + row.names=LETTERS[1:6]) rse <- SummarizedExperiment(assays=SimpleList(counts=counts), + rowRanges=rowRanges, colData=colData) rowRanges(rse) GRanges object with 200 ranges and 1 metadata column: seqnames ranges strand | feature_id | [1] chr1 [858613, 858712] - | ID001 rowRanges(counts) Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘rowRanges’ for signature ‘"matrix"’ library(matrixStats) ##it is already loading so this doesn't alter the Actually in this case matrixStats is loaded and attached. Sometimes the difference is significant. search path rowRanges(rse) GRanges object with 200 ranges and 1 metadata column: seqnames ranges strand | feature_id | [1] chr1 [858613, 858712] - | ID001 rowRanges(counts) Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘rowRanges’ for signature ‘"matrix"’ So -- we got a warning when there was a collision in namespaces, when SummarizedExperiment was attached, and an indication that rowRanges is an S4 generic when we encountered the error. When should we introduce the method setMethod("rowRanges", "matrix", function(x, ...) matrixStats::rowRanges(x, ...)) that would foster the behavior I think you are looking for? head(matrixStats::rowRanges(counts)) [,1] [,2] [1,] 51.27791 9350.048 [2,] 1417.41010 8272.040 sessionInfo() R Under development (unstable) (2016-08-25 r71150) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 14.04.5 LTS locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_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] parallel stats4stats graphics grDevices utils
Re: [Bioc-devel] conflict rowRanges SummarizedExperiment/matrixStats
I am sure there are better responses to come, but here are a few initial comments. On Thu, Apr 6, 2017 at 5:42 AM, Maarten van Itersonwrote: > Dear all, > > SummarizedExperiment and matrixStats both contain a method/function called > rowRanges one operates on a SummarizedExperiment-object the other on a > matrix. matrixStats is required by SummarizedExperiment, or a package it is > depending on, so rowRanges is masked when loading SummarizedExperiment. > > I thought a function/method is called depended on the type of the object; > There are at least two interpretations of this. If a function that is an S3 generic is called on an entity whose class corresponds to an existing method, that method will be invoked. If a function that is an S4 generic is called with (a sequence of) arguments corresponding to a method with signature equivalent to the sequence of classes of the arguments, that method will be invoked. In matrixStats, rowRanges is just a first level function, and will be invoked directly on anything that is passed -- e.g., rowRanges(4) is just an error, when matrixStats alone is loaded. matrix or SummarizedExperiment-object, such that functions/methods with the > same name can coexist. However, this doesn't seems to work for rowRanges. > The only way to access rowRanges from matrixStats when SummarizedExperiment > is already loaded is using the double colon operator > matrixStats::rowRanges. Is this intentional or is there a other way to > solve this? > > Regards, > Maarten > > Here is a small example showing the issue: > > > library(SummarizedExperiment) > Loading required package: matrixStats > matrixStats v0.51.0 (2016-10-08) successfully loaded. See ?matrixStats for > help. > Attaching package: ‘matrixStats’ > Attaching package: ‘SummarizedExperiment’ > The following object is masked from ‘package:matrixStats’: > rowRanges > > nrows <- 200; ncols <- 6 > > counts <- matrix(runif(nrows * ncols, 1, 1e4), nrows) > > rowRanges <- GRanges(rep(c("chr1", "chr2"), c(50, 150)), > + IRanges(floor(runif(200, 1e5, 1e6)), width=100), > + strand=sample(c("+", "-"), 200, TRUE), > + feature_id=sprintf("ID%03d", 1:200)) > > colData <- DataFrame(Treatment=rep(c("ChIP", "Input"), 3), > + row.names=LETTERS[1:6]) > > rse <- SummarizedExperiment(assays=SimpleList(counts=counts), > + rowRanges=rowRanges, colData=colData) > > > > rowRanges(rse) > GRanges object with 200 ranges and 1 metadata column: > seqnames ranges strand | feature_id > | > [1] chr1 [858613, 858712] - | ID001 > > > > rowRanges(counts) > Error in (function (classes, fdef, mtable) : > unable to find an inherited method for function ‘rowRanges’ for signature > ‘"matrix"’ > > > > library(matrixStats) ##it is already loading so this doesn't alter the > Actually in this case matrixStats is loaded and attached. Sometimes the difference is significant. > search path > > > > rowRanges(rse) > GRanges object with 200 ranges and 1 metadata column: > seqnames ranges strand | feature_id > | > [1] chr1 [858613, 858712] - | ID001 > > rowRanges(counts) > Error in (function (classes, fdef, mtable) : > unable to find an inherited method for function ‘rowRanges’ for signature > ‘"matrix"’ > So -- we got a warning when there was a collision in namespaces, when SummarizedExperiment was attached, and an indication that rowRanges is an S4 generic when we encountered the error. When should we introduce the method setMethod("rowRanges", "matrix", function(x, ...) matrixStats::rowRanges(x, ...)) that would foster the behavior I think you are looking for? > > > head(matrixStats::rowRanges(counts)) >[,1] [,2] > [1,] 51.27791 9350.048 > [2,] 1417.41010 8272.040 > > sessionInfo() > R Under development (unstable) (2016-08-25 r71150) > Platform: x86_64-pc-linux-gnu (64-bit) > Running under: Ubuntu 14.04.5 LTS > > locale: > [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C > [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 > [5] LC_MONETARY=en_US.UTF-8LC_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] parallel stats4stats graphics grDevices utils datasets > [8] methods base > > other attached packages: > [1] SummarizedExperiment_1.5.7 DelayedArray_0.1.7 > [3] matrixStats_0.51.0 Biobase_2.35.1 > [5] GenomicRanges_1.27.23 GenomeInfoDb_1.11.10 > [7] IRanges_2.9.19 S4Vectors_0.13.15 > [9] BiocGenerics_0.21.3 > > loaded via a namespace (and not attached): > [1] lattice_0.20-34 bitops_1.0-6grid_3.4.0 > [4] zlibbioc_1.21.0 XVector_0.15.2 Matrix_1.2-8 > [7]
[Bioc-devel] conflict rowRanges SummarizedExperiment/matrixStats
Dear all, SummarizedExperiment and matrixStats both contain a method/function called rowRanges one operates on a SummarizedExperiment-object the other on a matrix. matrixStats is required by SummarizedExperiment, or a package it is depending on, so rowRanges is masked when loading SummarizedExperiment. I thought a function/method is called depended on the type of the object; matrix or SummarizedExperiment-object, such that functions/methods with the same name can coexist. However, this doesn't seems to work for rowRanges. The only way to access rowRanges from matrixStats when SummarizedExperiment is already loaded is using the double colon operator matrixStats::rowRanges. Is this intentional or is there a other way to solve this? Regards, Maarten Here is a small example showing the issue: > library(SummarizedExperiment) Loading required package: matrixStats matrixStats v0.51.0 (2016-10-08) successfully loaded. See ?matrixStats for help. Attaching package: ‘matrixStats’ Attaching package: ‘SummarizedExperiment’ The following object is masked from ‘package:matrixStats’: rowRanges > nrows <- 200; ncols <- 6 > counts <- matrix(runif(nrows * ncols, 1, 1e4), nrows) > rowRanges <- GRanges(rep(c("chr1", "chr2"), c(50, 150)), + IRanges(floor(runif(200, 1e5, 1e6)), width=100), + strand=sample(c("+", "-"), 200, TRUE), + feature_id=sprintf("ID%03d", 1:200)) > colData <- DataFrame(Treatment=rep(c("ChIP", "Input"), 3), + row.names=LETTERS[1:6]) > rse <- SummarizedExperiment(assays=SimpleList(counts=counts), + rowRanges=rowRanges, colData=colData) > > rowRanges(rse) GRanges object with 200 ranges and 1 metadata column: seqnames ranges strand | feature_id | [1] chr1 [858613, 858712] - | ID001 > > rowRanges(counts) Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘rowRanges’ for signature ‘"matrix"’ > > library(matrixStats) ##it is already loading so this doesn't alter the search path > > rowRanges(rse) GRanges object with 200 ranges and 1 metadata column: seqnames ranges strand | feature_id | [1] chr1 [858613, 858712] - | ID001 > rowRanges(counts) Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘rowRanges’ for signature ‘"matrix"’ > > head(matrixStats::rowRanges(counts)) [,1] [,2] [1,] 51.27791 9350.048 [2,] 1417.41010 8272.040 > sessionInfo() R Under development (unstable) (2016-08-25 r71150) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 14.04.5 LTS locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_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] parallel stats4stats graphics grDevices utils datasets [8] methods base other attached packages: [1] SummarizedExperiment_1.5.7 DelayedArray_0.1.7 [3] matrixStats_0.51.0 Biobase_2.35.1 [5] GenomicRanges_1.27.23 GenomeInfoDb_1.11.10 [7] IRanges_2.9.19 S4Vectors_0.13.15 [9] BiocGenerics_0.21.3 loaded via a namespace (and not attached): [1] lattice_0.20-34 bitops_1.0-6grid_3.4.0 [4] zlibbioc_1.21.0 XVector_0.15.2 Matrix_1.2-8 [7] RCurl_1.95-4.8 GenomeInfoDbData_0.99.0 [[alternative HTML version deleted]] ___ Bioc-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/bioc-devel