Category

Genomic Interval Manipulation


Usage

bedtools makewindows [OPTIONS] [-g <genome> OR -b <bed>] [ -w <window_size> OR -n <number of windows> ]


Manual

This tool is part of the bedtools suite.

Options

Input Options
  • -g genome: Genome file size (see notes below). Windows will be created for each chromosome in the file. This can be retrieved with tools like fetchChromSizes.
  • -b bed: BED file (with chrom,start,end fields). Windows will be created for each interval in the file.
Windows Output Options
  • -w window_size: Divide each input interval (either a chromosome or a BED interval) to fixed-sized windows (i.e. same number of nucleotide in each window). Can be combined with -s step_size
  • -s step_size: Step size: i.e., how many base pairs to step before creating a new window. Used to create "sliding" windows. - Defaults to window size (non-sliding windows).
  • -n number_of_windows: Divide each input interval (either a chromosome or a BED interval) to fixed number of windows (i.e. same number of windows, with varying window sizes).
  • -reverse: Reverse numbering of windows in the output, i.e. report windows in decreasing order
ID Naming Options
  • -i src|winnum|srcwinnum: The default output is 3 columns: chrom, start, end. With this option, a name column will be added.
    • -i src - use the source interval's name.
    • -i winnum - use the window number as the ID (e.g. 1,2,3,4...).
    • -i srcwinnum - use the source interval's name with the window number. See below for usage examples.

Notes

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

Tips

One can use the fetchChromSizes to extract chromosome sizes.

Examples

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
...

 

File formats this tool works with
BED

Share your experience or ask a question