Line 123: |
Line 123: |
| original.CopyParameters(mp); | | original.CopyParameters(mp); |
| | | |
| + | // ======================================================================================= |
| + | // We can update parameters by comparing a reference haplotype to the others ============= |
| #pragma omp parallel for | | #pragma omp parallel for |
| for (int i = 0; i < iterations; i++) | | for (int i = 0; i < iterations; i++) |
Line 146: |
Line 148: |
| } | | } |
| | | |
| + | // ======================================================================================= |
| + | // Or, by comparing a sampled haplotype to the reference ================================= |
| if (round >= rounds / 2) | | if (round >= rounds / 2) |
| { | | { |
Line 177: |
Line 181: |
| } | | } |
| } | | } |
− | | + | |
| + | // ======================================================================================= |
| + | // At the end of each iteration, we need to update the model ============================= |
| mp.UpdateModel(); | | mp.UpdateModel(); |
| } | | } |
Line 192: |
Line 198: |
| reference.ListMajorAlleles(); | | reference.ListMajorAlleles(); |
| | | |
− | printf("Generating Draft .info File ...\n\n"); | + | // ======================================================================================= |
− | | + | // Now, we can do some imputation - but first open output files! ========================= |
− | // Output some basic information | |
− | IFILE info = ifopen(prefix + ".info.draft", "wb");
| |
− | | |
− | ifprintf(info, "SNP\tAl1\tAl2\tFreq1\tGenotyped\n");
| |
− | | |
− | for (int i = 0, j = 0; i <= stopIndex; i++)
| |
− | if (i >= startIndex)
| |
− | ifprintf(info, "%s\t%s\t%s\t%.4f\t%s\n",
| |
− | (const char *) refMarkerList[i],
| |
− | reference.MajorAlleleLabel(i), reference.MinorAlleleLabel(i),
| |
− | reference.freq[reference.major[i]][i],
| |
− | j < markerIndex.Length() && i == markerIndex[j] ? (j++, "Genotyped") : "-");
| |
− | else
| |
− | if (j < markerIndex.Length() && i == markerIndex[j])
| |
− | j++;
| |
− | | |
− | ifclose(info);
| |
− | | |
| printf("Imputing Genotypes ...\n"); | | printf("Imputing Genotypes ...\n"); |
| | | |
Line 240: |
Line 228: |
| ImputationStatistics stats(reference.markerCount); | | ImputationStatistics stats(reference.markerCount); |
| | | |
− | // Impute each haplotype | + | // ======================================================================================= |
| + | // Now, loop through haplotypes, imputing one at a time ================================== |
| #pragma omp parallel for | | #pragma omp parallel for |
| for (int i = 0; i < target.count; i++) | | for (int i = 0; i < target.count; i++) |
Line 322: |
Line 311: |
| } | | } |
| | | |
| + | // ============================================================================ |
| + | // Close output files ========================================================= |
| ifclose(dosages); | | ifclose(dosages); |
| | | |
Line 332: |
Line 323: |
| if (probabilities != NULL) | | if (probabilities != NULL) |
| ifclose(probabilities); | | ifclose(probabilities); |
| + | |
| + | // =========================================================================== |
| + | // Report runtime statistics ================================================= |
| | | |
| time_t stop = time(NULL); | | time_t stop = time(NULL); |