Question: How to get the best overlap
0
gravatar for g744695539
4 months ago by
g7446955390
g7446955390 wrote:

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!

overlap bedtools • 143 views
ADD COMMENTlink modified 4 months ago • written 4 months ago by g7446955390
1

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

ADD REPLYlink written 4 months ago by husensofteng270

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 REPLYlink written 4 months ago by karl.stamm3.8k
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: 1008 users visited in the last hour