I have a Granges object (gr) and a GRangesList (grlist) of the same length. I want to intersect them element-wise, that is, I want to know if any element in grlist[[i]] is (fully) contained in gr[i].
I can of course do something of the loop variant:
intersect<-lapply(seq(length(gr)), function(i) overlapsAny(gr[i],grlist[[i]]).
Is there a better way to do this that I'm missing? mapply would have been useful
here but as far as I know it doesn't accept GRanges.
If it's of any relevance, the members of grlist are exons of genes. I know (from a previous step in my pipeline) that gr[i] partially overlaps the gene whose exons are represented by grlist[[i]], and I ant to know if there is at least one exon contained in it.
Now, gr1 is within gr, hence there is a range in grlist[] that is within gr so I want the function to return TRUE for gr.
However, none of the ranges in gr2 (and hence grlist[]) are within gr, thus I want the function to return FALSE for gr.
Thanks in advacne