bigBed Track Format

The bigBed format stores annotation items that can be either a simple or a linked collection of exons, much as BED files do. BigBed files are created from BED type files using the program bedToBigBed. The resulting bigBed files are in an indexed binary format. The main advantage of the bigBed files is that only those portions of the files needed to display a particular region are transferred to the Genome Browser server. Because of this, bigBed has considerably faster display performance than regular BED when working with large data sets. The bigBed file remains on your local web-accessible server (http, https, or ftp), not on the UCSC server, and only the portion that is needed for the currently displayed chromosomal position is locally cached as a "sparse file". If you do not have access to a web-accessible server and need hosting space for your bigBed files, please see the Hosting section of the Track Hub Help documentation.

Additional indices can be created for the items in a bigBed file to support item search in track hubs. See Example #3 below for an example of how to build an additional index.

See this wiki page for help in selecting the graphing track data format that is most appropriate for your type of data.

Note that the bedToBigBed utility uses a substantial amount of memory: approximately 25% more RAM than the uncompressed BED input file.

Quickstart example commands

It is not hard to create a bigBed file. The following UNIX commands create one on a Linux machine (swap macOSX for linux for an Apple environment). The steps are explained in more detail in the following sections on this page:
wget https://genome.ucsc.edu/goldenPath/help/examples/bedExample.txt
wget https://genome.ucsc.edu/goldenPath/help/hg19.chrom.sizes
wget http://hgdownload.soe.ucsc.edu/admin/exe/linux.x86_64/bedToBigBed
chmod a+x bedToBigBed
./bedToBigBed bedExample.txt hg19.chrom.sizes myBigBed.bb
mv myBigBed.bb ~/public_html/
The last step assumes that your ~/public_html/ directory is accessible from the internet. This may not be the case on your server. You may have to copy the file to another server and web-accessible location at your University. Once you know the URL to the file myBigBed.bb, you can paste this URL into the custom track box on the UCSC Genome Browser to display the file.

Creating a bigBed track

To create a bigBed track, follow these steps (for concrete Unix commands, see the examples below on this page):

Step 1. Create a BED format file following the directions here. When converting a BED file to a bigBed file, you are limited to one track of data in your input file; therefore, you must create a separate BED file for each data track. Your BED file must be sorted.

If your BED file was originally a custom track, remove any existing "track" or "browser" lines from your BED file so that it contains only data. Also the input BED must be sorted, performed with this command: sort -k1,1 -k2,2n unsorted.bed > input.bed

Step 2. Download the bedToBigBed program from the binary utilities directory. Example #2 below shows the exact Unix command.

The bedToBigBed program can be run with several additional options. Some of these, such as the -as and -type options, are used in examples below. The -type option, describes the size of the bigBed file, -type=bedN[+[P]], where N is an integer between 3 and 12 and the optional +[P] parameter specifies the number of extra fields, not required, but preferred. Describing the size of the bigBed file is needed for access to extra fields like name, itemRgb, etc. Examples:-type=bed6 or -type=bed6+ or -type=bed6+3 . For a full list of the available options, type bedToBigBed (with no arguments) on the command line to display the usage message.

Step 3. Use the fetchChromSizes script from the same directory to create the chrom.sizes file for the UCSC database you are working with (e.g., hg19). If the assembly genNom is hosted by UCSC, chrom.sizes can be a URL like: http://hgdownload.soe.ucsc.edu/goldenPath/genNom/bigZips/genNom.chrom.sizes.

Step 4. Use the bedToBigBed utility to create a bigBed file from your sorted BED file, using the input.bed file and chrom.sizes files created in Steps 1 and 3:

bedToBigBed input.bed chrom.sizes myBigBed.bb

Step 5. Move the newly created bigBed file (myBigBed.bb) to a web-accessible http, https, or ftp location. At this point you should have a URL to your data, such as "https://institution.edu/myBigBed.bb", and the file should be accessible outside of your institution/hosting providers network. For more information on where to host your data, please see the Hosting section of the Track Hub Help documentation.

