Skip to content

Commit

Permalink
Reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Aug 13, 2018
1 parent 3d50da2 commit d3c91c3
Show file tree
Hide file tree
Showing 4 changed files with 354 additions and 365 deletions.
72 changes: 46 additions & 26 deletions docs/site/config_advanced.md
Expand Up @@ -244,26 +244,11 @@ Also note: The "label" which is used in the text for mouseover will be used for

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"
Expand Down Expand Up @@ -338,18 +323,17 @@ Feature tracks can be configured to display a context menu of options when a use
             },
        ]
     }
```

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](#click-configuration-options "wikilink").

![800px|center|thumb|The context menu rendered from this example configuration.](assets/config/800px-Jbrowse_rightclick.png)

To add a separator, put the following item in your menuTemplate

`{ type: 'dijit/MenuSeparator' }`
{ 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",
Expand All @@ -365,14 +349,14 @@ Note that you can keep the default right-click menu items in JBrowse by just set
         "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.

![600px|center|thumb|The context menu with default items included.](assets/config/600px-Menu-customization2.png)
Expand All @@ -387,15 +371,13 @@ A click action (left-click on a feature or on an item in a context menu) can be

Or a structure containing options like:

~~~~ {.javascript}
{
"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:

Expand All @@ -414,16 +396,14 @@ The available options for a click action are:
- 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](#customizing-mouse-over-behavior "wikilink") for details on the mouse-over behavior.
- title: title used for the popup window

Using callbacks to customize feature tracks
-------------------------------------------
### 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.

~~~~ {.javascript}
{
"style" : {
"className" : "feature2"
Expand All @@ -440,3 +420,43 @@ Here is an example feature callback, in context in the trackList.json file, that
"label" : "ExampleFeatures",
"type" : "FeatureTrack"
},

## Configuring track locations with Apache

Files do not have to be in the default location. They can be in different locations, such as a mounted filesystem, using apache.
```
   <VirtualHost #:443>
       Alias /genomes /data/share/web_public/jbrowse_ucschg19/genomes
       Alias /ucschg19 /data/share/web_public/jbrowse_ucschg19/reference_data
   </VirtualHost>
```
and then your trackList.json
```
{
  "tracks" : [
     {
        "style" : {
           "className" : "generic_parent",
           "featureCss" : "background-color: #1400fa; height: 6px;",
           "histCss" : "background-color: #1400fa;"
        },
        "hooks" : {
           "modify" : "function(track, feat, elem) {\n    var fType = feat.get(\"Type\");\n    if (fType) {\n        elem.className = \"basic\";\n        switch (fType) {\n        case \"CDS\":\n        case \"thick\":\n            elem.style.height = \"10px\";\n            elem.style.marginTop = \"-3px\";\n            break;\n        case \"UTR\":\n        case \"thin\":\n            elem.style.height = \"6px\";\n            elem.style.marginTop = \"-1px\";\n            break;\n        }\n        elem.style.backgroundColor = \"#1400fa\";\n    }\n}\n"
        },
        "key" : "ucscGenePfam",
        "urlTemplate" : "/ucschg19/tracks/ucscGenePfam/{refseq}/trackData.json",
        "compress" : 0,
        "label" : "ucscGenePfam",
        "type" : "FeatureTrack",
       },
       {
         "label"         : "NAME_OF_STUDY_genomes",
         "key"           : "Name_of_study Genomes",
         "storeClass"    : "JBrowse/Store/SeqFeature/VCFTabix",
         "urlTemplate"   : "/genomes/NAME_OF_STUDY_genomes/{refseq}/NAME_OF_STUDY_{refseq}.vcf.gz",
         "tbiUrlTemplate": "/genomes/NAME_OF_STUDY_genomes/{refseq}/NAME_OF_STUDY_{refseq}.vcf.gz.tbi",
         "type"          : "JBrowse/View/Track/HTMLVariants",
         "noExport" : "true",
       },
```

0 comments on commit d3c91c3

Please sign in to comment.