-
-
Save jurgjn/1582d1f014164c70e25a091002c76e7a to your computer and use it in GitHub Desktop.
bedGraph to bigWig
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 | |
# check commands: slopBed, bedGraphToBigWig and bedClip | |
which bedtools &>/dev/null || { echo "bedtools not found! Download bedTools: <http://code.google.com/p/bedtools/>"; exit 1; } | |
which bedGraphToBigWig &>/dev/null || { echo "bedGraphToBigWig not found! Download: <http://hgdownload.cse.ucsc.edu/admin/exe/>"; exit 1; } | |
which bedClip &>/dev/null || { echo "bedClip not found! Download: <http://hgdownload.cse.ucsc.edu/admin/exe/>"; exit 1; } | |
# end of checking | |
if [ $# -lt 2 ];then | |
echo "Need 2 parameters! <bedgraph> <chrom info>" | |
exit | |
fi | |
F=$1 | |
G=$2 | |
bedtools slop -i ${F} -g ${G} -b 0 | bedClip stdin ${G} ${F}.clip | |
LC_COLLATE=C sort -k1,1 -k2,2n --temporary-directory=./ ${F}.clip > ${F}.sort.clip | |
bedGraphToBigWig ${F}.sort.clip ${G} ${F/bdg/bw} | |
rm -f ${F}.clip ${F}.sort.clip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment