Neighbor Joining and Unrooted Trees

Here are two programs.

does clustering using the Neighbor Joining algorithm
draws an unrooted tree of the results

A typical usage is like this:

    nejo diffile.txt | utree > unrooted.eps

Or, with a few parameters:

    nejo NLdif.txt | utree -f 14 -h > NLunrooted.eps


Download sources and examples: utree.tar.gz or

Modifying the tree

Read how to swap branches of an unrooted tree.

Related clustering methods in R

You need the following R packages: Then you can run these demos: The ape package provides a few related clustering methods: The first is identical to the nejo program.

Import/export between nejo/utree and R

From nejo to R

Use the clnewick program to transform the output of nejo into the Newick tree format:

    nejo NLdif.txt | clnewick > NLnewick.txt

(clnewick is part of RuG/L04. You need at least version 0.03)

You can then import the clustering into R:

    t <- read.tree("NLnewick.txt")
    plot(t, type="unrooted", no.margin=TRUE)

From R to utree

Here is a function that you can use to export the result in R of nj, bionj, fastme.bal or fastme.ols into the format understood by the utree program:

Here is an example of how to use it in R:

    t <- fastme.bal(PA)
    tree2cl(t, "PAfastME.txt")

Then you can draw an unrooted tree with the utree program:

    utree PAfastME.txt > PAfastME.eps