Category

Genomic Interval Manipulation


Usage

bedtools unionbedg [OPTIONS] -i FILE1 FILE2 .. FILEn


Manual

This tool is part of the bedtools suite, and it's also known as unionBedGraphs.

Required arguments

  • -i FILE1 FILE2 .. FILEn: BedGraph files to combine. Assumes each file is sorted by chrom/start, and intervals in each are non-overlapping.

Options

  • -header: Print a header line (chrom/start/end + names of each file).
  • -names name1 name2 .. nameN: A list of names (one per file) to describe each file in -i. Names will be printed in the header line.
  • -g STRING: Use a genome file to calculate empty regions.
  • -empty: Report empty regions (start/end intervals without values in all files). Requires the -g FILE parameter.
  • -filler TEXT: Use TEXT when representing intervals having no value. Default is '0', but you can use 'N/A' or any text.
  • -examples: Show detailed usage examples.

Examples

Input files:

$ cat 1.bg
chr1  1000    1500    10
chr1  2000    2100    20

$ cat 2.bg
chr1  900 1600    60
chr1  1700    2050    50

$ cat 3.bg
chr1  1980    2070    80
chr1  2090    2100    20

$ cat sizes.txt
chr1  5000

Union/combine the files:

$ unionBedGraphs -i 1.bg 2.bg 3.bg
chr1  900 1000    0   60  0
chr1  1000    1500    10  60  0
chr1  1500    1600    0   60  0
chr1  1700    1980    0   50  0
chr1  1980    2000    0   50  80
chr1  2000    2050    20  50  80
chr1  2050    2070    20  0   80
chr1  2070    2090    20  0   0
chr1  2090    2100    20  0   20

Union/combine the files, with a header line (titles are the file names):

$ unionBedGraphs -header -i 1.bg 2.bg 3.bg
chrom start   end 1   2   3
chr1  900 1000    0   60  0
chr1  1000    1500    10  60  0
chr1  1500    1600    0   60  0
chr1  1700    1980    0   50  0
chr1  1980    2000    0   50  80
chr1  2000    2050    20  50  80
chr1  2050    2070    20  0   80
chr1  2070    2090    20  0   0
chr1  2090    2100    20  0   20

Union/combine the files, with a header line and custom names:

$ unionBedGraphs -header -i 1.bg 2.bg 3.bg -names WT-1 WT-2 KO-1
chrom start   end WT-1    WT-2    KO-1
chr1  900 1000    0   60  0
chr1  1000    1500    10  60  0
chr1  1500    1600    0   60  0
chr1  1700    1980    0   50  0
chr1  1980    2000    0   50  80
chr1  2000    2050    20  50  80
chr1  2050    2070    20  0   80
chr1  2070    2090    20  0   0
chr1  2090    2100    20  0   20

Union/combine, showing empty regions (note, requires -g):

$ unionBedGraphs -header -empty -g sizes.txt -i 1.bg 2.bg 3.bg
chrom start   end 1   2   3
chr1  0   900 0   0   0
chr1  900 1000    0   60  0
chr1  1000    1500    10  60  0
chr1  1500    1600    0   60  0
chr1  1600    1700    0   0   0
chr1  1700    1980    0   50  0
chr1  1980    2000    0   50  80
chr1  2000    2050    20  50  80
chr1  2050    2070    20  0   80
chr1  2070    2090    20  0   0
chr1  2090    2100    20  0   20
chr1  2100    5000    0   0   0

File formats this tool works with
bedGraph

Share your experience or ask a question