I have 2 GRanges objects (gr1,gr2). I want to find partial overlaps between them, that is I want to find which ranges in gr2 overlap the i th range in gr1 but are not entirely contained in it (its fine if gr1[i] is entirely contained in some of those gr2 ranges).
I thought I can use findOverlaps once with type='any' and once with type='within',
something along these lines:
overlapsAny<-as.data.frame(findOverlaps(query=gr2,subject=gr1,type='any'))
overlapsFull<-as.data.frame(findOverlaps(query=gr2,subject=gr1,type='within'))
overlapsAny$Combination<-apply(overlapsAny,1,function(row) paste(row$queryHits,row$subjectHits,sep='.'))
overlapsFull$combination<-apply(overlapsFull,1,function(row) paste(row$queryHits,row$subjectHits,sep='.'))
partial<-!(which(overlapsAny$Combination%in%overlapsFull$combination)
Is there a less convoluted way to do this (such as directly intersecting hits objects somehow)?
Thanks in adavnce
Dolev Rahat