[Bioperl-l] Fwd: Problem with Bio::Tree::Draw::Cladogram

Roy Chaudhuri roy.chaudhuri at gmail.com
Wed Mar 14 15:18:48 UTC 2012


Hi Sari,

I think the problem is that Bio::Taxon considers id to be the taxon id, 
but it inherits from Bio::Tree::NodeI, which defines id as the 
human-readable name. Since you are already adding names, as a workaround 
you should be able to also add them to the id slot using:
$node->id($name[$c]);
They should then print out with your tree.

Cheers,
Roy.

On 14/03/2012 00:47, Sari Khaleel wrote:
> Hello, My name is Sari Khaleel, I'm a master's student at UD and I've
> been playing with this module. My problem is that the cladogram shows
> the node's taxid instead of the node's name, as in the attached
> picture below. I went through the code and it seems that print()
> function prints the node's id (its taxid) instead of its name. Is
> there anyway around that.
>
> Here's a simplified version of what I'm trying to do .. it's a simple
> script that tries to build a tree and print from a list of taxids:
>
> my $db = Bio::DB::Taxonomy->new(-source =>  'entrez'); # use NCBI Entrez over HTTP
> my @taxids = qw(296483 398577 269482 331272 331271 266265);
> my @names = qw (a b c d e f);
>
> # Get taxons from entrez
> 	my %taxid2taxon;
>         foreach my $taxid (@taxids){
>             $taxid2taxon{$taxid} = $db->get_taxon(-taxonid =>  $taxid);
>         }
>
>         my $tree; my $c =0;
>         foreach my $taxid (@taxids){
>             my $node = $taxid2taxon{$taxid};
>             $node->name('supplied', $name[$c]);
>
>             if (! $tree){
>                 $tree = Bio::Tree::Tree->new(-verbose =>  $db->verbose, -node =>  $node);
>             }
>             else{
>                 $tree->merge_lineage($node);
>             }
> 	    $c++;
>         }
>
>
>     # Print the tree as a cladogram
>         my $obj1 = Bio::Tree::Draw::Cladogram->new(-tree =>  $tree);
>         $obj1->print(-file =>  "cladogram.eps");
>
> # DONE
>
>
> Sari
>
>
>
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l




More information about the Bioperl-l mailing list