Skip to content
Jim Robinson edited this page Aug 23, 2016 · 24 revisions

The singleton Browser object implements the API to the IGV application. The object is created by calling the function igv.createBrowser with two arguments: (1) The parent element (usually a div); the browser object will be inserted into the DOM as a child of this object, and (2) A JSON-like configuration object that defines the browser's initial state. Once created, the browser object is accessible via the global object igv.browser.

The example below initializes igv with the hg19 reference genome and a single annotation track, and also sets some default values for BAM tracks and the general track color palette.

    browser = igv.createBrowser(div, options);

    options = {
            reference: {
                id: "hg19",
                fastaURL: "//igv.broadinstitute.org/genomes/seq/1kg_v37/human_g1k_v37_decoy.fasta",
                cytobandURL: "//igv.broadinstitute.org/genomes/seq/b37/b37_cytoband.txt"
            },

            trackDefaults: {
                palette: ["#00A0B0", "#6A4A3C", "#CC333F", "#EB6841"],
                bam: {
                    coverageThreshold: 0.2,
                    coverageQualityWeight: true
                }
            },

            tracks: [
                {
                    name: "Genes",
                    url: "//igv.broadinstitute.org/annotations/hg19/genes/gencode.v18.collapsed.bed",
                    index: "//igv.broadinstitute.org/annotations/hg19/genes/gencode.v18.collapsed.bed.idx",
                    displayMode: "EXPANDED"
                }
            ]
        };

Initializing the browser configuration options

The object that configures the browser's initial state includes details for the reference genome, track default settings, the initial set of loaded tracks, and the initial view locus. It also controls some aspects of the user interface. Most fields are optional or have defaults.

Option Description Default
reference Object defining reference sequence. See object details below.
showKaryo If true, show a whole-genome karyotype view. false
showNavigation If true, show basic navigation controls (search, zoom in, zoom out). true
showRuler If true, show a genomic ruler track. true
tracks Array of configuration objects defining tracks initially displayed when app launches.
trackDefaults Embedded object defining default settings for specific track types (see table below).
locus Initial genomic location
flanking Distance (in bp) to pad sides of gene when navigating. 1000
search Object defining a web service for supporting search by gene or other annotation. See object details below. Optional
apiKey Google API key. Optional
doubleClickDelay Maximum between mouse clicks in milliseconds to trigger a double-click 500

reference object details

Option Description Default
id UCSC or other id string. Optional but recommended.
fastaURL URL to an indexed FASTA file. Required if id is not in the hosted list below
indexURL URL to a FASTA index (.fai file). Optional .fai
cytobandURL URL to a cytoband ideogram file in UCSC format. Optional
indexed Flag indicating if the FASTA is indexed. Optional true

Hosted genomes. FASTA, index, and cytoband URLs can be ommitted for genomes in this list.

  • id = "hg19"
  • id = "hg18"

search object details

The search object defines a webservice for fetching genomic location given a gene name or other symbol. The service should return a JSON object with the following structure. The results array is an array of objects with a chromosome, start, and end field. The names of these fields are specified in the configuration object.

{
  <resultsField> : <array of results>
}
Option Description Default
url URL to search service. The URL should include the string $FEATURE$. This string will be replaced by the symbol being queried.
resultsField JSON field name for property containing the array of results. Treats the response as an array of results.
coords Indicates genomic coordinate convention used. Possible values are 0 and 1 1
chromosomeField JSON field name for the chromosome property chromosome
startField JSON field name for the start position property start
endField JSON field name for the end position property end

The results array contain objects with chromosome, start, and end fields named as specified above. The type of the chromosome field is string, the type of start and end fields is integer.

E.g. a search for TP53 against hg19 using the defaults should look like this:

[{"chromosome":"chr17","start":7572927,"end":7579912}]

Clone this wiki locally