GRanges get hits from (only) antisense strand with findOverlaps().
1
0
Entering edit mode
svenbioinf • 0
@svenbioinf-11239
Last seen 2.6 years ago
Münster

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!

GRanges findoverlaps antisense • 1.5k views
ADD COMMENT
2
Entering edit mode
li lilingdu ▴ 450
@li-lilingdu-1884
Last seen 6.5 years ago
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"))) 

hitsI=findOverlaps(gr1,drop.self=T,ignore.strand=T)

 

##just filter

hitsI[strand(gr1[from(hitsI)])!=strand(gr1[to(hitsI)]),]

 

 

 

 

 

 

ADD COMMENT
0
Entering edit mode

This is so good! Nice and simple. Thanks a lot, Li Lilingdu!

ADD REPLY

Login before adding your answer.

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