This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Bedtools intersect tab and bed files

How can you call Bedtools intersect on a tab and bed file? without getting the typical error shown below?

Differing number of BED fields encountered at line: #. Exiting...

My bed file has 15 columns and my tab file has 18

bedtools intersect tab bed

I don't think you can use bedtools intersect to intersect a BED file with a tab-delimited file that is not in BED format. Even though a BED file is essentially a tab-delimited file, it has a particular format. If you can convert your tab-file to BED format then maybe it will work.

1 answer

Expanding on komal.rathi's comment,

Create a BED file out of your tab file, follow the steps below:

  1. Add this line: #dummy header to a new empty file
  2. Use awk or cut to extract from your tab-delimited file the fields corresponding to the BED file you already have. Redirect and append (>>) the output of this command to the file created above.
  3. Use bedtools intersect on the BED files that you have now.

Log in to answer this question.