[Bioperl-l] TreeIO, how (does) it work?

Jason Stajich jason at bioperl.org
Mon Feb 12 03:05:18 UTC 2007


On Feb 11, 2007, at 6:40 PM, Wolverine Fran wrote:

> Hi,
>
> I have a problem. I don't understand how TreeIO reads the trees:
> my input: ((dog:0.04,cat:0.08):0.12,(human:0.15,mouse:0.2));
>
> An unrooted tree with 4 tips and 2 internal nodes.
> when I asked for:
> print "Total number of nodes ",$tree->number_nodes;
>
> I get 6 but when I ask for:
> foreach my $node (@nodes) {
> 	print $node->internal_id,",";
> }
> I get 6,0,1,2,3,4,5. Total 7.
>
> The root is number 6 and 2 and 5 are my internal nodes.
> If I set the root to be number 5 this node 6 is still present.
> Why? what is the node 6?

Node 6 is to hold the root or a fake root with a trifurcation for  
unrooted trees.  Did you actually call the reroot method to set the  
root to node 5?

>
> when I try the following:
>   $node5 = $tree->find_node(-internal_id => '5');
>   $node6 = $tree->find_node(-internal_id => '6');
>   $node2 = $tree->find_node(-internal_id => '2');
>   $distance1 = $tree->distance(-nodes =>[$node5,$node2]);
>   $distance2 = $tree->distance(-nodes =>[$node5,$node6]);
>   $distance3 = $tree->distance(-nodes =>[$node2,$node6]);
>   or any other distance I get 2 warnings:
>   -------------------- WARNING ---------------------
> MSG: Must provide a valid array reference for -nodes
> ---------------------------------------------------
>
> -------------------- WARNING ---------------------
> MSG: Could not find distance!
> ---------------------------------------------------
> What am I doing incorrectly?
>
The distance method is just summing branch lengths on the path  
between two nodes.  Is that what are you trying to do?

The error message you report doesn't make sense as
"Must provide a valid array reference for -nodes"
is only printed when you call is_monophyletic or is_paraphyletic as  
far as I can tell.

what version of bioperl are you using?

> I am practicing with AlignIO and TreeIO to calculate the maximum  
> likelihood
> for a given tree. So,other information about that would be of great  
> help. I am practicing with
> this to see how Bioperl can help me with more complex problems.
>
You are trying to calculate the likelihood of a tree or are you  
trying to generate a ML tree from an alignment?

> Thank you very much for your help!
>
> _________________________________________________________________
> Acepta el reto MSN Premium: Correos más divertidos con fotos y textos
> increíbles en MSN Premium. Descárgalo y pruébalo 2 meses gratis.
> http://join.msn.com? 
> XAPID=1697&DI=1055&HL=Footer_mailsenviados_correosmasdivertidos
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l

--
Jason Stajich
Miller Research Fellow
University of California, Berkeley
lab: 510.642.8441
http://pmb.berkeley.edu/~taylor/people/js.html
http://fungalgenomes.org/





More information about the Bioperl-l mailing list