Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

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

In this tutorial, we're going to learn how to do the following in IGV:

  • Create a custom genome database (usually used for microbial genomes) or 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.

 

Workflow 1: Viewing E. coli data in IGV

Data files

You can start this tutorial two ways:

  1. If you have a mapping directory with output from 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.
  2. Expand
    titleIf you have not done the other tutorials and want a "canned" data set provided for you, click here for example files.
    Code Block
    $BI/gva_course/mapping/IGV  # location of example files
    cp -r /corral-repl/utexas/BioITeam/gva_course/mapping/IGV .  # example command to copy to current directory
    scp -r username@ls5.tacc.utexas.edu:/corral-repl/utexas/BioITeam/gva_course/mapping/IGV . # to copy to a local computer skipping the step of copying to a lonestar directory and secure copying from there.

    Then skip down to #Launching IGV.

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 do 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.

...

titleWe'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.

To use it you need to first download the file readseq.jar linked from here. To get this onto TACC easily, use:

...

Table of Contents

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

In this tutorial, we're going to learn how to do the following in IGV:

  • Create a custom genome database (usually used for microbial genomes) or 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.


Workflow 1: Viewing E. coli data in IGV

Data files

You can start this tutorial two ways:

  1. If you have a mapping directory with output from 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.
  2. Expand
    titleIf you have not done the other tutorials and want a "canned" data set provided for you, click here for example files.
    Code Block
    $BI/gva_course/mapping/IGV  # location of example files
    cp -r /corral-repl/utexas/BioITeam/gva_course/mapping/IGV .  # example command to copy to current directory
    scp -r username@ls5.tacc.utexas.edu:/corral-repl/utexas/BioITeam/gva_course/mapping/IGV . # to copy to a local computer skipping the step of copying to a lonestar directory and secure copying from there.

    Then skip down to #Launching IGV.

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.

Expand
titlereadseq.jar is already installed it into the $BI/bin directory so you don't have to install it yourself, but here are the steps that can be used to install it in a local directory.

To use it you need to first download the file readseq.jar linked from here. To get this onto TACC easily, use:

Code Block
wget https://sourceforge.net/projects/readseq/files/readseq/2.1.19/readseq.jar 

