bedtools 2.0 merge - "unable to open file or unable to determine types"
3
2
Entering edit mode
10.2 years ago

I have a sorted bedfile comprised of three columns: seqid, start, and end.

sort -k1,1 -k2,2n tmp2.bed > tmp3.bed
1    6589256    6589207
1    11627195    12127194
1    12616616    12116617
1    18283067    18273068
1    21826932    21926931
1    28787213    28788212
1    31195434    31195483
1    39374350    39364351
1    42307024    42357023
1    47379997    47374998
~/tools/bedtools2/bin/bedtools merge -i tmp3.bed
Error: unable to open file or unable to determine types for file tmp3.bed

Probably something silly, but I'm not seeing it.

EDIT:

The second column - start must be before the end coordinates. It would be nice if bedtools threw an informative error as the user sucks.

bedtools • 13k views
ADD COMMENT
1
Entering edit mode

bedtools do throw such error messages:

Error: malformed BED entry at line 1. Start was greater than end. Exiting.

I got this message using your example (bedtools v2.19.1).

ADD REPLY
0
Entering edit mode

That is weird because my version is above your version number and I didn't get that error.

bedtools v2.21.0-2-g6a92b11

ADD REPLY
0
Entering edit mode

What version of bedtools? Are you sure it is tab-delimited (check with cat -t)?

ADD REPLY
4
Entering edit mode
9.4 years ago
trutane ▴ 40

Another thing that will cause bedtools merge to produce this error is if the bed file contains an uncommented column header line such as:

chrom   start   end
1       243651534       243651752
1       243663020       243668636
1       243663020       243663088
1       243663038       243663088

Commenting the header with a leading # will make bedtools happy again:

#chrom   start   end
1       243651534       243651752
1       243663020       243668636
1       243663020       243663088
1       243663038       243663088

The bed file spec doesn't explicitly state anything about the legality of header lines or their expected format (e.g. should be preceded with '#'). Since the columns are proscribed for bed format, a header is not really necessary but can be convenient. Glad that bedtools supports it -- just don't forget to comment it!

bedtools version: 2.22.1

ADD COMMENT
1
Entering edit mode
9.8 years ago
mgadrianam ▴ 30

I get the same error messages:

How did you solved. Could you please help me. I appreciated your help

Sincerely,
Adriana

ADD COMMENT
2
Entering edit mode
awk '{if ($2 > $3) print $1"\t"$3"\t"$2; else print $1"\t"$2"\t"$3}' old.bed > new.bed
ADD REPLY
0
Entering edit mode

Thanks a lot

ADD REPLY
0
Entering edit mode
10.2 years ago

Solved: Some of the ends are before the starts. Stupid mistake.

ADD COMMENT

Login before adding your answer.

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