[Bioc-devel] conflict rowRanges SummarizedExperiment/matrixStats

Maarten van Iterson mviterson at gmail.com
Thu Apr 6 11:42:50 CEST 2017


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
           <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
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"’
>
> 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]]



More information about the Bioc-devel mailing list