How to avoid repeated overlap pair for GRanges object in grid?
2
0
Entering edit mode
@jurat-shahidin-9488
Last seen 4.7 years ago
Chicago, IL, USA

Hi everyone:

I have peak files in GRanges object which needed to observe overlapping one another, I proceed all possible overlap pairs for given GRanges object, but certainly there is repeated overlap happens. How can I avoid of this sort of repeating that keep overlapping process more neat? Thanks

my objective is once I got paired overlap, do not let repeated overlap happen again. How can I get rid of this repeated overlap for genomic regions in parallel processing? Can anyone propose possible idea to solve this? Thanks

Best regards:

Jurat

r genomicranges • 1.4k views
ADD COMMENT
2
Entering edit mode
@herve-pages-1542
Last seen 14 hours ago
Seattle, WA, United States

This seems like a follow up to my suggestion to walk only the 1 <= i < j <= N space instead of 1 <= i , j <= N:

A: Iterate through set of GRanges in the list - advise is needed

Translated into code it's just a matter of doing something like

# N(N-1)/2 iterations
for (i in seq_len(N)) {
    for (j in seq_len(i-1)) {
        ...
    }
}

instead of

# N^2 iterations
for (i in seq_len(N)) {
    for (j in seq_len(N)) {
        ...
    }
}

This is a very general pattern in programming. No rocket science. Has nothing to do with GRanges objects.

H.

ADD COMMENT
1
Entering edit mode

And  combn(N, 2) is handy in such cases.

ADD REPLY
2
Entering edit mode
@jurat-shahidin-9488
Last seen 4.7 years ago
Chicago, IL, USA

efficiently walk on the upper/below triangle (including diagonal) for all possible paired overlap in square grid :

grs.li <- GRangesList(gr1=GRanges(), gr2=GRanges(), gr3=GRanges(), ...)

nlen <- length(grs)
idx <- expand.grid("query"=1:nlen, "subject"=1:nlen)
idx <- idx[index[,1] <= idx[,2],]

ov.hit <- Map(function(i, j)  findOverlaps(grs[[i]], grs[[j]]), idx[,1], idx[,2] )

 

ADD COMMENT

Login before adding your answer.

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