0
|
1 #!/usr/bin/perl
|
|
2
|
|
3 use strict;
|
|
4 use File::Basename;
|
|
5 my $dirname = dirname(__FILE__);
|
|
6
|
|
7 my $in = $ARGV[0];
|
|
8 my $yaxis = $ARGV[1];
|
|
9 my $output = $ARGV[2];
|
|
10
|
|
11 open(H,">$output");
|
|
12 print H qq~
|
|
13 <script src="https://code.highcharts.com/highcharts.js"></script>
|
|
14 <script src="https://code.highcharts.com/highcharts-more.js"></script>
|
|
15 <script src="https://code.highcharts.com/modules/exporting.js"></script>
|
|
16 <script src="https://code.highcharts.com/modules/export-data.js"></script>
|
|
17 <script src="https://code.highcharts.com/modules/accessibility.js"></script>
|
|
18
|
|
19 <figure class="highcharts-figure">
|
|
20 <div id="container"></div>
|
|
21 </figure>~;
|
|
22
|
|
23
|
|
24 my %hash;
|
|
25 open(F,$in);
|
|
26 my $first = <F>;
|
|
27 $first =~s/\n//g;$first =~s/\r//g;
|
|
28 my %level;
|
|
29 my $order = "";
|
|
30 my @headers = split(/\t/,$first);
|
|
31 while(<F>){
|
|
32 my $line = $_;
|
2
|
33 $line =~s/\n//g;$line =~s/\r//g;$line =~s/\"//g;
|
0
|
34 my @infos = split(/\t/,$line);
|
|
35 my $cat = $infos[0];
|
|
36 for (my $i = 1; $i <= $#infos; $i++){
|
|
37 $hash{$cat}{$headers[$i]}.= $infos[$i]."\n";
|
|
38 if ($order !~/$headers[$i]/){
|
|
39 $order .= $headers[$i]."|";
|
|
40 }
|
|
41 $level{$headers[$i]}=1;
|
|
42 }
|
|
43 }
|
|
44 close(F);
|
|
45
|
|
46 my @categories = split(/\|/,$order);
|
|
47
|
|
48 my $categories = "\"".join("\",\"",@categories)."\"";
|
|
49 my %series;
|
|
50 foreach my $cat(keys(%hash)){
|
|
51 my $refhash = $hash{$cat};
|
|
52 my %subhash = %$refhash;
|
|
53 foreach my $header(@categories){
|
|
54 my $values = $hash{$cat}{$header};
|
2
|
55 $values =~s/;/\n/g;
|
|
56 if ($values =~/\d+/){
|
|
57 open(F,">inforcalc");print F $values;close(F);
|
|
58 my $cmd = `Rscript $dirname/calc.r <inforcalc`;
|
|
59 unlink("infocalc");
|
|
60 my ($min,$max,$quantile1,$quantile2,$quantile3,$quantile4,$quantile5) = split(";",$cmd);
|
|
61 $series{$cat} .= " [$min,$quantile2,$quantile3,$quantile4,$max],\n";
|
|
62 }
|
|
63 else{
|
|
64 $series{$cat} .= " [0,0,0,0,0],\n";
|
|
65 }
|
0
|
66 }
|
|
67 }
|
|
68
|
|
69 my $javascript = qq~
|
|
70 <script type='text/javascript'>
|
|
71 Highcharts.chart('container', {
|
|
72
|
|
73 chart: {
|
|
74 type: 'boxplot'
|
|
75 },
|
|
76 legend: {
|
|
77 enabled: true
|
|
78 },
|
|
79 title: {
|
|
80 text: ''
|
|
81 },
|
|
82 xAxis: {
|
|
83 categories: [$categories]
|
|
84 },
|
|
85 yAxis: {
|
|
86 title: {
|
|
87 text: '$yaxis'
|
|
88 }
|
|
89 },
|
|
90
|
|
91 series: [
|
|
92 ~;
|
|
93 foreach my $cat(keys(%hash)){
|
|
94 $javascript .= "{name: '$cat',\n";
|
|
95 my $values = $series{$cat};
|
|
96 chop($values);chop($values);
|
|
97 $javascript .= "data: [ $values ] },\n";
|
|
98 }
|
|
99 chop($javascript);chop($javascript);
|
|
100 $javascript .= "]\n });\n";
|
|
101 $javascript .= "</script>";
|
|
102 print H $javascript;
|
|
103 close(H);
|
|
104
|
|
105
|