Step 6. If the file name ends with a .bigBed or .bb suffix, you can paste the URL of the file directly into the custom track management page, click "submit" and view the file as a track in the Genome Browser. By default, the file name will be used to name the track. To configure the track name and descriptions, you must create a "track line", as shown in Example 1 Configuration Step 1.

Alternatively, if you want to set the track labels and other options yourself, construct a custom track using a single track line. Note that any of the track attributes listed here are applicable to tracks of type bigBed. The most basic version of the track line will look something like this:

track type=bigBed name="My Big Bed" description="A Graph of Data from My Lab" bigDataUrl=http://myorg.edu/mylab/myBigBed.bb

Paste this custom track line into the text box on the custom track management page.

Examples

Example #1: Load an existing bigBed file

In this example, you will load an existing bigBed file, bigBedExample.bb, on the UCSC http server. This file contains data on chromosome 21 on the human hg19 assembly.

To create a custom track using this bigBed file:

  1. Paste the URL http://genome.ucsc.edu/goldenPath/help/examples/bigBedExample.bb into the custom track management page for the human assembly hg19 (Feb. 2009).
  2. Click the "submit" button.
  3. On the next page that displays, click the "go" link. To view the data in the bigBed track in the Genome Browser navigate to chr21:33,031,597-33,041,570.

Configuration

You can customize the track display by including track and browser lines that define certain parameters:

  1. Construct a track line that references the bigBedExample.bb file:
    track type=bigBed name="bigBed Example One" description="A bigBed file" bigDataUrl=http://genome.ucsc.edu/goldenPath/help/examples/bigBedExample.bb
  2. Paste the track line into the custom track management page, click the "submit" button. On the next page that displays, click the "go" link. To view the data in the bigBed track in the Genome Browser navigate to chr21:33,031,597-33,041,570.
  3. With the addition of the following browser line with the track line you can ensure that the custom track opens at the correct position when you paste in the information:
    browser position chr21:33,031,597-33,041,570
    track type=bigBed name="bigBed Example One" description="A bigBed file" bigDataUrl=http://genome.ucsc.edu/goldenPath/help/examples/bigBedExample.bb
    Paste the browser and track lines into the custom track page, click the "submit" button and the "go" link to see the data.

Example #2: Create a bigBed file from a BED file

In this example, you will convert a sample BED file to bigBed format.

  1. Save the BED file bedExample.txt to a server, ideally one that is accessible from the internet. (Steps 1 and 2 in Creating a bigBed track, above).
    wget https://genome.ucsc.edu/goldenPath/help/examples/bedExample.txt
  2. Save the file hg19.chrom.sizes to your computer. It contains the chrom.sizes data for the human (hg19) assembly (Step 3, above).
    wget https://genome.ucsc.edu/goldenPath/help/hg19.chrom.sizes
  3. If you use your own file, it has to be sorted, first on the chrom field, and secondarily on the chromStart field. You can use the utility bedSort available here or the following UNIX sort command to do this:

    sort -k1,1 -k2,2n unsorted.bed > input.bed
  4. Download the bedToBigBed utility (Step 2, above). Replace "linux" below with "macOSX" if your server is a Mac.
    wget http://hgdownload.soe.ucsc.edu/admin/exe/linux.x86_64/bedToBigBed
    chmod a+x bedToBigBed
  5. Run the utility to create the bigBed output file (Step 4, above):
    ./bedToBigBed bedExample.txt hg19.chrom.sizes myBigBed.bb
  6. Place the bigBed file you just created (myBigBed.bb) on a web-accessible server (Step 5, above).
    mv myBigBed.bb ~/public_html/
    At some Universities, this involves using the commands ftp, scp or rsync to copy the file to a different server, one that is accessible from the internet. We have documentation how to find such a server.
  7. Paste the URL itself into the Custom Tracks entry form or construct a track line that points to your bigBed file (Step 5, above).
  8. Create the custom track on the human assembly hg19 (Feb. 2009), and view it in the Genome Browser (Step 6, above). Note that the original BED file contains data on chromosome 21 only.

Example #3: Create a bigBed file with extra (custom) fields

