How do I estimate branch length of a maximum parsimony phylogeny in R? I am trying to estimate a phylogenetic tree in R with ape and phangorn. With pratchet() and optim.parsimony(), I can estimate a phylogenetic tree, but branch lengths are not estimated. Is there a way to estimate a phylogeny with branch lengths with the following made-up data:

x &lt;- data.frame("L1" = c(0,0,1,0,0,0,1,1,1,1,0,0,0,0,1), "L2" = c(0,1,1,0,1,1,0,1,1,0,1,1,0,1,1),"L3" = c(1,1,1,0,0,0,1,1,1,0,0,0,1,1,1), "L4"=c(0,0,1,1,0,0,0,0,1,1,0,0,0,0,1))
@Nathan S. Watson-Haigh's answer does give branch lengths, but NOT parsimony branch lengths, which may be what the OP wanted.  nnls.phylo is giving distances calculated from a pairwise distance matrix. To get the parsimony branch lengths (i.e. number of changes mapped on to each branch), score the tree against the dataset using acctran:

treeRatchet &lt;- pratchet(primates)
treeRatchet.BL &lt;- acctran(treeRatchet,primates)
plot(treeRatchet.BL,main='Phylogeny (Parsimony branch lengths)')



Note that the branch lengths in the parsimony phylogram are 'chunkier' than those in the nnls.phylo phylogram -- that's because 


they are all integers, and 
they aren't corrected with reference to a model of substitution that considers multiple hits or base composition.