File: perm.h

package info (click to toggle)
plink 1.07%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 3,136 kB
  • sloc: cpp: 72,375; makefile: 123; sh: 12
file content (115 lines) | stat: -rw-r--r-- 3,461 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
109
110
111
112
113
114
115


//////////////////////////////////////////////////////////////////
//                                                              //
//           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 __PERM_H__
#define __PERM_H__

#include "options.h"

using namespace std;

class Perm { 
  
  int t;                 // Number of tests
  long int replicates;   // Basic number of replicates
  long int performed;    // Number of replicates actually performed

  bool count;            // Output counts, not p-values

  ofstream PDUMP;        // Verbose permutation dump
  bool dump_best;        // Record just best permutation result
  bool dump_all;         // Record all permutation results
   
  vector<int> order;     // For --rank, record order of original
  vector<int> reorder;     // For --rank, record order of original, reverse mapping

  /////////////////////////////
  // Gene-dropping permutation

  bool genedrop;
  map<Individual*,int> idmap; 

  ///////////////////////////////////////////
  // Standard phenotype-swapping permutation

  // Parameters for adaptive permutation
  bool adaptive;
  
  int min;               // Minimum number of permutations
  double zt;             // SD CI range (based on par::adaptive_alpha)
  int interval;          // Prune tests every (I+N*I2) permutations

  // Main storage
  vector<int> R;         // number of successes
  vector<int> maxR;      // number of genome-wide successes
  vector<long int> N;    // number of trials (adaptive)
  
  // Cluster information
  vector< vector<int> > s;
  int ns;                // number of clusters
  
  Plink & P;             // reference to Plink class

 public:

  Perm(Plink &); 
  
  void closeDUMP() 
    {
      if (dump_all || dump_best)
	PDUMP.close();
    }
  
  // For basic permutation
  vector<int> pheno;     // label-swapped phenotype
  vector<int> geno;     // label-swapped phenotype

  vector<bool> test;             // whether to stop with this test
  vector<bool> snp_test;         // whether to skip these SNPs in 
                                 // a set-based test


  void                setTests(int x);
  void                setAdaptiveSetSNPs(int x);

  void                originalOrder();
  void                setOriginalRanking(vector_t&);
  bool                finished();
  bool                update(vector<double>&, vector<double>&);
  bool                updateSNP(double,double,int);
  void                nextSNP();
  vector<double> &    report();
  int                 current_reps() { return performed; }
  int                 reps_done(int);
  double              pvalue(int);
  double              max_pvalue(int);
  int                 rank(int);
  void                permuteInCluster();
  void                setPermClusters(Plink &);

  void                preGeneDrop();
  void                geneDrop();
  void                dropAlleles(Plink &,
				  Individual*,
				  int,
				  int,
				  vector<bool>&,
				  vector<bool>&,
				  vector<bool>&,
				  map<Individual*,int> &);
  
  
};


#endif