narrow function for GRangesList objects?
1
0
Entering edit mode
Janet Young ▴ 740
@janet-young-2360
Last seen 4.4 years ago
Fred Hutchinson Cancer Research Center,…

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
genomicranges • 1.4k views
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode
Janet Young ▴ 740
@janet-young-2360
Last seen 4.4 years ago
Fred Hutchinson Cancer Research Center,…

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

ADD COMMENT
0
Entering edit mode

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

Valerie

ADD REPLY

Login before adding your answer.

Traffic: 690 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6