This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Is it possible to highlight specific regions in the UCSC browser?

So far I've only seen this done manually with alt+dragging mouse. However, can I set specific regions to highlight? How can I do this giving the start and stop positions instead of dragging?

highlight browser ucsc regions

1 answer

hi again _quantum_girl_ ,

Still infatuated with UCSC I see (amazing resource). You might consider looking at their videos and joining UCSC-specific chats (I linked one such resource below).

To highlight specific regions using exact start and stop positions without manual mouse dragging, you can use a few different approaches depending on your workflow. Here are the primary methods and the associated command-line tools for each:

1. URL Parameters (The Direct Approach)

The most immediate way to highlight specific coordinates is by appending the highlight parameter directly to the UCSC Genome Browser session URL.

  • Approach: Define the assembly, chromosome, start, stop, and an optional hex color code. Multiple highlights can be concatenated using a pipe (|).
  • Syntax: &highlight=<db>.<chrom>:<chromStart>-<chromEnd>#<HexColor> (Note: Special characters like # and | should be URL-encoded as %23 and %7C, respectively).
  • Command-Line Tools: This approach relies on URL generation rather than UCSC binaries. Standard CLI text processors like awk or sed are typically used to iterate over a list of regions and dynamically construct the URL strings.

2. Custom Annotation Tracks (BED Format)

Instead of modifying the browser's background highlight, you can upload a custom track that draws colored blocks over your regions of interest.

  • Approach: Create a BED file containing your start and stop positions. To control the color, use at least a BED9 format and include a track definition line with itemRgb=On. Note that UCSC requires 0-based, half-open coordinates.
  • Syntax:
    track name="Highlights" itemRgb="On" visibility=pack
    chr1    1000    2000    Region1    0    +    1000    2000    255,0,0
    
  • Command-Line Tools:
    • awk: Useful for mathematically shifting coordinates (e.g., converting 1-based VCF/GTF coordinates to 0-based BED format).
    • sort / bedtools: Used to strictly order your coordinates (sort -k1,1 -k2,2n), which optimizes browser rendering and is a prerequisite for binary conversion.

3. Track Decorators (For Large Datasets & Track Hubs)

For programmatic, large-scale annotations—or when hosting Track Hubs—UCSC supports "Track Decorators." This allows you to overlay highlights (blocks or glyphs) directly onto existing track features.

  • Approach: Create a decorator (decorated??) BED file that links specific coordinates to an existing feature, then compile it into a compressed binary format.
  • Command-Line Tools:
    • bedToBigBed: The core UCSC utility required to compile the text-based decorator BED file into an indexed bigBed (.bb) file.
    • fetchChromSizes: A UCSC script used to pull the exact chromosome lengths for your target assembly, which bedToBigBed requires to validate your coordinates during compilation.

For more visual context on how these tracks operate, the UCSC team provides a practical overview of managing tracks and visualizing targeted regions in this presentation: UCSC Genome Browser: Tracks, tips and tricks.

Outside of the UCSC-ome, you can take any such region and plug it into one of 10^1944955853895 visualization resources created for genomics, at least 4 of which are really good.

VAL

Log in to answer this question.