NGS: Getting coverage from bam file for displaying peaks in UCSC browser in bigwig format.
Hola people!
Quick tutorial on how to convert bam file to bedGraph (different from bed files) for displaying them into UCSC browser. We will convert them to bigwig (bw), which are more portable, encrypted and less space consuming data formats.
Step 1: using a combination of 'samtools' and 'bedtools' and ofcourse 'shell pipe'
samtools view -b file.bam | genomeCoverageBed -ibam stdin -bg -g genomeIndex/mm9.chrom > file.bedGraph &
input file = file.bam; output = file.bedGraph
genomeIndex = mm9.chrom (to get the genome index, which a text file containing the mouse genome size per chromosome, use fetchChromSizes, get it from UCSC ftp http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/fetchChromSizes)
Step2 : sort obtained bedGraph file chromosome wise using sort
sort -k1,1 -k2,2n file.bedGraph > file.bedGraph.sorted
Step 2: converting bedGraph to bigwig
using bedGraphToBigWig utility from UCSC tools (http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/bedGraphToBigWig)
bedGraphToBigWig file.bedGraph.sorted genomeIndex/mm9.chrom file.bw
I will make another post, how to use 'bw' (bigwig) files for viewing them on server using a https link and sharing a url.
Any problems, please comment, I will try to answer.
Cheers
Sukhdeep Singh
Max Planck Society

















