Skip to content

Commit

Permalink
Merge pull request #1150 from veg/develop
Browse files Browse the repository at this point in the history
2.5.14 rc
  • Loading branch information
spond authored May 8, 2020
2 parents 5249b52 + 2bef225 commit d9538f6
Show file tree
Hide file tree
Showing 29 changed files with 807 additions and 88 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ include_directories(
#-------------------------------------------------------------------------------
# shared hyphy hbl stdlib target
#-------------------------------------------------------------------------------
install(DIRECTORY res/ DESTINATION lib/hyphy)
install(DIRECTORY res/ DESTINATION share/hyphy)

#-------------------------------------------------------------------------------
# HYPHYMP target
Expand Down Expand Up @@ -409,7 +409,7 @@ if(${MPI_FOUND})
# set definitions here 'cause "s_t_p" below doesn't like lists
set_property(
TARGET HYPHYMPI
APPEND PROPERTY COMPILE_DEFINITIONS __HYPHYMPI__ __UNIX__ _HYPHY_LIBDIRECTORY_="${CMAKE_INSTALL_PREFIX}/lib/hyphy"
APPEND PROPERTY COMPILE_DEFINITIONS __HYPHYMPI__ __UNIX__ _HYPHY_LIBDIRECTORY_="${CMAKE_INSTALL_PREFIX}/share/hyphy"
)

message ("${DEFAULT_LINK_FLAGS} ${MPI_LINK_FLAGS} ${OpenMP_CXX_FLAGS}")
Expand Down Expand Up @@ -564,12 +564,12 @@ set_property(

set_property(
TARGET hyphy HYPHYGTEST HYPHYDEBUG
APPEND PROPERTY COMPILE_DEFINITIONS _HYPHY_LIBDIRECTORY_="${CMAKE_INSTALL_PREFIX}/lib/hyphy"
APPEND PROPERTY COMPILE_DEFINITIONS _HYPHY_LIBDIRECTORY_="${CMAKE_INSTALL_PREFIX}/share/hyphy"
)

set_property(
TARGET hyphy HYPHYGTEST HYPHYDEBUG HYPHY-PROFILE
APPEND PROPERTY COMPILE_DEFINITIONS _HYPHY_LIBDIRECTORY_="${CMAKE_INSTALL_PREFIX}/lib/hyphy"
APPEND PROPERTY COMPILE_DEFINITIONS _HYPHY_LIBDIRECTORY_="${CMAKE_INSTALL_PREFIX}/share/hyphy"
)


Expand Down Expand Up @@ -618,5 +618,5 @@ add_test (CONTRAST-FEL HYPHYMP tests/hbltests/libv3/CFEL.wbf)
add_test (GARD HYPHYMP tests/hbltests/libv3/GARD.wbf)
add_test (FADE HYPHYMP tests/hbltests/libv3/FADE.wbf)
add_test (NAME ABSREL COMMAND HYPHYMP tests/hbltests/libv3/ABSREL.wbf)
add_test (NAME ABSREL-MH COMMAND HYPHYMP tests/hbltests/libv3/ABSREL-MH.wbf)
#add_test (NAME ABSREL-MH COMMAND HYPHYMP tests/hbltests/libv3/ABSREL-MH.wbf)

78 changes: 74 additions & 4 deletions res/TemplateBatchFiles/SelectionAnalyses/FEL.bf
Original file line number Diff line number Diff line change
Expand Up @@ -254,21 +254,91 @@ lfunction fel.handle_a_site (lf, filter_data, partition_index, pattern_info, mod

if (^"fel.srv"){
^"fel.alpha_scaler" = 1;
} else
{
start.grid = {
"0" : {
"fel.beta_scaler_test": 0.1,
"fel.beta_scaler_nuisance" : 0.1,
"fel.alpha_scaler" : 0.01
},
"1" : {
"fel.beta_scaler_test": 0.1,
"fel.beta_scaler_nuisance" : 0.1,
"fel.alpha_scaler" : 1
},
"2" : {
"fel.beta_scaler_test": 0.5,
"fel.beta_scaler_nuisance" : 0.5,
"fel.alpha_scaler" : 1
},
"3" : {
"fel.beta_scaler_test": 1.,
"fel.beta_scaler_nuisance" : 1.,
"fel.alpha_scaler" : 1
},
"4" : {
"fel.beta_scaler_test": 5.,
"fel.beta_scaler_nuisance" : 5.,
"fel.alpha_scaler" : 1
},
"5" : {
"fel.beta_scaler_test": 0.1,
"fel.beta_scaler_nuisance" : 0.1,
"fel.alpha_scaler" : 10.
}
};
} else {
^"fel.alpha_scaler" := 1;
start.grid = {
"0" : {
"fel.beta_scaler_test": 0.01,
"fel.beta_scaler_nuisance" : 0.01
},
"1" : {
"fel.beta_scaler_test": 0.1,
"fel.beta_scaler_nuisance" : 0.1
},
"2" : {
"fel.beta_scaler_test": 0.25,
"fel.beta_scaler_nuisance" : 1
},
"3" : {
"fel.beta_scaler_test": 0.5,
"fel.beta_scaler_nuisance" : 0.5
},
"4" : {
"fel.beta_scaler_test": 1.0,
"fel.beta_scaler_nuisance" : 1.0
},
"5" : {
"fel.beta_scaler_test": 5.0,
"fel.beta_scaler_nuisance" : 5.0
}
};
}
^"fel.beta_scaler_test" = 1;
^"fel.beta_scaler_nuisance" = 1;

Optimize (results, ^lf);

//utility.SetEnvVariable ("VERBOSITY_LEVEL", 10);


Optimize (results, ^lf
, {
"OPTIMIZATION_METHOD" : "nedler-mead",
"OPTIMIZATION_PRECISION" : 1e-5,
"OPTIMIZATION_START_GRID" : start.grid
}
);

//assert (0);
//Optimize (results, ^lf);

alternative = estimators.ExtractMLEs (lf, model_mapping);
alternative [utility.getGlobalValue("terms.fit.log_likelihood")] = results[1][0];

^"fel.alpha_scaler" = (^"fel.alpha_scaler" + 3*^"fel.beta_scaler_test")/4;
parameters.SetConstraint ("fel.beta_scaler_test","fel.alpha_scaler", "");

//Optimize (results, ^lf, {"OPTIMIZATION_METHOD" : "nedler-mead", OPTIMIZATION_PRECISION: 1e-5});
Optimize (results, ^lf);

Null = estimators.ExtractMLEs (lf, model_mapping);
Expand Down
50 changes: 40 additions & 10 deletions res/TemplateBatchFiles/SelectionAnalyses/FUBAR.bf
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ fubar.display_orders = {terms.original_name: -1,
fubar.prompts = {
"grid" : TRUE,
"chain" : TRUE,
"method" : TRUE
"method" : TRUE,
"non-zero" : TRUE
};

fubar.run_settings = {
Expand All @@ -76,7 +77,8 @@ fubar.run_settings = {
"burn-in" : 1e6,
"samples" : 100,
"concentration" : 0.5,
"posterior" : 0.9
"posterior" : 0.9,
"non-zero" : FALSE
};


Expand Down Expand Up @@ -120,8 +122,9 @@ fubar.json[terms.json.analysis] = fubar.analysis_description;
KeywordArgument ("code", "Which genetic code should be used", "Universal");
KeywordArgument ("alignment", "An in-frame codon alignment in one of the formats supported by HyPhy");
KeywordArgument ("tree", "A phylogenetic tree (optionally annotated with {})", null, "Please select a tree file for the data:");

// Additional Keyword Arguments ("output" and "cache") called below after namespace fubar.
// Additional Keyword Arguments ("grid", "method", "chain", "chain-length", "burn-in", "samples" and "concentration") called from within the "fubar.RunPrompts" function.
// Additional Keyword Arguments ("non-zero" "grid", "method", "chain", "chain-length", "burn-in", "samples" and "concentration") called from within the "fubar.RunPrompts" function.


namespace fubar {
Expand Down Expand Up @@ -225,7 +228,7 @@ if (utility.Has (fubar.cache, terms.fubar.cache.grid, "Matrix") && utility.Has (
// define FUBAR model

fubar.RunPrompts (fubar.prompts);
fubar.grid.matrix = fubar.DefineAlphaBetaGrid (fubar.run_settings["grid size"]);
fubar.grid.matrix = fubar.DefineAlphaBetaGrid (fubar.run_settings["grid size"], fubar.run_settings["non-zero"]);

io.ReportProgressMessageMD ("fubar", "codon_fit", "Computing the phylogenetic likelihood function on the grid ");
io.ReportProgressMessageMD ("fubar", "codon_fit", "* Determining appropriate tree scaling based on the best score from a `fubar.run_settings['grid size']` x `fubar.run_settings['grid size']` rate grid");
Expand Down Expand Up @@ -679,6 +682,8 @@ lfunction fubar.ComputeENFP_CI (p_i,sig_level) {
//----------------------------------------------------------------------------

function fubar.RunPrompts (prompts) {


if (prompts["grid"]) {
KeywordArgument ("grid", "The number of grid points", "20");
fubar.run_settings["grid size"] = io.PromptUser ("> Number of grid points per dimension (total number is D^2)",fubar.run_settings["grid size"],5,50,TRUE);
Expand Down Expand Up @@ -715,6 +720,19 @@ function fubar.RunPrompts (prompts) {
fubar.run_settings["concentration"] = io.PromptUser ("> The concentration parameter of the Dirichlet prior",fubar.run_settings["concentration"],0.001,1,FALSE);
prompts["chain"] = FALSE;
}

if (prompts["non-zero"]) {

KeywordArgument ("non-zero", "Enforce non-zero synonymous rates on the grid to enable dN/dS calculations", "No");

fubar.run_settings["non-zero"] = io.SelectAnOption ({
"Yes" : "The grid will exclude zero synonymous rates, resulting in finite dN/dS values",
"No" : "The grid will include zero synonymous rates, resulting in infinite dN/dS values"
}, "Enforce non-zero synonymous rates on the grid") == "Yes";

prompts["non-zero"] = FALSE;
}

}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -771,7 +789,7 @@ lfunction fubar.scalers.Unconstrain (tree_name, node_name, model_description) {

//------------------------------------------------------------------------------------------------//

lfunction fubar.DefineAlphaBetaGrid (one_d_points) {
lfunction fubar.DefineAlphaBetaGrid (one_d_points, non_zero) {


one_d_points = Max (one_d_points, 5);
Expand All @@ -797,12 +815,24 @@ lfunction fubar.DefineAlphaBetaGrid (one_d_points) {
}

_p = 0;
for (_r = 0; _r < one_d_points; _r += 1) {
for (_c = 0; _c < one_d_points; _c += 1) {
alphaBetaGrid[_p][0] = oneDGrid[_r];
alphaBetaGrid[_p][1] = oneDGrid[_c];
_p += 1;
if (non_zero) {
min_value = Max (1e-3, oneDGrid[0]);
for (_r = 0; _r < one_d_points; _r += 1) {
for (_c = 0; _c < one_d_points; _c += 1) {
alphaBetaGrid[_p][0] = Max (oneDGrid[_r], min_value);
alphaBetaGrid[_p][1] = oneDGrid[_c];
_p += 1;
}
}

} else {
for (_r = 0; _r < one_d_points; _r += 1) {
for (_c = 0; _c < one_d_points; _c += 1) {
alphaBetaGrid[_p][0] = oneDGrid[_r];
alphaBetaGrid[_p][1] = oneDGrid[_c];
_p += 1;
}
}
}

return alphaBetaGrid;
Expand Down
6 changes: 4 additions & 2 deletions res/TemplateBatchFiles/SelectionAnalyses/MEME.bf
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,9 @@ lfunction meme.handle_a_site (lf_fel, lf_bsrel, filter_data, partition_index, pa

//console.log ("Optimizing FEL for pattern " + pattern_info);
//io.SpoolLF (lf_fel, "/tmp/meme.debug" + ^"MPI_NODE_ID", "FEL");
Optimize (results, ^lf_fel);
Optimize (results, ^lf_fel
, {"OPTIMIZATION_METHOD" : "nedler-mead", OPTIMIZATION_PRECISION: 1e-4}
);

fel = estimators.ExtractMLEs (lf_fel, model_mapping);
fel[utility.getGlobalValue("terms.fit.log_likelihood")] = results[1][0];
Expand All @@ -508,7 +510,7 @@ lfunction meme.handle_a_site (lf_fel, lf_bsrel, filter_data, partition_index, pa
//io.SpoolLF (lf_bsrel, "/tmp/meme.debug", "MEME");

Optimize (results, ^lf_bsrel, {
//"OPTIMIZATION_METHOD" : "gradient-descent",
"OPTIMIZATION_METHOD" : "nedler-mead",
"OPTIMIZATION_START_GRID" :
{
"0" : {
Expand Down
5 changes: 4 additions & 1 deletion res/TemplateBatchFiles/SelectionAnalyses/PRIME.bf
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,9 @@ lfunction prime.handle_a_site (lf_fel, lf_prop, filter_data, partition_index, pa
^"prime.site_beta" = 1;
^"prime.site_beta" :> 0;

Optimize (results, ^lf_fel);
Optimize (results, ^lf_fel
, {"OPTIMIZATION_METHOD" : "nedler-mead", OPTIMIZATION_PRECISION: 1e-4}
);
fel = estimators.ExtractMLEs (lf_fel, model_mapping);
fel[utility.getGlobalValue("terms.fit.log_likelihood")] = results[1][0];
//console.log ("\n" + results[1][0]);
Expand All @@ -572,6 +574,7 @@ lfunction prime.handle_a_site (lf_fel, lf_prop, filter_data, partition_index, pa


Optimize (results, ^lf_prop, {
"OPTIMIZATION_METHOD" : "nedler-mead",
//"OPTIMIZATION_METHOD" : "gradient-descent",
/*"OPTIMIZATION_START_GRID" :
{
Expand Down
Loading

0 comments on commit d9538f6

Please sign in to comment.