[BioC] GRangesList filtering

Valerie Obenchain vobencha at fhcrc.org
Tue May 1 17:21:58 CEST 2012


ccing Halian

On 05/01/2012 08:20 AM, Valerie Obenchain wrote:
> Hi Halian,
>
>   gr1 <- GRanges(seqnames = "chr2", ranges = IRanges(3, 6))
>   gr2 <- GRanges(seqnames = c("chr1", "chr1"), ranges = 
> IRanges(c(7,13), width = 3))
>   gr3 <- GRanges(seqnames = c("chr1", "chr2"), ranges = IRanges(c(1, 
> 4), c(3, 9)))
>   grl <- GRangesList("gr1" = gr1, "gr2" = gr2, "gr3" = gr3)
>
>   grl[seqnames(grl) == "chr2"]
>
> Valerie
>
>
> On 05/01/2012 07:26 AM, Halian Vilela wrote:
>> Hey guys,
>>
>> I would like to know if there are any methods of efficiently subset a
>> GRangeList by it seqnames.
>>
>> I have something like this:
>>
>>
>> GRangesList of length 86046:
>> $1
>> GRanges with 27 ranges and 3 elementMetadata values:
>>         seqnames               ranges strand   |   exon_id   
>> exon_name exon_rank
>> <Rle> <IRanges> <Rle>    |<integer> <character> <integer>
>>     [1]     chr1 [66999065, 66999090]      +   |         
>> 1<NA>          1
>>     [2]     chr1 [66999928, 67000051]      +   |         
>> 2<NA>          2
>>     [3]     chr1 [67091529, 67091593]      +   |         
>> 3<NA>          3
>>     [4]     chr1 [67098752, 67098777]      +   |         
>> 4<NA>          4
>>     [5]     chr1 [67099762, 67099846]      +   |         
>> 5<NA>          5
>>     [6]     chr1 [67105459, 67105516]      +   |         
>> 6<NA>          6
>>     [7]     chr1 [67108492, 67108547]      +   |         
>> 7<NA>          7
>>     [8]     chr1 [67109226, 67109402]      +   |         
>> 8<NA>          8
>>     [9]     chr1 [67126195, 67126207]      +   |         
>> 9<NA>          9
>>     ...      ...                  ...    ... ...       ...         
>> ...       ...
>>
>>
>>
>> In which each element ($1,$2,$3,...) represents a transcript and it
>> set of exons...
>>
>> In the seqnames colum I have the chromosomes ranging from 1 to Y (all
>> 24 human cromosomes), what I would like to know is how to get just the
>> elements accounting for chromosome 14...
>>
>> I have made successfully by unlisting the structure into a huge normal
>> GRange and then subseting normally:
>>
>> ex<- unlist(ex_tx)
>> ex14<- ex[which(seqnames(ex) == "chr14")]
>>
>>
>> But obviously I lose the GRangesList structure. So are there any way
>> to subset this directly in the GRangesList without the need to unlist,
>> in a way that my result is also a GRangesList ?
>>
>> Thanks,
>> Halian
>>
>>     [[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
>



More information about the Bioconductor mailing list