Dear all, I'm using the "ape" package in R and want to draw a phylogenetic tree with not only the tip labels but also some labels for the edges. e.g. Mark the edge AB as "m" in the tree ABC. Couldn't find a way to do that. Can someone help? Thanks, Hua
?edgelabels On Sun, 2007-11-11 at 16:51 -0800, Hua Li wrote:> Dear all, > > I'm using the "ape" package in R and want to draw a > phylogenetic tree with not only the tip labels but > also some labels for the edges. e.g. Mark the edge AB > as "m" in the tree ABC. > > Couldn't find a way to do that. Can someone help? > > Thanks, > > Hua > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Simon Blomberg, BSc (Hons), PhD, MAppStat. Lecturer and Consultant Statistician Faculty of Biological and Chemical Sciences The University of Queensland St. Lucia Queensland 4072 Australia Room 320 Goddard Building (8) T: +61 7 3365 2506 email: S.Blomberg1_at_uq.edu.au Policies: 1. I will NOT analyse your data for you. 2. Your deadline is your problem. The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey.
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 --- Ben Bolker <bolker at ufl.edu> wrote:> > > > Hua Li wrote: > > > > Dear Simon and everyone, > > > > Thanks for response. > > > > Specifically, I have a tree with species "A, B, C" > and > > can be written as > > "((A:45.15,C:45.15):46.19,B:91.34):0.0;" . If I > use > > the R command > >> mytreeABC > > > > [1] "((A:45.15,C:45.15):46.19,B:91.34):0.0;" > > > >> plot(read.tree(text = mytreeABC)) > > > > --- Simon Blomberg <s.blomberg1 at uq.edu.au> wrote: > > > >> ?edgelabels > >> > > > > Did you look at the examples in the file > suggested by Simon? > Unfortunately, the PS file but not the JPG came > through in the > version I read. > > It seems to me you may want _node_ labels rather > than _edge_ labels? See below ... > > mytreeABC = "((A:45.15,C:45.15):46.19,B:91.34):0.0;" > t1 = read.tree(text=mytreeABC) > library(ape) > plot(t1) > edgelabels(1:4) > nodelabels(c("a","b")) > > -- > View this message in context: >http://www.nabble.com/help-on-drawing-a-tree-with-%22ape%22--tf4789546.html#a13711995> Sent from the R help mailing list archive at > Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. >____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page.
-----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-----