After that, you simply need to know where you downloaded it. As it is an executable $HOME or $WORK would be good places for it if you were going to use it on TACC (incase you can't remember where the BioITeam installation is) or if you were going to put it on your laptop as you may get tired transferring files back and forth just to do simple file conversions if you have to do them often. In tomorrows final tutorial there will be a section about making java calls easier.

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" name):

...

Expand
titleWhy the funny 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's pretty confusing.

 

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:

Code Block
cds
mkdir BDIBGVA_IGV_Tutorial
cd BDIBGVA_IGV_Tutorial
java -cp /corral-repl/utexas/BioITeam/bin/readseq.jar run $SCRATCH/BDIBGVA_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 desktop

IGV is an interactive graphical viewer program. You can't run it on TACC, so we need to get the relevant files back to your desktop machine.

...

Code Block
languagebash
titleNote the need to add the suffix _fix to "samtools_tutorial" in final 4 copy steps if used the single file execution
mkdir BDIBGVA_IGV_export
cp -i NC_012967.1.gbk.gff BDIBGVA_IGV_export  # copy the new file you just converted to the export directory
cp -i $SCRATCH/BDIBGVA_bowtie2_mapping/NC_012967.1.fasta BDIBGVA_IGV_export
cp -i $SCRATCH/BDIBGVA_samtools_tutorial/NC_012967.1.fasta.fai BDIBGVA_IGV_export
cp -i $SCRATCH/BDIBGVA_samtools_tutorial/SRR030257.vcf BDIBGVA_IGV_export
cp -i $SCRATCH/BDIBGVA_samtools_tutorial/SRR030257.sorted.bam BDIBGVA_IGV_export/bowtie2.sorted.bam
cp -i $SCRATCH/BDIBGVA_samtools_tutorial/SRR030257.sorted.bam.bai BDIBGVA_IGV_export/bowtie2.sorted.bam.bai
tar -czvf BDIBGVA_IGV_export.tar.gz BDIBGVA_IGV_export

Now, copy the entire compressed IGV directory back to your local Desktop machine.

Expand
titleAnother refresher on how to copy files back from lonestar

In the terminal connected to Lonestar, figure out the complete path to the IGV directory.

Code Block
pwd

Open a new terminal window on your Desktop. Fill in the parts in brackets <> in this command:

Code Block
scp -r <username>@ls5.tacc.utexas.edu:<full_path_to_IGV>/BDIBGVA_IGV_export.tar.gz .
# enter your password 
tar -xvzf BDIBGVA_IGV_export.tar.gz

Anchor
Launching IGV
Launching IGV

Launching IGV

Warning

For the remainder of the tutorial, work on your local machine. NOT TACC!

There are multiple ways to launch IGV on a local computer, in decreasing order of recommendation due to recent mac OS updates and easy of use:

  1. This downloads the IGV executable and tells the command line to launch it (via the java command).

    wget http://www.broadinstitute.org/igv/projects/downloads/IGV_2.3.32.zip unzip IGV_2.3.32.zip cd IGV_2.3.32 java -Xmx2g -jar igv.jar
    Expand
    titleLocally on the classroom machines booted in Mac OSX

    Click here to download and install the mac application version. Save it to your desktop, then extract the zip file and launch the application.

    Expand
    titleLocally on the classroom machines booted in Linux
    Code Block
    your laptop with application version

    Click here to download and install the mac application version. Save it to your desktop, then extract the zip file and launch the application.

  2. Expand
    titleIn a Web browser

    Navigate a web browser to this page:http://www.broadinstitute.org/software/igv/download. You will need to register your email address to use this option, but in years of registration I have never noticed any emails from them. Go ahead and click on the "Launch with 2 GB" option. This will download a "Java Web Start" file that you can launch by locating it on your Desktop and double-clicking.

    Warning
    titleMac warning

    This will not work on recent Mac OS updates without severely modifying security permissions as administrator (which you can not do on a classroom computer). Recommended to use Mac directions above during the classis a bit much to do for this class if you don't continue to use it).

  3. Expand
    titleLocally Install the full version on a Mac or Windows computer

    Click here to download version 2.35.53 2 of IGV or visit https://www.broadinstitute.org/software/igv/download to download the latest binary version. After unzipping, you should be able to click on igv.bat for Windows or igv.command on MacOSX to lauch IGV. If this is not working, you might need to try the web start.

    Warning
    titleMac warning

    This will not work on recent Mac OS updates without severely modifying security permissions as administrator. Recommended to use Mac directions above.

 


Load genome into IGV

From the main window of IGV, click on Genomes > Create .genome File... and you should be presented with the following window.

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 needs to 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.

...

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-downhomeend.
  • 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 and control-b to jump forward and backward within that list of features. Try this on the variant calls track.
  • 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. Try this to compare a few different regions between the bowtie and BWA results.
  • 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

...

What is a typical mapping quality (MQ) for a read? Convert this to the probability that it is mismapped.

Expand
titleRemember the formula for a Phred quality score?

The estimated probability that a read is mapped incorrectly is 10^(-MQ/10).

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 and control-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.

...

titleSome interesting example coordinates
  • Expand
    titleCoordinate 161,041. What gene is this in and what is the effect on the protein sequence?

    Gene is pcnB, mutation is a snp

  • Expand
    titleCoordinate 3,248,957. What gene is this in and what is the effect on the protein sequence?

    Gene is infB, mutation is a snp

  • Expand
    titleCoordinate 3,894,997. What type of mutation is this?

    Deletion of the rbsD gene

...

Expand
titleCheck out the rbsA gene region? What's going on here?

There was a large deletion. Can you figure out the exact coordinates of the endpoints?

Navigate to coordinate 3,289,962. Compare the results for different alignment programs and settings. Can you explain what's going on here?

...

There is a 16 base deletion in the gltB gene reading frame.

What is going on in the pykF gene region? You might see red read pairs. What does that mean? Can you guess what type of mutation occurred here?

...

The read pairs are discordantly mapped. There was an insertion of a new copy of a mobile genetic element (an IS150 element) that exists at other locations in the reference sequence.

...

Workflow 2: 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 

Data from the 1000 Genomes Project can be found directly from the Broad's server for IGV. There are now MANY genomes available this way.

Find one or more dbSNP accession numbers for SNPs apparent in one of the two 1000 genomes project trios in the GABBR1 gene.

Steps:

  1. Download and install the Integrative Genome Viewer from the Broad Institute. 
  2. 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)
  3. Get some data: File > Load from Server… > 1000 genomes > Alignments > ACB > exome > HG01880
  4. Navigate to the rightmost exons of the GABBR1 gene.
  5. Zoom in until you find some SNPs. (Hint look just to the left of the 2nd exon).
  6. What type of library is this? (Hint: zoom out)
  7. If you knew this was a cancer patient, consider how strongly you would think this may be a potentially causative mutation.
  8. Imagine it was actually in the exon rather than just into the intron... would that make you consider it more?
  9. Load and look at the SNP track: File > Load from server > Annotations > Variants and Repeats > dbSNP 1.4.7
  10. The track may load with the Refseq genes, making it useful to resize that window to view both the gene and the dbSNP information simultaneously.
  11. Consider if this makes you think it more likely or less likely that this is a causative mutation.

Optional Tutorial Exercises ...

 

Expand
titleTo visualize mapped data 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.

Warning
titleSubmit to the TACC queue or run in an idev shell
Code Block
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.

...

titleBlast and IGV

