Question: Bedtools merge messing chromosome start - end points
0
gravatar for nitinra
5 weeks ago by
nitinra0
nitinra0 wrote:

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!

ADD COMMENTlink modified 5 weeks ago by Jorge Amigo12k • written 5 weeks ago by nitinra0
0
gravatar for Pierre Lindenbaum
5 weeks ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum131k wrote:

Can anyone please suggest a way to do it?

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

ADD COMMENTlink written 5 weeks ago by Pierre Lindenbaum131k
0
gravatar for Jorge Amigo
5 weeks ago by
Jorge Amigo12k
Santiago de Compostela, Spain
Jorge Amigo12k wrote:

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 COMMENTlink written 5 weeks ago by Jorge Amigo12k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1868 users visited in the last hour