Skip to content

Commit

Permalink
Streamline commandline args
Browse files Browse the repository at this point in the history
  • Loading branch information
mkerin committed May 20, 2020
1 parent 75ba633 commit 94ed286
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ class Data
n_signif_envs_sq++;
}
} catch (const std::exception &e) {
if (p.xtra_verbose) {
if (p.debug) {
std::cout << "Error when checking for significant squared envs ";
std::cout << "(I believe this is due to attempting linear regression ";
std::cout << "with a singular matrix)" << std::endl;
Expand Down
6 changes: 2 additions & 4 deletions src/parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ class parameters {
int env_update_repeats;
unsigned int n_thread, main_chunk_size, gxe_chunk_size;
std::uint32_t range_start, range_end;
bool range, maf_lim, info_lim, xtra_verbose, joint_covar_update, mode_RHEreg_LM;
bool range, maf_lim, info_lim, joint_covar_update, mode_RHEreg_LM;
bool mode_vb, use_vb_on_covars;
bool select_rsid, interaction_analysis, verbose, low_mem;
bool elbo_tol_set_by_user, alpha_tol_set_by_user, mode_empirical_bayes;
bool keep_constant_variants, user_requests_round1;
bool keep_constant_variants;
bool mode_alternating_updates, mode_RHE, mode_RHE_fast;
bool mode_no_gxe, debug, force_write_vparams;
bool init_weights_with_snpwise_scan, flip_high_maf_variants, min_spike_diff_set;
Expand Down Expand Up @@ -126,14 +126,12 @@ class parameters {
mode_dump_processed_data = false;
// check allele probs sum to 1 by default
verbose = false;
xtra_verbose = false;
use_vb_on_covars = true;
alpha_tol_set_by_user = false;
elbo_tol_set_by_user = false;
elbo_tol = 0.01;
alpha_tol = 0.001;
keep_constant_variants = false;
user_requests_round1 = false;
}

~parameters() = default;
Expand Down
15 changes: 5 additions & 10 deletions src/parse_arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ void parse_arguments(parameters &p, int argc, char **argv) {

options.add_options("General")
("verbose", "", cxxopts::value<bool>(p.verbose))
("bgen", "Path to BGEN file. This must be indexed (eg. with BGENIX). By default this is stored in RAM using O(NM) bytes.", cxxopts::value<std::string>(p.bgen_file))
("streamBgen", "Path to BGEN file. This must be indexed (eg. with BGENIX). This can be used with --RHEreg or --singleSnpStats.", cxxopts::value<std::string>())
("mStreamBgen", "Text file containing paths to multiple BGEN files. They must all be indexed (eg. with BGENIX). This can be used with --RHE or --mode_calc_snpstats.", cxxopts::value<std::string>())
("bgen", "Path to BGEN file, genetic data stored in RAM using O(NM) bytes.", cxxopts::value<std::string>(p.bgen_file))
("streamBgen", "Path to BGEN file, genetic data streamed from file. Used for single SNP association testing or randomized HE regression.", cxxopts::value<std::string>())
("mStreamBgen", "Text file containing paths to multiple BGEN files, genetic data streamed from file.", cxxopts::value<std::string>())
("pheno", "Path to phenotype file. Must have a header and have the same number of rows as samples in the BGEN file.", cxxopts::value<std::string>(p.pheno_file))
("covar", "Path to file of covariates. Must have a header and have the same number of rows as samples in the BGEN file.", cxxopts::value<std::string>(p.covar_file))
("environment", "Path to file of environmental variables. Must have a header and have the same number of rows as samples in the BGEN file.", cxxopts::value<std::string>(p.env_file))
Expand Down Expand Up @@ -112,8 +112,8 @@ void parse_arguments(parameters &p, int argc, char **argv) {
;

options.add_options("RHE")
("RHEreg", "Run randomised HE-regression algorithm", cxxopts::value<bool>())
("RHEreg-groups", "Text file containing group of each SNP for use with multicomponent randomised HE regression", cxxopts::value<std::string>())
("RHEreg", "Run randomized HE-regression algorithm", cxxopts::value<bool>())
("RHEreg-groups", "Text file containing group of each SNP for use with multicomponent randomized HE regression", cxxopts::value<std::string>())
("mRHEreg-groups", "Text file to paths of --RHE-groups files. Each should correspond to the bgen files given in --mStreamBgen", cxxopts::value<std::string>())
("n-RHEreg-samples", "Number of random vectors used in RHE algorithm (default 40)", cxxopts::value<long>(p.n_pve_samples))
("n-RHEreg-jacknife", "Number of jacknife samples used in RHE algorithm (default 100)", cxxopts::value<long>(p.n_jacknife))
Expand Down Expand Up @@ -333,16 +333,11 @@ void parse_arguments(parameters &p, int argc, char **argv) {
}
if(opts.count("xtra-verbose")) {
p.verbose = true;
p.xtra_verbose = true;
if(!opts.count("param_dump_interval")) {
p.param_dump_interval = 50;
}
}

if(opts.count("mode-debug")) {
p.debug = true;
p.verbose = true;
p.xtra_verbose = true;
if(!opts.count("param_dump_interval")) {
p.param_dump_interval = 50;
}
Expand Down
4 changes: 2 additions & 2 deletions src/rhe_reg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ void RHEreg::compute_RHE_trace_operators() {
}
}
if (p.verbose) std::cout << n_var << " variants pass QC filters" << std::endl;
if (p.xtra_verbose && p.RHE_multicomponent) {
if (p.debug && p.RHE_multicomponent) {
std::cout << n_find_operations << " find operations performed" << std::endl;
}
}
Expand Down Expand Up @@ -398,7 +398,7 @@ void RHEreg::solve_RHE(std::vector<RHEreg_Component>& components) {


// Write to file
if(world_rank == 0 && p.xtra_verbose) {
if(world_rank == 0 && p.debug) {
auto filename = fileUtils::fstream_init(outf, p.out_file, "", "_h2_dump");
std::cout << "Dumping Heritability to " << filename << std::endl;
Eigen::VectorXd tmp(Eigen::Map<Eigen::VectorXd>(CC.data(),CC.cols()*CC.rows()));
Expand Down
6 changes: 3 additions & 3 deletions src/vbayes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ class VBayes {
std::vector<Hyps>& all_hyps,
std::vector<VbTracker>& all_tracker){
// minimise KL Divergence and assign elbo estimate
if (p.xtra_verbose) std::cout << "Starting inner loop" << std::endl;
if (p.debug) std::cout << "Starting inner loop" << std::endl;
int print_interval = 25;
if(random_init) {
throw std::logic_error("Random start depreciated.");
Expand Down Expand Up @@ -502,7 +502,7 @@ class VBayes {
}

// Dump converged state
if (p.xtra_verbose) std::cout << "Dumping converged params" << std::endl;
if (p.debug) std::cout << "Dumping converged params" << std::endl;
for (int nn = 0; nn < n_grid; nn++) {
all_tracker[nn].dump_state("_converged", n_samples, n_covar, n_var,
n_env, n_effects,
Expand Down Expand Up @@ -630,7 +630,7 @@ class VBayes {
//
if(p.joint_covar_update) {
if(first_covar_update) {
if(p.xtra_verbose) {
if(p.debug) {
std::cout << "Performing first VB update of covar effects" << std::endl;
}
Eigen::MatrixXd CtCRidge = C.transpose() * C;
Expand Down

0 comments on commit 94ed286

Please sign in to comment.