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:
http://sourceforge.net/projects/samtools/files/tabix/

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.

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

Prepare custom track of annotation data (or "bed" track)

0 Make sure you have the tabix program installed.
You can download the latest source and compile:
http://sourceforge.net/projects/samtools/files/tabix/

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.

1 Skip this step if your file is BED format.

Run the command bigBedToBed in UCSC genome browser tool set and convert the bigBed file to a bed text file.

2 Compress the BED file:
$ bgzip input.bed

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

3 Build tabix index of the compressed BED file:
$ tabix -p bed input.bed.gz

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

4 Display this file as a custom bed 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.

The BED format used by WashU Epigenome Browser:
  1. chromosome name
  2. start coordinate
  3. stop coordinate
  4. Name (if absent, use dot)
  5. ID (unique non-negative integer)
  6. Strand (+/-/.)

Prepare custom track of numerical data

0 Make sure you have the tabix program installed.
You can download the latest source and compile:
http://sourceforge.net/projects/samtools/files/tabix/

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.

1 Skip this step if your file is bedGraph format.

For bigWig files...
Rrun the command bigWigToBedGraph in UCSC genome browser tool set and convert the bigWig file to a bedgraph text file.

For wiggle files...
Convert them into bedgraph text files. Only a few lines of code is needed for this task.
Or if you really hate coding, you can convert the wiggle file to bigWig format using wigToBigWig (also from UCSC genome browser tool set), then do bigWigToBedGraph.

2 Compress the bedgraph text file:
$ bgzip input.bedgraph

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

3 Build tabix index of the compressed bedgraph file
$ tabix -p bed input.bedgraph.gz

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

4 Display this file as a custom bedgraph 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.