Navigation Banner
  next up previous
Next: Local clocks: localclocks.bf Up: Molecular Clocks Previous: Molecular Clocks

Global clocks: molclock.bf

The batch file molclock.bf is a simple example of testing for a global molecular clock. The code should be familiar, except for the new MolecularClock statement, which declares that the values of the parameter mu should follow a molecular clock on the entire tree myTree. An important difference in this batch file is that the Topology statement defines a rooted tree. Had an unrooted tree been used, it would be treated as a rooted tree with a multifurcation at the root.

SetDialogPrompt("Select a nucleotide data file:"); 
DataSet myData  = ReadDataFile(PROMPT_FOR_FILE);
DataSetFilter myFilter = CreateFilter(myData,1);
HarvestFrequencies(obsFreqs,myFilter,1,1,1);

equalFreqs = {{0.25}{0.25}{0.25}{0.25}};

myTopology = "(((a,b),c),og)"; /* Note: need a rooted tree! */

F81RateMatrix  = {{*,m,m,m}{m,*,m,m}{m,m,*,m}{m,m,m,*}};
Model F81 = (F81RateMatrix, obsFreqs);

fprintf(stdout,"\n\n Unconstrained Analysis: \n");
Tree myTree = myTopology;
LikelihoodFunction theLikFun = (myFilter, myTree);
Optimize(results,theLikFun);
fprintf(stdout,theLikFun);
unconstrainedLnLik = results[1][0];
numparUn = results[1][1];

fprintf(stdout,"\n\n Molecular Clock Analysis: \n");
MolecularClock(myTree,m);
LikelihoodFunction theLikFun = (myFilter, myTree);
Optimize(results,theLikFun);
fprintf(stdout,theLikFun);
constrainedLnLik = results[1][0];
numparCon = results[1][1];

lnlikDelta = 2 (unconstrainedLnLik-constrainedLnLik);
pValue = 1-CChi2 (lnlikDelta, numparUn - numparCon);

fprintf (stdout, "\n\n P-value for Global Molecular Clock Test:", pValue, "\n");

The output of this analysis reveals a likelihood value of -589.2528 without a clock, and a value of -593.0986 when a clock is imposed. You also see that code has been added to compute the likelihood ratio test of the clock hypothesis, including the calculation of the P-value (0.021) based on the chi-squared approximation for the likelihood ratio test statistic. These calculations make use of the Hy-Phy command CChi2 (see the Batch Language Command Reference).



Spencer Muse
2000-05-31
 
Sergei L. Kosakovsky Pond and Spencer V. Muse, 1997-2002