This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to convert phylo object to hclust object in R

I think there several similar question but I can't solve my issue following with previous answer.

I am trying to convert phylo object to hclust object by following.

dna <- read.dna("my.dna.aln", format="fasta")
dist <- dist.dna(dna)
dna.nj <- nj(dist)
dna.hcl <- as.hclust(dna.nj)
 error in as.hclust.phylo(dna.nj) : the tree is not ultrametric

I really need to convert hclust rather than dendrogram. When I tried to use chronopl it gives me following error

 chronopl(dna.nj, 0, age.min = 1, age.max = NULL,node = "root", S = 1, tol = 1e-8,CV = FALSE, eval.max = 500, iter.max = 500)

 error in chronopl(dna.nj, 0, age.min = 1, age.max = NULL, node = "root": 
 at least one terminal branch is of length zero:
 you should remove it to have a meaningful estimation.

Do you have any suggestion. Thank you, Taiki

ape r alignment

2 answers

Did you check this? https://www.rdocumentation.org/packages/ape/versions/5.0/topics/as.phylo

Approach the problem from the other end:

dist.dist <- as.dist(dist)
DNA.hc <- hclust(dist.dist, method = "average")

Log in to answer this question.