How to get the best overlap
0
0
Entering edit mode
4.5 years ago
g744695539 • 0

Hi! I have many bed files like A.bed. And B.bed is converted from a gtf.

cat A.bed
chr7    158788004   158788417
chr7    158793650   158793726
chr7    158797942   158798076
chr7    158799050   158799072

bedtools intersect -a A.bed  -b B.bed -wa -wb
chr7    158788004   158788417   chr7    158788004   158788093   ENSG00000117868.15  exon    -
chr7    158788004   158788417   chr7    158788094   158788344   ENSG00000117868.15  intron  -
chr7    158788004   158788417   chr7    158788345   158788417   ENSG00000117868.15  exon    -
chr7    158793650   158793726   chr7    158793650   158793726   ENSG00000117868.15  exon    -
chr7    158793650   158793726   chr7    158793674   158793726   ENSG00000117868.15  exon    -
chr7    158797942   158798076   chr7    158797942   158798076   ENSG00000117868.15  exon    -
chr7    158799050   158799072   chr7    158799031   158799072   ENSG00000117868.15  exon    -

Now, I hope to get the result like this. For each feature in A.bed, only output the best overlap

chr7    158788004   158788417   chr7    158788004   158788093   ENSG00000117868.15  exon    -
chr7    158788004   158788417   chr7    158788094   158788344   ENSG00000117868.15  intron  -
chr7    158788004   158788417   chr7    158788345   158788417   ENSG00000117868.15  exon    -
chr7    158793650   158793726   chr7    158793650   158793726   ENSG00000117868.15  exon    -
chr7    158797942   158798076   chr7    158797942   158798076   ENSG00000117868.15  exon    -
chr7    158799050   158799072   chr7    158799031   158799072   ENSG00000117868.15  exon    -

Is there any good way? Thanks!

bedtools overlap • 905 views
ADD COMMENT
1
Entering edit mode

it would make it easier if you could write one more line explaining the expected outcome than me comparing 16 lines manually!

ADD REPLY
0
Entering edit mode

Yeah I'm not reading those tables. Maybe original poster could explain what a best overlap is? I've always been happy with bedtools overlap, maybe using some flags when I wanted certain behaviors, bedtools has a lot of options.

ADD REPLY

Login before adding your answer.

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