Advertisement
jhangyu

Circos Plot.sh

Jun 21st, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.86 KB | None | 0 0
  1. #Install Circos
  2. conda install circos
  3. #Install dependency modules
  4. cpanm -v Carp Clone Config::General Cwd Data::Dumper Digest::MD5 File::Basename File::Spec::Functions File::Temp FindBin Font::TTF::Font GD GD::Polyline Getopt::Long IO::File List::MoreUtils List::Util Math::Bezier Math::BigFloat Math::Round Math::VecStat Memoize POSIX Params::Validate Pod::Usage Readonly Regexp::Common SVG Set::IntSpan Statistics::Basic Storable Sys::Hostname Text::Balanced Text::Format Time::HiRes
  5.  
  6. #Turn VCF Spots into number counts in region
  7. for ID in $(ls | grep -P -o '.*(?=(.vcf))')
  8. do
  9.     if [ ! -f ${ID}.dat.txt ] ;then
  10.         awk '/^#/ {next} {printf("%s\t%d\n",$1,$2-$2%10000);}' ${ID}.vcf | sort | uniq -c | awk '{printf("%s\t%s\t%d\t%s\n",$2,$3,$3+10000,$1);}' > ${ID}.dat.txt
  11.     fi
  12. done
  13.  
  14. for ID in $(ls | grep -P -o '.*(?=(.dat.txt))')
  15. do
  16.     if [ ! -f ${ID}.chrd.txt ] ;then
  17.         echo process ${ID} changing chromosome id to name
  18.         cp ${ID}.dat.txt ${ID}.chrd.txt
  19.         pids="$pids $!"
  20.         wait $pids
  21.         while read ref_seq chr
  22.         do
  23.             #Convert ref_seq ID into chromosome number
  24.             sed -i s/${ref_seq}/${chr}/g ${ID}.chrd.txt
  25.             pids="$pids $!"
  26.             wait $pids
  27.         done < ref_chr.list
  28.     fi
  29.     if [ ! -f ${ID}.png ] ;then
  30.         echo Create ${ID} config file for circos
  31.         #Input the plot file and the max point
  32.         maxpoint=$(sort -rnk4 ${ID}.chrd.txt | awk '!x[$2]++' | head -1 | cut -f 4)
  33.         sed s/plotfileinput.txt/${ID}.chrd.txt/g vcf_density.conf > ${ID}_vcf_density.conf
  34.         sed -i s/max_point_vale/${maxpoint}/g ${ID}_vcf_density.conf
  35.         pids="$pids $!"
  36.         wait $pids
  37.         echo Drawing ${ID} circos plot
  38.         circos -outputdir ./ -outputfile ${ID} -conf ${ID}_vcf_density.conf
  39.         pids="$pids $!"
  40.         wait $pids
  41.     fi
  42.     rm ${ID}.dat.txt
  43. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement