Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/gtr_optim' into opt_mix_model
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaskf committed Sep 28, 2023
2 parents b1bf6ef + ed32c71 commit 0967c57
Show file tree
Hide file tree
Showing 8 changed files with 387 additions and 74 deletions.
31 changes: 31 additions & 0 deletions gtroptim_flags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--link-exchange-rates
This flag indicates to the program that you want to optimize a single rate
matrix that's linked between every class. It triggers the optimizeLinkedSubst
method within the ModelMixture class which utilizes BFGS to optimize the
model parameters.

--rates-file
Tells the program to generate a .ratemat file that includes the linked
exchange rate matrix, assuming the above option is used.

--gtr20-model
Which model should be used as the starting point when optimizing with
GTR20. Comes with an associated value: POISSON, or LG.
By default, it uses POISSON. (previously it defaulted to LG)

--reset-method
Defines the behavior of the Optimization::restartParameters routine.
Comes with an associated value: const, or rand. Default: const.
"const" is the new behavior that we have defined wherein the rate matrix
values are all multiplied by a constant value if one or more values goes
over the boundary. "rand" is the previous behavior wherein all values
are multiplied by random_double() * (upper[i] - lower[i])/3 + lower[i].

--guess-multiplier
Very closely related to the above option, if the reset method is "const",
then this controls the constant value by which to multiply each value
(hereby referred to as "c"). If parameters are detected to go over the
upper boundary, then every parameter is multiplied by c, if the result isn't
also under the lower boundary. Conversely, if parameters are detected to go
under the lower boundary, then every parameter is multiplied by 1/c, if the
result isn't also over the upper boundary.
27 changes: 27 additions & 0 deletions main/phyloanalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,33 @@ void reportRate(ostream &out, PhyloTree &tree) {
" of the portion of the Gamma distribution falling in the category." << endl;
}
}
//output ratemat to iqtree file -JD
if(Params::getInstance().optimize_linked_gtr) {
string fname = Params::getInstance().out_prefix;
fname += ".ratemat";
ifstream f(fname.c_str());
if(f.good()) {
out << endl << "Rate matrix:" << endl;
cout << endl << "Rate matrix:" << endl;
string data;
getline(f,data);
size_t last = 0;
size_t next = 0;
while ((next = data.find(" ", last)) != string::npos) {
string outline = data.substr(last, next-last) + " ";
out << outline;
cout << outline;
last = next + 1;
}
out << data.substr(last) << endl;
cout << data.substr(last) << endl;
if(!Params::getInstance().rates_file) { //delete ratemat files if not using flag to keep them
remove(fname.c_str());
remove((fname+"_init").c_str());
}
}
f.close();
}
out << endl;
}

Expand Down
Loading

0 comments on commit 0967c57

Please sign in to comment.