File: haplowindow.h

package info (click to toggle)
plink 1.07%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 3,136 kB
  • sloc: cpp: 72,375; makefile: 123; sh: 12
file content (108 lines) | stat: -rw-r--r-- 2,522 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108

//////////////////////////////////////////////////////////////////
//                                                              //
//           PLINK (c) 2005-2006 Shaun Purcell                  //
//                                                              //
// This file is distributed under the GNU General Public        //
// License, Version 2.  Please see the file COPYING for more    //
// details                                                      //
//                                                              //
//////////////////////////////////////////////////////////////////


#ifndef __HAPWINDOW_H_
#define __HAPWINDOW_H__

class HaploPhase;
class Plink;
class MultiLocusGenotype;

class HaploWindow
{

 public:

  int ns; // Number of SNPs in haplotype
  int nh; // Number of possible haplotypes
  int np; // Number of phases, diploid

  // Parent 'region', PLINK
  HaploPhase * haplo;
  Plink * P;

  // Start and stop positions (relative to region)
  int start, stop;

  // Haplotype frequencies
  vector_t f;

  // Window haplotype codes
  vector<vector<bool> > hap;

  // Stub codes for each haplotype (for quick lookup)
  vector<int> leftStub;
  vector<int> rightStub;

  // Lookup table for haplotype number given SNPs
  map<vector<bool>,int> hapmap;

  // List of SNP numbers
  intvec_t S;

  // Posterior probabilities, per individual
  matrix_t pp;

  // Haplotype phases, per individual
  table_t hap1;
  table_t hap2;

  // Ambiguous for this window?
  boolvec_t ambig;

  // Unamiguous haplotype counts
  vector_t uc;

  // Store count, reference individual
  set<MultiLocusGenotype*> genotypes;

  // Store which genoGroup a person belongs to
  vector<MultiLocusGenotype*> genoGroup;

  // Finished with this window?
  bool converged;
  bool left_passed;
  bool right_passed;


  // Convergence
  vector<bool> zero;
  double sampleLogLikelihood;
  int iter;

  ///////////////////////////////
  // Functions

  HaploWindow(HaploPhase *, Plink *);

  ~HaploWindow();

  void expandGenogroups();
  void enumerateGenogroups();
  void pruneGenogroups(double t=par::haplo_plem_window_prune_phase);
  void enumerateHaplotypes(intvec_t &);
  void setStubCodes();
  void performEM();
  void enumeratePhase(int);
  void prunePhase(int,double t=par::haplo_plem_window_prune_phase);
  void reportPhase();
  string haplotypeName(int i);

  // Get overlap frequency from a window
  vector_t leftStubFrequency();
  vector_t rightStubFrequency();

  void tallyUnambiguousCounts();

};

#endif