
Tutorial 1
Purpose: configuring, starting and stopping chains.

nhpb is a program for phylogenetic reconstruction. It is phylogenetically related to the pb program of the PhyloBayes package. Compared to pb, nhpb allows for non homogeneous models, using a doubly stochastic system, creating breakpoints along the tree. After each breakpoint, the sequences evolve according towards new equilibrium frequencies, a priori independent from those that were active upstream of the breakpoint. The total number of breakpoints is a free variable of the model, and is thus automatically estimated during MCMC.

In fact, nhpb implements two fundamental models: GTR-BP (or shortly, bp), and CAT-BP (catbp). In the first case, the non-homogeneous component of the model (the breakpoint system) is combined with a general time reversible matrix: the model is thus time-non-homogeneous, but it is still homogeneous along the sequence (all sites are described by the same matrix). In the case of CAT-BP, the breakpoint system is combined with the CAT model (Lartillot and Philippe 2004), such as implemented by default into the "pb" program. The CAT-BP model is thus both sequence- and time- heterogeneous.

That repository contains 5 files:
README		: This README file,
arthro20_aa.nex : An arthropoda mitochondrial protein dataset,
topo1.tre	: A first phylip topology (only branch labels),
topo2.tre	: A second phylip topology (labels and branch lengths),
clean		: A script for cleaning all files created during the tutorial1, except these 5 ones. 

Note that the nhpg program script the use of programs newchain (create a new chain) and phylobayes (running a chain).



1) To print the help
../../nhpb -h 



2) To run a default catbp free topology experiment:
../../nhpb -d arthro20_aa.nex -f catbpfree1 -m catbp -y ../../

This line command essentially means that you want to run the program of the dataset called "arthro20_aa.nex", using the catbp model. Note that you must give the path to the binaries (thus, to the program nhpb itself), using the "-y" option. Here, it is assumed that you are HERE (in the "tutorial1" directory), which means that the binaries are 2 steps upstream of here, hence the "../../". All this is a bit obnoxious, but this is because the initial binary has been wrapped up into a script, and in some situations (e.g. in certain types of queues) the script may not be able to locate the binaries directly. 

Default options are:
50 CAT categories (change with option -n, e.g. -n 100)
4 categories for rates across sites (change with option -r, e.g. -r 8)
chain will save 2000 points (or samples), before stopping (change with -z, e.g. -z 1000)
1 sample saved each cycle (change with -e 2)

Note that under CATBP, the number of category is fixed, in contrast to the version of CAT implemented by "pb", which automatically estimates the number of categories. Thus, you may first run CAT with the "pb" program of the PhyloBayes package in order to determine the posterior number of categories, and then use that number for your experiments with "nhpb" (option -n)
If there are too few categories, problem of convergences may be encountered,
If there are too many, the chain will be slow and some categories will never be used.



3) Run default bp free topology experiment:
../../nhpb -d arthro20_aa.nex -f bpfree1 -m bp -y ../../



4) Fixed topology analysis (option -T aFile)
../../nhpb -d arthro20_aa.nex -f catbpfxd1 -m catbp -T topo1.tre -y ../../

Where topo1.tre is a phylip file containing the topology,
The tree must end with ;
The tree may contain species names (or labels), or species names and branch lengths.



5) Stopping the chains
../../nhpb -s catbpfree1
../../nhpb -s bpfree1
../../nhpb -s catbpfxd1

You must wait the end of the current cycle (may take a few seconds)



6) Continuing a stopped chain
../../nhpb -d arthro20_aa.nex -f catbpfxd1 -m catbp -T topo1.tre -y ../../

That command will also continue the already extant chain "catbpfxd1" from the current sample.
Then stop the continued chain ../../nhpb -s catbpfxd1.



7) Force to restart the chain (-o or --overwrite):
../../nhpb -d arthro20_aa.nex -f catbpfxd1 -m catbp -T topo1.tre -y ../../ -o

Option -o force the chain to restart, and overwrite the extant one catbpfxd1.
Then stop the chain ../../nhpb -s catbpfxd1.



8) Mode verbose, option -v,
../../nhpb -d arthro20_aa.nex -f catbpfxd1 -m catbp -T topo1.tre -y ../../ -o -v

The verbose mode displays informations about inputs and chain state 
- Bad file format ? 
- Chain already existing ?
- Do the user really want to overwrite a chain ?
- Display the settings for a new, or overwrote, chain

Option -v will allow to ask you if you really want to erase the chain, write "yes" is so.
Note that, without the verbose mode (-v), overwriting the extant chain is done automatically.
Then, for any trouble with running nhpb, the verbose mode should yield informations about the problem.
Then stop the chain ../../nhpb -s catbpfxd1.



9) Submitting the job on a cluster, option -q or --qsub
../../nhpb -d arthro20_aa.nex -f catbpfxd1 -m catbp -T topo1.tre -y ~/nh_PhyloBayes_0.1/data/ -x ~/nh_PhyloBayes_0.1/data/tutorial/tutorial1/ -o -q

The chain is restarted (option -o).
The chain is submitted with qsub (option -q).
Note that you must give both the path to binaries (option -y) and the one to the current working directory (option -x). 
Then stop the chain ../../nhpb -s catbpfxd1.
Note that we assume the package to be installed in ~ your home directory.



10) Cleaning the tutorial repository
./clean
