Branch length modification of a phylogenetic tree in R

4.9k views Asked by At

I have a phylo file in NEWICK format with a few distance of a very little length (aprox. of 1.042e-06) and I need to "eliminate" these little distances.

I have thought to multiply all distances by 10, because for what I further need the tree this multiplication do not produce any effect. For doing that I have found the ape package in R and the function compute.brlen, as with this function you can change the length of the branches by a function.

Any idea on how to multiply the length of the branches by 10 with this function?

I have tried to do compute.brlen(tree, main=expression(rho==10)), but I think this is incorrect for what I want.

1

There are 1 answers

0
dudu On BEST ANSWER

Try to do this:

require(ape)       # get the ape package
mytree = rtree(10) # make a random tree, you should have instead read.tree(path_to_tree_file)
mytree$edge.length = mytree$edge.length * 10 #or any other scalar that you want

Keep in mind that this will scale all the branch lengths in the phylogeny.