BigBed files can store extra fields in addition to the predefined BED fields. In this example, you will create your own bigBed file from a fully featured existing BED file that contains the standard BED fields up to and including the color field called itemRgb (field 9), plus two additional non-standard fields (two alternate names for each item in the file). The standard BED column itemRgb contains an R,G,B color value (e.g. "255,0,0"). The resulting bigBed file will have nine standard BED columns and two additional non-standard user-defined columns.

If you add extra fields to your bigBed file, you must include an AutoSql format (.as) file describing the fields. In this file, all fields (standard and non-standard) are described with a short internal name and also a human-readable description. For more information on AutoSql, see Kent and Brumbaugh, 2002, as well as examples of .as files in this directory. Then, the bedToBigBed program is run with the arguments -type=bed9+2 and also -as=bedExample2.as to help correctly interpret all the columns in the data.

This example also demonstrates how to create an extra search index on the name field, and the first of the extra fields to be used for track item search. The searchIndex setting requires the input BED data to be case-sensitive sorted (sort -k1,1 -k2,2n), where newer versions of the tool bedToBigBed (available here) are enhanced to catch improper input.

  1. Save the BED file bedExample2.bed to your computer (Steps 1 and 2 in Creating a bigBed track, above).
  2. Save the file hg18.chrom.sizes to your computer. This file contains the chrom.sizes for the human (hg18) assembly (Step 4, above).
  3. Save the AutoSql file bedExample2.as to your computer. This file contains descriptions of the BED fields, and is required when the BED file contains a color field.
  4. Download the bedToBigBed utility (Step 3, above).
  5. Run the utility to create a bigBed output file with an index on the name field and the first extra field: (Step 5, above):
    bedToBigBed -as=bedExample2.as -type=bed9+2 -extraIndex=name,geneSymbol bedExample2.bed hg18.chrom.sizes myBigBed2.bb
  6. Place the bigBed file you just created (myBigBed2.bb) on a web-accessible server (Step 6, above).
  7. Paste the URL of the file into the custom tracks entry form, or alternatively construct a track line that points to your bigBed file (Step 7, above). Because this bigBed file includes a field for color, you must include the itemRgb attribute in the track line. It will look somewhat similar to this (note that you must insert the URL specific to your own bigBed file):
    track type=bigBed name="bigBed Example Three" description="A bigBed File with Color and two Extra Fields" itemRgb="On" bigDataUrl=http://yourWebAddress/myBigBed2.bb
  8. Create the custom track on the human assembly hg18 (Mar. 2006), and view it in the Genome Browser (step 8, above). Note that the original BED file contains data on chromosome 7 only.
  9. If you are using the bigBed file in a track hub, you can use the additional indices for track item searches. See the setting "searchIndex" in the Track Database Definition Document for more information. For example, if you run the bedToBigBed utility with the option -extraIndex=name, you will be able to search on the "name" field by adding the line searchIndex name to the stanza about your bigBed in the hub's trackDb.txt file.
  10. Extra fields can contain text for labels or for display with mouseover (if the BED "name" field is needed for something that is not the label). See the trackDb settings "mouseOverField" and "labelField" for more information.
  11. When you click on features, the contents of all extra fields are shown as a table. You can modify the layout of the resulting page with the trackDb settings "skipFields", "sepFields" and "skipEmptyFields", and transform text fields into links with the "urls" trackDb setting.
  12. Extra fields that start with the character "_" are reserved for internal use (special display code); their contents are not shown on the details page.

Sharing Your Data with Others

If you would like to share your bigBed data track with a colleague, the best solution is to save your current view as a stable Genome Browser Session Link. This will save the position and all settings that you made, all track visibilities, filters, highlights, etc.

If you want to create URLs to your bigBed file programmatically from software, look at Example #6 on this page.

Extracting Data from the bigBed Format

Because the bigBed files are indexed binary files, it can be difficult to extract data from them. UCSC has developed the following programs to assist in working with bigBed formats, available from the binary utilities directory:

These programs accept either file names or URLs to files as input. As with all UCSC Genome Browser programs, simply type the program name (with no parameters) on the command line to view the usage statement.

Troubleshooting

If you get an error when you run the bedToBigBed program, check your input BED file for data coordinates that extend past the end of the chromosome. If these are present, run the bedClip program (available here) to remove the problematic row(s) in your input BED file before using the bedToBigBed program.