

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
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


?edgelabels
On Sun, 20071111 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
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, 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.
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


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))
I would get a tree as shown in "Rresult.ps" file.
However, I would like the tree to show like in
"treeABC.jpg" file.
In case the rhlep list do not allow attachment, here
is what Rresult.ps look like:
B


 C

A
for the tree I want (in treeABC.jpg), I would mark the
edge AC as "b", and the edge AB as "a".
Thank you very much for help!
Hua
 Simon Blomberg < [hidden email]> wrote:
> ?edgelabels
>
> On Sun, 20071111 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
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/rhelp> > PLEASE do read the posting guide
> http://www.Rproject.org/postingguide.html> > and provide commented, minimal, selfcontained,
> 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.
>
>
__________________________________________________
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


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@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"))


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("ab","b","bd","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 < [hidden email]> 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 < [hidden email]> 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/helpondrawingatreewith%22ape%22tf4789546.html#a13711995 ____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


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("ab","b","bd","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("ab","b","bd","d","d","a"))
str(t1)
t1$edge.length
names(t1$edge.length)[c(2,4,6)]=c("b","d","a")
plot(t1)
edgelabels(c("ab","b","bd","d","d","a"),adj=c(0.5,1.25))
with(as.list(t1$edge.length),
edgelabels(c(ab,b,bd,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.orgiD8DBQFHOao+c5UpGjwzenMRAq+xAJ4/FFxTaUXhco2ZSNU4xOHCHWhyQQCfYFV/
8ymnDHBrtFVDELiZrC2WQ+I=
=A1e3
END PGP SIGNATURE
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Thanks again, Ben.
Specifically my question should be;
If I know that I'll be using variables to represent
the distances between species:
a = AB
b = AC
d = CD
and I also know my tree can be written as
"((A:51.78,(C:24.6,D:24.6):27.18):40.06,B:91.84):0.0;"
is there a way to allow me mark the edges without
having to see the tree topology first, so that when I
use "edgelabels", the symbols and the order (
c("ab","b","bd","d","d","a") ) should be
automatically arranged other than being specified by
me. In other words, I don't want to be the one who
tells R the command
"edgelabels(c("ab","b","bd","d","d","a"))". I'd
rather a way R finds out itself. (for example, after
some calculation, R knows the edgelabes should be the
way specified above other than, say, c("a", "b", "c",
"ab", "ac", "bc"). )
Thank you!
Hua
 Ben Bolker < [hidden email]> wrote:
> 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("ab","b","bd","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("ab","b","bd","d","d","a"))
> str(t1)
> t1$edge.length
> names(t1$edge.length)[c(2,4,6)]=c("b","d","a")
> plot(t1)
>
edgelabels(c("ab","b","bd","d","d","a"),adj=c(0.5,1.25))
> with(as.list(t1$edge.length),
>
>
edgelabels(c(ab,b,bd,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
>
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Hua Li wrote
Thanks again, Ben.
Specifically my question should be;
If I know that I'll be using variables to represent
the distances between species:
a = AB
b = AC
d = CD
and I also know my tree can be written as
"((A:51.78,(C:24.6,D:24.6):27.18):40.06,B:91.84):0.0;"
is there a way to allow me mark the edges without
having to see the tree topology first, so that when I
use "edgelabels", the symbols and the order (
c("ab","b","bd","d","d","a") ) should be
automatically arranged other than being specified by
me. In other words, I don't want to be the one who
tells R the command
"edgelabels(c("ab","b","bd","d","d","a"))". I'd
rather a way R finds out itself. (for example, after
some calculation, R knows the edgelabes should be the
way specified above other than, say, c("a", "b", "c",
"ab", "ac", "bc"). )
This is a little bit hard, I will have to think about it ...
install.packages("fortunes"); library(fortunes); fortune("Yoda")
Ben

