[R] Hclust tree to Figtree w/ branch lengths

Julian Banchier moreke at luukku.com
Fri Jan 18 19:50:41 CET 2013


I'm doing hierarchical clustering, and want to export my dendrogram to a
tree-viewing/editing software. I can do this by converting the data to
Newick format (hc2Newick in ctc package), but I can't get branch lengths to
show in the resulting phylogram. I figured it might help to convert my
hclust object into a phylo object (as.phylo in ape package), but the
following lines give me this "Error in UseMethod("as.phylo") : no applicable
method for 'as.phylo' applied to an object of class "character":

data = read.table("C:/path/data.txt")
d <- dist(data, method = "euclidean")
fit <- as.phylo(hclust(d, method="ward")

Would anyone have an idea about how to make this work?

Thanks so much in advance!

View this message in context: http://r.789695.n4.nabble.com/Hclust-tree-to-Figtree-w-branch-lengths-tp4655990.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list