Question: R: Ape/Phylobase: Unable To Convert Ultrametric, Binary Tree To Hclust Object (Warning Message)
gravatar for Timtico
9.7 years ago by
Timtico330 wrote:

Hello, 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:

test.tree <- read.tree(file = "G:/ape/testree.phylip", text = NULL, tree.names = NULL, skip = 0,
    comment.char = "#", keep.multi = FALSE) <- 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)
treeclust <- as.hclust.phylo(tree.phylo)

The resulting tree "looks" fine, I test to make sure the tree is ultrametric and binary, and want to convert it into a hclust object, to make eventually a dendrogram object of it.

[1] TRUE
[1] TRUE

After trying to make a hclust object out of the tree, I get an error:

> tree.phylo <-
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,


File download The Phylip file can be downloaded here

R phylogenetics • 4.6k views
ADD COMMENTlink modified 6.3 years ago by Biostar ♦♦ 20 • written 9.7 years ago by Timtico330
gravatar for Timtico
9.7 years ago by
Timtico330 wrote:

This problem appears to be related to the version of ape installed, and could be a bug in ape. Version 2.6-2 (latest) produces this bug, while 2.5-3 does not, as someone at stack overflow pointed out to me. I will test this myself

ADD COMMENTlink written 9.7 years ago by Timtico330

As an additional data point, your code works for me with ape_2.6-1, R 2.12.0.

ADD REPLYlink written 9.7 years ago by Brad Chapman9.5k

thanks for the testing. I'm unable to revert to an older version, as it seems the old archives don't contain the windows binaries.. (or I'm missing something)

ADD REPLYlink written 9.7 years ago by Timtico330
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1207 users visited in the last hour