Question: Merge overlapping intervals in a bed file containing different chromosomes
0
gravatar for dzisis1986
7 months ago by
dzisis198620
dzisis198620 wrote:

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
script merge bed • 192 views
ADD COMMENTlink modified 7 months ago by Pierre Lindenbaum128k • written 7 months ago by dzisis198620
0
gravatar for Pierre Lindenbaum
7 months ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum128k wrote:

sort and use bedtools merge

ADD COMMENTlink written 7 months ago by Pierre Lindenbaum128k

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 REPLYlink written 7 months ago by dzisis198620

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 REPLYlink written 7 months ago by Pierre Lindenbaum128k

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

ADD REPLYlink written 7 months ago by dzisis198620
1
sort -t $'\t' -k1,1 -k2,2n in.bed | bedtools merge > out.bed
ADD REPLYlink modified 7 months ago by ATpoint34k • written 7 months ago by Pierre Lindenbaum128k
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: 1172 users visited in the last hour