I've imported a ClustalW2 tree in R using the ape function and read.tree
function of the ape package. I estimate molecular ages using the chronopl function, resulting in a ultrametric, binary tree. From which I want to create a R build in dendrogram object.
The tree plots fine, and is a real phylo object. However i'm running into problems when trying to convert it:
Minimal Working Example:
require(ape)
test.tree <- read.tree(file = "testree.phylip", text = NULL, tree.names = NULL, skip = 0,
comment.char = "#", keep.multi = FALSE)
test.tree.nu <- chronopl(test.tree, 0, age.min = 1, age.max = NULL,
node = "root", S = 1, tol = 1e-8,
CV = FALSE, eval.max = 500, iter.max = 500)
is.ultrametric(test.tree.nu)
is.binary.tree(test.tree.nu)
treeclust <- as.hclust.phylo(test.tree.nu)
The resulting tree "looks" fine, I test to make sure the tree is not ultrametric and binary, and want to convert it into a hclust object, to make eventually a dendrogram object of it.
> is.binary.tree(test.tree.nu)
[1] TRUE
> is.ultrametric(test.tree.nu)
[1] TRUE
After trying to make a hclust object out of the tree, I get an error:
> tree.phylo <- as.hclust.phylo(test.tree.nu)
Error in if (tmp <= n) -tmp else nm[tmp] :
missing value where TRUE/FALSE needed
In addition: Warning message:
In nm[inode] <- 1:N :
number of items to replace is not a multiple of replacement length
I realize this is a very detailed question, and perhaps such questions which are specifically related to certain packages are better asked somewhere else, but I hope someone is able to help me.
All help is much appreciated,
Regards,
File download
The Phylip file can be downloaded here http://www.box.net/shared/rnbdk973ja