Skip to content
Prev 4846 / 21312 Next

[Bioc-devel] Subsetting an RleList object

Hi Thomas,

For the same reasons that you cannot subset by names a Vector object
with no names:

   > IRanges(1:4, width=10)[letters[1:4]]
   Error in normalizeSingleBracketSubscript(i, x) :
     cannot subset by character when names are NULL

you cannot subset an unnamed List object using a named list-like
subscript. So in your case, just remove the names on 'keep_ranges'
(which are probably not desired anyway) before using it as a
subscript:


   > keep_ranges
   CompressedIRangesList of length 18
   $`1`
   IRanges of length 1
       start end width
   [1]    20 108    89

   $`2`
   IRanges of length 1
       start end width
   [1]    43 131    89

   $`3`
   IRanges of length 1
       start end width
   [1]    21 105    85

   ...
   <15 more elements>

   > return_rles[ unname(keep_ranges) ]
   RleList of length 18
   [[1]]
   logical-Rle of length 89 with 1 run
     Lengths:   89
     Values : TRUE

   [[2]]
   logical-Rle of length 89 with 1 run
     Lengths:   89
     Values : TRUE

   [[3]]
   logical-Rle of length 85 with 1 run
     Lengths:   85
     Values : TRUE

   [[4]]
   logical-Rle of length 85 with 1 run
     Lengths:   85
     Values : TRUE

   [[5]]
   logical-Rle of length 102 with 1 run
     Lengths:  102
     Values : TRUE

   ...
   <13 more elements>

Prior to BioC 2.13, it was possible to subset an unnamed List object by
a named list-like subscript, and in that case, the names on the
subscript were ignored and the subscript was treated as parallel to the
object to subset. However this behavior was somehow dangerous (could
lead to subtle issues) and didn't follow the spirit of what subsetting
an unnamed Vector by name does. So it's not supported anymore.

Sorry for the inconvenience,
H.
On 10/29/2013 03:05 PM, Thomas Sandmann wrote: