#### The support.bioconductor.org editor has been updated to markdown! Please see more info at: Tutorial: Updated Support Site Editor

Question: How to avoid repeated overlap pair for GRanges object in grid?
0
2.6 years ago by
Italy
Jurat Shahidin60 wrote:

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

genomicranges R • 465 views
modified 2.3 years ago • written 2.6 years ago by Jurat Shahidin60
Answer: How to avoid repeated overlap pair for GRanges object in grid?
2
2.6 years ago by
Hervé Pagès ♦♦ 13k
United States
Hervé Pagès ♦♦ 13k wrote:

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)) {
...
}
}

# 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.

1

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

Answer: How to avoid repeated overlap pair for GRanges object in grid?
2
2.5 years ago by
Italy
Jurat Shahidin60 wrote:

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] )