IGV Tutorial -- GVA2020
Overview
The Integrative Genomics Viewer (IGV) from the Broad Center allows you to view several types of data files involved in any NGS analysis that employs a reference genome, including how reads from a dataset are mapped, gene annotations, and predicted genetic variants.
Learning Objectives
- Create a custom genome database (usually used for microbial genomes).
- Load a pre-existing genome assembly (usually used for the genomes of model organisms and higher Eukaryotes).
- Load output from mapping reads to a reference genome.
- Load output from calling genetic variants.
- Navigate the view of the genome and interpret the display of this data.
Theory
Because NGS datasets are very large, it is often impossible or inefficient to read them entirely into a computer's memory when searching for a specific piece of data. In order to more quickly retrieve the data we are interested in analyzing or viewing, most programs have a way of treating these data files as databases. Database indexes enable one to rapidly pull specific subsets of the data from them.
The Integrative Genomics Viewer is a program for reading several types of indexed database information, including mapped reads and variant calls, and displaying them on a reference genome. It is invaluable as a tool for viewing and interpreting the "raw data" of many NGS data analysis pipelines.
With all that being said, the goal of visualizing the data with IGV is not to look at every read, or even every base in the reference genome (which is actually the smaller of the 2 possibilities!). IGV works best to dig deeper on something that you already are interested in either because of what gene it is, or is something that seems confusing (ie trying to figure out why mapping quality declines for a particular variant), or are trying to familiarize yourself with the concepts of what is going on.
Installing IGV
This is done on your local computer not on TACC. IGV can not be installed on TACC which should make some sense to you as IGV is a program designed to let you visualize information and we know TACC doesn't allow GUIs.
There are multiple ways to launch IGV on a local computer. For this course I recommend in a separate a web browser window/tab going to: http://www.broadinstitute.org/software/igv/download and selecting the appropriate operating system. Mac users will need to unzip the file and launch the application. Window's users will need to download, choose an installation location, agree to some licenses, navigate to your installation location and then launch the program. Believe it or not, this is a significantly improved process compared to actions that used to be required.
Viewing E. coli data in IGV
Data files
You can start this tutorial two ways:
If you have completed the Mapping tutorial and the SNV calling tutorial, then you should use those files for part 1 of this tutorial. You can proceed with either one alone, or with both.
I strongly encourage everyone to complete these tutorials rather than relying on the canned data. I routinely work with raw fastq files, map them, and call variants on them. Outside of this course I use IGV maybe 1 time a year, and I don't think I'm an uncommon case.
Prepare a GFF feature file for the reference sequence
IGV likes its reference genome files in GFF (Gene Feature Format). Unfortunately, our old friend bp_seqconvert.pl
doesn't deal with GFF. So, we're going to show you another tool for sequence format conversion called Readseq. We've already installed it into the $BI/bin directory so you don't have to, but here we provide the steps that can be used to install it in a local directory.
Readseq is written in java which makes it a little more complicated to use, but the general command to run the software is one of these (note that you do need to include the entire path, not just the "readseq.jar" command name):
java -jar /corral-repl/utexas/BioITeam/bin/readseq.jar java -cp /corral-repl/utexas/BioITeam/bin/readseq.jar run
This should return the help for Readseq.
Explaining the long invocation
You are actually using the command java
and telling it where to find a "jar" file of java code to run. The -jar
and -cp
options run it in different ways. It is important to learn that java executables (.jar files) always require specifying the full path to the executable. In tomorrows final lecture we'll cover how you can work around this so you can build your own shortcuts and not have to remember where all your .jar files are stored (can be particularly difficult if you store them in different places (like some in your $HOME/local/bin directory, and some in various BioITeam directories.
To do the conversion that we want, use this command:
cds mkdir GVA_IGV_Tutorial cd GVA_IGV_Tutorial java -cp /corral-repl/utexas/BioITeam/bin/readseq.jar run $SCRATCH/GVA_bowtie2_mapping/NC_012967.1.gbk -f GFF -o NC_012967.1.gbk.gff
It's a bit hard to figure out because, unlike most conventions, it takes the unnamed arguments before the optional flag arguments, there is no example command, and you have to switch -jar
to -cp
. Search online for usage examples when you can't figure something out from the help. Take a look at the contents of the original Genbank file and the new GFF file and try to get a handle on what is going on in this conversion using commands like head and tail.
Copy files to your local computer
Again, since IGV is an interactive graphical viewer program that we'll be running on our local computer, we need to get the files we want to visualize onto your desktop machine.
The files we need include:
- Indexed reference FASTA files
- GFF reference sequence feature files
- Sorted and indexed mapped read BAM files
- VCF result files
- Depending on your analysis you may need or can use additional files but those won't be discussed here
Rather than transferring each file individually, from multiple different directories, the easiest (and most common, and best practice) thing to do is:
- create a new directory (suggest you include a keyword like export)
- copy all the files you want to transfer into the new directory
- compress the directory to speed up the transfer
In the case of this tutorial, since many of the tutorial output files had the same names (but resided in different directories) we need to be sure to give them unique destination names when you copy them into the new directory together. Additionally, to ensure you don't overwrite files that you want (here is another reminder about there being no undo command in linux) you can (and is good practice to) use the -n or -i option with the cp command. On ls5 the -n command will not allow you to overwrite files, while the -i command will prompt you before overwriting anything. It is worth noting that there is a slight difference in different versions of linux/bash that with these command options and they may not work on all systems so double check with the help flag before using it.
cds mkdir GVA_IGV_export cp -i $SCRATCH/GVA_IGV_Tutorial/NC_012967.1.gbk.gff GVA_IGV_export # this is the new file you just created above cp -i $SCRATCH/GVA_bowtie2_mapping/NC_012967.1.fasta GVA_IGV_export cp -i $SCRATCH/GVA_samtools_tutorial/NC_012967.1.fasta.fai GVA_IGV_export cp -i $SCRATCH/GVA_samtools_tutorial/SRR030257.vcf GVA_IGV_export cp -i $SCRATCH/GVA_samtools_tutorial/SRR030257.sorted.bam GVA_IGV_export/bowtie2.sorted.bam cp -i $SCRATCH/GVA_samtools_tutorial/SRR030257.sorted.bam.bai GVA_IGV_export/bowtie2.sorted.bam.bai tar -czvf GVA_IGV_export.tar.gz GVA_IGV_export
Now, copy the entire compressed IGV directory back to your local Desktop machine. Remember there is a separate tutorial that covers scp file transfers in more detail that can be found here. In this case, you would replace README in that tutorial with GVA_IGV_export.tar.gz and need to determine the full path to that file using the pwd command.
Once you have transferred the compressed file, you will need to expand the file on your local machine so that you can access the individual files in IGV.
tar -xzvf GVA_IGV_export.tar.gz
For the remainder of the tutorial, work on your local machine. NOT TACC!
Load genome into IGV
Screens may differ slightly than images show
Most of the differences will be trivial differences between windows and mac versions, or difficulties in getting the identical level of zoom in/out on the genome, but there may be some that are important and impact learning. If you are unclear if the difference is important get my attention on zoom and we'll work through it.
From the main window of IGV, click on Genomes > Create .genome File... and you should be presented with the following window that you can fill out with information specific to your system.
Enter the ID and Name of the Genome you are working with (these can be anything that makes sense to you) and select the path to your *.fasta file (the index, *.fai file must be in the same directory), then select the path to your *.gff file for the Gene File. Click OK and then save this *.genome file inside the same folder as your data.
Load mapped reads into IGV
From the main window of IGV, click on File > Load from File.... Choose bowtie2.sorted.bam
After importing your reference genome and loading an alignment file, click on the + button in the upper right until reads appear! Then, your screen should look similar to the following:
Load variant calls into IGV
We're really interested in places in the genome where we think there are mutations. In the Variant calling tutorial we identified such locations but lacked a good way to visualize them. This is your opportunity to visualize them. We have already transferred the SRR030257.vcf
file back to your local computer, but before we can visualize them, we need to (guess what?) index it. To answer some common questions:
To answer some common questions:
- Yes this index is different than the index you made for the reference genome.
- Yes it is different than the index you made of the sam files.
- Yes it is different than the index you made of the sorted bam files.
- Yes this is confusing.
- No there was nothing that required 4 different programs/groups to call this by the same name.
- Yes there are more than 4 different types of indexes you may encounter.
Getting back to our tutorial, you can create your new index from within IGV:
- Choose Tools > Run igvtools....
- Choose "index" from the commands drop-down menu.
- Select the
SRR030257.vcf
file for "Input File" - Click the "run" button.
It will look like nothing has happened aside from the appearance of "Done" in the messages box, but you can now close the "Run" window and choose File > Load from File. If you navigate to your IGV directory, you will now see a brand new SRR030257.vcf.idx
file. You can now load the SRR030257.vcf
file, and it will show up as a new track near the top of your window.
Tip: You can also index BAM and FASTA files the same way inside of IGV if you haven't already created indexes for them. But, it's usually easier and quicker to do this on the command line at TACC as indexing BAM files in particular can be a computationally hefty task.
You are now free to investigate different areas and their alignments in the genome.
Navigating in IGV
There are a lot of things you can do in IGV. Here are a few:
- Zoom in using the slider in the upper right. Do this until you see mapped reads and finally individual bases appear.
- Navigate by clicking and dragging in the window. This is how you move left and right along the genome.
- Navigate more quickly. Use
page-up
page-down
,home
,end
. - Jump to the next point of interest. Click on a track name on the left side of the window (Ex: SRR030257.vcf), to select it. You can then use
control-f
andcontrol-b
to jump forward and backward within that list of features. Try this on the variant calls track to jump to regions of interest. - Jump right to a gene. (If you have gene features loaded.) Type its name into the search box. Try "topA".
- Load multiple BAM alignments or VCF files at once. You can use this feature to compare different mappings of bowtie2 and bowtie2 with improved quality reads, or different filtering options from the SNV tutorial.
- Change the appearance of genes. Right click on the gene track and try "expanded". Experiment with the other options.
- Change the appearance of reads. Right click on a BAM track and choose "show all bases" and "expanded". Experiment with the other options.
See the IGV Manual for more tips and how to load other kinds of data.
Exercises
Interested in determining the probability that a read is not where it should be? What is a typical mapping quality (MQ) for a read?
Can you find a variant where the sequenced sample differs from the reference? This would be like looking for a needle in a haystack if not for the use of variant callers and the
control-f
andcontrol-b
options to zoom right to areas where there are discrepancies between reads and the reference genome that might indicate there were mutations in the sequenced E. coli.
Viewing Human Genome Data in IGV
Now that you've familiarized yourself with IGV using a "simple" bacteria, let's look at something a "little" more complex: the human genome.
Advanced exercise: human data scavenger hunt
Throughout this class we have used the wget command several times to download files directly to TACC which is running bash on a linux environment. As IGV only works on your local computer rather than TACC, downloading files directly to your laptop is more practical. Unfortunately wget is a linux only command and unix does not have it so instead we shall use the curl command to download some human data to IGV and look at it. The following commands should be run in a terminal window that is not logged into tacc.
cd ~/Desktop mkdir GVA_human_IGV cd GVA_human_IGV curl -O https://xfer.genome.wustl.edu/gxfer1/project/gms/testdata/bams/hcc1143/HCC1143.normal.21.19M-20M.bam curl -O https://xfer.genome.wustl.edu/gxfer1/project/gms/testdata/bams/hcc1143/HCC1143.normal.21.19M-20M.bam.bai
If you look at the file names, you may notice that this bam file and its index correspond to human chromosome 21 from position 19 million to 20 million or less than 1/4 of our bacterial genome. This limited data set is to hopefully avoid IGV crashing.
Steps:
- Close IGV (if you have it open from the first tutorial with your mapping, SNV, and SV data) and reopen it.
- Select "Human hg19" as the reference genome from the top left drop down (you may need to select "more" to have hg19 as an option)
- Load the bam files you downloaded: File > Load from File… and select HCC1143.normal.21.19M-20M.bam
- Turn on dbSNP annotations File > Load from Server… >Annotation > Variation and Repeats > dbSNP 1.4.7
- Right click on the track name on the left and select sort alignments by start location
There are 2 mutations visible in the chr21:19,479,237-19,479,814 region answer the following questions:
There are 2 SNPs visible in the chr21:19,666,833-19,667,007 region. Answer the following questions:
What other interesting things can you find?
Optional Tutorial Exercises ...
Visualize how other samples map without calling variants:
You will need to index your reference FASTA and convert your SAM output files into sorted and indexed BAM files. The "why?" behind these steps is described more fully in the Variant calling tutorial. If you are in your mapping
directory, these commands will perform the necessary steps.
Submit to the TACC queue or run in an idev shell
samtools faidx NC_012967.1.fasta samtools view -b -S -o bowtie/SRR030257.bam bowtie/SRR030257.sam samtools sort bowtie/SRR030257.bam -o bowtie/SRR030257.sorted samtools index bowtie/SRR030257.sorted.bam
Repeat the last three commands for each SAM output file that you want to visualize in IGV.
Visualize mapped reads and predicted variants from any later tutorials
Alternative genome browsers:
- Tablet - a lightweight NGS data browser
- Visualize mapped data at UCSC genome browser
In your work if you come across another (particularly if you find it very useful, or easier to use than IGV) I'd love to hear from you.
Welcome to the University Wiki Service! Please use your IID (yourEID@eid.utexas.edu) when prompted for your email address during login or click here to enter your EID. If you are experiencing any issues loading content on pages, please try these steps to clear your browser cache.