in reply to Re^3: Generating colour codes according to value
in thread Generating colour codes according to value

Yes!! I should have said I want one colour per peptide frequency, sorry

  • Comment on Re^4: Generating colour codes according to value

Replies are listed 'Best First'.
Re^5: Generating colour codes according to value
by LanX (Saint) on Aug 17, 2016 at 18:07 UTC
    The keys of

      %frequencyColors = reverse %bindersBla

    are the different frequencies.

    scalar keys will give you the number.

    Now you are free to set the values to colors.

    Please show some effort and try to hack it by yourself now.

    update

    To late. ...

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

Re^5: Generating colour codes according to value
by Anonymous Monk on Aug 17, 2016 at 18:07 UTC
    So, does this help?
    #!/usr/bin/perl + use strict; use warnings; use Color::Spectrum qw/generate/; use List::MoreUtils qw/uniq/; use Data::Dump qw/pp/; my %peptides = ( HISCLTFGR => 16, MQLFHLCLI => 8, WGMDIDPYK => 4, YVNVNMGLK => 3, AYRPPNAPI => 2, ELMNLATWV => 2, EYLVSFGVW => 1, FFPSIRDLL => 1, FLPSDFFPS => 1, IISCSCPTV => 1 ); my @unique_indices = uniq values %peptides; my $num_colours = scalar @unique_indices; my @colours = generate($num_colours, '#FF0000', '#0060BF'); my %values_to_colours; $values_to_colours{$unique_indices[$_]} = $colours[$_] for 0..$#colour +s; pp %values_to_colours;