Question: Bedtools intersect with index
0
gravatar for landscape95
15 months ago by
landscape95160
landscape95160 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 • 436 views
ADD COMMENTlink modified 15 months ago by Alex Reynolds28k • written 15 months ago by landscape95160
1
gravatar for Alex Reynolds
15 months ago by
Alex Reynolds28k
Seattle, WA USA
Alex Reynolds28k 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 15 months ago • written 15 months ago by Alex Reynolds28k
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: 2234 users visited in the last hour