Bedtools intersect with index
1
0
Entering edit mode
5.9 years ago
landscape95 ▴ 190

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 • 1.3k views
ADD COMMENT
1
Entering edit mode
5.9 years ago

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 COMMENT

Login before adding your answer.

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