[Bioc-devel] Subsetting an RleList object

Hervé Pagès hpages at fhcrc.org
Tue Oct 29 23:40:34 CET 2013


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:
> Hi Herve,
>
> I have updated to IRanges 1.20.4 now, but unfortunately, I still
> encounter an error when I try to subset a CompressedRleList or
> SimpleRleList with a CompressedIRangesList or SimpleIRangesList.
>
> Would you mind having a look at where I am going wrong ? (My two example
> objects are available in the rdata object at the url shown below).
>
> con=url("http://dl.dropboxusercontent.com/u/126180/example.rdata")
> load( con )
> return_rles[ keep_ranges ]
>
> Error in subsetListByList(x, i) (from List-class.R#205) :
>    cannot subscript an unnamed list-like object by a named list-like object
>
> R version 3.0.2 (2013-09-25)
> Platform: x86_64-unknown-linux-gnu (64-bit)
>
> 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  stats     graphics  grDevices utils     datasets  methods
> [8] base
>
> other attached packages:
>   [1] trimPrimers_1.3.0    Rsamtools_1.14.1     Biostrings_2.30.0
>   [4] GenomicRanges_1.14.2 XVector_0.2.0        IRanges_1.20.4
>   [7] BiocGenerics_0.8.0   Defaults_1.1-1       BiocInstaller_1.12.0
> [10] roxygen2_2.2.2       digest_0.6.3         devtools_1.3
>
> loaded via a namespace (and not attached):
>   [1] bitops_1.0-6   brew_1.0-6     compiler_3.0.2 evaluate_0.5.1 httr_0.2
>   [6] memoise_0.1    RCurl_1.95-4.1 stats4_3.0.2   stringr_0.6.2
>   tools_3.0.2
> [11] whisker_0.3-2  zlibbioc_1.8.0

-- 
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 fhcrc.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



More information about the Bioc-devel mailing list