[BioC] subset a RleList using GRanges object?
Janet Young
jayoung at fhcrc.org
Wed Dec 4 19:58:32 CET 2013
Thanks, all. Yes, that coercion will do it for me: z[as(myRange, "RangesList")]. It's always nice for the end user when you take care of those kinds of things behind the scenes for us - sounds like what you're considering implementing might take care of it.
Robert: thanks for the ideas! But my needs are a little different, though - I'm keeping the individual values in the region I'm interested in (I'm plotting RNA-seq coverage on just a single gene, but my coverage object is for the whole genome).
Janet
On Dec 4, 2013, at 10:09 AM, Hervé Pagès wrote:
> Hi Michael,
>
> On 12/03/2013 07:13 PM, Michael Lawrence wrote:
>> For now, just coerce to a RangesList.
>>
>> z [ as(myRange, "RangesList") ]
>>
>> Herve might consider adding a [,List,GenomicRanges method... kind of a
>> logical leap though from seqnames to list element names.
>
> This is something I've been considering for a while. I think we should
> do it. The mapping between the seqnames of a GRanges and the names of a
> RangesList is well established at this point e.g. the coercion (back and
> forth) between the two already does that.
>
> Cheers,
> H.
>
>>
>> extractCoverageForPositions is different; it extracts an integer vector
>> given a vector of width-one positions.
>>
>>
>>
>>
>>
>>
>> On Tue, Dec 3, 2013 at 4:53 PM, Janet Young <jayoung at fhcrc.org> wrote:
>>
>>> Hi there,
>>>
>>> I'm playing around with coverage data generated outside of R, planning to
>>> plot RNA-seq coverage for some genes we're interested in.
>>>
>>> I have a request - it'd be nice from my point of view if it were possible
>>> to look at a small region an RleList (or CompressedRleList) using a GRanges
>>> object to focus on that smaller region. Looks like I can subset a single
>>> Rle object with an IRanges object, but I wonder if this nice feature could
>>> be extended to GRanges objects?
>>>
>>> Some code is below to show what I'm trying to do.
>>>
>>> thanks veruy much,
>>>
>>> Janet
>>>
>>>
>>>
>>> library(GenomicRanges)
>>>
>>> ## an example RleList
>>> x <- Rle(10:1, 1:10)
>>> y <- Rle(10:1, 1:10)
>>> z <- RleList( chr1=x, chr2=y)
>>>
>>> ## an example GRanges object
>>> myRange <- GRanges( seqnames="chr1", ranges=IRanges(start=10,end=15) )
>>>
>>> ## subsetting an Rle using an IRanges object works, as expected:
>>> z[["chr1"]] [ ranges(myRange) ]
>>>
>>> ## but subsetting an RleList by GRanges object doesn't work
>>> z [ myRange ]
>>> # Error in normalizeSingleBracketSubscript(i, x) : invalid subscript type
>>>
>>> sessionInfo()
>>>
>>> R Under development (unstable) (2013-11-06 r64163)
>>> 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] GenomicRanges_1.15.10 XVector_0.3.2 IRanges_1.21.13
>>> [4] BiocGenerics_0.9.1
>>>
>>> loaded via a namespace (and not attached):
>>> [1] stats4_3.1.0
>>>
>>>
>>>
>>>
>>> -------------------------------------------------------------------
>>>
>>> Dr. Janet Young
>>>
>>> Malik lab
>>> http://research.fhcrc.org/malik/en.html
>>>
>>> Fred Hutchinson Cancer Research Center
>>> 1100 Fairview Avenue N., A2-025,
>>> P.O. Box 19024, Seattle, WA 98109-1024, USA.
>>>
>>> tel: (206) 667 4512
>>> email: jayoung ...at... fhcrc.org
>>>
>>> -------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Bioconductor mailing list
>>> Bioconductor at r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/bioconductor
>>> Search the archives:
>>> http://news.gmane.org/gmane.science.biology.informatics.conductor
>>>
>>
>> [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> Bioconductor mailing list
>> Bioconductor at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/bioconductor
>> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
>>
>
> --
> 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 Bioconductor
mailing list