bedtool sort not working properly?

1,904 views
Skip to first unread message

robi...@gmail.com

unread,
May 21, 2015, 4:34:51 PM5/21/15
to bedtools...@googlegroups.com
Hi,

I'm trying to sort and then merge a bed file. But the sortBed didn't working as expected, see below:

cat test.bed:

chr2 180036938 180037000

chr2 180037383 180037502

chr2 180037384 180037384

chr2 180037383 180037488

chr2 180037383 180037502

chr2 180037634 180038187

chr2 180038065 180038187

sortBed -i test.bed > test.sorted.bed

cat test.sorted.bed:

chr2 180036938 180037000

chr2 180037383 180037502

chr2 180037384 180037384

chr2 180037383 180037488

chr2 180037383 180037502

chr2 180037634 180038187

chr2 180038065 180038187

mergeBed -i test.sorted.bed

Error: Sorted input specified, but the file test.sorted.bed has the following out of order record

chr2 180037383 180037488

Could you please help me solve this? 

Thank you!

Robin

Aaron Quinlan

unread,
May 25, 2015, 1:51:46 PM5/25/15
to bedtools...@googlegroups.com
Sorry for this, It looks like the sort tool does not handle zero-length BED records correctly.
I would recommend sorting with the following until we can drop in a fix. Moreover, it is probably better to just use UNIX sort anyway given that it will scale much more favorably than bedtools sort.

sort -k1,1 -k2,2n test.bed > test.sorted.bed

Best,
Aaron 

--
You received this message because you are subscribed to the Google Groups "bedtools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bedtools-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages