Commit d89e7597 authored by Romain Feron's avatar Romain Feron
Browse files

Fixed subset not computing max number of individuals + allowed to override popmap groups with -G

parent 0b793ce8
......@@ -32,8 +32,8 @@ struct Parameters {
// "subset" specific parameters
uint subset_min_group1 = 0;
uint subset_min_group2 = 0;
uint subset_max_group1 = 0;
uint subset_max_group2 = 0;
uint subset_max_group1 = 9999;
uint subset_max_group2 = 9999;
uint subset_min_individuals = 0;
uint subset_max_individuals = 9999;
......
......@@ -52,11 +52,15 @@ Popmap load_popmap(Parameters& parameters, bool compare) {
log("Groups specified with --groups (\"" + parameters.group1 + "\", \"" + parameters.group2 + "\") were not found in popmap groups (" + print_groups(popmap) + ")", LOG_ERROR);
exit(1);
} else if (compare and popmap.counts.size() == 2) { // If only two groups in popmap, use them (override user-specified groups for now)
} else if (compare and popmap.counts.size() == 2) { // Only two groups in popmap
auto i = std::begin(popmap.counts);
parameters.group1 = i->first;
parameters.group2 = (++i)->first;
if (parameters.group1 == "" and parameters.group2 == "") { // Fill groups from popmap if not specified by the user
auto i = std::begin(popmap.counts);
parameters.group1 = i->first;
parameters.group2 = (++i)->first;
}
}
std::string popmap_success_message = "Loaded popmap (" + print_groups(popmap, true) + ")";
......
......@@ -6,6 +6,10 @@ void subset(Parameters& parameters) {
Popmap popmap = load_popmap(parameters);
if (parameters.set_max_group1) parameters.subset_max_group1 = popmap.counts[parameters.group1];
if (parameters.set_max_group2) parameters.subset_max_group2 = popmap.counts[parameters.group2];
if (parameters.set_max_individuals) parameters.subset_max_individuals = static_cast<uint>(popmap.groups.size());
log("RADSex subset started");
log("Comparing groups \"" + parameters.group1 + "\" and \"" + parameters.group2 + "\"");
......@@ -56,7 +60,7 @@ void processor(MarkersQueue& markers_queue, Popmap& popmap, Parameters& paramete
marker.n_individuals >= parameters.subset_min_individuals and marker.n_individuals <= parameters.subset_max_individuals) {
chi_squared = get_chi_squared(marker.groups[parameters.group1], marker.groups[parameters.group2], popmap.counts[parameters.group1], popmap.counts[parameters.group2]);
marker.p = get_chi_squared_p(chi_squared);
marker.p = static_cast<float>(get_chi_squared_p(chi_squared));
parameters.output_fasta ? marker.output_fasta(output_file, parameters.min_depth) : marker.output_table(output_file);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment