Question: bedops -u does not work properly
0
gravatar for Ming Tang
2.9 years ago by
Ming Tang2.6k
Houston/MD Anderson Cancer Center
Ming Tang2.6k wrote:

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

intersect bedops bed • 751 views
ADD COMMENTlink modified 2.9 years ago by Alex Reynolds31k • written 2.9 years ago by Ming Tang2.6k

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

ADD REPLYlink modified 2.9 years ago • written 2.9 years ago by Sinji3.0k

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

ADD REPLYlink written 2.9 years ago by Ming Tang2.6k

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 REPLYlink modified 2.9 years ago • written 2.9 years ago by Sinji3.0k

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 REPLYlink written 2.9 years ago by Ming Tang2.6k
2

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

ADD REPLYlink written 2.9 years ago by Sinji3.0k

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

ADD REPLYlink written 2.9 years ago by Ming Tang2.6k

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

ADD REPLYlink written 2.9 years ago by Ming Tang2.6k
1

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 REPLYlink written 2.9 years ago by Alex Reynolds31k
1
gravatar for Alex Reynolds
2.9 years ago by
Alex Reynolds31k
Seattle, WA USA
Alex Reynolds31k wrote:

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 COMMENTlink modified 2.9 years ago • written 2.9 years ago by Alex Reynolds31k

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

ADD REPLYlink written 2.9 years ago by Ming Tang2.6k
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: 2219 users visited in the last hour