Contents

1 Overview

The igvR package provides easy programmatic access in R to the web-based javascript library igv.js in order to create and display genome tracks in its richly interactive web browser visual interface. I am grateful to Jim Robinson, Douglass Turner and colleagues for their fine work.

In this vignette we present a few very simple uses of igvR:

Your display will look like this at the conclusion of this demo:

2 Load the libraries we need

library(igvR)

Create the igvR instance, with all default parameters (portRange, quiet, title). Javascript and HTML is loaded into your browser, igv.js is initialized, a websocket connection between your R process and that web page is constructed, over which subsequent commands and data will travel.

igv <- igvR()
setBrowserWindowTitle(igv, "simple igvR demo")
setGenome(igv, "hg38")

3 Display a list of the currently supported genomes

print(getSupportedGenomes(igv))

4 Display MYC

showGenomicRegion(igv, "MYC")

5 Create and display minimal 1-row data.frame centered below MYC on chr8

loc <- getGenomicRegion(igv)

tbl.bed <- data.frame(chrom=loc$chrom, start=loc$start + 2000, end=loc$end-2000,
                      name="simple.example", stringsAsFactors=FALSE)

track <- DataFrameAnnotationTrack("simple bed", tbl.bed, color="random")
displayTrack(igv, track)

6 Create and display a simulated quantitative (bedGraph) track

loc <- getGenomicRegion(igv)
size <- with(loc, 1 + end - start)
starts <- seq(loc$start, loc$end, by=5)
ends   <- starts + 5
values <- sample(1:100, size=length(starts), replace=TRUE)

tbl.bedGraph <- data.frame(chrom=rep("chr8", length(starts)), start=starts, end=ends,
                           value=values, stringsAsFactors=FALSE)

track <- DataFrameQuantitativeTrack("bedGraph", tbl.bedGraph, color="red", autoscale=FALSE,
                                    min=80, max=100)
displayTrack(igv, track)

7 Zoom out

loc <- getGenomicRegion(igv)
half.span <- round((loc$end-loc$start)/2)

new.region <- with(loc, sprintf("%s:%d-%d", chrom, start-half.span, end+half.span))
showGenomicRegion(igv, new.region)

8 Session Info

sessionInfo()
````