Skip to content

Commit

Permalink
Adds --min-ratio-behavior option to allow for skipping chunks with lo…
Browse files Browse the repository at this point in the history
…w number of target sites.
  • Loading branch information
jonathonl committed Nov 9, 2023
1 parent 42bead8 commit 144874d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,14 @@ class imputation
float tar_ref_ratio = float(typed_only_reference_data.variant_size()) / float(full_reference_data.variant_size());
std::cerr << "Typed sites to imputed sites ratio: " << tar_ref_ratio << " (" << typed_only_reference_data.variant_size() << "/" << full_reference_data.variant_size() << ")\n";
if (tar_ref_ratio < args.min_ratio())
return std::cerr << "Error: not enough target variants are available to impute this chunk. The --min-ratio, --chunk, or --region options may need to be altered.\n", false;
{
std::cerr << (args.fail_min_ratio() ? "Error" : "Warning") << ": not enough target variants are available to impute this chunk. The --min-ratio, --chunk, or --region options may need to be altered." << std::endl;
if (!args.fail_min_ratio())
std::cerr << "Warning: skipping chunk " << impute_region.chromosome() << ":" << impute_region.from() << "-" << impute_region.to() << std::endl;
if (args.fail_min_ratio())
return false;
return true; // skip
}

if (target_only_sites.size())
{
Expand Down
8 changes: 8 additions & 0 deletions src/prog_args.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class prog_args : public getopt_wrapper
bool compress_reference_ = false;
bool pass_only_ = false;
bool meta_ = false; // deprecated
bool fail_min_ratio_ = true;
bool help_ = false;
bool version_ = false;

Expand Down Expand Up @@ -81,6 +82,7 @@ class prog_args : public getopt_wrapper
bool update_m3vcf() const { return update_m3vcf_; }
bool compress_reference() const { return compress_reference_; }
bool pass_only() const { return pass_only_; }
bool fail_min_ratio() const { return fail_min_ratio_; }

prog_args() :
getopt_wrapper(
Expand All @@ -106,6 +108,7 @@ class prog_args : public getopt_wrapper
{"decay", required_argument, 0, '\x02', "Decay rate for dosages in flanking regions (default: disabled with 0)"},
{"min-r2", required_argument, 0, '\x02', "Minimum estimated r-square for output variants"},
{"min-ratio", required_argument, 0, '\x02', "Minimum ratio of number of target sites to reference sites (default: 0.00001)"},
{"min-ratio-behavior", required_argument, 0, '\x02', "Behavior for when --min-ratio is not met (\"skip\" or \"fail\"; default: fail)"}, // maybe add "warn"
{"match-error", required_argument, 0, '\x02', "Error parameter for HMM match probabilities (default: 0.01)"},
{"min-recom", required_argument, 0, '\x02', "Minimum recombination probability (default: 0.00001)"},
{"prob-threshold", required_argument, 0, '\x02', "Probability threshold used for template selection"},
Expand Down Expand Up @@ -299,6 +302,11 @@ class prog_args : public getopt_wrapper
min_ratio_ = std::min(1., std::max(0., std::atof(optarg ? optarg : "")));
break;
}
else if (long_opt_str == "min-ratio-behavior")
{
fail_min_ratio_ = std::string(optarg ? optarg : "") == "fail";
break;
}
else if (long_opt_str == "match-error")
{
error_param_ = std::min(0.5, std::max(0., std::atof(optarg ? optarg : "")));
Expand Down

0 comments on commit 144874d

Please sign in to comment.