Skip to content

Instantly share code, notes, and snippets.

@mtw
Created February 22, 2014 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtw/9155795 to your computer and use it in GitHub Desktop.
Save mtw/9155795 to your computer and use it in GitHub Desktop.
Creates stranded BigWig files from BED
#!/bin/bash
chromsizes="./chrom.sizes"
genomeCoverageBed=`which genomeCoverageBed`
bedGraphToBigWig=`which bedGraphToBigWig`
vis="./vis"
samples=9
fromsample=1
rep=2
fromrep=1
if ! [ -f "$chromsizes" ]; then
echo "chrom.sizes file not found"
exit 2
fi
mkdir -p $vis
for s in $(seq $fromsample $samples)
do
for r in $(seq $fromrep $rep)
do
sample=D${s}_R${r}
echo processing $sample
$genomeCoverageBed -bg -i ${sample}.pos.bed -g ${chromsizes} -strand + > ${vis}/${sample}.pos.bg
$genomeCoverageBed -bg -i ${sample}.neg.bed -g ${chromsizes} -strand - > ${vis}/${sample}.neg.bg.1
cat ${vis}/${sample}.neg.bg.1 | awk '{ $4 = - $4 ; print $0 }' > ${vis}/${sample}.neg.bg && rm ${vis}/${sample}.neg.bg.1
$bedGraphToBigWig ${vis}/${sample}.pos.bg ${chromsizes} ${vis}/${sample}.pos.bw &
$bedGraphToBigWig ${vis}/${sample}.neg.bg ${chromsizes} ${vis}/${sample}.neg.bw &
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment