BamView is a free interactive display of read alignments in BAM data files. It has been developed by the Pathogen Group at the Sanger Institute.

BamView can be launched with Java Web Start by clicking below:

LAUNCH BamView

Or download BamView from:

Alternatively launch the development version of Artemis. Within Artemis, the BamView panel shows the reads alongside the annotation. To use this in Artemis open up a sequence file and open the BamView panel from the "File" menu and select the "Read BAM..." option.

The source code is available as part of the Artemis code which can be downloaded from GitHub.

† Note for MacOSX: occasionally a browser decides to display the contents of the .dmg file rather than downloading it. If this happens hold down the control key and click on the download link or right click on the download link and save the link as a file.

BamView: Viewing mapped read alignment data in the context of the reference sequence.
Tim Carver; Ulrike Böhme; Thomas D. Otto; Julian Parkhill; Matthew Berriman Bioinformatics 2010;
doi: 10.1093/bioinformatics/btq010

BamView: visualizing and interpretation of next-generation sequencing read alignments.
Tim Carver; Simon R. Harris; Thomas D. Otto; Matthew Berriman; Julian Parkhill; Jacqueline A. McQuillan Brief. Bioinform. (2012);
doi: 10.1093/bib/bbr073

This application displays read alignments/mappings. As the name suggests it reads a BAM file that has been sorted and indexed using SAMtools.

Requirements

BamView requires Java 1.6 as it makes use of the Java bindings (Picard) to read the BAM file.

Command line options

To run the application on UNIX from the downloaded jar file run the UNIX:

java -mx512m -jar BamView.jar

and extra command line options are given when '-h' is used:

java -jar BamView.jar -h

BAM files can be specified on the command line with the '-a' option:

java -mx512m -jar BamView.jar -a pathToFile/sorted.bam

If a BAM filename is not given on the command line BamView will prompt for a file to be entered. The BAM index file should have the same name as the BAM file but with a '.bai' suffix. Multiple BAM files can be loaded and overlaid in the viewer. To make this easier BamView will read in files that contain a list of filenames.

Right click menu

A menu is shown when right clicking on the BamView window (see figure below). This provides a number of viewing options. If you right click over a read it also gives an option in the menu to show the details of that read in a separate window. Under the 'Show' menu there is an option to display the SNP's.

Figure showing the menu that appears when right clicking on BamView. The vertical red lines mark the SNP's. The panel has been cloned to show two views simultaneously.
BamView

Viewing insertions and deletions

When zoomed in to the nucleotide level insertions are marked by purple vertical lines (see figure below). The insertion type is displayed as a tooltip when the mouse is positioned over the insertion. Deletions are marked with horizontal lines joining the sections of the read they belong to (see figure below). Clicking on a read highlights the read pair with a red border and the deletion lines become red.

BamView

Base qualities

Bases can be coloured by ('Colour By' -> 'Base Quality') their quality scores (blue <10; green <20; orange <30; black ≥30).

BamView

Viewing multiple BAM files

Additional BAM files can be read and overlaid in BamView by right clicking on the BamView panel and selecting the 'Add BAM...' option from the popup menu. The BAM files that are displayed can be switched off and on from the 'BAM files' menu in the popup menu.

Alternatively paths to multiple BAM files can be read from a file of file names. A file containing the list of BAM file names can be used when BamView is launched and prompts for a file name. It can also be given as an option on the command line:

java -mx512m -jar BamView.jar -a bam.list

Reading BAM files from HTTP links

The sorted BAM and the index files can be read from an HTTP server. The URL can be supplied when BamView is opened:

Open BAM

Or on the command line:

java -jar BamView.jar -a 'http://127.0.0.1/BAM/sorted_new_bam.out.bam'

A file containing a lists of HTTP links to BAM files can also be used and read from an HTTP link, for example:

java -jar BamView.jar -a 'http://127.0.0.1/BAM/bam.list'

Increasing the Memory

Displaying BAM files with high coverage of reads is memory intensive. The 'Stack' view is generally quicker and the less memory intensive of the views. It may also be necessary to increase the memory available to the application.

On linux change the -mx value on the command line above. This is used to specify the maximum size, in bytes, of the memory allocation pool, e.g. -mx512m sets it to 512MB. This should be set to a smaller value than the total memory available on your computer.

On MacOSX, this value is set in the file Info.plist in the directory BamView.app/Contents. Towards the bottom of the file there are a couple of lines that look like this:

<key>VMOptions</key>
<string>-Xmx800m</string>

Changing the value after -Xmx will change the memory used by BamView.

On windows create a shortcut to the BamView JAR file. Edit the properties of the shortcut and add "java -mx512m -jar " to the start of the Target: field. -mx512m sets the maximum memory Java will allocate to BamView.

Large Lists of Contigs

To facilitate the selection of a particular contig, in the drop down list of available sequences, it is possible to type the contig name into the drop down box.

Web Start Examples:

LAUNCH in BamView

