[Bioc-devel] Subsetting an RleList object
Hervé Pagès
hpages at fhcrc.org
Tue Oct 29 00:01:58 CET 2013
On 10/28/2013 11:16 AM, Hervé Pagès wrote:
> Hi Thomas,
>
> Thanks for the report. I'm looking at this. Will let you know
> when the problem is fixed.
What has changed in BioC 2.13 is that, by default, the RleList()
constructor now returns a CompressedRleList object instead of a
SimpleRleList object:
return_rles <- RleList(Rle(values=TRUE,lengths=151),
Rle(values=TRUE,lengths=151),
Rle(values=TRUE,lengths=151))
Then:
> class(return_rles) # used to be SimpleRleList (in BioC < 2.13)
[1] "CompressedRleList"
attr(,"package")
[1] "IRanges"
and `[<-` doesn't work (and never has) on a CompressedRleList object
when the subscript is a list-like object:
> return_rles[ list(20:108, 41:131, 21:105) ] <- TRUE
Error in callNextMethod() :
in processing 'callNextMethod', found a '...' in the matched call,
but no corresponding '...' argument
So an immeadiate work-around for you is to call RleList() with
'compress=FALSE' to create a SimpleRleList object:
return_rles <- RleList(Rle(values=TRUE,lengths=151),
Rle(values=TRUE,lengths=151),
Rle(values=TRUE,lengths=151),
compress=FALSE)
Then:
> return_rles[ list(20:108, 41:131, 21:105) ] <- TRUE
This also works with an IRangesList subscript:
keep_ranges <- IRangesList(IRanges(start=20, end=108),
IRanges(start=41, end=131),
IRanges(start=21, end=105))
Then:
> return_rles[ keep_ranges ] <- TRUE
2 issues that need to be addressed:
(1) `[<-` should work on a CompressedRleList object when using a
list-like subscript.
(2) The RleList() constructor should warn that its behavior has
changed when called without specifying the 'compress' arg.
A fix is on its way.
H.
>
> H.
>
>
> On 10/25/2013 11:33 AM, Thomas Sandmann wrote:
>> Sorry, forgot that attachments don't make it through.
>> Here's how to generate the example objects and reproduce the error:
>>
>> library(IRanges)
>> keep_ranges <- IRangesList( IRanges( start=20, end=108), IRanges(
>> start=41,
>> end=131), IRanges( start=21, end=105))
>> return_rles <- RleList( Rle(values=TRUE,lengths=151),
>> Rle(values=TRUE,lengths=151), Rle(values=TRUE,lengths=151))
>> return_rles[ keep_ranges ] <- TRUE
>>
>> return_rles[ keep_ranges ] ## subsetting works
>> return_rles[ keep_ranges ] <- TRUE ## assignment doesn't work
>> Error in callNextMethod() :
>> in processing 'callNextMethod', found a '...' in the matched call,
>> but no
>> corresponding '...' argument
>>
>>
>>
>> On Fri, Oct 25, 2013 at 11:23 AM, Thomas Sandmann <sandmat1 at gene.com>
>> wrote:
>>
>>> Dear BioC developers,
>>>
>>> I am trying to subset an RleList with an IRangesList (see attached rdata
>>> object). Unfortunately, the following line fails with IRanges 1.20.0:
>>>
>>> return_rles[keep_ranges] <- TRUE
>>> Error in subsetListByList_replace(x, i, value) :
>>> cannot subscript an unnamed list-like object by a named list-like
>>> object
>>>
>>> Unnaming the IRangesList doesn't help, either:
>>>
>>> return_rles[unname(keep_ranges)] <- TRUE
>>> Error in callNextMethod() :
>>> in processing 'callNextMethod', found a '...' in the matched call,
>>> but
>>> no corresponding '...' argument
>>>
>>> The same operation worked with IRanges 1.18.2 using the (now deprecated)
>>> seqselect method:
>>>
>>> seqselect( return_rles, keep_ranges ) <- TRUE
>>>
>>> Any hints ?
>>>
>>> Thanks,
>>> Thomas
>>>
>>> SessionInfo()
>>> R version 3.0.2 (2013-09-25)
>>> Platform: x86_64-apple-darwin10.8.0 (64-bit)
>>>
>>> locale:
>>> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>>>
>>> attached base packages:
>>> [1] parallel stats graphics grDevices utils datasets methods
>>> base
>>>
>>> other attached packages:
>>> [1] BiocInstaller_1.12.0 IRanges_1.20.0 BiocGenerics_0.8.0
>>> devtools_1.3
>>>
>>> loaded via a namespace (and not attached):
>>> [1] digest_0.6.3 evaluate_0.5.1 httr_0.2 memoise_0.1
>>> RCurl_1.95-4.1 stats4_3.0.2 stringr_0.6.2
>>> [8] tools_3.0.2 whisker_0.3-2
>>>
>>
>>
>>
>
--
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