How to Load BAM, VCF, BED, and FASTA Files into IGV
By Dr. Zubair Khalid, DVM, MS, PhD ·

By the end of this walkthrough you will be able to prepare a BAM alignment file, a VCF variant file, a BED interval file, and a FASTA reference so that each one opens cleanly in the Integrative Genomics Viewer (IGV). You will know which index file each format needs, how to check that the index exists, how to choose the right reference genome, and how to confirm that reads, variants, and intervals are landing on the correct coordinates. You will also be able to recognize the common failure modes, such as a BAM without an index, a VCF compressed with plain gzip, or a chromosome naming mismatch between the alignment and the reference.
You need IGV installed on your computer, a Java runtime that matches the IGV release you downloaded, and the command line tools samtools, bgzip, and tabix. A current bcftools installation is useful for sorting and normalizing variant files. You need your four data files and, for each file that requires one, its index. You also need to know the genome build used when the reads were aligned, for example GRCh38 or GRCh37, because a file aligned to one build will not display correctly against another.
IGV is a desktop genome browser developed at the Broad Institute. It draws a reference sequence along a horizontal axis and stacks annotation, variant, and alignment tracks above it. The four formats covered here are the common core of a visualization session. BAM carries aligned reads. VCF carries variant calls. BED carries interval annotations. FASTA carries the reference sequence that gives every other track its coordinate system. Reviews of high-throughput sequencing resources describe the use of common file formats for coding and storing genomic data alongside web-accessible tools for visualization and analysis [1]. The same file format logic applies whether you use IGV or another browser.
What Each File Contributes to an IGV Session
BAM: aligned reads
BAM stands for Binary Alignment Map. It is a compressed binary representation of reads that have been aligned to a reference genome. Each record stores the read name, a flag, the reference contig, the leftmost alignment position, mapping quality, the CIGAR string that describes insertions and deletions, mate information, template length, the read sequence, and per-base quality scores. IGV uses the BAM index to fetch only the reads in the genomic window you are viewing. Without an index, the viewer cannot randomly access a region of a large file.
The BAM container is not limited to DNA reads. The proBAM framework uses a BAM-based representation to place peptide spectrum matches in a genomic context, and the resulting files can be visualized in genome browsers [2]. That example shows why BAM became a general alignment container. For a standard DNA session, a coordinate-sorted BAM plus a .bai or .csi index is the expected input.
VCF: variant calls
VCF stands for Variant Call Format. It is a text format with a header block and one line per variant. The standard columns are CHROM, POS, ID, REF, ALT, QUAL, FILTER, INFO, FORMAT, and one or more sample columns. Positions in VCF are 1-based. Visualization tools commonly accept VCF as the input for mutation profiles, alongside formats such as MAF and TSV [3]. IGV displays VCF records as a variant track, with options to color by genotype, label alleles, and filter by quality or sample.
For IGV, a VCF should be coordinate-sorted, bgzipped, and tabix-indexed. A plain .vcf file can be opened for small datasets, but large uncompressed VCF files are slow to parse and use much more memory. A .vcf.gz made with ordinary gzip is not randomly accessible, so tabix cannot index it.
BED: interval annotations
BED stands for Browser Extensible Data. It is a tab-delimited text format for genomic intervals. The first three columns are chrom, chromStart, and chromEnd. The start is 0-based and the end is half-open, meaning the interval includes the start coordinate but not the end coordinate. Additional columns can carry a name, score, strand, thick blocks, item colors, and block definitions.
BED is the format you use for gene models, regulatory regions, capture targets, blacklist regions, or any custom interval set. Related annotation formats such as GFF3 are also common in genome browsers, and a GFF3 file produced by an analysis tool can be loaded into a local browser to inspect questionable regions [4]. The coordinate convention is the main difference. BED is 0-based, while GFF3 and VCF are 1-based.
FASTA: the reference sequence
FASTA is a text format for nucleotide or protein sequences. Each sequence begins with a header line that starts with a greater-than symbol, followed by the sequence on one or more lines. In IGV, a FASTA file is normally loaded as the reference genome, not as a feature track. Genome browsers load a reference genome from a FASTA format file, and the same reference sequence then anchors every track in the session [5].
A FASTA reference needs an .fai index for random access. For some tools, a sequence dictionary in .dict format is also useful. The contig names in the FASTA must match the contig names in the BAM, VCF, and BED files exactly. chr1 and 1 are different strings to a computer, even though they refer to the same chromosome in a human genome.
FASTQ versus FASTA
FASTQ and FASTA are often confused because both are text formats that hold sequence. FASTQ stores raw sequencing reads with four lines per read: a header, the sequence, a separator, and a string of per-base quality scores. FASTA stores sequence only, with no quality scores. IGV does not display raw FASTQ reads. To see reads in IGV, you must first align the FASTQ files to a reference and produce a BAM or CRAM file. The FASTQ is the input to the aligner, and the BAM is the input to the browser.
This distinction explains a frequent support question. A user downloads FASTQ files from a sequencing center, opens IGV, and cannot find a way to load them. The answer is that FASTQ is not an alignment format. The files need to pass through an aligner such as BWA, Bowtie 2, or STAR before IGV can display them.
Format Reference Table
| Format | What it holds | IGV track type | Required companion | Coordinate convention |
|---|---|---|---|---|
| BAM | Aligned reads | Alignment track | .bai or .csi index | 0-based in file, 1-based in display |
| CRAM | Compressed aligned reads | Alignment track | .crai index and reference | 0-based in file, 1-based in display |
| VCF | Variant calls | Variant track | .tbi or .idx index for bgzipped files | 1-based |
| BED | Genomic intervals | Feature track | .tbi index for bgzipped files | 0-based, half-open |
| FASTA | Reference sequence | Reference genome | .fai index, optional .dict | 1-based in display |
| FASTQ | Raw reads with qualities | Not supported directly | Alignment to a reference first | Not applicable in IGV |
Before You Start: Tools, Memory, and Reference Choice
Check that the command line tools are installed and on your path. Open a terminal and run:
samtools --version
bgzip --version
tabix --version
bcftools --version
java -version
The expected output is a set of version lines. For example, samtools prints its version and the versions of the libraries it uses. If a command is not found, install the tools through your package manager, conda, or the official release binaries before continuing. IGV itself is a Java application. Recent releases require a Java runtime, and the download page states the supported version. If IGV does not start, check the Java version first.
Memory matters. IGV runs inside a Java virtual machine, and the default maximum heap may be too small for a whole-genome BAM with several tracks. The -Xmx flag sets the maximum heap. A value of 4 GB is reasonable for targeted panels and small genomes. A value of 8 GB or more helps with whole-genome human BAM files and multiple annotation tracks. You can launch IGV from the command line with a larger heap:
java -Xmx8g -jar igv.jar
The -Xmx8g option means the Java process may use up to 8 GB of RAM. Do not set it higher than the physical memory available on the machine. If IGV becomes slow or throws an out-of-memory error after loading several tracks, close the session, raise the heap, and reopen the files.
Choose the reference genome before loading any tracks. IGV ships with common genomes such as human hg18, hg19, hg38, mouse mm10, and others. The genome build in IGV must match the build used for the BAM and VCF. If your organism or assembly is not in the list, load your own FASTA. The genome is the coordinate backbone, so a mismatch here makes every downstream track misleading.
Step-by-Step: Preparing and Loading the Files
Step 1. Confirm the genome build and contig naming
Inspect the sequence dictionary inside the BAM header. This tells you which reference was used and how the contigs are named.
samtools view -H sample.bam | grep '^@SQ' | head
Expected output looks like this:
@SQ SN:chr1 LN:248956422
@SQ SN:chr2 LN:242193529
@SQ SN:chr3 LN:198295559
The SN field is the sequence name and the LN field is the length. Now inspect the FASTA headers:
grep '^>' genome.fa | head
Expected output:
>chr1
>chr2
>chr3
The names must match. If the BAM uses chr1 and the FASTA uses 1, IGV will not place the reads on the reference. You have two options. Use a reference FASTA with matching names, or rename the contigs in one of the files with a tool such as bcftools annotate, rename-chrs for VCF or samtools reheader for BAM. Renaming a BAM header is safe only if the alignments are already on the correct assembly and only the naming style differs. Never rename contigs to force a build match when the underlying assembly is different.
Step 2. Prepare the FASTA reference
Index the FASTA so that IGV and other tools can seek to a region without reading the entire file:
samtools faidx genome.fa
samtools dict genome.fa -o genome.dict
ls -1 genome.fa*
Expected output:
genome.fa
genome.fa.fai
genome.dict
The .fai file is a small text index. Each line contains the contig name, length, offset of the first base, number of bases per line, and number of bytes per line. For example:
chr1 248956422 6 60 61
The samtools dict command creates a sequence dictionary with contig names and lengths. The dictionary is not always required for IGV, but it is useful for other genome tools and for checking that the FASTA is well formed.
Step 3. Prepare the BAM file
A BAM must be coordinate-sorted and indexed. Check the file integrity first:
samtools quickcheck -v sample.bam
If the file is complete, the command prints nothing and returns a zero exit status. If it prints an error, the BAM is truncated or corrupt. Do not try to load a corrupt BAM in IGV.
Sort the BAM by coordinate:
samtools sort -@ 4 -m 2G -o sample.sorted.bam sample.bam
The -@ 4 option uses four threads for compression and sorting. The -m 2G option gives each sorting thread up to 2 GB of memory. The -o option sets the output file name. After sorting, index the file:
samtools index -@ 4 sample.sorted.bam
ls -lh sample.sorted.bam*
Expected output:
-rw-r--r-- 1 user staff 2.4G sample.sorted.bam
-rw-r--r-- 1 user staff 1.1M sample.sorted.bam.bai
The .bai file is the default index. For a reference with contigs longer than 512 Mb, use a CSI index instead:
samtools index -c sample.sorted.bam
The -c option creates sample.sorted.bam.csi. IGV accepts both .bai and .csi indexes. Keep the index next to the BAM and use the same base name. If you rename the BAM, rename the index to match.
Step 4. Prepare the VCF file
Sort the VCF by coordinate if it is not already sorted, then compress it with bgzip and index it with tabix:
bcftools sort -Oz -o variants.sorted.vcf.gz variants.vcf
tabix -p vcf variants.sorted.vcf.gz
ls -lh variants.sorted.vcf.gz*
Expected output:
-rw-r--r-- 1 user staff 184M variants.sorted.vcf.gz
-rw-r--r-- 1 user staff 2.3M variants.sorted.vcf.gz.tbi
If the VCF is already sorted, you can compress and index it directly:
bgzip -c variants.vcf > variants.vcf.gz
tabix -p vcf variants.vcf.gz
The -p vcf option tells tabix to use the VCF preset, which knows that the sequence name is column 1 and the position is column 2. bgzip is not the same as gzip. Ordinary gzip creates a stream that must be decompressed from the beginning, which prevents random access. bgzip creates a series of compressed blocks with an index, and tabix uses that index to jump to a region. A .vcf.gz made with gzip will fail tabix indexing or produce an index that IGV cannot use.
For clinical or research variants, normalize the VCF before loading. bcftools norm -f genome.fa left-aligns and trims indels and can split multiallelic records. Normalization makes the VCF easier to compare with other calls and reduces apparent discrepancies at the same locus. It does not change the genome build.
Step 5. Prepare the BED file
Sort the BED file by chromosome and start position:
sort -k1,1 -k2,2n intervals.bed > intervals.sorted.bed
The -k1,1 option sorts by the first column, the chromosome. The -k2,2n option sorts numerically by the second column, the start position. For small BED files, IGV can load the plain text file directly. For large files with hundreds of thousands or millions of intervals, bgzip and index it:
bgzip -c intervals.sorted.bed > intervals.sorted.bed.gz
tabix -p bed intervals.sorted.bed.gz
ls -lh intervals.sorted.bed.gz*
Expected output:
-rw-r--r-- 1 user staff 12M intervals.sorted.bed.gz
-rw-r--r-- 1 user staff 220K intervals.sorted.bed.gz.tbi
The -p bed preset tells tabix that the file is BED, with sequence name in column 1, start in column 2, and end in column 3. Remove any track lines or browser lines before indexing, or keep them only at the top of the file. A track line in the middle of a BED file will break sorting and indexing.
Step 6. Launch IGV and load the reference genome
Open IGV. If you are using a built-in genome, select it from the genome drop-down list in the toolbar. If you are using a custom FASTA, choose Genomes > Load Genome from File and select genome.fa. IGV reads the .fai index and displays the chromosome ideogram or the contig list. The reference sequence loads as the coordinate backbone. Genome browsers routinely load a reference genome from a FASTA file, and that step is the anchor for every subsequent track [5].
After the genome loads, the locus field at the top of the window accepts coordinates. Type a region such as chr1:100,000-110,000 and press Enter. The view zooms to that window. If the genome is loaded correctly, the sequence appears at the nucleotide level when you zoom in far enough.
Step 7. Load the BAM file
Choose File > Load from File and select sample.sorted.bam. You can also drag the BAM onto the IGV window or use File > Load from URL for a remote file. IGV reads the .bai index and draws an alignment track. At a whole-genome view, the track usually shows a coverage histogram rather than individual reads. Zoom in to a specific locus to see reads as gray or colored bars.
The alignment track has display options that matter for interpretation. The track height can be set to squish, expand, or a fixed height. The color mode can group reads by strand, pair orientation, insert size, or sample. The coverage track can be shown or hidden. These controls are in the track menu on the right-click context menu or in the track settings panel.
Step 8. Load the VCF file
Choose File > Load from File and select variants.sorted.vcf.gz. IGV reads the .tbi index and draws a variant track. At a zoomed-out view, variants may appear as a density plot. Zoom in to see individual records as colored marks or letters. The variant track settings let you color by genotype, show allele fractions, filter by quality, and select samples from a multi-sample VCF.
If the VCF contains many samples and you want to view only one, open the variant track settings and choose the sample. IGV will then display genotypes and allele fractions for that sample. For a somatic VCF, the tumor and normal sample names are usually present in the header, and you can switch between them.
Step 9. Load the BED file
Choose File > Load from File and select intervals.sorted.bed or intervals.sorted.bed.gz. IGV draws a feature track with rectangles for each interval. If the BED has a name column, the names appear as labels when the track is expanded. If it has a score column, the score can be used to color or filter features. The track can be moved up or down in the track panel to sit next to the alignment or variant track it annotates.
Step 10. Navigate and verify each track
Type a locus that you know contains reads and variants. For example, if your BAM has reads at chr1:1,000,000-1,010,000, enter that region. Check three things. First, the alignment track should show reads with a reasonable mapping quality and no unusual pileup of mismatches. Second, the variant track should show records at the expected positions. Third, the BED track should show intervals where you expect them. If one track is empty while the others are populated, the empty track has a naming, build, or indexing problem.
Save the session before closing IGV. Choose File > Save Session and save the .xml file. The session records the genome, the tracks, the display settings, and the current locus. You can reopen it later with File > Open Session. Saving a session is faster than re-adding six tracks one at a time, and it makes the view reproducible for a collaborator.
Checking That the Files Loaded Correctly
Command line checks catch problems before they reach IGV. For a BAM, samtools idxstats reports the number of mapped and unmapped reads per contig:
samtools idxstats sample.sorted.bam | head
Expected output:
chr1 248956422 48213 0
chr2 242193529 41002 0
chr3 198295559 37544 0
The columns are contig name, contig length, mapped reads, and unmapped reads. A row with a contig name that does not appear in your FASTA is a warning sign. The final row with an asterisk reports unmapped reads.
For a VCF, bcftools stats reports the number of records and the transition-to-transversion ratio:
bcftools stats variants.sorted.vcf.gz | grep '^SN'
Expected output includes lines such as:
SN number of samples: 1
SN number of records: 48211
SN number of SNPs: 44120
SN number of indels: 4091
If the record count is zero, the VCF is empty or the filter removed everything. If the number of samples is wrong, the VCF may have been merged incorrectly.
For a BED file, check that the first three columns are valid and that no interval has a start greater than its end:
awk 'BEGIN{FS="\t"} $2 > $3 {print}' intervals.sorted.bed | head
No output means no invalid intervals. Any output lines should be inspected and fixed before loading.
In IGV, the visual checks are straightforward. The alignment track should show reads at the locus. The variant track should show marks at the expected positions. The feature track should show intervals. The reference sequence should match the nucleotide you expect at a known position. If all four agree, the session is internally consistent.
Key Options and What They Do
| Task | Option or command | What it controls | Typical setting |
|---|---|---|---|
| Sort BAM | samtools sort -@ | Threads for sorting and compression | 4 |
| Sort BAM memory | samtools sort -m | Memory per sorting thread | 2G |
| BAM index for long contigs | samtools index -c | Creates a CSI index | Use when a contig exceeds 512 Mb |
| VCF compression | bgzip | Block compression with random access | Required before tabix |
| VCF index | tabix -p vcf | Tabix preset for VCF | vcf |
| BED index | tabix -p bed | Tabix preset for BED | bed |
| IGV memory | java -Xmx | Maximum Java heap | 4g to 8g |
The -@ and -m options trade memory and CPU for speed. A laptop with 16 GB of RAM can use four threads and 2 GB per thread comfortably. A server with more memory can use eight threads. The -c option is needed only when a reference contig is longer than the 512 Mb limit of the standard BAI index. Most human, mouse, and crop genomes do not need it, but some plant and amphibian assemblies do.
The IGV heap setting is the most common performance lever. A heap that is too small produces an out-of-memory error when several tracks load at once. A heap that is too large can cause the operating system to swap if the machine has less free memory than the requested maximum. Set the heap to a value that fits the machine and the data.
Common Mistakes and Limitations
Unsorted BAM. IGV expects a coordinate-sorted BAM for indexed access. A name-sorted or unsorted BAM may load without an index but will not support efficient region navigation. The fix is to run samtools sort and then samtools index. The BAM header should contain SO:coordinate in the @HD line.
Missing or stale index. A BAM without a .bai or .csi file cannot be randomly accessed. An index created before the BAM was re-sorted is also stale. IGV may show a message that the index is missing or out of date. Regenerate the index after every sort or filtering step. The same rule applies to VCF and bgzipped BED files.
Wrong genome build. A BAM aligned to GRCh37 loaded against GRCh38 will show reads in the wrong places or no reads at all. The chromosome names may match while the coordinates do not. Check the @SQ lengths in the BAM header against the lengths of the reference you plan to use. The lengths are the quickest build fingerprint.
Chromosome naming mismatch. chr1 versus 1 is the most common cause of an empty track. IGV does not guess that two names refer to the same sequence. Either load a reference with the same naming style or rename the contigs in the data file. Be careful with mitochondrial contigs, which may appear as chrM, MT, or chrMT.
VCF compressed with ordinary gzip. A .vcf.gz produced by gzip is not tabix-compatible. The fix is to decompress and recompress with bgzip, then run tabix -p vcf. If the file is large, use zcat variants.vcf.gz | bgzip > variants.bgzip.vcf.gz and index the result.
BED coordinate off-by-one. BED starts are 0-based and IGV displays 1-based coordinates. A BED interval chr1 99 200 covers the same bases as the 1-based display interval chr1:100-200. If your interval appears shifted by one base, check the convention. GFF3 and VCF use 1-based coordinates and do not need the same conversion.
FASTQ loaded by mistake. IGV cannot display raw FASTQ. A FASTQ file must be aligned first. If you need to inspect raw read quality, use a tool such as FastQC or a read viewer. IGV is a genome browser for aligned data.
Large VCF loaded uncompressed. A multi-gigabyte plain VCF may load slowly or exhaust the heap. Compress and index it. For a very large cohort VCF, consider subsetting to the samples or regions you need before loading.
CRAM without a reference. CRAM is a compressed alignment format that depends on the reference sequence for decoding. IGV needs the reference FASTA to read CRAM. If the reference is missing or does not match the one used to create the CRAM, reads will fail to decode. BAM avoids this dependency because it stores the read sequence directly.
Over-interpreting downsampled reads. IGV downsamples alignments by default to keep rendering fast. The pileup you see may not be the full set of reads at that position. If you need exact counts, export the region with samtools view and count from the file, or raise the downsampling limit in the IGV preferences. The visual display is for exploration, not for final quantification.
Assuming IGV is an analysis engine. IGV is a viewer. It does not call variants, normalize alignments, or compute differential expression. It displays files produced by other tools. A variant track that looks empty may be a filtering issue in the VCF, not an IGV problem. Check the file with bcftools view or bcftools stats before troubleshooting the browser.
Network file access. Loading a BAM or VCF from a remote URL works only if the server supports range requests and the index is available at the expected path. A web server that streams the whole file without range support will make IGV slow or unresponsive. Copy large files to local storage when possible.
Practical Tips for Smooth IGV Sessions
Put the genome build and file type in every file name. A file named sample.GRCh38.sorted.bam is easier to pair with sample.GRCh38.sorted.bam.bai than a file named final.bam. The same naming discipline helps with VCF and BED files.
Keep the index next to the data file and use the same base name. IGV looks for the index by appending the expected suffix. If the BAM is sample.sorted.bam, the index should be sample.sorted.bam.bai or sample.sorted.bam.csi. Renaming one without the other breaks the link.
Load the reference first, then the annotation tracks, then the alignment and variant tracks. This order makes it easier to spot a track that lands on the wrong contig. If the BED intervals appear on the correct chromosome but the reads do not, the problem is in the BAM or the reference, not the BED.
Use sessions for reproducible views. Save the session after setting track colors, heights, and the locus of interest. A saved session is a small XML file that records the genome and track paths. It is easier to share than a list of files and display settings.
Take snapshots for figures. IGV can save the current view as an image. Set the track heights and colors before taking the snapshot. For publication, use a consistent color scheme across samples and label the genome build in the figure legend.
Check the VCF sample columns before coloring by genotype. A multi-sample VCF may have dozens of sample columns, and the default display may not be the sample you care about. Open the track settings and select the sample explicitly.
Normalize and filter VCF files before loading. A VCF with thousands of low-quality records can obscure the variants you care about. Use bcftools view -i 'QUAL>20' or the IGV track filter to reduce clutter. Keep the original file and create a filtered copy for visualization.
Use bigWig and bigBed for large continuous or interval tracks. These binary formats are indexed and load quickly in genome browsers. FineMAV, for example, outputs its selection scores as bigWig files, a format supported by many genome browsers [6]. If you have coverage or score data at millions of positions, convert to bigWig rather than loading a huge text file.
Frequently Asked Questions
Does IGV load FASTQ files?
No. IGV does not display raw FASTQ reads. FASTQ files must be aligned to a reference to produce BAM or CRAM files, and those alignment files are what IGV opens.
Why does my BAM show no reads in IGV?
The most common causes are a genome build mismatch, a chromosome naming mismatch such as chr1 versus 1, or a missing index. Check the BAM header with samtools view -H and compare the contig names and lengths to the reference loaded in IGV.
Can I load a VCF that is not bgzipped?
Yes, for small files. IGV can open a plain .vcf file directly. For large files, bgzip and tabix indexing are strongly preferred because they allow random access and reduce memory use. A .vcf.gz made with ordinary gzip is not tabix-compatible.
What index does IGV need for a BED file?
Plain BED files can be loaded without an index. Bgzipped BED files need a .tbi index created with tabix -p bed. Indexing is useful when the BED contains hundreds of thousands of intervals or more.
How do I load a custom genome into IGV?
Choose Genomes > Load Genome from File and select the FASTA file. The FASTA should have a .fai index created with samtools faidx. The contig names in the FASTA must match the contig names in your BAM, VCF, and BED files.
Why are my variants shifted by one base?
BED is 0-based and VCF is 1-based. A BED interval that starts at 99 covers the same first base as a VCF position of 100. Check the coordinate convention of each file. IGV displays 1-based coordinates, so BED intervals can look shifted by one base in the ruler.
Can IGV display CRAM files?
Yes. CRAM is a compressed alignment format, and IGV can display it if the matching reference FASTA is available. The CRAM file also needs a .crai index. BAM is simpler when you want to avoid carrying a separate reference for decoding.
How do I share an IGV session?
Save the session with File > Save Session. The resulting XML file records the genome, the track paths, and the display settings. Share the XML file along with the data files, or place the data files in the same relative paths so the session can find them.
Sources
- Online resources for genomic analysis using high-throughput sequencing.
- proBAMsuite, a Bioinformatics Framework for Genome-Based Representation and Analysis of Proteomics Data.
- CoMutPlotter: a web tool for visual summary of mutations in cancer cohorts.
- BioNanoAnalyst: a visualisation tool to assess genome assembly quality using BioNano data.
- Setting Up the JBrowse 2 Genome Browser.
- Prioritising positively selected variants in whole-genome sequencing data using FineMAV.