I have a phylogenetic tree with absolute branch lengths in million years. How can i compute a distance matrix with values between 0 and 1?
Assuming you have a phylogenetic tree in R, you can compute the distance between each taxa by using the cophenetic.phylo() function in the ape package.
From there if you divide by the maximum value of the matrix, you will get a matrix that is between 0 & 1.
For example:
tree = rtree(5)
dist.mat = cophenetic.phylo(tree)
dist.mat
t2 t1 t4 t5 t3
t2 0.0000000 0.9832129 1.815684 1.646854 1.483749
t1 0.9832129 0.0000000 1.166180 1.779498 1.616393
t4 1.8156839 1.1661797 0.000000 2.611969 2.448864
t5 1.6468535 1.7794981 2.611969 0.000000 1.527042
t3 1.4837485 1.6163931 2.448864 1.527042 0.000000
dist.mat / max(dist.mat)
t2 t1 t4 t5 t3
t2 0.0000000 0.3764259 0.6951399 0.6305027 0.5680575
t1 0.3764259 0.0000000 0.4464753 0.6812860 0.6188408
t4 0.6951399 0.4464753 0.0000000 1.0000000 0.9375548
t5 0.6305027 0.6812860 1.0000000 0.0000000 0.5846325
t3 0.5680575 0.6188408 0.9375548 0.5846325 0.0000000