Question: Does Bedops Have A Command Similar To The Bedtools Makewindows?
5
gravatar for Irsan
6.2 years ago by
Irsan6.8k
Amsterdam
Irsan6.8k wrote:

With bedtools you can make genomic windows from a genome file or a bed file

input.bed

chr1    1000000 1500000
chr3    500000  900000

[prompt]$ bedtools makewindows -b input.bed -w 250000

chr1    1000000 1250000
chr1    1250000 1500000
chr3    500000  750000
chr3    750000  900000

Does the bedops suite provide a similar way to create genomic windows?

bedtools • 3.7k views
ADD COMMENTlink modified 4.2 years ago by Alex Reynolds27k • written 6.2 years ago by Irsan6.8k
4

Does it matter? The two tools complement each other pretty well. Why not just use the windows created by bedtools with bedops?

ADD REPLYlink written 6.2 years ago by Aaronquinlan10k

hi aaronquinlan, i am trying to minimize the amount of dependencies of our pipelines. but it seems like we will continue to use both

ADD REPLYlink modified 6.2 years ago • written 6.2 years ago by Irsan6.8k
3
gravatar for sjneph
6.2 years ago by
sjneph600
sjneph600 wrote:

Hi Isran,
Here is a pretty straightforward script that breaks up regions into fixed-sized chunks, using a standard awk 'program'. I put it inside of a simple c-shell script. You wouldn't have to do that though. If you name this script, say, as windowed-chunks, then you'd invoke as:

[prompt]$ ./windowed-chunks 250000 input.bed


#!/bin/csh -ef                                                                                                                                                                    
if ( $#argv != 2 ) then
  printf "Expect a window size and an input BED file!\n"
  exit -1
endif

awk -v winsize=$1 \
'{ \
  i = $2; \
  while ( i < $3 ) { \
    j = i+winsize; \
    if ( j > $3 ) { j = $3; } \
    print $1"\t"i"\t"j; \
    i = j; \
  } \
}' $2

exit 0

You could embed this awk statement into a bash or sh script instead if you wanted, or even a simpler awk script (this would allow you to get rid of all of the '\' characters I used). If you wanted to make this script a bit more robust, you could add checks that the window size given isn't a negative number or string, and other little things like that. If you have questions regarding BEDOPS, feel free to join the forum at http://bedops.uwencode.org/forum/ - we'd be happy to help.

ADD COMMENTlink modified 6.2 years ago • written 6.2 years ago by sjneph600

Hi sjneph, thanks for your reply. Did not realize it could be that easy. I can extend your code so that it also allows for windows with a step size. And I will have a look at the bedops forum, last time I checked it did not look very active so that's why I asked here :-)

ADD REPLYlink written 6.2 years ago by Irsan6.8k
1

You bet. The forum has been very quiet for a while now. We monitor it regularly, but there is very little activity as you pointed out. I'd like to see that change. I guess I'll float around out here too. This is my first post, so I'm happy it was helpful.

ADD REPLYlink written 6.2 years ago by sjneph600
3
gravatar for Alex Reynolds
4.2 years ago by
Alex Reynolds27k
Seattle, WA USA
Alex Reynolds27k wrote:

Version 2.4.3 of the bedops tool now offers --chop and  --stagger functions to melt input regions into non-overlapping, adjacent or overlapping windows.

For instance, given input.bed:

chr1    1000000 1500000
chr3    500000  900000

You can use --chop 250000 to get the desired adjacent windows:

$ bedops --chop 250000 input.bed 
chr1    1000000 1250000
chr1    1250000 1500000
chr3    500000  750000
chr3    750000  900000

Use of --stagger will step the window from the initial start position by the specified amount, keeping within bounds. Here's an example that makes overlapping windows:

$ bedops --chop 250000 --stagger 100000 input.bed
chr1    1000000    1250000
chr1    1100000    1350000
chr1    1200000    1450000
chr1    1300000    1500000
chr1    1400000    1500000
chr3    500000    750000
chr3    600000    850000
chr3    700000    900000
chr3    800000    900000

The stagger value can be larger than the chop to create non-overlapping windows, where all output elements fall within the bounds of the input elements:

$ bedops --chop 50000 --stagger 100000 input.bed
chr1    1000000    1050000
chr1    1100000    1150000
chr1    1200000    1250000
chr1    1300000    1350000
chr1    1400000    1450000
chr3    500000    550000
chr3    600000    650000
chr3    700000    750000
chr3    800000    850000
ADD COMMENTlink modified 4.2 years ago • written 4.2 years ago by Alex Reynolds27k
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: 1037 users visited in the last hour