This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Error when using Bedtools fisher on sorted bed files

Hi Everyone,

I am doing a ChIP-Seq analysis on a small dataset of 6 samples (Wild-type and knockout having 3 replicates each). I wanted to run a Fisher exact test using bedtools. My bed files are all sorted. But I am getting this error.

Error: Sorted input specified, but the file /Users/xxx/narrowPeak/531-sorted.bed has the following record with a different sort order than the genomeFile /Applications/bedtools2/genomes/mouse.mm9.genome

What does this mean and how do I fix this ?

Thank you

chip-seq bedtools fisher test

check that the order of the chromosome names and the order of your sort is the same as in the genome.

1 answer

I too have had this problem- but what has helped me is to sort the mm9.genome file with the same code as in the case of the actual bed files:

sort -k1,1 mouse.mm9.genome > sorted_mouse.mm9.genome
sort -k1,1 -k2,2n a.bed > a_sorted.bed
sort -k1,1 -k2,2n b.bed > b_sorted.bed
bedtools fisher -a a_sorted.bed -b b_sorted.bed -g sorted_mouse.mm9.genome

Log in to answer this question.