Merge overlapping intervals in a bed file containing different chromosomes
1
1
Entering edit mode
5.1 years ago
dzisis1986 ▴ 70

Hello I have a file test.bed like this :

    chr2    3300000 3499999 0   0.013255902570394
    chr3    300000  499999  0   0.015744466292456
    chr4    9400000 9599999 0   0.045555030342908
    chr5    1700000 1899999 0   0.013255902570394
    chr5    23900000    24099999    0   0.037583056937021
    chr5    3000000 3199999 0   2.62328977303342E-06
    chr5    3100000 3299999 0   1.61951552785474E-08
    chr5    3200000 3399999 0   0.001461420574531
    chr5    3700000 3899999 0   0.013255902570394
    chr5    3800000 3999999 0   0.013255902570394

I would like to merge intervals that are overlapping and create a new merged.bed file like this :

chr2    3300000 3499999
chr3    300000  499999
chr4    9400000 9599999
chr5    1700000 1899999
chr5    3000000  3399999
chr5    3700000  3999999
chr5    23900000    24099999
merge bed script • 1.4k views
ADD COMMENT
0
Entering edit mode
5.1 years ago

sort and use bedtools merge

ADD COMMENT
0
Entering edit mode

I already did this but something is wrong with sort , maybe the fact that there are different chr and when i use bedtools merge i have an error like :

Error: Sorted input specified, but the file sorted.bed has the following out of order record
chr5    3700000 3899999 0   0.013255902570394
ADD REPLY
0
Entering edit mode

I already did this

you should have told us

maybe the fact that there are different chr an

how did you sort the file. what was the command line ?

ADD REPLY
0
Entering edit mode

i used different sort command like sortBed -i and also sort -n -k1.11 -nk2,2 . but still the same problem !

ADD REPLY
1
Entering edit mode
sort -t $'\t' -k1,1 -k2,2n in.bed | bedtools merge > out.bed
ADD REPLY

Login before adding your answer.

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