Navigation Banner
  next up previous
Next: More complex models Up: Global vesus local parameters: Previous: Interpretation.

Implementation.

The code for localglobal.bf is the following:

OPTIMIZATION_PRECISION=0.0001;
OPTIMIZATION_PRECISION_METHOD=1;

LIKELIHOOD_FUNCTION_OUTPUT = 4;

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

fprintf(stdout,"\n\n Original HKY85 Analysis  \n\n");
HKY85RateMatrix = {{*,b,a,b}{b,*,b,a}{a,b,*,b}{b,a,b,*}};
Model HKY85 = (HKY85RateMatrix, obsFreqs);
Tree myTree = ((a,b),c,og);
LikelihoodFunction theLikFun = (myFilter, myTree);
Optimize(results,theLikFun);
fprintf(stdout,theLikFun);

fprintf(stdout,"\n\n Local HKY85 Analysis  \n\n");
LocalHKY85Matrix = {{*,b,b*R,b}{b,*,b,b*R}{b*R,b,*,b}{b,b*R,b,*}};
Model LocalHKY85 = (LocalHKY85Matrix, obsFreqs);
Tree myTree = ((a,b),c,og);
LikelihoodFunction theLikFun = (myFilter, myTree);
Optimize(results,theLikFun);
fprintf(stdout,theLikFun);

fprintf(stdout,"\n\n Global HKY85 Analysis  \n\n");
global V=2.0; 
GlobalHKY85Matrix = {{*,b,b*V,b}{b,*,b,b*V}{b*V,b,*,b}{b,b*V,b,*}};
Model GlobalHKY85 = (GlobalHKY85Matrix, obsFreqs);
Tree myTree = ((a,b),c,og);
LikelihoodFunction theLikFun = (myFilter, myTree);
Optimize(results,theLikFun);
fprintf(stdout,theLikFun);

The first three lines of the file illustrate the use of three of the many constants that Hy-Phy uses to tailor its behavior. The first two affect the precision (and speed) of the optimization process; the third changes the format of the printed likelihood function. (For details, see the Batch Language Command Reference).

The code for the first analysis is identical to that from models.bf. You will note that the second analysis uses the same code, with the value of a replaced by R*b. The substitution matrix and model have been assigned different names for illustrative purposes. Again, these two parameterizations are equivalent.

The global analysis introduces a new statment:
\begin{hpcode}
global V=2.0;
\end{hpcode}
This statement declares V to be a global variable. By default, the description of a model (and variables within that model) is used as a template that is copied for every branch on the tree. An important fact is that we can not simply redefine R as a global variable. The scope of a variable is determined at the time of its creation and can not be altered. Thus, it was necessary to create the new variable, V.


next up previous
Next: More complex models Up: Global vesus local parameters: Previous: Interpretation.
Spencer Muse
2000-05-31
 
Sergei L. Kosakovsky Pond and Spencer V. Muse, 1997-2002