This runs on processed alignment files (bam) to create normalized visualization tracks, primarily for use in IGV/UCSC Genome Browser. Note that this script requires a preset effective genome size and a genome sequence file in 2bit format (see UCSC utility faToTwoBit for conversion of .fa files).



sample directory where fastq files are located in a" directory fastq (thanks to "


allocated threads for the job; note that memory amt" proportional to number of threads / 20 * 128G (Ruddle)" which ends up being about 6GB per thread"


This script requires the following:

  • deepTools v2.2.4


#' Preset parameters
MEMPERTHREAD=6                 # GB; 128 GB of RAM / 20 cores per node
EFFGENOMESIZE=2150570000       # Effective genome size (mm10) [hg19 = 2451960000]
BLACKLIST=/home/ra364/Reference/Mus_musculus/Ensembl/GRCm38/Annotation/Genes/mm10_blacklist.bed    #' UCSC chr

#' 0. Read in Parameters
SDIR=$(readlink -f $1)
PREFIX=$(basename $SDIR)

#' 0. Echo parameters back
echo ""
echo "Beginning to process your bam files for conversion to bigwig.."
echo ".. Memory per thread is: $MEMPERTHREAD GB"
echo ".. Filtering reads from the blacklist: $BLACKLIST"
echo ".. Effective Genome Size (mm10): $EFFGENOMESIZE"
echo ""
echo "Working on: $SDIR"
echo ".. Using prefix: $PREFIX"
echo ".. Using $THREADS threads"
echo ""

# echo ".. Loading module Langs/Python/2.7.11_libs.."
# module load Langs/Python/2.7.11_libs

#' 1. Part 1.
echo "1. Calculating coverage for bigwig.."
mkdir -p $SDIR/bigwig
cd $SDIR

bamCoverage \
    -b $SDIR/bam_clean/${PREFIX}.bam \
    -o $SDIR/bigwig/${PREFIX}.bw \
    --outFileFormat=bigwig \
    --blackListFileName $BLACKLIST \
    --numberOfProcessors=$THREADS \
    --binSize=10 \
    --smoothLength=30 \
    --normalizeTo1x $EFFGENOMESIZE \
    --extendReads=300 \
#' do not set ignoreDups when using GC bias correction
#'    -b $SDIR/correctGCBias/${PREFIX}_gc.bam \

echo ""
echo "Coverage calculation complete."
echo ""