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

Fixed bug with p-value lower than precision of a double

Added a minimum value of 10^-16 for p-values
parent 9ee178c8
......@@ -151,7 +151,8 @@ void mapping(Parameters& parameters) {
if (best_alignment[2] < 1 and best.mapq > min_quality) { // Keep sequences with unique best alignment and with mapq > minimum quality
sex_bias = float(sex_count[0]) / float(n_males_total) - float(sex_count[1]) / float(n_females_total); // Sex bias. There should never be 0 males or females in the entire population.
chi_squared = get_chi_squared(sex_count[0], sex_count[1], n_males_total, n_females_total);
(chi_squared == chi_squared) ? p = get_chi_squared_p(chi_squared) : p = 1; // chi square is NaN --> sequence found in all individuals --> set p to 1
(chi_squared == chi_squared) ? p = get_chi_squared_p(chi_squared) : p = 1.0; // chi square is NaN --> sequence found in all individuals --> set p to 1
p < 0.0000000000000001 ? p = 0.0000000000000001 : p = p;
output_file << id << "\t" << index->bns->anns[best.rid].name << "\t" << best.pos << "\t" << sex_bias << "\t" << p << "\n";
++retained_sequences;
}
......
......@@ -19,7 +19,7 @@ struct Locus {
std::vector<std::string> coverage;
};
typedef std::unordered_map<uint, std::unordered_map<uint, std::pair<uint64_t, float>>> sd_table;
typedef std::unordered_map<uint, std::unordered_map<uint, std::pair<uint64_t, double>>> sd_table;
// Output current date and time in format specified with DMTTMFMT and DTTMSZ
char* print_time (char *buff);
......
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