From 1d421ad2a39f40f9144955330d41dbc8e5724603 Mon Sep 17 00:00:00 2001 From: preecej Date: Sat, 7 Jan 2012 02:11:07 +0000 Subject: [PATCH] Fixed white-box paralogy bug (caused to even-numbered max paralogs); cleanly separated heat-map f(x) from custom BoxColor; spread heat-map increments more evenly across the gradient via fixed outer bounds svn path=/; revision=255 --- .../perl_singletons/pathway_gene_swapper.pl | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/Personnel/preecej/perl_singletons/pathway_gene_swapper.pl b/Personnel/preecej/perl_singletons/pathway_gene_swapper.pl index 490959f..5734596 100644 --- a/Personnel/preecej/perl_singletons/pathway_gene_swapper.pl +++ b/Personnel/preecej/perl_singletons/pathway_gene_swapper.pl @@ -6,7 +6,7 @@ Pathway Gene Swapper =head1 VERSION -0.2 +0.3 =head1 DESCRIPTION @@ -36,7 +36,8 @@ replacement genes. Any new gene boxes may be painted with a custom color and border, and will be stacked and offset for ease of visualization (much like a deck -of cards). +of cards). If the heat-map option is invoked, the custom box color will +be ignored and a red-blue gradient will be applied to all mapped boxes. =head1 FUTURE CHANGES @@ -68,7 +69,12 @@ pathway_gene_swapper.pl -i INPUT_FILE -g GENE_MAPPING_FILE -c CONFIG_FILE -o OUT =head1 DEPENDENCIES and PREREQUISITES - - Non-standard Perl modules: Switch, Data::Dumper, XML::DOM + - Non-standard Perl modules: + Switch + Data::Dumper + XML::DOM + Graphics::ColorUtils + - The input file must be a valid GPML file - The CSV file must have a single-line column header. @@ -323,14 +329,23 @@ sub set_gradient($) my %blue_red_gradient; my $max_grad = $_[0]; - my $inc = sprintf("%.2f", 1/$max_grad); - my $count = 1; + my $inc = sprintf("%.2f", 0.98/($max_grad-1)); + + # set the fixed outer bounds + my $lower_bound = grad2rgb("blue_red",0.01); + $lower_bound =~ s/\#//; + $blue_red_gradient{1} = $lower_bound; + + my $upper_bound = grad2rgb("blue_red",0.99); + $upper_bound =~ s/\#//; + $blue_red_gradient{$max_grad} = $upper_bound; - for (my $i=$inc; $i<=0.99; $i=$i+$inc) { - my $tmp_hex = grad2rgb("blue_red",$i); + # set the inner increments + for (my $count = 2; $count<$max_grad; $count++) { + my $tmp_hex = grad2rgb("blue_red",($inc+0.01)); $tmp_hex =~ s/\#//; $blue_red_gradient{$count} = $tmp_hex; - $count++; + $inc += $inc; } return %blue_red_gradient; @@ -439,6 +454,8 @@ sub import_data if ($apply_homolog_heat) { %gradient = set_gradient($max_homolog_count); + if ($debug) { print "...\n" + . Dumper(%gradient) . "\n\n"; } } print "Opening GPML pathway file and reading data...\n\n"; @@ -775,7 +792,7 @@ sub swap_genes $curr_graphics->setAttribute("Width",$configs{"BoxWidth"}); # add "heat" to genes with multiple homologs - if ($apply_homolog_heat && ($gene_suffix_counter > 0)) + if ($apply_homolog_heat) { $curr_graphics->setAttribute("FillColor", $gradient{scalar(@new_nodes_map)}); $curr_graphics->setAttribute("Color","8888ff"); -- 2.34.1