3 Author: Hu Xuesong @ BGI <huxuesong@genomics.org.cn>
4 Version: 0.1.1 @ 20111111
9 die "Usage: $0 <datfile> [max-depth-to-plot]\n" unless @ARGV;
14 my (%GCdat,@GCvalues);
15 open IN
,'<',$name or die "Error openimg $name: $!\n";
17 if (/^#WinSize=(\d+)/) {
23 my ($gc,undef,$depcnt,$mean)=split /\s+/;
25 $GCdat{$gc}=[$depcnt,$mean];
26 #print "{$gc}=[$depcnt,$mean]\n";
31 open OUT
,'>',$name.'.gc' or die "Error openimg ${name}.gc: $!\n";
32 print OUT
"#WinSize: $WinSize\n",join("\t",'#GC%(left border)','MeanDepth'),"\n";
35 my ($summer,$counter)=(0,0);
37 if ($gc-$lastGC>=$step) {
38 print OUT
join("\t",$lastGC,$summer/$counter),"\n" if $counter;
40 ($summer,$counter)=(0,0);
42 next unless exists $GCdat{$gc};
43 $summer += $GCdat{$gc}->[1] * $GCdat{$gc}->[0];
44 $counter += $GCdat{$gc}->[0];
46 #print OUT join("\t",$GCvalues[-1],$summer/$counter),"\n" if $counter;
49 chomp(my $user=`id -nru`);
51 if ($user eq 'galaxy') {
53 $font='/home/galaxy/fonts/arial.ttf';
55 $gnuplot='/opt/blc/genome/biosoft/gnuplot-4.4.0/bin/gnuplot';
56 $font='/ifs1/ST_ASMB/USER/huxuesong/public/fonts/arial.ttf';
58 open P
,'>',$name.'.dem' or die "Error openimg $name.dem: $!\n";
59 my $yrange='#set yrange [0:10]';
61 $yrange="set yrange [0:$maxdep]";
69 set xtics 0,5 nomirror
70 set ytics nomirror format "% 4.0f"
73 #set term png font "$font" 64 size 4204,3154 truecolor linewidth 3
74 set term png font "$font" 16 size 1600,1200
75 set output "$name.png"
76 set multiplot layout 2,1
77 set title "GC-dep plot of Window_Size=$WinSize"
80 set y2label "Max Depth"
87 using 1:11 with lines axis x1y2 lt rgb "#006400" lw 2 title 'max depth', \\
88 '' using 1:6:5:9:8 with candlesticks lt rgb "navy" lw 2 title 'depth box' whiskerbars 0.5, \\
89 '' using 1:7:7:7:7 with candlesticks lt -1 lw 2 notitle, \\
90 '' using 1:4 with points lt rgb "red" lw 3 title 'mean depth'
93 set y2tics textcolor rgb "#FFFFFF"
95 set xtics out nooffset format ''
100 set ytics nomirror format "% 4.0f" 1,10,1e5
102 plot '$name' using 1:3 with boxes fs solid 0.62 lt rgb "navy" lw 1.5 title 'window count'
104 #pause -1 "Hit return to continue"
108 system($gnuplot,$name.'.dem');