Skip to main content

Expand BED File

ExpandBED

Expands input BED file by adding positions to the border or around the center.

ExpandBED_center-10bp

This script is related to several Bedtools functions and is typically used to expand a set of peak annotations from the center to create a set of genomic intervals of fixed size. BED files with fixed interval lengths are useful for a variety of tools including ScriptManager's Tag Pileup occupancy counts, Extract FASTA sequence for Four Color plots, and even for a number of other third-party analysis tools.

The script can also pad the intervals of BED coordinates to create intervals that aren't necessarily all of a fixed length.

File input (BED)​

This script processes BED-type files so make sure your input is properly formatted and uses the appropriate .bed extension if you are working from the GUI.

Expansion strategy & size​

Depending on the strategy selected, the "Size of Expansion" (in bp) can mean different things.

  • Expand from Center: The figure at the top of the page illustrates the "expand from center" expansion strategy where the midpoint is determined by script and then the window is expanded evenly on both sides of the midpoint to the size of expansion specified by the user. This results in a BED file with intervals of a fixed length.
  • Add to Border: This strategy pads both sides of the borders of the input intervals by a fixed amount specified by the user ("Size of Expansion"). Depending on whether or not the input BED file contains intervals of a fixed length, the resulting expansions will not necessarily include intervals of a fixed length.
Exact bp details of center expansion

Note that an "expand from center" operation may be implemented a little differently across different tools because the "midpoint" of finite units (you can't split a nucleotide) can be determined by different conventions. Since all center expansions are expanded to even-lengthed windows, the midpoint is set to the position just-left of the midpoint.

ExpandBED_center-10bp

ScriptManager also attempts to preserve the relative center in a strand-aware way. Below is a visualization in IGV of an example input set of input BED intervals and the output of a 10bp expansion from the center (-c 10). The figure was visualized in IGV and labeled with what ScriptManager (and plotter) treats as the "0" position for the midpoint. Note that the "0" position in even-input expansions is always the "left" nucleotide of the center relative to the strand orientation.

View some examples by input length:

ExpandBED_c100_input1bp

Output format​

For each input BED file, a new BED file is created with the original filename and a *_<sizeofexpansion>bp.bed suffix.

Output GZip​

Toggling this allows the user to write output to a compressed file format using a general compression (gzip) which has the added advantage of speeding up the execution time by shrinking the I/O load (esp for large output). The .gz extension will be appended as appropriate.

Command Line Interface​

Usage:

java -jar ScriptManager.jar coordinate-manipulation expand-bed [-hsV] [-b=<border>]
[-c=<center>] [-o=<output>] <bedFile>

Positional Input​

This tool takes a single BED file for input.

Output Options​

OptionDescription
-o, --outputspecify output filename (default name will be same as original with expansion info and .bed ext)
-s, --stdoutoutput gff to STDOUT
-z, --gzipgzip output (default=false)

Expansion Options​

OptionDescription
-c, --centerexpand from center (default, at 250bp)
-b, --borderadd to border