GBrowse2 provides a pretty nice feature that enables anonymous users to upload their own data and set up a custom, private track for visualization in the context of all the permanent, official tracks provided by the host. A wide variety of configuration options are available to customize the look, feel, and behavior of each individual data track. If you have administrative access to the genome browser, you can even adding Perl callback functions to configuration settings to enable dynamic calculation of each genomic feature’s color, shape (glyph), label, hover text, and click action. This is a powerful and flexible approach that enables a high level of customization and integration.
This week, I wanted to add feature-specific color-coding to my custom data track. My first attempt was to add callback functions to the
bgcolor configuration settings to calculate the feature’s color based on a discriminative GFF3 attribute. Unfortunately, scriptable configurations are not available for anonymous user tracks. This is undoubtedly for good reason (since allowing these would introduce significant security vulnerabilities), but this means I had to figure out another approach to color-coding.
The GBrowse mailing list suggested I encode a discriminative value in the “score” column of the (GFF3) data file and then use the
graded_segments glyph for rendering. This did indeed provide some color coding. However, the
graded_segments glyph only allows you to specify one base color, and modulating a feature’s score will only change the intensity or fill of that color, not the hue itself. I decided to look around a bit more, and discovered the
heat_map glyph. This glyph allows you to specify two colors. Then, the color for each feature is determined by the mapping of that feature’s score to the continuous spectrum between the two specified colors. I liked this approach much better, as it gave me a much larger palette with which to work.
For my final solution, I ended up setting each feature’s score to a discrete value between 0 and 1 (inclusive), and then adding the following settings to my track configuration.
glyph = heat_map min_score = 0 max_score = 1 start_color = red end_color = green
This turned out quite nicely. The value 0 maps to red, 0.25 maps to orange, 0.5 maps to yellow, 0.75 maps to a light green, and 1.0 maps to a darker true green.