Subtrack HOWTO


How to emulate the UCSC-style subtracks in GBrowse

AKA How to display dense qualitative data in linear tracks that resemble wiggle tracks

Browser Differences

GBrowse and UCSC differ in how glyphs are organized

How can we make something like a sub-track in gbrowse?

Quantitative Wiggle Tracks

There are speed optimizations for both range queries and graphical rendering.

You also only need one line of GFF in the database for each wiggle_box track/chromosome.

Non-quantitative Wiggle Tracks

An example of a GFF2WIG(BED) script.

#!/usr/bin/perl -w
use strict;

my $name = shift;
my $desc = shift;

@ARGV or die "I need three args: name, desc, filename";

print qq(track type=wiggle_0 name="$name" description="$desc"\n);
while (<>) {
  my ($ref,$start,$end,$score) = (split)[0,3,4,5];
  $ref =~ s/CHROMOSOME_|chr//;
  $start--; # zero-based, half-open
  $score = 255 if $score !~ /^[-.Ee0-9]$/;

  print join("\t",$ref,$start,$end,$score), "\n";

GFF-based, individual features

An example WIG(BED) to GFF3 converter

#!/usr/bin/perl -w
use strict;

@ARGV > 2 or die "use these args: source_tag primary_tag filename\nNOTE primary_tag must be a valid SOFA term!\n";

my $source = shift;
my $type   = shift;

for (@ARGV) {
  $_ = "sort -k1,1 -k2,2n $_ |";

print "##gff-version 3\n";
my $peak_idx = 0;
while (<>) {
  my ($ref,$start,$end,$score) = split;
  $ref =~ /^([IVX]+|MtDNA)$/ or next;
  # we will assume that bed lines use the proper zero-based, half open system

  my $group = "ID=peak".++$peak_idx.";Name=${source}_$peak_idx";
  print join("\t",$ref,$source,$type,$start,$end,$score,qw/. ./,$group), "\n";
 group on = source

GFF-based, multi-level features


I  my_big_thing    match      1     15000000 .      . . ID=Big_thing_I
I  my_little_thing match_part 1     1000     1.234  . . Parent=Big_thing_I;Name="Little_thing_1"
I  my_little_thing match_part 5001  6000     0.234  . . Parent=Big_thing_I;Name="Little_thing_1"
I  my_little_thing match_part 11000 12000    -2.234 . . Parent=Big_thing_I;Name="Little_thing_1"