Entering edit mode
Hello guys,
Given a GRanges object with 3 ranges on the "+" strand and 2 on the "-" strand:
gr1 <- GRanges(c(1,1,1,1,1),strand=Rle(c("+","+","+","-","-"),c(1,1,1,1,1)), IRanges(c(1,2,10,1,1), c(8,7,15,5,5)),mcols=data.frame(id=c("T1","T3","T5","T6","T7"))) > gr1 GRanges object with 5 ranges and 1 metadata column: seqnames ranges strand | mcols.id <Rle> <IRanges> <Rle> | <factor> [1] 1 [ 1, 8] + | T1 [2] 1 [ 2, 7] + | T3 [3] 1 [10, 15] + | T5 [4] 1 [ 1, 5] - | T6 [5] 1 [ 1, 5] - | T7
I would like to get all hits on the antisense strand for each range. That means for all ranges on the "+" strand hits from the "-" and for all ranges on "-" the "+" hits.
NO hits on the same strand! FindOverlaps() (like below) gives me all hits from everywhere. How can I change this?
> hitsI=findOverlaps(gr1,drop.self=T,ignore.strand=T) #ignore.strand=T > hitsI > hitsI=findOverlaps(gr1,drop.self=T,ignore.strand=T) #ignore.strand=T > hitsI SelfHits object with 12 hits and 0 metadata columns: queryHits subjectHits <integer> <integer> [1] 1 4 [2] 1 5 [3] 1 2 [4] 2 1 [5] 2 4 ... ... ... [8] 4 5 [9] 4 2 [10] 5 1 [11] 5 4 [12] 5 2
What i would like to have:
queryHits subjectHits <integer> <integer> [1] 1 4 [2] 1 5 [5] 2 4 ... ... ... [9] 4 2 [10] 5 1 [12] 5 2
Any help would be greatly appreciated!
This is so good! Nice and simple. Thanks a lot, Li Lilingdu!