Sunday, September 9, 2012

Generate tabix file from SAM/BAM file

 Update 6/1/2013: SAM format is no longer supported, please use BAM format files instead.

0 Make sure you have the tabix program installed.
You can download the latest source and compile:

Or if you're using Ubuntu operating system, install it using apt-get:
$ apt-get install tabix
You should have both tabix and bgzip programs available on your computer.

Skip this step if you have a SAM file.

Convert the BAM file to SAM file using samtools:
$ samtools view input.bam > input.sam

2 Compress the SAM file:
$ bgzip input.sam

The old file is gone and a new file "input.sam.gz" is there instead.

3 Build tabix index of the compressed SAM file:
$ tabix -p sam input.sam.gz

The "input.sam.gz" is untouched but an index file "input.sam.gz.tbi" is generated.

4 Display this file as a custom SAM track on WashU Genome Browser.
Put the .gz and .gz.tbi files on the SAME directory on your web server.
Use only the URL to the .gz file to make the custom track.