Thanks for the detailed answer. I used <() quite a bit as well :) learning to use more BEDOPS.
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
1 answer
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!
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?
Log in to answer this question.
I think you have to include the
--ecflag for error checking no?yes, you are right. -ec is for checking error. but bedops -u should not expect sorted bed files, right?
I think the requirements for all bedops operations including
-uare 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-uflag changes that, at least not in my experience. I always sort every file I give bedops just for this reason.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:)
Great, and yes, bedops is among my most used tools, very powerful!
it is under-appreciated compared with bedtools, another good one :)
even version: 2.4.30 (typical) is having the same issue.
Just give
bedops -usorted 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.