Many thanks for your fast reply. Does it also work for a given, specific list of leaves and not the whole tree? Thanks.
Dear all,
I would like to find a way to calculate the total branch lengths between all specified leaves from a newick file, and the first node common to them all.
I am grateful for ideas on how to do this. I hope this is clear enough.
Many thanks for your help.
KS.
2 answers
Likely, there is no way to provide a list of nodes as a parameter. I would approach this via pruning the tree instance by splicing not-needed nodes out at first and computing the sum second. But I am not sure how well this will preserve the branches lengths (however that manual says it does with "-preserve_lengths => 1"). Hope this helps. You are welcome!
the R package apeprovides a function, cophenetic, for this. It calculates a square matrix for all tips and you can slice out the comparisons you are interested in:
library(ape)
data(bird.families)
cophenetic(bird.families)['Eurostopodidae', 'Passeridae']
There is also dist.nodes for any pair of nodes (one of which can be a tip) and mrca to find the first-shared node for two tips, but it's probably easier just to calculate the whole matrix. You can read in trees with read.tree.
Log in to answer this question.