BigWig Manipulation


bigWigAverageOverBed [options] in.bed


This tool is part of UCSC Genome Browser's utilities.

Required arguments

  • The input bigWig file with scores stored.
  • in.bed: The input bed file which defines the regions that you want to aggregate the scores. Note: bigWigAverageOverBed expects the in.bed is in either BED4 (chrom, chromStart, chromEnd, and name) or BED12 (BED4+score, strand, thickStart, thickEnd, itemRgb, blockCount, blockSizes, and blockStarts) format. If the in.bed is in BED12 format, the last three columns (blockCount, blockSizes, and blockStarts) must be:
    • blockCount: the number of blocks (exons) in the BED line (integer). If values in this column are not integers, the program will raise exceptions like `invalid unsigned integer: "Low-DNase"`
    • blockSizes: A comma-separated list of the block sizes. The number of items in this list should correspond to blockCount.
    • blockStarts: A comma-separated list of block starts. All of the blockStart positions should be calculated relative to chromStart. The number of items in this list should correspond to blockCount. Path to write the results. The output columns are:
    • name: name field from bed, which should be unique
    • size: size of bed (sum of exon sizes)
    • covered: # bases within exons covered by bigWig
    • sum: sum of values over all bases covered
    • mean0: average over bases with non-covered bases counting as zeroes
    • mean: average over just covered bases


  • -stats=stats.ra: Output a collection of overall statistics to stat.ra file. These statistics include: 
    • basesInGenome: Genome size
    • basesInSpots: Size of query regions
    • basesInSpotsWithSignal: Size of query regions with signal values
    • sumSignal: sum of signals in the entire genome
    • spotSumSignal: sum of signals in the query regions
    • spotRatio: $\frac{\text{spotSumSignal}}{\text{sumSignal}}$
    • enrichment: $\frac{\text{spotSumSignal}}{\text{basesInSpots}}/\frac{\text{sumSignal}}{\text{basesInGenome}}$
    • maxEnrichment: $\frac{\text{basesInGenome}}{\text{basesInSpots}}$
    Available to versions released after March 4, 2014.
  • -bedOut=out.bed: Make output bed that is echo of input bed but with mean column appended. Available to versions released after August 11, 2011.
  • -sampleAroundCenter=N: Take sample at region N bases wide centered around bed item, rather than the usual sample in the bed item. Available to versions released after August 11, 2011.
  • -minMax: include two additional columns containing the min and max observed in the area. Available to versions released after August 7, 2014.


Compute the average signal for each region for a DNase experiment
$ bigWigAverageOverBed K562_DNase.bigWig rDHS.bed
$ head
EH38E2776520	152	152	25.7478	0.169393	0.169393
EH38E2776521	268	268	93.0052	0.347034	0.347034
EH38E2776522	161	161	15.7171	0.0976216	0.0976216
EH38E2776523	223	223	18.7438	0.0840528	0.0840528
EH38E2776524	350	350	258.306	0.738017	0.738017
EH38E2776528	246	246	202.474	0.823065	0.823065
EH38E2776529	242	242	1.03611	0.00428145	0.00428145
EH38E2776530	152	152	11.6338	0.0765383	0.0765383
EH38E2776532	228	228	190.955	0.83752	0.83752
EH38E2776534	338	338	130.477	0.386025	0.386025
Compute the average signal and append the mean values to the bed file

By using the -bedOut option, the program makes a new bed file, which is identical to the input bed file, except that a new column with the corresponding mean values being added to the end of the file:

$ bigWigAverageOverBed -bedOut=rDHS.out.bed K562.bigWig rDHS.bed
$ head rDHS.out.bed
chr1    104896    105048    EH38E2776520    0.169393
chr1    138866    139134    EH38E2776521    0.347034
chr1    180743    180904    EH38E2776522    0.0976216
chr1    181014    181237    EH38E2776523    0.0840528
chr1    181289    181639    EH38E2776524    0.738017
chr1    267925    268171    EH38E2776528    0.823065
chr1    271226    271468    EH38E2776529    0.00428145
chr1    274329    274481    EH38E2776530    0.0765383
chr1    586036    586264    EH38E2776532    0.83752
chr1    605330    605668    EH38E2776534    0.386025
Extend certain basepairs from the centers of regions and calculate the stats

By using the -sampleAroundCenter option, the program calculates the center of all regions, extends N basepairs, and use these extended regions for generating stats.

$ bigWigAverageOverBed -sampleAroundCenter=500 K562.bigWig rDHS.bed


File formats this tool works with

Share your experience or ask a question