Bedtools merge messing chromosome start - end points
2
0
Entering edit mode
4.2 years ago
nitinra ▴ 50

Hello everyone,

I am trying to merge my bedtools genomecov output using the bedtools merge option. I am using this data :

Chromosome_1    0   54  0
Chromosome_1    54  204 3
Chromosome_1    204 410 0
Chromosome_1    410 476 2
Chromosome_1    476 502 4 ....

I used the following command to run:

' bedtools merge' -i input.sorted.bam -c 4 -o mean > output. coverage

Here is the output:

Chromosome_1 0 7841240 48.9278333
Chromosome_10 0 9941773 17.7389834

I am expecting to get:

Chromosome_1 0 7841240 48.9278333
Chromosome_2 7841240 x  23.9494951

Can anyone please suggest a way to do it?

TIA!

genome merge bedtools merge bedtools • 840 views
ADD COMMENT
0
Entering edit mode
4.2 years ago

Can anyone please suggest a way to do it?

use sort -t $'\t' -k1,1V -k2,2n or bedtools sort with option -g

ADD COMMENT
0
Entering edit mode
4.2 years ago

bedtools merge does not mess around with your chromosomes. In fact if you use it with bedfiles it expects them to be previously sorted with sort -k1,1 -k2,2n, therefore chromosomes end up being sorted as 1 10..19 2 20..22 MT X Y.

If you need some other sorting, just provide it yourself at the end of your command as Pierre suggested:

bedtools merge -i input.sorted.bam -c 4 -o mean | sort -k1,1V -k2,2n > output. coverage
ADD COMMENT

Login before adding your answer.

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