830 - Haplotyper::ImputeGenotypes()

From Genome Analysis Wiki
Revision as of 15:06, 13 September 2013 by Goncalo (talk | contribs) (Created page with "</source lang="cpp"> void Haplotyper::ImputeGenotypes() { RewindMemoryPool(); // Process the last position RetrieveMemoryBlock(markers - 1); ImputeGenotypes(le...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

</source lang="cpp"> void Haplotyper::ImputeGenotypes()

  {
  RewindMemoryPool();
  // Process the last position
  RetrieveMemoryBlock(markers - 1);
  ImputeGenotypes(leftMatrices[markers - 1], markers - 1);
  SetupPrior(rightMatrices[0]);
  ConditionOnData(rightMatrices[0], 0, current_genotypes[0]);
  float *temp;
  float *from = rightMatrices[0];
  float *to = rightMatrices[1];
  for (int i = markers - 2; i >= 0; i--)
     {
     // Move things along
     Transpose(from, to, thetas[i]);
     // Find nearest informative marker
     double theta = 0.0;
     int left = i;
     while (left > 0 && genotypes[states / 2][left] == GENOTYPE_MISSING)
        {
        // Cumulative recombination fraction to nearest marker
        theta = theta + thetas[left - 1] - theta * thetas[left - 1];
        left--;
        }
     RetrieveMemoryBlock(left);
     float * leftMatrix = leftMatrices[left];
     if (left != i)
        {
        Transpose(leftMatrix, from, theta);
        leftMatrix = from;
        }
     ImputeGenotypes(leftMatrix, to, i);
     ConditionOnData(to, i, genotypes[states / 2][i]);
     temp = from;
     from = to;
     to = temp;
     }
  }

</source>