[BioC] Confusion over inconsistencies with showMethods('Rle') when loaded via GenomicRanges

Steve Lianoglou mailinglist.honeypot at gmail.com
Thu Jan 31 03:55:02 CET 2013


Hi Pete,

On Wed, Jan 30, 2013 at 7:17 PM,  <hickey at wehi.edu.au> wrote:
> Hi Steve,
>
> Thanks for your explanation. I'm just learning about the S4 class and
> methods so I suspected I'd missed something. I ran your example on my
> machine and it returned the same output.
>
> I've now found the real problem in my code but don't understand why is
> causing inheritance problems for Rle. Basically, there's a line in my class
> definitions to define a class union, namely: setClassUnion('vectorOrNULL',
> c("vector", "NULL"). Depending on whether that line is included before I try
> to construct the GRanges object determines whether the object is
> successfully created. Can anyone please explain this to me?
[snip]

> ## But this version does not work as intended
> ## Firstly, start a fresh R session
>> library(GenomicRanges)
[snip]

>> setClassUnion("vectorOrNULL", c("vector", "NULL")) ## This line is the
>> culprit
>> out <- list(chr = rep('chr21', 10), 1:10, start = 1:10, end = 2:11)
>> showMethods('Rle')
> Function: Rle (package IRanges)
> values="missing", lengths="missing"
> values="vectorORfactor", lengths="integer"
> values="vectorORfactor", lengths="missing"
> values="vectorORfactor", lengths="numeric"
>
>> gr <- GRanges(seqnames = out[['chr']], ranges = IRanges(start =
>> out[['start']], end = out[['end']]))
> Error in function (classes, fdef, mtable)  :
>   unable to find an inherited method for function ‘Rle’ for signature
> ‘"character", "missing"’
>> showMethods('Rle')
> Function: Rle (package IRanges)
> values="missing", lengths="missing"
> values="vectorORfactor", lengths="integer"
> values="vectorORfactor", lengths="missing"
> values="vectorORfactor", lengths="numeric"
>
> ## Inheritance problems for Rle

Interesting ... my guess is because with your new class union, both of
these are now TRUE:

R> is(c('a', 'b', 'c'), 'vectorORfactor')
[1] TRUE

R> is(c('a', 'b', 'c'), 'vectorOrNULL')
[1] TRUE

But it really feels like the class union shouldn't be getting in the
way -- I mean, if one then writes an Rle method for c("vectorOrNULL",
"missing"), I can imagine what the problem might be, but that's not
the case here.

Hmmm ... if I were a bit bolder, I'd hazard that this might even be a
bug somewhere in some S4 dispatching mojo, but I'm not
well-versed-enough in its voodoo to make that claim.

I suspect Martin will likely chime in to point out what is the what, here ;-)

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact



More information about the Bioconductor mailing list