[Bioc-devel] conflict rowRanges SummarizedExperiment/matrixStats
Maarten van Iterson
mviterson at gmail.com
Mon Apr 10 08:46:06 CEST 2017
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ès <hpages at fredhutch.org> wrote:
> 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 <mviterson at gmail.com>
>> 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
>>> <Rle> <IRanges> <Rle> | <character>
>>> [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
>>> <Rle> <IRanges> <Rle> | <character>
>>> [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-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] parallel stats4 stats 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-6 grid_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 at r-project.org mailing list
>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.et
>>> hz.ch_mailman_listinfo_bioc-2Ddevel&d=DwIGaQ&c=eRAMFD45gAfqt
>>> 84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=bB
>>> lLwXlJ4Cst2nHAHB8kAuTS_AWz1pR3o1IU1AAx0VA&s=dRF1ozBM8vw7I37K
>>> i98duGs7d33ewviTTJaXYdkTNYc&e=
>>>
>>
>> [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> Bioc-devel at r-project.org mailing list
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.et
>> hz.ch_mailman_listinfo_bioc-2Ddevel&d=DwIGaQ&c=eRAMFD45gAfqt
>> 84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=bB
>> lLwXlJ4Cst2nHAHB8kAuTS_AWz1pR3o1IU1AAx0VA&s=dRF1ozBM8vw7I37K
>> i98duGs7d33ewviTTJaXYdkTNYc&e=
>>
>>
> --
> Hervé Pagès
>
> Program in Computational Biology
> Division of Public Health Sciences
> Fred Hutchinson Cancer Research Center
> 1100 Fairview Ave. N, M1-B514
> P.O. Box 19024
> Seattle, WA 98109-1024
>
> E-mail: hpages at fredhutch.org
> Phone: (206) 667-5791
> Fax: (206) 667-1319
>
[[alternative HTML version deleted]]
More information about the Bioc-devel
mailing list