0

I have been using the R ape package to create a minimum spanning tree from a distance matrix. if my distance matrix is, for example:

distmat sample1 sample2 sample3 sample4 sample5 sample1 0 5 4 4 6 sample2 5 0 1 1 3 sample3 4 1 0 0 2 sample4 4 1 0 0 2 sample5 6 3 2 2 0

I'm using ape package mst function to calculate a minimum spanning tree:

MST = ape::mst(distmat)

To get branch lengths, I'm using:

MSTwlength = MST MSTwlength [MST >0] <- distmat[MST >0] MSTwlength sample1 sample2 sample3 sample4 sample5 sample1 0 0 4 0 0 sample2 0 0 1 0 0 sample3 4 1 0 0 2 sample4 0 0 0 0 0 sample5 0 0 2 0 0 attr(,"class") [1] "mst"

Now I want to export this minimum spanning tree to a Newick format. Any ideas how to do that? I have searched APE and TreeTools manuals and tutorials and found nothing. Thank you, Mor

0 Answers0