How to retrieve ranges within 1000bp of each range in an IRanges object?
1
0
Entering edit mode
s1437643 ▴ 20
@s1437643-9524
Last seen 4.6 years ago

I have an IRanges object which contains regions of interest and read counts for a given sample in the metadata column. I would like to iterate through each of the regions and get the counts for regions which are within 1,000 bp of the current region. I have tried the following but It is too slow and I wondered if there were any faster alternatives?

for (i in 1:length(regions)) {
    iranges <- ranges(regions)
    range <- iranges[i]
    start <- start(range) - 1000
    end <- end(range) + 1000
    hits <- findOverlaps(IRanges(start=start, end=end), regions)
}

IRanges • 743 views
ADD COMMENT
0
Entering edit mode

You can try to have a look at

findOverlaps(regions + 1000, regions)

or

findOverlaps(regions, regions, maxgap = 1000)
ADD REPLY
0
Entering edit mode
@michael-lawrence-3846
Last seen 2.4 years ago
United States

For counting the overlaps, use countOverlaps():

countOverlaps(regions, maxgap = 1000)
ADD COMMENT

Login before adding your answer.

Traffic: 734 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