Integrate bigWig files into GBrowse

Lately, I have waisted quite a lot of time trying to integrate bigWig files into GBrowse.

At first, I had problems with installation of Bio::DB::BigWig in Ubuntu 14.04 x64. I had to combine tips from several places (this was the most helpful):

tar xfz userApps.src.tgz
cd userApps/kent/src/

# in inc/ replace `CFLAGS=` line with `CFLAGS=-fPIC` 

cd lib/
cd ..

sudo -i
export MACHTYPE=x86_64
export KENT_SRC=`pwd`
cpan Bio::DB::BigWig

Then, I have spent quite a lot of time trying to incorporate multiple bigWig files at once. This can accomplished with Bio::DB::BigWigSet. Just add this to your genome.conf:

db_adaptor      = Bio::DB::BigWigSet
db_args         = -dir /path/to/your/bigWig/files
                  -feature_type summary
database        = RibosomalRNASeq
feature         = summary
glyph           = wiggle_density
height          = 15
category        = Ribosomal RNA-Seq

Note, your bigWig files should be placed in one directory and end with .bw.
Additionally, you can create file that will define additional information about your samples.

BAM2bigWig conversion using pybedtools

Today I was looking for a handy way of converting BAM to bigWig. Biostars turned out to be handy place for a start. Guess what, there is ready module implemented in pybedtools that does exactly that:

from pybedtools.contrib.bigwig import bam_to_bigwig
bam_to_bigwig(bam='path/to/bam', genome='hg19', output='path/to/bigwig')

Unfortunately, my genome of interested in not hosted at UCSC, so I needed to alter bam_to_bigwig slightly. In addition, I’ve replaced the read counting function mapped_read_count with my own implementation that rely on BAM index and therefore return number of alignments nearly instantly. This reduces the time by some minutes for large BAMs.

My own implementation can be found github repo: -i SOME.BAM -g GENOME.fa -o