bedops -u does not work properly
1
0
Entering edit mode
6.9 years ago
Ming Tommy Tang ★ 4.5k

bedops -u is not sorting the bed files

bedops --version
bedops
  citation: http://bioinformatics.oxfordjournals.org/content/28/14/1919.abstract
  version:  2.4.14
  authors:  Shane Neph & Scott Kuehn

#dummy file:
 cat my.bed 
chr1    1   5   peak_1
chr1    2   6   peak_2
chr1    3   7   peak_3
chr1    2   4   peak_4
chr1    8   10  peak_5
chr1    3   6   peak_6

#test bedops -u 

bedops -u my.bed my.bed 
chr1    1   5   peak_1
chr1    1   5   peak_1
chr1    2   6   peak_2
chr1    2   6   peak_2
chr1    3   7   peak_3
chr1    2   4   peak_4
chr1    3   7   peak_3
chr1    2   4   peak_4
chr1    8   10  peak_5
chr1    3   6   peak_6
chr1    8   10  peak_5
chr1    3   6   peak_6

correct output should be:

sort-bed my.bed my.bed 
chr1    1   5   peak_1
chr1    1   5   peak_1
chr1    2   4   peak_4
chr1    2   4   peak_4
chr1    2   6   peak_2
chr1    2   6   peak_2
chr1    3   6   peak_6
chr1    3   6   peak_6
chr1    3   7   peak_3
chr1    3   7   peak_3
chr1    8   10  peak_5
chr1    8   10  peak_5

please fix this, my bedops -u *bed | bedmap —count —echo —delimit ‘\t’ - is failing... according to http://bedops.readthedocs.io/en/latest/content/usage-examples/multiple-inputs.html
bedmap should complain that if the input is not sorted rather than just let it go silently.

Thanks,
Tommy

bedops bed intersect • 2.7k views
ADD COMMENT
0
Entering edit mode

I think you have to include the --ec flag for error checking no?

ADD REPLY
0
Entering edit mode

yes, you are right. -ec is for checking error. but bedops -u should not expect sorted bed files, right?

ADD REPLY
0
Entering edit mode

I think the requirements for all bedops operations including -u are that the input be sorted prior to being run, however, i've never gotten any errors when giving un-sorted files to bedops, I don't think the -u flag changes that, at least not in my experience. I always sort every file I give bedops just for this reason.

ADD REPLY
0
Entering edit mode

Now it makes sense. every input bed file should be sorted. with -u it does not give me errors, but just missing many overlapping entries. bedops is a very good tool BTW:)

ADD REPLY
2
Entering edit mode

Great, and yes, bedops is among my most used tools, very powerful!

ADD REPLY
0
Entering edit mode

it is under-appreciated compared with bedtools, another good one :)

ADD REPLY
0
Entering edit mode

even version: 2.4.30 (typical) is having the same issue.

ADD REPLY
1
Entering edit mode

Just give bedops -u sorted data and it will work fine.

Everyone should definitely update to 2.4.30 where possible, which includes a number of major speed enhancements and fixes across the board.

ADD REPLY
2
Entering edit mode
6.9 years ago

You need to provide sorted inputs to bedops -u. It doesn't replace sort-bed!

 $ sort-bed my.bed > my.sorted.bed
 $ bedops -u my.sorted.bed my.sorted.bed > answer.bed

The file answer.bed is sorted correctly. You don't need to sort answer.bed. This is because the inputs are sorted, which allows bedops -u to do a merge sort under the hood.

Or if you like process substitutions, you can skip making intermediate files:

$ bedops -u <(sort-bed my.bed) <(sort-bed my.bed) > answer.bed

Those <(sort-bed my.bed) blocks are short-lived equivalents to my.sorted.bed.

I think --ec should tell you if your inputs are not sorted. Hope this helps and thanks for using BEDOPS!

ADD COMMENT
0
Entering edit mode

Thanks for the detailed answer. I used <() quite a bit as well :) learning to use more BEDOPS.

ADD REPLY
0
Entering edit mode

To clarify my doubt ..so when i have say replicates from same condition then i have to use this -u, --everything and when I want to find overlap between lets say different biological condition I have to use this one -m, --merge. Or I m doing it opposite way?

ADD REPLY

Login before adding your answer.

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