Reference Code backup Executable files
Makes adjacent or sliding windows across a genome or regions defined in a BED file.
bedtools makewindows [OPTIONS] [-g <genome> OR -b <bed>] [ -w <window_size> OR -n <number of windows> ]
This tool is part of the bedtools
suite.
fetchChromSizes
.-s step_size
The genome file should tab delimited and structured as follows:
<chromName><TAB><chromSize>
For example, Human (hg19):
chr1 249250621 chr2 243199373 ... chr18_gl000207_random 4262
One can use the fetchChromSizes
to extract chromosome sizes.
Divide the human genome into windows of 1MB with -w 1000000
:
$ bedtools makewindows-g hg19.txt
-w 1000000
chr1 0 1000000 chr1 1000000 2000000 chr1 2000000 3000000 chr1 3000000 4000000 chr1 4000000 5000000 ...
Divide the human genome into sliding (=overlapping) windows of 1MB, with 500KB overlap with -w 1000000
and -s 500000
:
$ bedtools makewindows-g hg19.txt
-w 1000000
-s 500000
chr1 0 1000000 chr1 500000 1500000 chr1 1000000 2000000 chr1 1500000 2500000 chr1 2000000 3000000 ...
Divide each chromosome in human genome to 1000 windows of equal size with -n 1000
:
$ bedtools makewindows-g hg19.txt
-n 1000
chr1 0 249251 chr1 249251 498502 chr1 498502 747753 chr1 747753 997004 chr1 997004 1246255 ...
Divide each interval in the given BED file into 10 equal-sized windows with -n 10
:
$ cat input.bed chr5 60000 70000 chr5 73000 90000 chr5 100000 101000 $ bedtools makewindows-b input.bed
-n 10
chr5 60000 61000 chr5 61000 62000 chr5 62000 63000 chr5 63000 64000 chr5 64000 65000 ...
Add a name column, based on the window number with -i winnum
:
$ cat input.bed chr5 60000 70000 AAA chr5 73000 90000 BBB chr5 100000 101000 CCC $ bedtools makewindows-b input.bed
-n 3
-i winnum
chr5 60000 63334 1 chr5 63334 66668 2 chr5 66668 70000 3 chr5 73000 78667 1 chr5 78667 84334 2 chr5 84334 90000 3 chr5 100000 100334 1 chr5 100334 100668 2 chr5 100668 101000 3 ...
Reverse window numbers with -i winnum
and -reverse:
$ cat input.bed chr5 60000 70000 AAA chr5 73000 90000 BBB chr5 100000 101000 CCC $ bedtools makewindows-b input.bed
-n 3
-i winnum
-reverse chr5 60000 63334 3 chr5 63334 66668 2 chr5 66668 70000 1 chr5 73000 78667 3 chr5 78667 84334 2 chr5 84334 90000 1 chr5 100000 100334 3 chr5 100334 100668 2 chr5 100668 101000 1 ...
Add a name column, based on the source ID + window number with -i srcwinnum
:
$ cat input.bed chr5 60000 70000 AAA chr5 73000 90000 BBB chr5 100000 101000 CCC $ bedtools makewindows-b input.bed
-n 3
-i srcwinnum
chr5 60000 63334 AAA**1 chr5 63334 66668 AAA**2 chr5 66668 70000 AAA**3 chr5 73000 78667 BBB**1 chr5 78667 84334 BBB**2 chr5 84334 90000 BBB**3 chr5 100000 100334 CCC**1 chr5 100334 100668 CCC**2 chr5 100668 101000 CCC**3 ...