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

small bug fixes for new sex distribution output

parent 0c43f907
......@@ -48,7 +48,7 @@ void output_process_reads(std::string& output_file_path, std::vector<std::string
void output_sex_distribution_matrix(std::string& output_file_path, std::unordered_map<uint, std::unordered_map<uint, uint64_t>>& results, uint n_males, uint n_females) {
void output_sex_distribution_matrix(std::string& output_file_path, sd_table& results, uint n_males, uint n_females) {
/* Input:
* - Path to an output file
......@@ -62,11 +62,11 @@ void output_sex_distribution_matrix(std::string& output_file_path, std::unordere
uint i = 0;
results[0][0] = 0; // Sequences found in none of the individuals (after filtering for minimum coverage) should not appear in the results
results[0][0].first = 0; // Sequences found in none of the individuals (after filtering for minimum coverage) should not appear in the results
for (uint f=0; f < n_females; ++f) {
for (uint m=0; m < n_males; ++m) {
output_file << results[m][f];
output_file << results[m][f].first;
if (i < n_males - 1) output_file << "\t";
++i;
}
......@@ -77,7 +77,7 @@ void output_sex_distribution_matrix(std::string& output_file_path, std::unordere
void output_sex_distribution(std::string& output_file_path, std::unordered_map<uint, std::unordered_map<uint, uint64_t>>& results, uint n_males, uint n_females) {
void output_sex_distribution(std::string& output_file_path, sd_table& results, uint n_males, uint n_females) {
/* Input:
* - Path to an output file
......@@ -94,8 +94,8 @@ void output_sex_distribution(std::string& output_file_path, std::unordered_map<u
output_file << "Males" << "\t" << "Females" << "\t" << "Sequences" << "\t" << "P-value" << "\t" << "Significant" << "\n";
// Generate output file
for (uint f=0; f < n_females; ++f) {
for (uint m=0; m < n_males; ++m) {
for (uint m=0; m < n_males; ++m) {
for (uint f=0; f < n_females; ++f) {
if (f + m != 0) {
output_file << m << "\t" << f << "\t" << results[m][f].first << "\t" << results[m][f].second << "\n";
}
......
......@@ -11,7 +11,10 @@
void output_process_reads(std::string& output_file_path, std::vector<std::string>& individuals, std::unordered_map<std::string, std::unordered_map<std::string, uint16_t>>& results, uint min_cov);
// Create output file for the sex_distribution analysis
void output_sex_distribution(std::string& output_file_path, std::unordered_map<uint, std::unordered_map<uint, uint64_t>>& results, uint n_males, uint n_females);
void output_sex_distribution_matrix(std::string& output_file_path, sd_table& results, uint n_males, uint n_females);
// Create output file for the sex_distribution analysis
void output_sex_distribution(std::string& output_file_path, sd_table& results, uint n_males, uint n_females);
// Create output file for the group_loci analysis
void output_group_loci(std::string& output_file_path, std::unordered_map<std::string, std::vector<Locus>>& results, std::vector<std::string>& header);
......@@ -106,7 +106,7 @@ void sex_distribution(Parameters& parameters) {
for (uint m=0; m < n_males; ++m) {
if (f + m != 0) {
chi_squared = get_chi_squared(m, f, n_males, n_females);
results[m][f].second = get_chi_squared_p(chi_squared) * n_sequences;
results[m][f].second = std::min(1.0, get_chi_squared_p(chi_squared) * n_sequences); // p-value corrected with Bonferroni, with max of 1
}
}
}
......
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