[Bioperl-l] Cladogram construction

Julian Onions julian.onions at gmail.com
Fri Jan 8 16:53:50 UTC 2010


Does anyone have any sample code for building cladograms based on Pars (one
of Phylip tools) type format (or any other format actually)
I've got something sort of working but I get no weights on the tree -
everything appears as nan. I'd also like to set one of the species to be an
outgroup. This is the closest sample I've found so far.


#!/usr/bin/perl -w
use strict;
use Bio::AlignIO;
use Bio::Tree::DistanceFactory;
use Bio::Align::ProteinStatistics;
use Bio::TreeIO;
use Bio::Tree::Draw::Cladogram;
my $alnfile = shift @ARGV || die "need a file to run";

my $input= Bio::AlignIO->new(-format => 'fasta',
    -file    => $alnfile);

if( my $aln = $input->next_aln ) {
 my $dfactory = Bio::Tree::DistanceFactory->new(-method => 'NJ');
 my $stats = Bio::Align::ProteinStatistics->new;
 my $distmat = $stats->distance(-align => $aln,
         -method => 'Kimura');
 my $treeout = Bio::TreeIO->new(-format => 'newick');
 my $tree = $dfactory->make_tree($distmat);
 $treeout->write_tree($tree);
  my $obj1 = Bio::Tree::Draw::Cladogram->new(-tree    => $tree,
                                             -compact => 0);
  $obj1->print(-file => "tree.eps");
} else {
 die "could not find any alignments in the file $alnfile";
}



Pars input looks like
3 4
Robin   101
Blackbird 100
Sparrow 100


Thanks,
Julian.



More information about the Bioperl-l mailing list