Skip to content

Instantly share code, notes, and snippets.

@taoliu
Created July 26, 2015 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save taoliu/166a465edbfb75aadbfa to your computer and use it in GitHub Desktop.
Save taoliu/166a465edbfb75aadbfa to your computer and use it in GitHub Desktop.
UCSC narrowPeak to bigBed
#!/bin/bash
# set the path to as file for narrowPeak. Locate it in your UCSC source code directory or google...
asfile=/data/db/UCSC_sqls/encode/narrowPeak.as
which bedToBigBed &>/dev/null || { echo "bedToBigBed not found! Download: <http://hgdownload.cse.ucsc.edu/admin/exe/>"; exit 1; }
if [ $# -lt 2 ];then
echo "Need 2 parameters! <narrowPeak> <chrom info>"
exit
fi
F=$1
G=$2
bedtools slop -i ${F} -g ${G} -b 0 | bedClip stdin ${G} ${F}.clip
# fix scores over 1000
perl -pi -e 'chomp;@_=split;if ($_[4]>1000) {$_[4]=1000} $_=join("\t",@_)."\n"' ${F}.clip
bedToBigBed -type=bed6+4 -as=${asfile} ${F}.clip $G ${F/.narrowPeak/}.bb
rm -f ${F}.clip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment