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

"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?

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

Replies are listed 'Best First'.
Re^4: Generating colour codes according to value
by Sandy_Bio_Perl (Beadle) on Aug 17, 2016 at 17:58 UTC

    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;
Re^4: Generating colour codes according to value
by Sandy_Bio_Perl (Beadle) on Aug 17, 2016 at 18:02 UTC

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