Question: Bedtools intersect with index
0
gravatar for landscape95
2.3 years ago by
landscape95170
landscape95170 wrote:

Hello everyone, I wonder are there any ways that bedtools intersect can display index of the matched pairs. For example: a.bed

chr1 10 20

chr1 30 40

chr1 50 80

b.bed

chr1 12 15

chr1 16 19

chr1 22 27

chr1 31 37

The results:

chr1 10 20 chr1 12 15 1 <- here is the index of the corresponding line index in b.bed file

chr1 10 20 chr1 16 19 2

chr1 30 40 chr1 31 37 4

Your help is really appreciated!

bedtools • 659 views
ADD COMMENTlink modified 2.3 years ago by Alex Reynolds30k • written 2.3 years ago by landscape95170
1
gravatar for Alex Reynolds
2.3 years ago by
Alex Reynolds30k
Seattle, WA USA
Alex Reynolds30k wrote:

Via BEDOPS bedmap:

$ bedmap --echo --echo-map --delim '\t' a.bed <(awk '{ print $0"\t"NR }' b.bed) > answer.bed

Just make sure your BED files are sorted per BEDOPS sort-bed. Hope this helps!

ADD COMMENTlink modified 2.3 years ago • written 2.3 years ago by Alex Reynolds30k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1659 users visited in the last hour