bedtools2 icon indicating copy to clipboard operation
bedtools2 copied to clipboard

bedtools merge error when handling reciporally overlap region

Open wildist-github opened this issue 3 years ago • 1 comments

Hello,

I have search multiple page but could find a solution my error, please kindly provide advices.

My purpose is to merge and count the overlap region by using following command sort -k1,1 -k2,2n unsort.txt > sort.txt bedtools merge -c 4 -o count_distinct -i sort.txt > merge.txt

But an error is encountered in which I have checked not caused by zero-length row(s) Error: Sorted input specified, but the file SRR17913475_star_EE_sort.txt has the following out of order record chr11 133779 134890 SRR17913475.3194907;1391289

After I examined the bed files, the error should be caused by these reciprocally overlapped rows chr11 133779 134890 SRR17913475.3194907;1391289 chr11 133779 138047 SRR17913475.25750549;1391285 chr11 133779 138047 SRR17913475.69351531;1391280 chr11 133779 138047 SRR17913475.75973107;1391281 chr11 133779 138047 SRR17913475.75973152;1391282 chr11 134797 134890 SRR17913475.100728617;1391313 chr11 134797 134890 SRR17913475.100906458;1391302 chr11 134797 134890 SRR17913475.1751957;1391339

Wanna ask if there is any solution to tickle these regions since the bed file has many rows showing a similar pattern, I could not handle them one by one

Thank you Walter

wildist-github avatar May 30 '22 07:05 wildist-github

I see the error now. Could you share the contents of the original file, as you are requesting merge operations on 5 columns, but the input you show has only 4 columns. Running the following command with version 2.30.0 works with no errors.

bedtools merge -i x.bed -c 4 -o count_distinct
chr11	133779	138047	8
bedtools --version
bedtools v2.30.0

arq5x avatar May 30 '22 23:05 arq5x