File: DE_graph_to_dot.pl

package info (click to toggle)
trinityrnaseq 2.11.0%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 417,528 kB
  • sloc: perl: 48,420; cpp: 17,749; java: 12,695; python: 3,124; sh: 1,030; ansic: 983; makefile: 688; xml: 62
file content (55 lines) | stat: -rwxr-xr-x 1,044 bytes parent folder | download | duplicates (8)
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/env perl

use strict;
use warnings;

my $usage = "usage: $0 DE.graph\n\n";

my $DE_graph = $ARGV[0] or die $usage;


=color_panel

> colorpanel(10, 'black', 'purple', 'red')
 [1] "#000000" "#28083C" "#501078" "#7818B4" "#A020F0" "#A020F0" "#B818B4"
 [8] "#D01078" "#E7083C" "#FF0000"

=cut


my @colors = (
    "#000000", "#28083C", "#501078", "#7818B4", "#A020F0", "#A020F0", "#B818B4",
    "#D01078", "#E7083C", "#FF0000"
    );


main: {

    print "digraph G {\n";
    
    open (my $fh, $DE_graph) or die "Error, cannot open file $DE_graph";
    my $line = <$fh>;
    chomp $line;
    close $fh;

    my @x = split(/\t/, $line);
    shift @x;
    foreach my $pair (@x) {
        my ($from, $to, $logFC) = split(/,/, $pair);
        
        my $color_index = int($logFC + 0.5);
        if ($color_index > $#colors) {
            $color_index = $#colors;
        }
        my $color = $colors[$color_index];
        
        print "    $from->$to\[color=\"$color\"]\n";
    }
    
    print "}\n";
    
    exit(0);
}