Hi Nick.

The following is a 'solution' that works with phytools; however, you should keep in mind that you will not generally be able to use a constant offset value if your tip labels vary in length. In that case, you would either have to use a variable offset or figure out the minimum offset required such that the circles fall outside of the taxon labels.

library(phytools)
par(lty="dotted",fg="black")
plotTree(force.ultrametric(sim_tree,"extend"),type="fan",lwd=1)
tiplabels(pch = 19, col = rainbow(3), offset = 6)
par(lty="solid",fg="transparent")
plotTree(sim_tree,type="fan",lwd=1,add=TRUE)
par(fg="black")

For a more general solution you might offset your taxon labels by a constant amount, or you can use the function strwidth and some basic trigonometry to find the position outside the taxon labels to draw your circles.

All the best, Liam

Liam J. Revell
Associate Professor, University of Massachusetts Boston
Profesor Asistente, Universidad Católica de la Ssma Concepción
web: http://faculty.umb.edu/liam.revell/, http://www.phytools.org

On 8/24/2018 10:04 AM, Carleson, Nick wrote:
Hello all,

I'm using the R package 'ape' to make non-ultrametric phylogenetic trees . I want to align tip labels together when drawing a tree with plot.phylo(), and also add on more labels using the tiplabels() function. But, I can't get additional tip labels from tiplabels aligned properly with those from plot.phylo. When I call tiplabels, the labels are being drawn at the true edge length instead of neatly around the plot with the tip labels drawn by plot.phylo. So, in the plot below, I want the tip labels (circles) to be aligned adjacent to the tip labels (names) drawn byplot.phylo.

Good: tips like t30, t31, and t2
Bad: tips like t1, t20, and t21




Can anyone help me out?

Below is the code to produce the tree above. I'm using ape version 5.1 and R version 3.4.3.

library(ape)
set.seed(31)
sim_tree <- rlineage(0.1, 0.05)
plot.phylo(sim_tree, type = "fan", align.tip.label = TRUE)
tiplabels(pch = 19, col = rainbow(3), offset = 6)

Thanks all!

**Nick Carleson*
*

**

PhD Student*| Oregon State University
*Graduate Research Assistant | *Botany and Plant Pathology**
*



_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

Reply via email to