Hi Rafael,

Rafael Rubio de Casas wrote on 02/02/2012 06:24:
Hi Nicolai,
Thanks for your message. I guess I wasn't completely clear in my
previous message.
tiplabels() does do a similar thing to what I want. In fact, it is what
I ahve been using. The problem is that I think that with tiplabels you
cannot place the colored dots at a particular position relative to the
tips on a circular cladogram.

You are right.

I thought that points() would be easier to adapt for that, but maybe not.

tiplabels() actually calls points() so you have to tell the function how to offset the coordinates which is not obvious because they are circular, -- though plot.phylo() does it when label.offset is used.

I guess what you want is to prevent the labels to hide the terminal edges. Here's a suggestion for this:

plot(phy, type="fan", label.offset=2, plot=FALSE)
tiplabels(pch=21, cex=1.5, bg=label[phy$tip.label])
par(new=TRUE)
plot(phy, type="fan", label.offset=2)

The idea is to first draw the tip labels, and then the tree, so that the terminal edges are not hidden by the labels. The first line sets the drawing region but nothing is plotted so the labels can be drawn. The trick is to call par(new=TRUE) so that plot() does not refresh the graph.

HTH

Emmanuel

Thanks for your help, anyways.
Cheers,
Rafa
On 2/1/2012 5:25 PM, Nicolai Cryer wrote:
Hey Rafael,

(By the way, thanks for the easily reproducible code).

I think you're looking for the tiplabels() function, so instead of
using points, try:

tiplabels(pch=21,cex=1.5, bg=label[phy$tip.label])

This should amount to the same kind of color coding, but the layout
doesn't break when plotting a radial tree.

Hope that helps,

Best,

Nicolai
On 2/1/2012 2:40 PM, Rafael Rubio de Casas wrote:
Dear R-Sig-Phylo users,
I have what I believe should be an easy problem:
I want to plot character states on the tips of a fan cladogram produced
by ape.
What I am looking for, I believe, is something similar to what you can
do with "points" on a rectangular phylogram. That is, assign points to
tips colored according to their trait value.
For instance, the following code generates what I want for a rectangular
phylogram:
library(ape); library(geiger)
phy=rcoal(25, tip.label=c(letters[1:25]))
phy=rescaleTree(phy,25)
trait=as.vector(sample(0:1,25,replace=T))
names(trait)=phy$tip.label
label=character(length(phy$tip.label))
names(label)=names(trait)
label[trait==0]="dodgerblue"
label[trait==1]="firebrick"
plot(phy, show.tip.label=T, label.offset=1.5,no.margin=TRUE)
points(rep(26, length(phy$tip.label)), 1:length(phy$tip.label), pch=21,
cex=1.5, bg=label[phy$tip.label])
My problem is that I don't know how to get the same sort of mapping of
trait states at the tips when using
plot(phy, type="fan")

Thanks in advance,
Rafa



--
Emmanuel Paradis
IRD, Jakarta, Indonesia
http://ape.mpl.ird.fr/

_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo

Reply via email to