Question: R: Ape Making An Ultrametric, Rooted, Binary Tree Which Can Be Converted Into An R Dendrogram Object
gravatar for Timtico
9.8 years ago by
Timtico330 wrote:

Dear all,

I realize that this question might be very (too) specific but I hope someone can help me out here. I'm trying to build a phylogenetic treeusing ClustalW2 (protein), and convert this into an R dendrogram object. This dendrogram object I want to use to rearrange some heatmaps I have (expression / labdata).

I use the ape package to read in the treefile that clustal (EBI) outputs in Phylip format. after this i define the outgroup and try to get it ultrametric using a Sanderson molecular aging algorithm (chronopl in the ape package). I need the tree to be ultrametric, rooted and binary to be able to convert it into an R dendrogram using the as.hclust.phylo function. Here is some R code (I can provide you with the treefile upon request).


### read in Phylip guidetree created in ClustalW2

sptree <- read.tree(file = "sptree3.phylip", text = NULL, tree.names = NULL, skip = 0,
    comment.char = "#", keep.multi = FALSE)

#plot(sptree, cex = 0.5)
outgroup <- match(c("root1","root2"),sptree$tip.label)
sptree.rooted <- root(sptree,outgroup,node = NULL)

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



> drop.tip(sptree.rooted.ultra,outgroup)
Phylogenetic tree with 126 tips and 125 internal nodes.

Tip labels:
    An01g00340, An07g02420, An02g12160, An07g01230, An11g10600, An17g01560, ...

Rooted; includes branch lengths.
> is.ultrametric(sptree.rooted.ultra)
[1] TRUE
> is.binary.tree(sptree.rooted.ultra)
[1] TRUE
> is.rooted(sptree.rooted.ultra)

So, I've been fiddling with the code alot, and at one stage I was able to create a binary, ultrametric, rooted tree. But I'm unable to replicate it using a different treefile. I use an artifical outgroup (root1 and root2) that are two random sequences. They group nicely together.

I hope someone with abit more experience in this. What is the best approach?

All help is much appreciated,


R phylogenetics • 17k views
ADD COMMENTlink modified 7.9 years ago by Joseph Hughes2.8k • written 9.8 years ago by Timtico330

Why the artificial outgroup? Maybe the error is in how you remove it? Also, what is the result of is.rooted(sptree.rooted) ? Maybe the root function failed for whatever reason - drop.tip should keep the rootedness if the tree is rooted.

ADD REPLYlink written 9.4 years ago by Roman Zenka10
gravatar for Joseph Hughes
7.9 years ago by
Joseph Hughes2.8k
Scotland, UK
Joseph Hughes2.8k wrote:


I have had similar issues with rooting using root but I got round it using by keeping the basal trichotomy but forcing the tree as rooted:

sptree$root.edge <- 0

I found this in the R help for root. I hope it helps.

ADD COMMENTlink modified 13 months ago by RamRS30k • written 7.9 years ago by Joseph Hughes2.8k
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: 1028 users visited in the last hour