Search
Question: narrow function for GRangesList objects?
0
gravatar for Janet Young
3.3 years ago by
Janet Young730
Fred Hutchinson Cancer Research Center, Seattle, WA, USA
Janet Young730 wrote:

Hi there,

I'm playing with a GRangesList object, and I noticed that the narrow function is not implemented for that class (but it is for IRangesList objects). (see code below). I tried the devel versions too.

Would that be easy for you to add?  It'd be useful if GRangesList objects could access a similar set of functions  as IRangesList objects.

thanks!

Janet

library(GenomicRanges)

## make example IRangesList object (copied from ?narrow)
range1 <- IRanges(start=c(1, 2, 3), end=c(5, 2, 8))
range2 <- IRanges(start=c(15, 45, 20, 1), end=c(15, 100, 80, 5))
range3 <- IRanges(start=c(-2, 6, 7), width=c(8, 0, 0))  # with empty ranges
collection <- IRangesList(one=range1, range2, range3)

## make a GRangesList object
GR1 <- GRanges("chr1",range1)
GR2 <- GRanges("chr2",range2)
GR3 <- GRanges("chr3",range3)
collection_GR <- GRangesList(one=GR1, GR2, GR3)

## narrow an IRangesList object (copied from ?narrow - this works)
narrow(collection[-3], start=2)

## narrow a GRangesList object - this does not work
narrow(collection_GR[-3], end=-2)
# Error in (function (classes, fdef, mtable)  : 
#   unable to find an inherited method for function ‘narrow’ for signature ‘"GRangesList"’

sessionInfo()

R version 3.2.1 (2015-06-18)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.5 (Yosemite)

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] stats4    parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] GenomicRanges_1.20.5 GenomeInfoDb_1.4.1   IRanges_2.2.7        S4Vectors_0.6.3      BiocGenerics_0.14.0 

loaded via a namespace (and not attached):
[1] XVector_0.8.0
ADD COMMENTlink modified 3.3 years ago • written 3.3 years ago by Janet Young730

A (more or less efficient) workaround is the unlist / relist trick relist(narrow(unlist(collection_GR), end=-2), collection_GR).

ADD REPLYlink modified 3.3 years ago • written 3.3 years ago by Martin Morgan ♦♦ 22k
0
gravatar for Janet Young
3.3 years ago by
Janet Young730
Fred Hutchinson Cancer Research Center, Seattle, WA, USA
Janet Young730 wrote:

Thanks, Martin: that works well.  That could be a useful tip for me for other GenomicRangesList operations, too.

ADD COMMENTlink written 3.3 years ago by Janet Young730

I've added narrow,GRangesList-method to GenomicRanges 1.21.19.

Valerie

ADD REPLYlink written 3.3 years ago by Valerie Obenchain ♦♦ 6.7k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 163 users visited in the last hour