Skip to content

Commit a7458e5

Browse files
committed
Optimize FunDi rho from initial 0.5 and new options to set initial rho and branch length
1 parent b518586 commit a7458e5

File tree

3 files changed

+49
-6
lines changed

3 files changed

+49
-6
lines changed

tree/phylotree.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2822,7 +2822,7 @@ double PhyloTree::computeFundiLikelihood() {
28222822
taxa_set.insert(*it);
28232823
}
28242824

2825-
cout << "rho = " << params->alisim_fundi_proportion << endl;
2825+
cout << "Fundi proportion rho: " << params->alisim_fundi_proportion << endl;
28262826

28272827
findNodeNames(taxa_set, central_branch, root, nullptr);
28282828
if (!central_branch.first) {
@@ -2910,6 +2910,16 @@ double PhyloTree::computeFundiLikelihood() {
29102910
// by BFGS algorithm
29112911
current_it = (PhyloNeighbor*)central_branch.second;
29122912
current_it_back = (PhyloNeighbor*)central_branch.second->node->findNeighbor(central_branch.first);
2913+
2914+
params->alisim_fundi_proportion = params->fundi_init_proportion;
2915+
if (params->fundi_init_branch_length > 0.0) {
2916+
current_it->length = params->fundi_init_branch_length;
2917+
current_it_back->length = params->fundi_init_branch_length;
2918+
}
2919+
2920+
cout << "Init rho = " << params->alisim_fundi_proportion
2921+
<< " and init branch length = " << current_it->length << endl;
2922+
29132923
variables[1] = params->alisim_fundi_proportion;
29142924
variables[2] = current_it->length;
29152925
lower_bound[1] = 0.0;

utils/tools.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,9 @@ void parseArg(int argc, char *argv[], Params &params) {
15711571
params.alisim_length_ratio = 2;
15721572
params.birth_rate = 0.8;
15731573
params.death_rate = 0.2;
1574-
params.alisim_fundi_proportion = 0;
1574+
params.alisim_fundi_proportion = 0.0;
1575+
params.fundi_init_proportion = 0.5;
1576+
params.fundi_init_branch_length = 0.0;
15751577
params.alisim_distribution_definitions = NULL;
15761578
params.alisim_skip_checking_memory = false;
15771579
params.alisim_write_internal_sequences = false;
@@ -2921,13 +2923,34 @@ void parseArg(int argc, char *argv[], Params &params) {
29212923
params.alisim_fundi_proportion = 0.0;
29222924
} else {
29232925
params.alisim_fundi_proportion = convert_double(fundi_input.c_str());
2924-
if (params.alisim_fundi_proportion > 1 || params.alisim_fundi_proportion < 0)
2926+
if (params.alisim_fundi_proportion > 1 || params.alisim_fundi_proportion <= 0)
29252927
throw "Proportion in FunDi model must be positive and not greater than 1";
29262928
}
29272929

29282930
continue;
29292931
}
2930-
if (strcmp(argv[cnt], "-ngs_gap") == 0) {
2932+
2933+
if (strcmp(argv[cnt], "--fundi-init-rho") == 0) {
2934+
cnt++;
2935+
if (cnt >= argc)
2936+
throw "Use --fundi-init-rho <proportion>";
2937+
params.fundi_init_proportion = convert_double(argv[cnt]);
2938+
if (params.fundi_init_proportion >= 1 || params.fundi_init_proportion <= 0)
2939+
throw "Initial proportion in FunDi model must be positive and smaller than 1";
2940+
continue;
2941+
}
2942+
2943+
if (strcmp(argv[cnt], "--fundi-init-branch") == 0) {
2944+
cnt++;
2945+
if (cnt >= argc)
2946+
throw "Use --fundi-init-branch <branch_legth>";
2947+
params.fundi_init_branch_length = convert_double(argv[cnt]);
2948+
if (params.fundi_init_branch_length >= params.max_branch_length || params.fundi_init_branch_length <= 0)
2949+
throw "Initial branch length in FunDi model must be positive and smaller than 10";
2950+
continue;
2951+
}
2952+
2953+
if (strcmp(argv[cnt], "-ngs_gap") == 0) {
29312954
params.ngs_ignore_gaps = false;
29322955
continue;
29332956
}
@@ -4777,7 +4800,7 @@ void parseArg(int argc, char *argv[], Params &params) {
47774800
params.modelfinder_eps = convert_double(argv[cnt]);
47784801
if (params.modelfinder_eps <= 0.0)
47794802
throw "ModelFinder epsilon must be positive";
4780-
if (params.modelEps > 1.0)
4803+
if (params.modelfinder_eps > 1.0)
47814804
throw "ModelFinder epsilon must not be larger than 1.0";
47824805
continue;
47834806
}

utils/tools.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2629,7 +2629,17 @@ class Params {
26292629
* fundi model - proportion
26302630
*/
26312631
double alisim_fundi_proportion;
2632-
2632+
2633+
/**
2634+
* fundi model - initial proportion for optimisation
2635+
*/
2636+
double fundi_init_proportion;
2637+
2638+
/**
2639+
* fundi model - initial branch length for optimisation
2640+
*/
2641+
double fundi_init_branch_length;
2642+
26332643
/**
26342644
* distribution_definition_file
26352645
*/

0 commit comments

Comments
 (0)