Question: Phylogenetics in R: obtaining internal branch lengths
1
gravatar for spiral01
4.4 years ago by
spiral01100
spiral01100 wrote:

I am currently using the ape package function read.tree to read in several thousand newick format trees into R. An example tree is:

((Anopheles_christyi:0.057946,Anopheles_epiroticus:0.076668):0.009683,((((Anopheles_arabiensis:0.005646,Anopheles_melas:0.00841):0.001469,Anopheles_quadriannulatus:0.006608):0.002261,(Anopheles_gambiae:0.000492,Anopheles_coluzzii:0.039824):0.010745):0.005868,Anopheles_merus:0.02839):0.083449):1.546411;

I am trying to remove trees that have several internal branches of short length but my problem is that these branch lengths do not transfer into r when I read the trees in. I can obtain edge lengths using: treelist[[1]]$edge.length but this ofcourse does not give me the internal branch lengths that I require. Here is the output:

[1] 0.086351 0.083449 0.005868 0.002261 0.001469 0.005646 0.008410 0.006608 0.010745
[10] 0.000492 0.039824 0.028390

So what I am asking is that is there a way of identifying internal branch lengths in R, and if not is there another package anyone could recommend to do this?

ape phylogenetics R • 3.7k views
ADD COMMENTlink modified 4.4 years ago by Klaus S140 • written 4.4 years ago by spiral01100

tree$edge.list gives the length of all branches, including internal ones. Is the problem that your example output of $edge.list doesn't match the values from your example tree ? In that case, I would suspect some tree formating issue. Reading your example tree with read.tree(), tree$edge.length gives me:

[1] 0.009683 0.057946 0.076668 0.083449 0.005868 0.002261 0.001469 0.005646 0.008410 0.006608 [11] 0.010745 0.000492 0.039824 0.028390

ADD REPLYlink modified 4.4 years ago • written 4.4 years ago by Jean-Karim Heriche23k
0
gravatar for Klaus S
4.4 years ago by
Klaus S140
Klaus S140 wrote:

If you would have looked in the help of read.tree, you will find:

...

Value

an object of class "phylo" with the following components:

edge

a two-column matrix of mode numeric where each row represents an edge of the tree; the nodes and the tips are symbolized with numbers; the tips are numbered 1, 2, ..., and the nodes are numbered after the tips. For each row, the first column gives the ancestor.

...

so

tree$edge.length[tree$edge[,2] > Ntip(tree)]

gives you the edge length of the internal edges.

ADD COMMENTlink written 4.4 years ago by Klaus S140
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1540 users visited in the last hour