The program fastme could be used to infer a NJ tree (Saitou and Nei 1987) and write it into the NEWICK-formatted file $outtree
from a PHYLIP-formatted square matrix file $infile
with the following command line:
The program fastme could be used to infer a BioNJ tree (Gascuel 1997) and write it into the NEWICK-formatted file $outtree
from a PHYLIP-formatted square matrix file $infile
with the following command line:
The following gawk one-liner infers a UPGMA tree (Sokal and Michener 1958) from a PHYLIP-formatted distance matrix $infile
(either square or lower-triangular) and writes it into the NEWICK-formatted file $outtree
:
gawk '(NR>1){t[++n]=$(c=j=1);--j;while(++c<=n){d[n][++j]=$c;mx=($c>mx)?$c:mx}s[n]=1;h[n]=mm=0}
END{dn=++n;while(--dn>1){mn=mx-(x=y=-1);i=n;while(--i>0&&mn>mm)if(s[j=i]>0)while(--j>0&&mn>mm)(s[j]>0&&d[i][j]<mn)&&mn=d[x=i][y=j];(mn>mm)&&mm=mn;sx=s[x];sy=s[y];mn/=2;
i=n;while(--i>0)(i!=x&&i!=y&&s[i]>0)&&d[(i<x)?x:i][(i<x)?i:x]=(sx*d[(i<x)?x:i][(i<x)?i:x]+sy*d[(i<y)?y:i][(i<y)?i:y])/(sx+sy);
t[x]=(sx>sy)?sprintf("("t[x]":%.9f,"t[y]":%.9f)",mn-h[x],mn-h[y]):sprintf("("t[y]":%.9f,"t[x]":%.9f)",mn-h[y],mn-h[x]);h[x]=mn;s[x]+=sy;s[y]=0} print t[--n]";"}' $infile > $outtree
Given a tree topology in the NEWICK-formatted file $treefile
, the program fastme could be used to refit its branch lengths from the PHYLIP-formatted square distance matrix file $infile
and writes the resulting tree into the file $outtree
.
The following command line performs the branch length refitting according to the Balanced Minimum Evolution (BME) criterion (see e.g. Desper and Gascuel 2002):
The following command line performs the branch length refitting according to the Ordinary Least-Square (OLS) criterion (see e.g. Desper and Gascuel 2002):