LAUNCH in Artemis

Download An Example:
  1. Click here to download an example Plasmodium falciparum reference.
  2. Click here to download a BAM file for Plasmodium falciparum.
  3. Click here to download the associated index file and put this in the same folder as the BAM file.
  4. Download Artemis or launch it from the web start link above and open the reference sequence.
  5. Then from the 'File' menu in Artemis select the option 'Read BAM...' to open the BamView window.
  6. Select the correct chromosome from the drop down list of reference sequences (MAL1, MAL2,...) at the top. Note that the bar at the top is on auto-hide by default in Artemis which means that is appears only when the mouse cursor is moved to the top of the BamView window.

This will open the BamView window similar to the example below. Right clicking on the window provides a pop-up menu from which different views can be selected.

Chromosome13

Note that the bottom of the BamView display can be dragged up and down to alter the size of the window. Below is a zoomed out illustration of the stack view:

Chromosome13

Below is an example of finding a sequencing error when comparing the reads to the reference.

Chromosome13

Outline

There are a number of tools to align sequence reads to a reference sequence. Read alignment data that is generated by Maq can be converted to SAM using SAMtools (maq2sam-long for maq-0.6.x and maq2sam-short for maq-0.7.x). There is also a script (export2sam.pl) that converts Illumina export to SAM. Bowtie is short read aligner which can also generate SAM files. There is a useful Bowtie tutorial here.SSAHA2 is designed as mapping of sequencing reads onto genomic reference sequences. One of the output formats in SSAHA2 is the SAM format. The BWA software is an efficient program that aligns relatively short.

Using the SAMtools view flag SAM files can be converted to the binary version (BAM).

SAMtools can be downloaded for different operating systems (UNIX, MacOSX and Windows) from the download link on the SAMtools home page.

To sort a BAM file with SAMtools run the command with the 'sort' flag, e.g.:

samtools sort Plasmodium3D7_RNASeq.bam Plasmodium3D7_RNASeq_sorted

To index the sorted BAM the command to run will look like this:

samtools index Plasmodium3D7_RNASeq_sorted.bam

Then BamView can be launched from the web start link above or run from the downloaded jar, e.g:

java -jar -mx512m BamView.jar -a Plasmodium3D7_RNASeq_sorted.bam -r Pf3D7_13.embl

Example

An example run using BWA to generate a BAM file from fastq files is given below:

  1. Click here to download 1788_1_1.fastq.
  2. Click here to download 1788_1_2.fastq.
  3. Click here to download the reference sequence 3D7.sequence.2.1.4.fasta.
  4. Download BWA and SAMtools and add these to your PATH.
  5. Then this shell script automates the commands required to generate the BAM. Make the script executable (chmod a+x little.bwa.bam.sh). This can be run with the command line:
    ./little.bwa.bam.sh 3D7.sequence.2.1.4.fasta \ 1788_1_1.fastq 1788_1_2.fastq 3D7 200
    where 3D7 is the output BAM ttfix and 200 is the expected insert size. Note that this can take a few hours to run.
  6. Then BamView can be launched from the web start link above or run from the downloaded jar, e.g:
    java -jar -mx512m ../artemis/BamView.jar \ -a 3D7.bam -r 3D7.sequence.2.1.4.fasta

Other example scripts are here for:

maq.pl and ssaha2 (version 2.5) must be in the path, as well as the samtools/misc/ directory (for maq). For malaria, ssaha will take a long time. Maq should need roughly 10x longer than bwa.

Troubleshooting if BamView is not opening:

  1. Ensure that you are using the most recent Java (at least Java1.6 - a warning message is shown if the version of Java you have is older than this).
  2. The BAM file needs to be sorted:
    samtools sort <in.bam> <out.prefix>
    and indexed
    samtools index <in.bam> [<out.index>]
  3. Check that you have the BAM index file in the same directory. BamView assumes that the name of the index file is the same as the BAM file but with the added .bai extension.
  4. If the BamView window is actually opening but just blank then try changing to a different view by right clicking on the BamView window. You may need to select the correct reference from the top left drop down list.
Colour schemes:
  1. Stack view and Strand stack view: paired reads are blue; single reads or reads with an unmapped pair are black; reads with the same start and end alignment positions are overlaid and are green.
  2. Inferred size view: paired reads are blue and those with an inversion are red. Reads that do not have a mapped mate are black and are optionally shown in the inferred insert size view.
  3. Paired stack view: paired reads are blue and those with an inversion are red.
  4. Zoomed in to the nucleotide level: the bases can be coloured by their mapping quality score:
    blue <10; green <20; orange <30; black ≥30.
BamView in Artemis:
  1. The asynchronous option (when selected from the menu) means that when you scroll along the sequence the BamView window only updates when scrolling stops. This makes scrolling faster when the coverage is high in the region being viewed. However this can be turned off to see the reads as you scroll along.

We welcome contributions and suggestions for new features to BamView.

If you have comments about this software please send them to the BamView developers.