IGV provides functionality that allows a user to create a script to take screenshots of regions of interest.
- Requirements
- Workflow
- Create BED File
- bedToIgv
- Load IGV Session
- Optional: Save IGV Session
- Run Batch Script
- Screenshots Across Multiple BAM Files
- Additional Information
- Create a bed file of regions of interest
- Use
bedToIgv
to convert the bed file into an IGV batch script - Open IGV and load the files that you want to visualize
- Run the IGV batch script
The easiest way to define the regions of interest is to create a BED file of the regions. IGV will navigate to the exact coordinates in the bed file. Often you will want to pad the regions for visualization. You can either pad the BED records directly or use the bedToIgv
script below to pad the records.
Example:
chr1 25158688 25161509
chr1 26489813 26490138
chr1 27935352 27935513
chr1 28247800 28248108
chr1 31575066 31577331
chr1 35101422 35111976
After creating the BED file, the bedtools igv
(bedToIgv
) tool can be used to convert the bed file into an IGV batch script. At a minimum, you should supply a BED file to bedToIgv
, but you may want to specify an output directory (-path), how to sort the screenshot (-sort), or how much padding to add to the records (-slop).
Usage:
Tool: bedtools igv (aka bedToIgv)
Version: v2.21.0
Summary: Creates a batch script to create IGV images
at each interval defined in a BED/GFF/VCF file.
Usage: bedtools igv [OPTIONS] -i <bed/gff/vcf>
Options:
-path The full path to which the IGV snapshots should be written.
(STRING) Default: ./
-sess The full path to an existing IGV session file to be
loaded prior to taking snapshots.
(STRING) Default is for no session to be loaded.
-sort The type of BAM sorting you would like to apply to each image.
Options: base, position, strand, quality, sample, and readGroup
Default is to apply no sorting at all.
-clps Collapse the aligned reads prior to taking a snapshot.
Default is to no collapse.
-name Use the "name" field (column 4) for each images filename.
Default is to use the "chr:start-pos.ext".
-slop Number of flanking base pairs on the left & right of the image.
- (INT) Default = 0.
-img The type of image to be created.
Options: png, eps, svg
Default is png.
Notes:
(1) The resulting script is meant to be run from within IGV.
(2) Unless you use the -sess option, it is assumed that prior to
running the script, youve loaded the proper genome and tracks.
Example:
[dfj@helium]~/>bedToIgv -path ./examples -slop 100 -i example.bed > example.batch
[dfj@helium]~/>cat example.batch
snapshotDirectory ./examples
goto chr1:25158588-25161609
snapshot chr1_25158688_25161509_slop100.png
goto chr1:26489713-26490238
snapshot chr1_26489813_26490138_slop100.png
goto chr1:27935252-27935613
snapshot chr1_27935352_27935513_slop100.png
goto chr1:28247700-28248208
snapshot chr1_28247800_28248108_slop100.png
goto chr1:31574966-31577431
snapshot chr1_31575066_31577331_slop100.png
goto chr1:35101322-35112076
snapshot chr1_35101422_35111976_slop100.png
The IGV batch script is run within IGV. Load the bam, vcf, and BED files that you want to visualize.
It is possible to load a saved IGV session, although in the past I have found this to sometimes behave erratically. This is useful if you are interested in creating screenshots from multiple bam files in the same script.
Once you have the window in the desired form, you can run the batch script. Under the "Tools" menu select "Run Batch Script..."
It is also possible to take screenshots across several files by loading them sequentially in the batch file, but bedToIgv
does not support this. In this case the IGV batch script should be created directly. The following example takes a screenshot of the BRCA1 region across three bam files:
new
snapshotDirectory /path/to/screenshot/directory
load /path/to/bam1/bam1.bam
goto chr17:41194312-41279500
snapshot bam1.BRCA1.png
new
load /path/to/bam2/bam2.bam
goto chr17:41194312-41279500
snapshot bam2.BRCA1.png
new
load /path/to/bam3/bam3.bam
goto chr17:41194312-41279500
snapshot bam3.BRCA1.png
Additional information can be found on the IGV website
If you want to modify the screenshot in a way that is not available using the bedToIgv tool, a list of available commands can be found here. These commands can be added directly to the IGV batch script.
hey , when I am using this script on windows, I can see that snapshots are taken but I can't find them in snapshotDirectory. Where are they stored ultimately ?