/usr/share/doc/libsvg-graph-perl/examples/heatmap2.pl is in libsvg-graph-perl 0.02-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #!/usr/bin/perl
use strict;
use Data::Dumper;
use SVG::Graph;
use SVG::Graph::Data;
use SVG::Graph::Data::Datum;
my @d1 = ();
my $head = <>;
chomp $head;
my @head = split /\t/, $head;
shift @head;
my($i,$j) = (1,1);
while(<>){
chomp;
my @cols = split /\t/;
shift @cols;
$j = 1;
foreach my $c (@cols){
$c = int($c);
$c = 200 if $c eq 'nan';
# $c = 200 if $c == 0;
my $logc = log($c > 0 ? $c : 0.000001) / log(2);
# $logc = 10 if $logc > 10;
# $logc = 3 if $logc < 3;
$logc = undef if $c == 0;
#warn $c , "\t", $logc;
push @d1, SVG::Graph::Data::Datum->new(x=>$j,y=>$i,z=>$logc);
$j++;
}
$i++;
}
my $svg = SVG->new(width=>850,height=>850);
my $graph = SVG::Graph->new(svg=>$svg,xoffset=>0,yoffset=>0,width=>800,height=>700,margin=>30);
my $frame0 = $graph->add_frame;
my $frame1 = $frame0->add_frame;
my $data1 = SVG::Graph::Data->new(data => \@d1);
$frame1->add_data($data1);
$frame0->add_glyph('axis','stroke'=>'black','stroke-width'=>2,'x_absolute_ticks'=>1,x_intertick_labels=>\@head);
$frame1->add_glyph('heatmap',rgb_h=>[255,0,0],rgb_m=>[0,0,0],rgb_l=>[0,255,0]);
print $graph->draw;
|