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

I want to have one colour per unique peptide, from red to green, with red associated with the most frequently observed peptides. $uniqueBinders just lets me know how many unique peptides there are in the list, so each unique binder will be the same colour. So, all 16 HISCLTFGR peptides will be red. However, peptides EYLVSFGVW and IISCSCPTV which both only appear once are not the same colour, because Color::Spectrum continues to alter the colour codes as the values in @colours change with each element from 'hot' to 'cold'. I would like peptides of a similar frequency to be the same colour

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

Replies are listed 'Best First'.
Re^3: Generating colour codes according to value
by Anonymous Monk on Aug 17, 2016 at 17:56 UTC

    "I want to have one colour per unique peptide, [...] I would like peptides of a similar frequency to be the same colour"

    Isn't that contradictory?

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

        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!

        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;

      Yes!! Sorry, I can see the error of my logic. I would in fact like one colour per peptide frequency