obtain non-overlapping regions within the file
2
0
Entering edit mode
8.6 years ago

Hi

I have a file like this

chr1 1 100
chr1 1 50
chr1 55 70
chr1 75 100
chr1 101 200

I want to obtain all non-overlapping regions into separate file. So my output will look like this

chr1 1 100
chr1 101 200

Is there any way to do this please let me know

non-overlapping bedtools • 3.3k views
ADD COMMENT
0
Entering edit mode

This was already answered here

ADD REPLY
2
Entering edit mode
8.6 years ago

With BEDOPS bedops and sort-bed:

$ sort-bed input.bed | bedops --merge - > answer.bed

Sorting is required to deal with matches in the second (start position) column. Make sure your input BED file is tab-delimited.

ADD COMMENT
1
Entering edit mode
8.6 years ago

...Since you tag bedtools, this should do:

sort -k1,1 -k2,2n in.bed | mergeBed > merged.bed
ADD COMMENT

Login before adding your answer.

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