Another useful trick with either IGV or UCSC: displaying your own BLAST results: BioPerl allows for super-easy conversion from blast output to a gff file; IGV and the UCSC browser both understand GFF files. The short script bl2gff.pl does the conversion. Let's use the blast result we had from a hypothetical test for the JAG1 gene to show you how. You'll need to provide the output file from your blast job as the input to the script (in this case "blast_jag1.058638".

Code Block
languagebash
titleExample of how to display BLAST results in IGV or UCSC
collapsetrue
grep '^gi' blast_jag1.o586038 > jag1_blast.out
module load perl
module load bioperl
bl2gff.pl jag1_blast.out > jag1_blast.out.gff

...

  • box. Try "topA".
  • Load multiple BAM alignments or VCF files at once. Try this to compare a few different regions between the bowtie and BWA results.
  • 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

  • Why are some reads different colors? Hint: Try changing the display options to show read pairs and editing some of the distance constraints.
  • Interested in determining the probability that a read is not where it should be? What is a typical mapping quality (MQ) for a read?

    Expand
    titleClick here for the formula.

    The estimated probability that a read is mapped incorrectly is 10^(-MQ/10). Where MQ is the mapping quality.

  • 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 and control-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.

    Expand
    titleSome interesting example coordinates
    • Expand
      titleCoordinate 161,041. What gene is this in and what is the effect on the protein sequence?

      Gene is pcnB, mutation is a snp

    • Expand
      titleCoordinate 3,248,957. What gene is this in and what is the effect on the protein sequence?

      Gene is infB, mutation is a snp

    • Expand
      titleCoordinate 3,894,997. What type of mutation is this?

      Deletion of the rbsD gene

    • Expand
      titleCheck out the rbsA gene region? What's going on here?

      There was a large deletion. Can you figure out the exact coordinates of the endpoints?

    • Navigate to coordinate 3,289,962. Compare the results for different alignment programs and settings. Can you explain what's going on here?

      Expand
      Answer
      Answer

      There is a 16 base deletion in the gltB gene reading frame.

    • What is going on in the pykF gene region? You might see red read pairs. What does that mean? Can you guess what type of mutation occurred here?

      Expand
      Answer
      Answer

      The read pairs are discordantly mapped. There was an insertion of a new copy of a mobile genetic element (an IS150 element) that exists at other locations in the reference sequence.

    • See if you can find more interesting locations. There are ~40 mutations total in this sample MOST of which are false positives.

Workflow 2: 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 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.

Code Block
languagebash
titleget some data
cd ~/Desktop
mkdir human_IGV
cd 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

These if you look at the file names, you may notice that this bam file and its index correspond to human chromosome 21 from 19 million to 20 million bases. This limited data set is to hopefully avoid IGV crashing. 

Steps:

  1. Close IGV (if you have it open from the first tutorial with your mapping, SNV, and SV data) and reopen it. 
  2. 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)
  3. Load the bam files you downloaded: File > Load from File…  and select HCC1143.normal.21.19M-20M.bam
  4. Turn on dbSNP annotations File > Load from Server… > Tutorials > Variants > dbSNP 1.3.1
  5. Right click on the track name on the left and select sort alignments by start location
  6. There are 2 mutations visible in the chr21:19,479,237-19,479,814 region answer the following questions:
    1. Are both SNPS supported by reads mapping to both the forward and reverse DNA strand (hint: make sure reads are colored by strand)?
    2. Which is more likely to be related to disease? why?

      Expand
      titleAnswers

      a. Yes, both forward and reverse reads (red and blue if colored by strand) contain the SNPs compared to the reference

      b. The one on the left does not correspond to a dbSNP entry and is therefore more likely to be related to disease state


  7. There are 2 SNPs visible in the chr21:19,666,833-19,667,007 region. Answer the following questions:

    1. Two mutations very close together is often a case of poor alignment scores. Is that the case here (remember this is human data)?

    2. Is either likely to be related to disease? 

      Expand
      titleAnswers

      a. No, each read only has 1 mutation on it, these are 2 different alleles each with its own SNP relative to 'wt'. Both are reported in dbSNP

      b. Neither is likely to be related to disease or at least to rare disease as both mutations have previously been identified as naturally occurring by dbSNP


  8. What is going on in the chr21:19,324,469-19,331,468 region?

    Expand
    titleAnswers

    Homozygous deletion. In the track on the left, right click and select 'view as pairs' to see linkage between R1 and R2 to see individual reads mapping to both sides of the deletion

  9. What is going on in the chr21:19,102,154-19,103,108 region?

    Expand
    titleAnswers

    This is an example of poor alignment to a repetitive AluY element. Notice how of the read pairs that map with numerous SNPs have 1 read that maps with lots of SNPs and the other read maps with none? This is caused by mapping reads to a limited area of the whole genome, if these reads had been allowed to map to the entire genome it is very likely that both read pairs would map without SNPs somewhere else in the genome.

  10. What other interesting things can you find?


Optional Tutorial Exercises ...


Expand
titleTo visualize mapped data 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.

Warning
titleSubmit to the TACC queue or run in an idev shell
Code Block
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.

You can use IGV to visualize mapped reads and predicted variants from any later tutorial!

...

Return to GVA2017 GVA2019 Home page