Bedtools fisher error
0
0
Entering edit mode
3.7 years ago
hemr3 ▴ 10

I've been having an issue with the bedtools fisher command. I want to compare a.bed and b.bed, but I consistently get two errors coming up. It's my intent to eventually compare multiple a.beds and b.beds to get a comparison graph.

This is the head of my a.bed (b.bed has the same structure), and I've tried both with and without the chr[..]. The chromInfo.txt file was downloaded directly from UCSC hg19.

head a.bed 
chr1    10525   10526   0.110923
chr1    10525   10526   0.121582
chr1    17841   17846   0.11867
chr1    18495   18496   0.015091
chr1    18495   18496   0.042807
chr1    19234   19235   0.088472
chr1    19234   19235   0.116273
chr1    20824   20825   0.082503
chr1    20824   20825   0.117711
chr1    21681   21682   0.091218

This is the bedtools command I used:

bedtools fisher -a a.bed -b b.bed -g chromInfo.txt

This gets the error:

Error: requested chromosome 1 does not exist in the genome file chromInfo.txt. Exiting.

At first I thought it was something to do with the fact that the files might not have been sorted in the same way, which has been addressed in other questions here, so I did this for a.bed, b.bed and chromInfo:

sort -k1,1 chromInfo.txt > chromInfo_sorted.txt
sort -k1,1 a.bed > sorted_a.bed
sort -k1,1 b.bed > sorted_b.bed

The new bedtools fisher command was:

bedtools fisher -a sorted_a.bed -b sorted_b.bed -g chromInfo_sorted.txt

But this just got the error:

Error: Sorted input specified, but the file a.bed has the following out of order record
chr1    2365    2367    0.148297

I assume if the command got to b.bed, it would produce the same error. I'd be very thankful for any advice!

(It may be worth noting that a.bed and b.bed were made from aDNA Neanderthal and Denisovan reads)

BEDtools bedtools Fisher's exact test error • 1.2k views
ADD COMMENT
1
Entering edit mode

right way to sort a bed file is :

sort -T . -t $'\t' -k1,1 -k2,2n a.bed
ADD REPLY
0
Entering edit mode

Thank you, this sorted it!

ADD REPLY
0
Entering edit mode

Try bedtools sortBed or sort instead of the Unix sort command. The difference between the two has been discussed in the following thread.

Difference between sortBed in bedtools and sort in unix

ADD REPLY
0
Entering edit mode

Thank you, that's good information to have!

ADD REPLY

Login before adding your answer.

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