Phylogenetics in R: obtaining internal branch lengths
1
1
Entering edit mode
8.5 years ago
spiral01 ▴ 110

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?

R phylogenetics ape • 6.4k views
ADD COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode
8.5 years ago
Klaus S ▴ 160

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 COMMENT

Login before adding your answer.

Traffic: 2973 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6