Christopher Fields > BioPerl > Bio::Tree::Draw::Cladogram



Annotate this POD


New  3
Open  3
View/Report Bugs


Bio::Tree::Draw::Cladogram - Drawing phylogenetic trees in Encapsulated PostScript (EPS) format.


  use Bio::Tree::Draw::Cladogram;
  use Bio::TreeIO;
  my $treeio = Bio::TreeIO->new('-format' => 'newick',
                               '-file'   => 'input.nwk');
  my $t1 = $treeio->next_tree;
  my $t2 = $treeio->next_tree;

  my $obj1 = Bio::Tree::Draw::Cladogram->new(-tree => $t1);
  $obj1->print(-file => 'cladogram.eps');

  if ($t2) {
    my $obj2 = Bio::Tree::Draw::Cladogram->new(-tree => $t1, -second => $t2);
    $obj2->print(-file => 'tanglegram.eps');


Bio::Tree::Draw::Cladogram is a Perl tool for drawing Bio::Tree::Tree objects in Encapsulated PostScript (EPS) format. It can be utilized both for displaying a single phylogenetic tree (a cladogram) and for the comparative display of two phylogenetic trees (a tanglegram) such as a gene tree and a species tree, a host tree and a parasite tree, two alternative trees for the same set of taxa, or two alternative trees for overlapping sets of taxa.

Phylogenetic trees are drawn as rectangular cladograms, with horizontal orientation and ancestral nodes centered over their descendents. The font used for taxa is Courier at 10 pt. A single Bio::Tree::Tree object is drawn with ancestors to the left and taxa flushed to the right. Two Bio::Tree::Tree objects are drawn with the first tree oriented left-to-right and the second tree oriented right-to-left, and with corresponding taxa connected by straight lines in a shade of gray. Each correspondence between a $taxon1 of the first tree and a $taxon2 of the second tree is established by setting $taxon1->add_tag_value('connection',$taxon2). Thus, a taxon of the first tree can be connected to more than one taxon of the second tree, and vice versa.

The branch from the parent to a child $node, as well as the child label, can be colored by setting $node->add_tag_value('Rcolor',$r), $node->add_tag_value('Gcolor',$g), and $node->add_tag_value('Bcolor',$b), where $r, $g, and $b are the desired values for red, green, and blue (zero for lowest, one for highest intensity).

This is a preliminary release of Bio::Tree::Draw::Cladogram. Future improvements include an option to output phylograms instead of cladograms. Beware that cladograms are automatically scaled according to branch lengths, but the current release has only been tested with trees having unit branch lengths.

The print method could be extended to output graphic formats other than EPS, although there are many graphics conversion programs around that accept EPS input. For instance, most Linux distributions include epstopdf, a Perl script that together with Ghostscript, converts EPS to PDF.


Mailing Lists

User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the Bioperl mailing list. Your participation is much appreciated.                  - General discussion  - About the mailing lists


Please direct usage questions or support issues to the mailing list:

rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible.

Reporting Bugs

Report bugs to the Bioperl bug tracking system to help us keep track of the bugs and their resolution. Bug reports can be submitted via the web:

AUTHOR - Gabriel Valiente ^


Code for coloring branches contributed by Georgii A Bazykin (


The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _


 Title   : new
 Usage   : my $obj = Bio::Tree::Draw::Cladogram->new();
 Function: Builds a new Bio::Tree::Draw::Cladogram object 
 Returns : Bio::Tree::Draw::Cladogram
 Args    : -tree => Bio::Tree::Tree object
           -second => Bio::Tree::Tree object (optional)
           -font => font name [string] (optional)
           -size => font size [integer] (optional)
           -top => top margin [integer] (optional)
           -bottom => bottom margin [integer] (optional)
           -left => left margin [integer] (optional)
           -right => right margin [integer] (optional)
           -tip => extra tip space [integer] (optional)
           -column => extra space between cladograms [integer] (optional)
           -compact => ignore branch lengths [boolean] (optional)
           -ratio => horizontal to vertical ratio [integer] (optional)
           -colors => use colors to color edges [boolean] (optional)
           -bootstrap => draw bootstrap or internal ids [boolean]


 Title   : print
 Usage   : $obj->print();
 Function: Outputs $obj in Encapsulated PostScript (EPS) format 
 Returns : 
 Args    : -file => filename (optional)
syntax highlighting: