Skip to content

Instantly share code, notes, and snippets.

@mtw
Created October 22, 2013 11:39
Show Gist options
  • Save mtw/7099129 to your computer and use it in GitHub Desktop.
Save mtw/7099129 to your computer and use it in GitHub Desktop.
Convert BAM to BigWig coverage (useful for visualization in UCSC Browser)
#!/bin/bash
# generate coverage profiles
vis="./vis"
chromsizes="foo.chrom.sizes"
genomeCoverageBed=`which genomeCoverageBed`
bedGraphToBigWig=`which bedGraphToBigWig`
if ! [ -d "$vis" ];
then
mkdir -p $vis
echo "created $vis"
fi
set -x
for BAM in $(ls *.bam)
do
$genomeCoverageBed -ibam $BAM -bg -g $chromsizes > $vis/$BAM.bg
$bedGraphToBigWig $vis/$BAM.bg $chromsizes $vis/$BAM.bw
done
set +x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment