Skip to content
Prev 4855 / 21312 Next

[Bioc-devel] Subsetting an RleList object

On 10/30/2013 10:07 AM, Michael Lawrence wrote:
The consensus amongst who? AFAICT this behavior was not documented
and no unit test broke when I modified List-wise extraction to match
the names, so it looked more like a grey area to me than a conscious
decision.

Also none of the 100 or so software packages that depend directly or
indirectly on IRanges seemed to be affected by this change. The reason
for this is that the most common use case for List-wise extraction is
something like this:

   > cvg <- RleList(chr1=Rle(c(0, 1, 0), c(10, 5, 8)),
                    chr2=Rle(c(1, 0), c(6, 14)))

   > cvg[cvg >= 1]
   RleList of length 2
   $chr1
   numeric-Rle of length 5 with 1 run
     Lengths: 5
     Values : 1

   $chr2
   numeric-Rle of length 6 with 1 run
     Lengths: 6
     Values : 1

And this use case is not affected by List-wise extraction matching or
not the names. Thomas's use case is very unusual: the subscript looks
like the result of a split() and, most of the times, I would expect this
subscript to be used to subset an object that is also the result of a
split() (by a split factor with the same levels). So the object to
subset and the subscript would normally both end up with the same
names. But in his case, the object to subset has no names, I don't know
why. If List-wise extraction matches the names, subsetting still does
the right thing even if the split factors have levels not in the same
order (or if some levels in the factor used to split the subscript
are missing). If it doesn't match the names, the subsetting will make
no sense and the user won't even know it. No surprise but wrong result.

H.