[R] help on drawing a tree with "ape"?
Ben Bolker
bolker at ufl.edu
Tue Nov 13 14:44:30 CET 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hua Li wrote:
> Thank you very much for the help, Ben!
>
> As a follow up, is there a way to specify the labels,
> through the way the text is written, rather than
> reading the edge positions from the graph? For
> example,
>
> mytree =
> "((A:51.78,(C:24.6,D:24.6):27.18):40.06,B:91.84):0.0;"
> plot(read.tree(text = mytree))
> edgelabels(c("a-b","b","b-d","d","d","a"))
>
> would give the graph I want. You may notice that if
> set a = 91.84; b= 51.78; d= 24.6, the labels I put on
> each edge is the corresponding lengths in variable
> form. The way I do it right now need me to first draw
> the tree and then manually set the labels, and I
> suppose there should be an easier way to get them by
> reading the way the tree is written
> ("((A:51.78,(C:24.6,D:24.6):27.18):40.06,B:91.84):0.0;")?
>
>
> Sorry for my low level questions. Just started using
> "ape" and research on phylogenetic trees.
>
> Best wishes,
>
> Hua
>
How about
library(ape)
mytree =
"((A:51.78,(C:24.6,D:24.6):27.18):40.06,B:91.84):0.0;"
t1 = read.tree(text = mytree)
plot(t1)
edgelabels(c("a-b","b","b-d","d","d","a"))
str(t1)
t1$edge.length
names(t1$edge.length)[c(2,4,6)]=c("b","d","a")
plot(t1)
edgelabels(c("a-b","b","b-d","d","d","a"),adj=c(0.5,1.25))
with(as.list(t1$edge.length),
edgelabels(c(a-b,b,b-d,d,d,a),adj=c(0.5,-0.5),bg="lightblue"))
?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHOao+c5UpGjwzenMRAq+xAJ4/FFxTaUXhco2ZSNU4xOHCHWhyQQCfYFV/
8ymnDHBrtFVDELiZrC2WQ+I=
=A1e3
-----END PGP SIGNATURE-----
More information about the R-help
mailing list