Created
February 22, 2014 14:38
-
-
Save mtw/9155795 to your computer and use it in GitHub Desktop.
Creates stranded BigWig files from BED
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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