~/www/Lesson12/plotGraph.pl.html #! /usr/bin/perl -w

use strict;
use GD::Graph::bars;

my $total = 81;
my @names = ('miR-1/206','miR-6','miR-192','let-7/98','miR-122','miR-13','miR-769');
my @hits = (28, 5, 10, 40, 32, 3, 5);
my @pvals = (5.8e-17, 2e-3, 9e-08, 2.2e-26, 1.5e-39, 1e-4, 2.6e-09);

@hits = map {$_ /=$total} @hits;
@pvals = map { -log($_) } @pvals;

my @data = (\@names ,\@hits,\@pvals);


my $graph = GD::Graph::bars->new(500,300);

$graph->set (
             y1_label           => 'Coverage (%)',
             y2_label           => 'Enrichment (log p-value)',
             two_axes           => 1,
             bar_spacing => 4,
             transparent => 0,
             title             => 'Candidate miR regulators'
            ) or die $graph->error();

$graph->set_legend('Coverage','Enrichment');

my $gd = $graph->plot(\@data) or die $graph->error();;

open(IMG, '>mirRes.png') or die;
binmode IMG;
print IMG $gd->png;