Tag Archives: phylogeny

TNT and Ubuntu

TNT (or ‘Tree analysis using New Technology’) is a relatively fast parsimony-based phylogenetics program. However, to be quite frank, it is also totally confusing. It took me some time, but I have put together a script that does pretty much everything I want it to do now, so I can just reuse the script every time I need to do something. I’m posting it here, in the hopes that other people will not have to spend so long figuring this all out. Just note though, the actual commands are in this type of font.Of course, everything that follows is what I’ve figured out through reading papers and trawling the internet, so suggestions are appreciated.

First things first, make sure your data is in the correct format. Theoretically, TNT can handle .nex files, but then again, my old car could theoretically do 220 km/h because the speedometer went that high. Your best bet is to just take your .nex file and reformat it to .tnt format, which pretty much involves deleting everything except the actual matrix, and then editing the first few lines. The first line should read ‘xread’, with the next line containing the number of characters, a space, and the number of taxa. (You can add a line between those for a comment, just be sure to put the comment in quotes)

For example, a simple data set might look like this:


xread
‘sample phylogeny’
5 3
taxonA 00011
taxonB 01111
taxonC 11111
;

While TNT is not the most user-friendly program, using scripts can help a lot, as you often will run the same set of analyses on different data sets. For my purposes, most of the time I want to run a basic tree search to find all of the most parsimonious trees, find a consensus tree from that (if necessary), map the characters, get bootstrap values and finally find the Bremer supports. At the bottom of the page I’ve posted my default TNT script that I use. Note that it does include comments (lines with a # in front) that will need to be deleted for the script to run properly. Also, replace ‘samplephylo’ with whatever you’ve named your .tnt file. Finally, when you’ve done all that, you need to move both the script and the .tnt file into the folder that contains all the files for the TNT program (on mine, the folder is called ‘tnt64-no-tax-limit’).

Finally, once you’ve done all that, you can run TNT (usually by navigating in a terminal to that same ‘tnt64-no-tax-limit’ using the change directory command [i.e. cd]), and then running TNT by typing something like ‘sudo ./tnt’. Note that TNT typically doesn’t run properly unless you run it as root/administrator (same applies to Mac OS X, except you’d run it as ‘sudo ./tnt.command’).

Often, TNT will throw error messages for no apparent reason. A few things to make sure of is that all the file names are letters or numbers only (no punctuation, including periods or underscores, and no spaces), that both the command script and .tnt file are in the same folder as the TNT program and that the program is being run as root/administrator. Hopefully by putting this up here, more people will be able to finally figure out how to use TNT.


#take everything after here and put it in a file in the tnt folder
#delete all the lines that start with the # sign
#replace the ‘samplephylo’ with the name of your file. I recommend converting
#your matrix to .tnt format, which is pretty simple
#check out the example.tnt file in the tnt folder to see how it’s done
#the most imprtant part is the first few lines,
#but be sure to convert any polymorphisms to [] brackets
#load the data file
procedure samplephylo.tnt;
#write all the output to this file
log samplephylo.out;
#do a basic run – finds a bunch of parsimonious trees quickly
mult ;
#this should find all the MPRs
bbreak=tbr;
#find the consensus tree
nelsen * ;
#map the synapomorphies on the tree
apo [ ;
#export the MPRs and the consensus tree to a file
export samplephylo.tre;
#do a bootstrap analysis – might need to up the runs
resample ;
#the stuff below does a Bremer analysis
#it’s a bit convoluted, but is the only way to get
#TNT to do a Bremer, because TNT isn’t really meant to
#do a Bremer analysis
hold 1000; sub 1 ; bbreak=tbr;
hold 2000; sub 2 ; bbreak=tbr;
hold 3000; sub 3 ; bbreak=tbr;
hold 4000; sub 4 ; bbreak=tbr;
hold 5000; sub 5 ; bbreak=tbr;
hold 6000; sub 6 ; bbreak=tbr;
hold 7000; sub 7 ; bbreak=tbr;
hold 8000; sub 8 ; bbreak=tbr;
#calculate the Bremer support from the suboptimal trees
bsupport ;
#quit the program – you can always do this manually
quit

MrBayes and multicore processors

Turns out setting up and using MrBayes on an Ubuntu system is much easier than I had thought. If all you want is the normal (serial) version of MrBayes, you can just download it from the repositories. However, if you want a serious speed up in the time it takes to get a good result, you can also run it in parallel on a multicore system (that is, pretty much any computer made in the last 4 years). To get it set up and running on Linux, I used some information I found in a forum post. To recap from there:

  1. Install the parallel libraries you need from the repositories. The package names I used were: mpich2, libmpich2-dev, and libmpich2-1.2, and libreadline6-dev.
  2. Download the source code file for MrBayes and unarchive it (on Ubuntu you can just right-click and select ‘Extract Here’
  3. Find the ‘Makefile’ in the source code and change the line that says ‘MPI ?= no’ so that it says ‘MPI = yes’
  4. Open a terminal, and navigate to the MrBayes folder (e.g. type in ‘cd /path/to/folder/mrbayes-3.1.2/’) and then make the package (type ‘Make’ at the prompt).  It might also be a good idea to change the file called ‘mb’ that is created to something like ‘mbpar’ so that you know it’s the parallel version. Also, I needed to make the file executable, so I typed ‘chmod +x mbpar’  to do that.
  5. Now, you’ll need to create a file in your home folder called ‘.mpd.conf’ with the line MPD_SECRETWORD=<secretword> in it. Change the <secretword> to something else though; it can be pretty much any word you like.
  6. ‘mpd &’ will launch the MPICH daemon, which needs to be running in order to handle communicating between the different cores.
  7. After all this, I was able to type ‘mpirun -np 2 /path/to/mrbayes/mbpar’ to run the parallel version of MrBayes in parallel on both cores of my dual core system. If you have more cores, you can always change the -np argument (e.g. to run it using 4 cores, type ‘mpirun -np 4 /path/to/mrbayes/mbpar’)

With the few tests I’ve done so far, I’ve seen about a 80% speed up by just using 2 cores instead of 1. It’s nice not to have to wait nearly so long to get my results. We’ll see what kind of time savings this could bring if I did it on an 8-core computer.