In this exercise we will generate an html page for variant review using igv html links.
IGV can be controlled from an external program by writing commands to its port, 60151 by default. A subset of these commands are available via http “get” requests, which makes it possible to control IGV from a web page. In this exercise we will make use of “load” and “goto” commands to generate a page for manual review of variant sites.
The steps to generate the page are similar to generating the batch script. The shell of the web page is provided in the file "variantReview.html", we just need to generate the content. This will consist of a single link to load our bam file, followed by a "goto" link for each variant.
Example "load" URL
http://localhost:60151/load?file=http://www.broadinstitute.org/igvdata/annotations/hg18/conservation/pi.12mer.wig.tdf
Example "goto" URL
http://localhost:60151/goto?locus=1:63635328
NOTE: In the instructions below insert your Mac user name wherever you see <USER NAME>.
The first step is to make the bam file accessible by our web server. Do this by copying NA12878.SLX.sample.bam and NA12878.SLX.sample.bam.bai to your Sites folder.
"cd" to the data/snps folder.
cp NA12878.SLX.sample.bam ~/Sites/.
cp NA12878.SLX.sample.bam.bai ~/Sites/.
Note: Alternatively we could have setup virtual directories or symbolic links to avoid the copy.
The bam file should now be accessible with the url
http://localhost/~<USER NAME>/NA12878.SLX.sample.bam.
Make a backup of variantReview.html
cp variantReview.html variantReview.bak
Edit variantReview.html with a plain text editor (NOT TEXTEDIT) and replace the string YOUR_USERNAME_HERE with your user name. As an alternative to manually editing the file we can use "sed". For example, if your username were jrobinso
sed 's/YOUR_USERNAME_HERE/jrobinso/' variantReview.bak > variantReview.html
Before proceeding further lets verify that our load link works. First copy the modified variantReview.html file to your Sites folder to make it accessible to the web server
cp variantReview.html ~<USER NAME>/Sites/variantReview.html
Next start IGV. After IGV launches load the review page into a browser with the link
http://localhost/~<USER NAME>/variantReview.html
Click the “Load Bam File” link. The file should now be loaded in IGV.
The rest of the html will contain links to skip to each variant site. The procedure for generating these links is similar to that for batch file creation. In this case we need to convert VCF lines such as
1 63635328 . G A ...
to html anchor elements such as this
<a href="http://localhost:60151/goto?locus=1:63635328">1:63635328</a><br/>or the more informative
<a href="http://localhost:60151/goto?locus=1:63635328">1:63635328 G>A</a><br/>
This can be done with the magic one-liner
grep -v ^# variants.vcf | awk '{print "<a href=\"http://localhost:60151/goto?locus=" $1 ":" $2 "\">" $1 ":" $2 " " $4 ">" $5 "</a>"}' > tmp.txt
After executing the command above use a text editor copy and paste the contents of the tmp.txt file to variantReview.html in the place indicated (VARIANT LIST GOES HERE).
Copy the updated variantReview.html to the Sites folder
cp variantReview.html ~<USER NAME>/Sites/variantReview.html
Refresh the web page and use the links to control IGV.
Use the images generated in the batch exercise in place of the text links. For example
<a href=&34;http://localhost:60151/goto?locus=1:159461772"><img height="300" width="300" src="http://localhost/~<user name>/images/g.1:159461772_G%3ET.png"/></a><br/>
Note: you must move the images folder to Sites for this to work, i.e. from your home directory
mv images Sites