Additional customizations to the pop-up boxes In JBrowse 1.11.5, some additional customizations to the pop-up boxes were added. 1. The ability to access the feature data was added to the callback signature of the fmtDetailValue_* functions. Example: fmtDetailValue_Name = function(name, feature) { /* only add links to the top-level feature */ if(feature.get('type')=='mRNA') { return name + ' [
2. The ability to customize the 'About track' popups was added. These callbacks are named fmtMetaValue_* and fmtMetaField_* 3. The ability to customize mouseover descriptions of the fieldnames was also added. These callbacks are named fmtDetailDescription_* and fmtMetaDescription_* 4. The ability to remove a field from the popup was added. You can do this by returning null from a fmtDetailField_* and fmtMetaField_* callback;
Customizing Left-click Behavior Beginning with JBrowse 1.5.0, the left-clicking behavior of feature tracks (both HTMLFeatures and CanvasFeatures) is highly configurable. To make something happen when left-clicking features on a track, add an onClick option to the feature track's configuration. In the example configuration below, left-clicks on features will open an embedded popup window showing the results of searching for that feature's name in NCBI's global search, and "search at NCBI" will show in a tooltip when the user hovers over a feature with the mouse: "tracks": [ { "label" : "ReadingFrame", "category" : "Genes", "class" : "dblhelix", "key" : "Frame usage", "onClick" : { "label": "search at NCBI", "url": "http://www.ncbi.nlm.nih.gov/gquery/?term={name}" } } ...
For details on all the options supported by onClick, see Click Configuration Options. Note: the styleÕlinkTemplate variable can also be used to specify a URL for left-click on features, but this is a legacy option.
Customizing Mouse-over behavior The onClick->label attribute from the previous section is used as the mouse-over description for features on the HTMLFeatures and CanvasFeatures tracks. In JBrowse 1.11.6, the onClick->label attribute was extended further to allow the mouse-over description to be customized using callbacks and template strings. Example for CanvasFeatures, allows full HTML tooltips. Here the {name} template is automatically filled in with the feature info:
Example for HTMLFeatures, which only allows plain text descriptions but can support newlines (essentially uses
for mouseover). "onClick": { "label": "Feature name {name}\nFeature start {start}\nFeature end {end}", "title" : "{name} {type}", "action": "defaultDialog" }
Example using a callback (for either HMTLFeatures or CanvasFeatures), using this.feature to access the feature details
"onClick": { "label": "function() { return 'Feature name: '+this.feature.get('name'); }", "title" : "{name} {type}", "action": "defaultDialog" }
Note: on CanvasFeatures, the action "defaultDialog" isn't necessary, but it is necessary for HTMLFeatures to keep the default dialog (as of writing, 1.11.6). Also note: The "label" which is used in the text for mouseover will be used for the title of any popup by default, so you might also specify a different title. Also also note: Your mouseover will crash if your features do not have an ID or name, even if you coded the mouseover to not use ID or name.
Configuring Summary Histograms Canvas-based feature tracks (CanvasFeatures) support an optional histograms configuration subsection that can contain a definition for a second datastore that holds quantitative data (usually either coverage depth or feature density) to be displayed when zoomed further out than featureScale (or if featureScale is not set, the scale determined by the store's feature density divided by maxFeatureScreenDensity). This is often used for BAM coverage on Alignments2 tracks using the histograms.urlTemplate and histograms.storeClass arguments. Example track [ tracks.mytrack ] histograms.storeClass = JBrowse/Store/SeqFeature/BigWig histograms.urlTemplate = coverage.bw storeClass = JBrowse/Store/SeqFeature/BAM urlTemplate = file.bam type = Alignments2
Customizing Right-click Context Menus Feature tracks can be configured to display a context menu of options when a user right-clicks a feature item. Here is an example of a track configured with a multi-level right-click context menu: { "feature" : [ "match" ], "track" : "Alignments", "category" : "Alignments", "class" : "feature4", "key" : "Example alignments", "hooks": { "modify": "function( track, feature, div ) { div.style.height = (Math.random()*10+8)+'px'; div.style.backgroundColor = ['green','blue','red','orange','purple'][Math.round(Math.random()*5)];}" }, "menuTemplate" : [ { "label" : "Item with submenu", # hello this is a comment "children" : [ { "label" : "Check gene on databases", "children" : [ { "label" : "Query trin for {name}", "iconClass" : "dijitIconBookmark", "action": "newWindow", "url" : "http://wiki.trin.org.au/{name}-{start}-{end}" }, { "label" : "Query example.com for {name}", "iconClass" : "dijitIconSearch", "url" : "http://example.com/{name}-{start}-{end}" } ] }, { "label" : "2nd child of demo" }, { "label" : "3rd child: this is a track" } ] }, { "label" : "Open example.com in an iframe popup", "title" : "The magnificent example.com (feature {name})", "iconClass" : "dijitIconDatabase", "action": "iframeDialog", "url" : "http://www.example.com?featurename={name}" }, { "label" : "Open popup with XHR HTML snippet (btw this is feature {name})", "title": "function(track,feature,div) { return 'Random XHR HTML '+Math.random()+' title!'; }", "iconClass" : "dijitIconDatabase", "action": "xhrDialog", "url" : "sample_data/test_snippet.html?featurename={name}:{start}-{end}" }, { "label" : "Open popup with content snippet (btw this is feature {name})", "title": "function(track,feature,div) { return 'Random content snippet '+Math.random()+' title!'; }", "iconClass" : "dijitIconDatabase", "action": "contentDialog", "content" : "function(track,feature,div) { return '
{name}
This is some test content about feature {name}!
This message brought to you by the number '+Math.round(Math.random()*100)+'.
}, { "label" : "function(track,feature,div) { return 'Run a JS callback '+Math.random()+' title!'; }", "iconClass" : "dijitIconDatabase", "action": "function( evt ){ alert('Hi there! Ran the callback on feature '+this.feature.get('name')); }" }, { "label": "Create a url with a callback", "action": "iframeDialog", "iconClass": "dijitIconDatabase", "title": "Create a url with a callback", "url": "function(track,feature) { return 'http://www.example.com?refseq='+track.refSeq.name +'&featurename='+feature.get('name')+'&start='+feature.get('start')+'&end='+feature.get('end'); }" }, ] }
This configuration results in a context menu like the one pictured below. For details on what each of the options supported by menu items does, see #Click Configuration Options.
The context menu rendered from this example configuration.
To add a separator, put the following item in your menuTemplate { type: 'dijit/MenuSeparator' }
Note that you can keep the default right-click menu items in JBrowse by just setting "blank" placeholders in the menuTemplate.
"menuTemplate" : [ { "label" : "View details", }, { "label" : "Highlight this gene", }, { "label" : "Open example.com in an iframe popup", "title" : "The magnificent example.com (feature{name})", "iconClass" : "dijitIconDatabase", "action": "iframeDialog", "url" : "http://www.example.com?featurename={name}" } ]
Alternatively, if you are using tracks.conf format, you can build a menuTemplate similar to the above configuration using the following: menuTemplate+=json:{"label": "View details"} menuTemplate+=json:{"label": "Highlight this gene"} menuTemplate+=json:{"label": "Open example.com in an iframe popup", "iconClass" : "dijitIconDatabase","action": "iframeDialog","url" : "http://www.example.com?featurename={name}"}
This results in a context menu like the one pictured below.
The context menu with default items included.
Note: You'll note in the above that "placeholder" menu items are put in place to prevent the default "View details" from being overwritten. There are some caveats with regards to these placeholder items. You can't rearrange them or choose which ones you want. You can only overwrite them. Custom items will overwrite the default ones one-by-one.
Click Configuration Options A click action (left-click on a feature or on an item in a context menu) can be configured to do nearly anything. It can be configured with a string JavaScript callback, like: "function( track, feature, featureDiv ) { alert('Run any JavaScript you want here!'); }"
Or a structure containing options like: { "iconClass" : "dijitIconDatabase", "action" : "iframeDialog", "url" : "http://www.ncbi.nlm.nih.gov/gquery/?term={name}", "label" : "Search for {name} at NCBI", "title" : "function(track,feature,div) { return 'Searching for '+feature.get('name')+' at NCBI'; }" }
The available options for a click action are: iconClass Used only for click actions in context menus. Usually, you will want to specify one of the Dijit icon classes here. Although they are not well documented, a list of available icon classes can be seen at https://github.com/dojo/dijit/blob/1.7.2/icons/commonIcons.css. action Either a JavaScript function to run in response to the click (e.g. "function(){..}"), or one of the following special strings: "iframeDialog" - the default - causes the given url to be opened in a popup dialog box within JBrowse, in an iframe element. "newWindow" - causes the given url to be opened in a new browser window. "navigateTo" - added in JBrowse 1.10.8, opens the given url in the same browser window, navigating the user away from JBrowse. "contentDialog" - causes the JavaScript string or callback set in the content option to be displayed in the dialog box. "defaultDialog" - Performs the normal popup action. See JBrowse_Configuration_Guide#Customizing_Mouse-over_behavior for an example of when this is useful. "xhrDialog" - causes the given url to be opened in a popup dialog, containing the HTML fetched from the given url option. The difference between "iframeDialog" and "xhrDialog" is that an iframeDialog's URL should point to a complete web page, while an xhrDialog's URL should point to a URL on the same server (or that supports CORS) that contains just a snippet of HTML (not a complete web page). For those familiar with GBrowse, the xhrDialog is similar to GBrowse popup balloons that use a url:... target, while the contentDialog is similar to a GBrowse popup balloon with a normal target. GBrowse does not have an equivalent of the iframeDialog.] "Javascript callback" - If you use a javascript callback for the action parameter, then the function signature will be function(clickEvent) { ... } and the clickEvent doesn't contain particularly useful info, but you can access the feature object using this.feature.get('name'); for example. content string (interpolated with feature fields) or JS callback that returns either a string or (beginning in 1.10.0) a dojo/Deferred object that will resolve to a string. Used only by a contentDialog. url URL used by newWindow, xhrDialog, or iframeDialog actions. label descriptive label for the link. In a right-click context menu, this will be the text in the menu item. In a onClick section, it will be the mouse-over description too. See JBrowse_Configuration_Guide#Customizing_Mouse-over_behavior for details on the mouse-over behavior. title title used for the popup window
Using callbacks to customize feature tracks JBrowse feature tracks, and individual JBrowse features, can be customized using JavaScript functions you write yourself. These functions are called every time a feature in a track is drawn, and allow you to customize virtually anything about the feature's display. What's more, all of the feature's data is accessible to your customization function, so you can even customize individual features' looks based on their data. As of JBrowse 1.3.0, feature callbacks are added by directly editing your trackList.json file with a text editor. Unfortunately, due to the limitations of the JSON format currently used for JBrowse configuration, the function must appear as a quoted (and JSON-escaped) string, on a single line. You may use the .conf format for the ability to specify functions that span multiple lines. Here is an example feature callback, in context in the trackList.json file, that can change a feature's background CSS property (which controls the feature's color) as a function of the feature's name. If the feature's name contains a number that is odd, it give the feature's HTML div element a red background. Otherwise, it gives it a blue background. { "style" : { "className" : "feature2" }, "key" : "Example Features", "feature" : [ "remark" ], "urlTemplate" : "tracks/ExampleFeatures/{refseq}/trackData.json", "hooks": { "modify": "function( track, f, fdiv ) { var nums = f.get('name').match(/\\d+/); if( nums && nums[0] % 2 ) { fdiv.style.background = 'red'; } else { fdiv.style.background = 'blue'; } }" }, "compress" : 0, "label" : "ExampleFeatures", "type" : "FeatureTrack" },
Alignment Tracks (BAM) JBrowse has several track types that are designed for displaying alignment data, particularly from BAM files. BAM files used with JBrowse must be compressed and sorted by leftmost coordinate. The JBrowse BAM parsing library makes extensive use of code from BioDalliance (http://www.biodalliance.org/).
Alignments2 Introduced in JBrowse 1.8.0, Alignments2 tracks are designed to display alignment data, such as from BAM files. This track type shows basepair-level mismatches, insertions, deletions, and skipped regions between aligned reads and the reference, and highlights paired reads in red if their mates are missing. Base mismatches are displayed based on the contents of the feature's MD field (containing a BAM MD mismatch string), and/or CIGAR field. If your BAM file does not contain MD tags, one common way to generate them is with the samtools calmd command. Alignments2 is a faster implementation of the older Alignments track type that draws alignments using the HTML5 canvas. In the interest of speed, Alignments2 tracks do not display any text labels or descriptions alongside features, and do not draw arrowheads indicating strandedness, instead relying on color to denote the strand of alignments. Alignments2 tracks support the same advanced clicking behavior as CanvasFeatures tracks, but does not support right-click menus.
The most basic Alignments2 track configuration in tracks.conf format is [tracks.alignments] urlTemplate=FM.01.new.sorted.chr11.bam type=Alignments2
The most basic track configuration in trackList.json format is
{ "label": "alignments", "urlTemplate": "FM.01.new.sorted.chr11.bam", "type": "Alignments2" }
Note that this uses several tricks, including automatically inferring track type to be JBrowse/View/Track/Alignments2 from just saying Alignments2 (it could have also said "type": "JBrowse/View/Track/Alignments2", and it also infers the storeClass to be JBrowse/Store/SeqFeature/BAM. You can use "storeClass": "JBrowse/Store/SeqFeature/BAM" for completeness. Not all track types infer the storeClass. List of configuration options: Alignments2 track configuration options
Option
Value
maxHeight
Available in JBrowse 1.9.0 and later. Maximum displayed height of the track in pixels. Defaults to 1000. Features that would cause the track to grow taller than the maxHeight are not shown. If a section of a track has features that are not drawn because of a maxHeight constraint, a notification is displayed at the bottom of that track section.
styleÕcolor
HTML-style color for drawn alignments. By default, this varies with the alignment's strandedness, and whether its mate pair is missing, using the styleÕcolor_fwd_strand, styleÕcolor_rev_strand, and styleÕcolor_missing_mate variables. To gain complete control over the displayed color, you could set this to be a function callback.
styleÕcolor_fwd_strand
HTML-style color for alignments on the forward strand. Default #EC8B8B, which is a light red.
styleÕcolor_rev_strand
HTML-style color for alignments on the reverse strand. Default #898FD8, which is a light blue.
styleÕcolor_missing_mate
HTML-style color for alignments with a missing mate. Default #D11919, which is a dark red.
styleÕheight
Height in pixels of each alignment. Default 7.
styleÕmarginBotton
Number of pixels of vertical spacing to put on the bottom of each alignment. Default 1.
styleÕshowMismatches
If true, draw mismatches (SNPs, insertions, deletions, skips) on the alignent. Default true.
styleÕmismatchFont
CSS string describing the font to use for labeling mismatches. Default "bold 10px Courier New,monospace".
histograms.storeClass
A store class for summary histograms used for the Alignments2 track. Usually JBrowse/Store/SeqFeature/BigWig. Can be used on any CanvasFeatures-type track but generally used in Alignments2 tracks
histograms.urlTemplate
Path to a histogram file (such as a BigWig) to be used for summary histograms used for the Alignments2 track. Can be used on any CanvasFeatures-type track but generally used in Alignments2 tracks
histograms.color
Color for the histograms e.g. "purple". Default is orange. Can be used on any CanvasFeatures-type track but generally used in Alignments2 tracks
histograms.binsPerBlock
"Granularity" of the bins in histogram. Default is 200 for Alignments2 tracks. Default is 25 on other CanvasFeatures type tracks.
hideDuplicateReads
Hide duplicate reads to the same location. Default: true
hideQCFailingReads
Hide QC failing reads that did not pass some aligner quality. Default: true
hideSecondary
Hide secondary reads which mapped to multiple locations. Default: true
hideUnmapped
Hide unmapped reads. Default: true
hideMissingMatepairs
If a read is missing a mate pair or paired-end match, hide the read. Default: false
hideForwardStrand
Hide all reads from the forward strand. Default: false
hideReverseStrand
Hide all reads from the reverse strand. Default: false
useReverseTemplate
Use an algorithm for reversing the template of paired-end reads so that they appear on the same strand. Default: false. Added in 1.11.6
useReverseTemplateOption
Present a checkbox to the user for changing the "Use reverse template" option. Default: true. Added in 1.11.6
useXS
Use an algorithm for only coloring reads when the XS tag indicates strandedness. Default: false. Added in 1.11.6
useXSOption
Present a checkbox to the user for changing the "Use XS" option. Default: true. Added in 1.11.6
cacheMismatches
Cache mismatch calculations so that long reads are faster to browser. Default: false. Added in 1.12.3
renderAlignments
Add a text display of the BAM alignment on a single line in the View details popup. Default: false
renderPrettyAlignments
Add a text display of the BAM alignment using prettier "BLAST style" to the View details popup. Default: false
Alignments2 coloring schemes Since JBrowse 1.11.3, there is a new coloring scheme for BAM files that allows for new coloring of paired end reads, such as a different coloring for unpaired reads and aberrant pairing split across chromosomes. The coloring styles that can be configured for the Alignments2 track are as follows Alignments2 track configuration options
Option styleÕcolor_fwd_strand
#EC8B8B (original red)
styleÕcolor_rev_strand
#8F8FD8 (original blue)
styleÕcolor_fwd_missing_mate
#D11919 (hard red)
styleÕcolor_rev_missing_mate
#1919D1 (hard blue)
styleÕcolor_fwd_strand_not_proper
#ECC8C8 (light red)
styleÕcolor_rev_strand_not_proper
#BEBED8 (light blue)
styleÕcolor_fwd_diff_chr
#000000 (black)
styleÕcolor_rev_diff_chr
#969696 (gray)
styleÕcolor_nostrand
#999999 (gray) Added in 1.11.6
If this scheme is undesirable, the style->color variable can be overridden entirely as well, with a callback for example
SNPCoverage Introduced in JBrowse 1.8.0, SNPCoverage tracks draw the coverage of alignment features along the genome, along with a graphical representation of base-mismatch (possible SNP) distribution, and tables showing frequencies for each mismatching base. Like the other alignment tracks, base mismatches are displayed based on the contents of the feature's MD field (containing a BAM MD mismatch string). Note: Since the SNPCoverage track dynamically calculates coverage and putative SNPs directly from alignment data, it is not recommended for use with very dense feature data, such as deep-coverage BAM files. For these types of files, it's recommended to pre-generate a BigWig file of the coverage and a VCF file of putative SNPs, and display those instead.
A SNPCoverage track with corresponding Alignments2 track.
Example SNPCoverage Configuration In your data/tracks.conf file: [tracks.my-bam-coverage-track] storeClass = JBrowse/Store/SeqFeature/BAM urlTemplate = volvox-sorted.bam type = JBrowse/View/Track/SNPCoverage metadata.Description = SNP/Coverage view of volvox-sorted.bam, simulated resequencing alignments. key = BAM - volvox-sorted SNPs/Coverage
Note that urlTemplate will refer to a file relative to the "data" directory that you are using.
Alignments Introduced in JBrowse 1.7.0, Alignments tracks are an HTML-based track type for alignment display. They display everything that Alignments2 do, and also can be configured with right-click menus and strand arrowheads. They display everything that Alignments2 tracks do, plus they support the same configuration options as feature tracks, including advanced clicking behavior, feature modification callbacks, and so forth. The price of this additional capability is that Alignments tracks are significantly slower when used with dense data such as deep BAM alignments. Alignments2 is recommended over Alignments for most users.
BAM Data Configuration Options BAM storage configuration options Option
Value
urlTemplate
URL for the BAM file to display.
baiUrlTemplate
URL for the corresponding BAM index (BAI) file. If not set, this is assumed to be the same URL as urlTemplate with .bai appended.
chunkSizeLimit
Maximum size in bytes of BAM chunks that the browser will try to deal with. Default 5000000 (5 MiB). When this is exceeded, most tracks will display some kind of "Too much data" message. If you increase this, be careful. You could blow up your web browser.
Note: you can also increase maxFeatureScreenDensity if you get the "Too much data to show; zoom in to see detail".
Example BAM Alignments2 track configuration { "storeClass" : "JBrowse/Store/SeqFeature/BAM", "urlTemplate" : "../../raw/volvox/volvox-sorted.bam", "label" : "volvox-sorted.bam", "type" : "JBrowse/View/Track/Alignments2" },
Apache Configuration Note If you are using the Apache web server, please be aware that the module mime_magic can cause BAM files to be served incorrectly. Usually, the error in the web developer console will be something like "Not a BAM file". Some packaged versions of Apache, particularly on Red Hat or CentOS-based systems, are configured with this module turned on by default. We recommend you deactivate this Apache module for the server or directory used to serve JBrowse files. If you do not want to deactivate this module for the entire server, try adding this line to your HTTPD config or .htaccess file: AddType application/octet-stream .bam .bami .bai
Wiggle/BigWig Tracks (XYPlot, Density) Introduced in JBrowse 1.5.0, Wiggle tracks require that the user's browser support HTML