The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Chromosome::Map - Generate GD images of chromosome maps

SYNOPSIS

 #!/usr/bin/perl -w 
 # This script produce a chromosomal map with several markers and QTL
 # interval region. A fake %GC content is added to the chromosome 
 
 use strict; 
 use Chromosome::Map;
 
 my %H = (ADL120 => '25', 
          ADL035 => '5', 
          ADL034 => '4', 
          MCW014 => '110', 
          MCW123 => '89', 
          MCW340 => '70', 
          LEI456 => '132', 
          LEI451 => '130', 
          LEI452 => '130.5', 
          LEI453 => '130.7', 
          LEI454 => '131', 
          LEI455 => '131.4', 
          LEI457 => '132', 
          MCW087 => '50', 
          MCW012 => '12', 
          MCW051 => '51', 
          ADL121 => '26', 
          ADL123 => '27', 
          ADL122 => '26.2', 
          MCW114 => '45', 
          LEI258 => '15', 
          MCW240 => '45.1', 
          MCW247 => '110', 
          LEI556 => '44', 
          MCW614 => '45.2', 
          ADL067 => '5.3', 
          MCW140 => '45.2', 
          LEI056 => '45.6', 
         ); 
 
 my $map = Chromosome::Map->new (-length     => '140', 
                                 -name       => 'GGA5', 
                                 -height     => '500', 
                                 -units      => 'cM', 
                                ); 
 
 my $size  = $map->get_map_size; 
 my $units = $map->get_map_units; 
 
 print "Map size: $size $units\n";
 
 my $mark_track = Chromosome::Map::Track->new (-name => 'Markers',
                                               -type => 'marker',
                                              );
 my $qtl_track  = Chromosome::Map::Track->new (-name => 'QTL',
                                               -type => 'interval',
                                              );
 my $GC_track  = Chromosome::Map::Track->new  (-name    => '%GC content',
                                               -type    => 'feature',
                                               -display => 'relative',
                                               -render  => 'gradient',
                                              );
 # adding tracks to map
 $map->add_track($mark_track);
 $map->add_track($qtl_track);
 $map->add_track($GC_track);
 
 my $nb_track = $map->get_nb_tracks;
 print "Nb track: $nb_track\n";
 
 # Generating a fake feature relative elements and add them in track
 # only for illustrative purpose
 my %GC;
 for (my $i=0;$i<=5000;$i++) {
     my $nb = abs ( rand ($size));
     my $value = abs ( rand (1));
     $GC{$nb} = $value;
 }
 
 foreach my $nb (keys %GC) {
     my $gc = Chromosome::Map::Feature->new (-loc => $nb,
                                             -color => 'indigo',
                                             -value => $GC{$nb},
                                             -valuetype => 'relative',
                                            );
     $GC_track->add_element($gc);
 }
 
 my @Color = qw (blueviolet darkgoldenrod black softblue khaki red blue tomato);
 
 foreach my $mark (keys %H) {
     my $i = abs (int( rand ($#Color) ) );
     my $marker = Chromosome::Map::Element->new(-name  => $mark,
                                                -loc   => $H{$mark},
                                                -color => $Color[$i],
                                               );
     $mark_track->add_element($marker);
 }
 
 # Define QTL element
 my $qtl1 = Chromosome::Map::Block->new (-name  => 'BW',
                                         -start => '3',
                                         -end   => '11',
                                         -color => 'darkgoldenrod',
                                        );
 
 my $qtl2 = Chromosome::Map::Block->new (-name  => 'FAT',
                                         -start => '92',
                                         -end   => '100',
                                         -color => 'darkgoldenrod',
                                        );
 
 my $qtl3 = Chromosome::Map::Block->new (-name  => 'LEAN',
                                         -start => '112',
                                         -end   => '120',
                                         -color => 'darkgoldenrod',
                                        );
 
 my $qtl4 = Chromosome::Map::Block->new (-name  => 'EGG DEV',
                                         -start => '95',
                                         -end   => '115',
                                        );
 
 my $qtl5 = Chromosome::Map::Block->new (-name  => 'IC',
                                         -start => '91',
                                         -end   => '122',
                                         -color => 'blueviolet',
                                        );
 
 my $qtl6 = Chromosome::Map::Block->new (-name  => 'BORN',
                                         -start => '20',
                                         -end   => '130',
                                        );
 
 my $qtl7 = Chromosome::Map::Block->new (-name  => 'REPRODUCTION',
                                         -start => '20',
                                         -end   => '130',
                                        );
 
 $qtl_track->add_element($qtl1);
 $qtl_track->add_element($qtl2);
 $qtl_track->add_element($qtl3);
 $qtl_track->add_element($qtl4);
 $qtl_track->add_element($qtl5);
 $qtl_track->add_element($qtl6);
 $qtl_track->add_element($qtl7);
 
 
 my $png = $map->png;
 my $filename_png = "chr_map.png";
 open (PNG, ">$filename_png") || die "cannot create file: $filename_png!\n";
 binmode PNG;
 print PNG $png;
 close PNG;

DESCRIPTION

The Chromosome::Map module can produce chromosomal map image file. It can be used to draw genetic or physical maps. Several tracks (i.e. list of marker) can be add to the chromosomal map: markers track and QTL interval region track (see synopsis). A code colors list is available at http://chicken.genouest.org/documentations/chromosomemap/#colors

METHODS

This section describes the class and object methods for the Chromosome::Map module.

Map object

First, you will begin by creating a new Chromosome::Map object:

 my $map = Chromosome::Map->new ( ... options ... );

The new() method creates a new panel object. The options are a set of tag/value pairs as follows:

 Option        Value                                                  Default
 ------        -----                                                  -------
 -name         title name of the chromosomal map                      none

 -start        location start of the map                              0
 -length       size of the map (i.e location end)                     none
 -units        unit of the map (i.e cM or MB, only for display)       none
 -height       size of the resulting image (pixel)                    none

 -pad_left     left margin                                            20
 -pad_right    right margin                                           20
 -pad_top      top margin                                             20
 -pad_bottom   bottom margin                                          40

Public methods description:

  • add_track: add an existing track to an existing map. return O in case of error

     $map->add_track($track) 
  • png: create a PNG image of the map

     $name = $map->png 
  • get_map_name: return the title name of the map

     $name = $map->get_map_name 
  • get_map_start: return the start location of the map

     $map_start = $map->get_map_start 
  • get_map_size: return the end location of the map (i.e. the map size)

     $map_size = $map->get_map_size 
  • get_map_units: return the unit of the map (i.e. cM, MB, KB...)

     $map_unit = $map->get_map_units 
  • get_nb_tracks: return the number of the tracks in the map

     $nb_track = $map->get_nb_tracks 
  • get_list_track: return a list (%Hash) of the tracks in the map

     %List = $map->get_list_track 

Track object

Then, you will create different tracks and add them to the Chromosome::Map object.

 my $track = Track->new ( ... options ... ); 
 $map->add_track($track); 

The new() method creates a new track object. The options are a set of tag/value pairs as follows:

 Option        Value                                                  Default
 ------        -----                                                  -------
 -name         title name of the track                                none
 
 -type         this tag will permit you to define the type of the     none
               track with the followin values:
               'marker': designed for markers
               'interval': designed for QTL interval region, could
               marker interval or gene location, too
               'feature': designed to plot physical features on
               chromosomes (%GC, nb genes)

if you choose the feature track type, you have to define some other specific options:

 Option        Value                                                  Default
 ------        -----                                                  ------- 
 -display      the tag will permit to define the rendering of the     absolute
               feature track with the following value:
               'absolute': if several feature values are present in
               one pixel interval, the feature values will be added
               for display.
               'relative': if several feature values are present in
               one pixel interval, the mean value of all the
               feature values will be used for display.

 -render       define the rendering effet of the feature track with   plain
               the following values:
               'plain': use plain color
               'gradient': gradient value according to the feature
               value
               'threshold': change color according to a threshold
               value

 -threshold    define the threshold value to change color in          none 
               threshold rendering effect

Note: you cannot add several feature tracks. Other feature tracks will be discard.

Public methods description:

  • add_element: add an existing element to an existing track. return O in case of error

     $track->add_element($element) 
  • get_track_name: return the start location of the map

     $track_name = $track->get_track_name 
  • get_track_type: return the track type (i.e. marker, interval or feature)

     $track_type = $track->get_track_type 
  • get_nb_elements: return the number of elements in a track

     $nb_element = $track->get_nb_elements 
  • get_list_element: return an ARRAY of the elements in the track

     @List = $track->get_list_element 
  • get_list_element_sorted_location: return an ARRAY of the elements in the track, sorted on their location

     @List = $track->get_list_element_sorted_location 

Element, Block and Feature objects

When your map and tracks object are created, then, you can create the elements you want to add into the tracks. There is three different type of object:

Element object

This object is primary designed to manage marker elements and to add them into a marker track. You will create it by passing the name (optional), the location of the element and the font color (optional, default=black).

 my $marker = Chromosome::Map::Element->new( ... options ... ) 

 Option        Value                                                  Default
 ------        -----                                                  -------  
 -name         element name (optional)                                none 
 -loc          element location                                       none 
 -color        color_name                                             black 

the -color tag will permit to define different element group and display them with different colors.

Block object

This object is primary designed to display chromosomal interval (i.e QTL region, genes, ...). This class is inherited from the element object with a field for the interval end location. You will create this object by passing it the block name (optional), block start and end location, and the block background color (note: the end location must be greater than thestart location).

 my $block = Chromosome::Map::Bloc->new( ... options ... ) 

 Option        Value                                                  Default
 ------        -----                                                  -------
 -name         block name (optional)                                  none 
 -loc          block start location                                   none  
 -end          block end location                                     none  
 -color        color_name                                             black
Feature object

This object is designed to display chromosome features as %GC content, gene density or whatever features with a numerical value. This object is also inherited from the element class. You will create this object by passing it the feature location, the feature value, the value type (i.e. absolute or relative) and color, depending on the display rendering choosen during the feature track creation.

 my $feature = Chromosome::Map::Feature->new( ... options ... ) 

 Option        Value                                                  Default
 ------        -----                                                  -------
 -loc          feature location                                       none 
 -value        feature value                                          none 
 -color        feature rendering color                                softblue 
 -threscolor   feature threshold color (if value > threshold)         red 
 -value        feature value                                          1 
 -valuetype    feature value type:                                    absolute 
               'absolute': absolute value (i.e. nb of genes)
               'relative': relative value (i.e. %GC)

Of course, you cannot mix different value types in one track.

The choice of value type has an impact on the rendering of the feature track. You have to choose carefully the value type tag and the display tag of the feature track object:

  • If you choose an 'absolute' value type element, you can either display it in absolute or relative render option in the track object.

    ex: let hypothetize you want to display the number of gene on your chromosome. For each gene, you will create a feature object:

     my $gene = Chromosome::Map::Feature->new (-loc=$location); 

    Then, you can display the feature track as 'absolute': in one pixel interval, the number of genes will be displayed. But, you can also display the number of genes as a percentage of the maximum number of genes on the chromosome: the render tag in the track object have to be set to 'relative'.

  • If you choose a 'relative' value type element, you HAVE to set the render tag in the track object to 'relative' (since displaying relative data in an absolute is non sense).

Common public methods (available with element, block and feature objects):

  • get_element_loc:

     $loc = $element->get_element_loc 
  • get_element_name:

     $element_name = $element->get_element_name 
  • get_element_color:

     $element_color = $element->get_element_color 

Block public method:

  • get_block_end:

     $block_end_location = $block->get_block_end 

Feature public methods:

  • get_feature_value: return the value of the feature object

     $value = $feature->get_feature_value 
  • get_feature_value_type: return the type of the value (relative or absolute)

     $value_type = $feature->get_feature_value_type
  • get_feature_threshold_color: return the threshold color (default=red)

     $threshold_col = $feature->get_feature_threshold_color 

AUTHOR

Frédéric Lecerf http://chicken.genouest.org

COPYRIGHT

Copyright (C) 2010, Frédéric Lecerf.

LICENSE

This module is free software; you can redistribute it or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 820:

Non-ASCII character seen before =encoding in 'Frédéric'. Assuming UTF-8