[R] problem accessing trees after read.nexus from ape package

From: Betty Gilbert <lgilbert_at_berkeley.edu>
Date: Tue 09 May 2006 - 11:37:14 EST


Hello,
I've been trying to figure out how to access the individual elements from an object of class phylo.
I am reading in 201 trees created by paup as below.

> read.nexus("A_30knj_200t.txt", tree.names= NULL) -> anj30
> anj30[1]

$tree1
$edge

       [,1] [,2]

  [1,] "-1" "-2"
  [2,] "-2" "-3"
  [3,] "-3" "1"
  [4,] "-3" "2"
  [5,] "-2" "-4"
  [6,] "-4" "3"
  [7,] "-4" "4"
  [8,] "-1" "-5"
  [9,] "-5" "-6"
[10,] "-6" "5"

[11,] "-6" "6"
[12,] "-5" "7"

$edge.length
  [1] 0.00000 0.00412 0.01012 0.00625 0.00576 0.00519 0.00536 0.01817 0.00713 0.00772 0.00913 0.01506

$tip.label
[1] "H" "G" "F" "E" "D" "C" "B"

attr(,"class")
[1] "phylo"

The only problem is i can't access or save the individual trees after importing. What i want to do is calculate the cophenetic distance for each tree and take the correlation between pairs of trees. I keep getting errors like this:

  x<- anj30[1]
> class(x)

[1] "list"

> as.phylo(x)

Error in as.phylo(x) : no applicable method for "as.phylo"
> cophenetic.phylo(x)


Error in cophenetic.phylo(x) : your tree has no branch lengths defined

and
> cophenetic.phylo(anj30[1])

Error in cophenetic.phylo(anj30[1]) : your tree has no branch lengths defined

If i paste the tree directly into read.tree() on the console then it works but I can't do this for thousands of trees ( which i have to process according to my PhD committee :) )

Does anyone know how to get the individual trees into usable variables? I apologize for my lack of familiarity with the package. thanks,
betty

-- 
Betty Gilbert
lgilbert@berkeley.edu
Taylor Lab
Plant and Microbial Biology
321 Koshland Hall
U.C. Berkeley
Berkeley, Ca 94720
	[[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Tue May 09 11:50:34 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 10 May 2006 - 04:09:59 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.