/usr/share/hyphy/TemplateBatchFiles/PairwiseRelativeRate.bf is in hyphy-common 2.2.7+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | ALLOW_SEQUENCE_MISMATCH = 1;
VERBOSITY_LEVEL = -1;
fprintf(stdout,"\n ---- RUNNING PAIRWISE RELATIVE RATE ANALYSIS ---- \n");
ChoiceList (dataType,"Data type",1,SKIP_NONE,"Nucleotide/Protein","Nucleotide or amino-acid (protein).",
"Codon","Codon (several available genetic codes).");
if (dataType<0)
{
return;
}
if (dataType)
{
NICETY_LEVEL = 3;
SetDialogPrompt ("Please choose a codon data file:");
#include "TemplateModels/chooseGeneticCode.def";
}
else
{
SetDialogPrompt ("Please choose a nucleotide or amino-acid data file:");
}
speciesCount = 0;
if ((OPTIMIZATION_PRECISION==0)||(OPTIMIZATION_PRECISION>0.001))
{
OPTIMIZATION_PRECISION = 0.001;
}
while (speciesCount < 3)
{
SetDialogPrompt ("Choose a data file with 3 or more sequences");
DataSet ds = ReadDataFile (PROMPT_FOR_FILE);
speciesCount = ds.species;
}
ChoiceList (thirdSpec,"Choose the outgroup:",1,SKIP_NONE,ds);
if (thirdSpec<0)
{
return;
}
GetString (outgroupName,ds,thirdSpec);
if (dataType)
{
DataSetFilter filteredData = CreateFilter (ds,3);
}
else
{
DataSetFilter filteredData = CreateFilter (ds,1);
}
SelectTemplateModel(filteredData);
relationString = ":=";
#include "selectModelParameters.bf";
SetDialogPrompt ("Save full results to:");
modelParameterCount = Rows("LAST_MODEL_PARAMETER_LIST");
fprintf (PROMPT_FOR_FILE,CLEAR_FILE);
MESSAGE_LOGGING = 0;
maxLength = 0;
for (firstSpec = 0; firstSpec < speciesCount; firstSpec = firstSpec+1)
{
GetString (firstName,ds,firstSpec);
tLength = Abs(outgroupName)+Abs(firstName);
for (secondSpec = firstSpec+1; secondSpec < speciesCount; secondSpec = secondSpec+1)
{
GetString (secondName,ds,secondSpec);
tLength2 = tLength + Abs (secondName) + 30;
if (tLength2>maxLength)
{
maxLength = tLength2;
}
}
}
maxLength = maxLength+6;
fprintf(stdout,"\n\n In the summary table below, branch lengths denote");
if (parameter2Constrain)
{
fprintf (stdout," the value of parameter ", funnyString, " for that branch.");
}
else
{
fprintf (stdout," the expected number of substituions per that branch.");
}
fprintf (stdout,"\n\n (*) corresponds to the .05 significance level\n (**) corresponds to the .01 significance level\n (***) corresponds to the .001 significance level.\n\n");
fprintf (stdout,"\n\n Taxa Triplet");
for (tLength = 15; tLength<maxLength; tLength=tLength+1)
{
fprintf (stdout," ");
}
fprintf (stdout," LRT P-Value \n");
separatorString = "-";
for (tLength = 0; tLength<=maxLength; tLength=tLength+1)
{
separatorString = separatorString + "-";
}
separatorString = separatorString + "+";
for (tLength = 0; tLength<12; tLength=tLength+1)
{
separatorString = separatorString + "-";
}
separatorString = separatorString + "+";
for (tLength = 0; tLength<12; tLength=tLength+1)
{
separatorString = separatorString + "-";
}
tLength2 = 0;
for (firstSpec = 0; firstSpec < speciesCount; firstSpec = firstSpec+1)
{
if (firstSpec == thirdSpec)
{
continue;
}
fprintf (stdout,separatorString);
GetString (firstName,ds,firstSpec);
for (secondSpec = firstSpec+1; secondSpec < speciesCount; secondSpec = secondSpec+1)
{
if (secondSpec == thirdSpec)
{
continue;
}
if (dataType)
{
DataSetFilter filteredData = CreateFilter (ds,3,"",(speciesIndex==firstSpec)||(speciesIndex==secondSpec)||(speciesIndex==thirdSpec),GeneticCodeExclusions);
}
else
{
DataSetFilter filteredData = CreateFilter (ds,1,"",(speciesIndex==firstSpec)||(speciesIndex==secondSpec)||(speciesIndex==thirdSpec));
}
HarvestFrequencies (rrEFV,filteredData,1,1,1);
if (FREQUENCY_SENSITIVE)
{
rrModelMatrix = 0;
if (USE_POSITION_SPECIFIC_FREQS)
{
HarvestFrequencies (vectorOfFrequencies,filteredData,3,1,1);
}
MULTIPLY_BY_FREQS = PopulateModelMatrix ("rrModelMatrix",rrEFV);
if (dataType)
{
rrCodonEFV = BuildCodonFrequencies (rrEFV);
Model rrModel = (rrModelMatrix,rrCodonEFV,MULTIPLY_BY_FREQS);
}
else
{
Model rrModel = (rrModelMatrix,rrEFV,MULTIPLY_BY_FREQS);
}
}
if ((firstSpec<thirdSpec)&&(secondSpec<thirdSpec))
{
treeString = "(FirstSpecies,SecondSpecies,OutGroup)";
i1 = 0;
i2 = 1;
i3 = 2;
}
else
{
if ((firstSpec>thirdSpec)&&(secondSpec>thirdSpec))
{
treeString = "(OutGroup,FirstSpecies,SecondSpecies)";
i1 = 1;
i2 = 2;
i3 = 0;
}
else
{
treeString = "(FirstSpecies,OutGroup,SecondSpecies)";
i1 = 0;
i2 = 2;
i3 = 1;
}
}
Tree threeTaxaTree = treeString;
LikelihoodFunction lf = (filteredData,threeTaxaTree);
Optimize (res,lf);
Tree constrained3TaxaTree = treeString;
/* now specify the constraint */
LikelihoodFunction lfConstrained = (filteredData,constrained3TaxaTree);
ReplicateConstraint (constraintString,constrained3TaxaTree.FirstSpecies, constrained3TaxaTree.SecondSpecies);
Optimize (res1,lfConstrained);
lnLikDiff = -2(res1[1][0]-res[1][0]);
degFDiff = res[1][1]-res1[1][1];
if (lnLikDiff>0)
{
pValue = 1.0-CChi2(lnLikDiff,degFDiff);
}
else
{
pValue = 1;
fprintf (MESSAGE_LOG,"\nA negative LRT statistic encoutered. You may want to increase the optimization precision settings to resolve numerical apporximation errors");
}
GetString (secondName,ds,secondSpec);
if (parameter2Constrain==0)
{
b_out = BranchLength(threeTaxaTree,i3);
b_1 = BranchLength(threeTaxaTree,i1);
b_2 = BranchLength(threeTaxaTree,i2);
}
else
{
b_out = res[0][modelParameterCount*i3+parameter2Constrain-1];
b_1 = res[0][modelParameterCount*i1+parameter2Constrain-1];
b_2 = res[0][modelParameterCount*i2+parameter2Constrain-1];
}
printTreeString = "("+outgroupName+":"+b_out+",("
+firstName+":"+b_1+","+secondName+":"+b_2+"))";
fprintf (stdout, "\n", printTreeString);
for (tLength=Abs(printTreeString);tLength<maxLength;tLength=tLength+1)
{
fprintf (stdout," ");
}
fprintf (stdout, " | ", Format(lnLikDiff,9,4)," | ", pValue );
if (pValue<0.05)
{
if (pValue<0.01)
{
if (pValue<0.001)
{
fprintf (stdout," (***) ");
}
else
{
fprintf (stdout," (**) ");
}
}
else
{
fprintf (stdout," (*) ");
}
}
if (!tLength2)
{
tLength2 = 1;
dataDimension = Columns(res);
fprintf (LAST_FILE_PATH,",,,Unconstrained Optimizations");
for (i=0;i<dataDimension;i=i+1)
{
fprintf (LAST_FILE_PATH,", ");
}
fprintf (LAST_FILE_PATH,"Constrained Optimizations");
for (i=0;i<dataDimension;i=i+1)
{
fprintf (LAST_FILE_PATH,", ");
}
fprintf (LAST_FILE_PATH,"\nOutgroup,Taxon 1,Taxon 2,Ln-likelihood");
for (i=0;i<dataDimension;i=i+1)
{
GetString (argName,lf,i);
fprintf (LAST_FILE_PATH,",",argName);
}
fprintf (LAST_FILE_PATH,",Ln-likelihood");
for (i=0;i<dataDimension;i=i+1)
{
GetString (argName,lfConstrained,i);
fprintf (LAST_FILE_PATH,",",argName);
}
fprintf (LAST_FILE_PATH,",LR,P-Value");
}
fprintf (LAST_FILE_PATH,"\n",outgroupName,",",firstName,",",secondName,",",res[1][0]);
for (i=0;i<dataDimension;i=i+1)
{
fprintf (LAST_FILE_PATH,",",res[0][i]);
}
fprintf (LAST_FILE_PATH,",",res1[1][0]);
for (i=0;i<dataDimension;i=i+1)
{
fprintf (LAST_FILE_PATH,",",res1[0][i]);
}
fprintf (LAST_FILE_PATH,",",lnLikDiff ,",",pValue);
}
fprintf (stdout,"\n");
}
MESSAGE_LOGGING = 1;
|