32 for(
unsigned i=1;i<n;++i)
39 double Cnsq(
unsigned n)
42 for(
unsigned i=1;i<n;++i)
67 unsigned na,
unsigned nb) :
68 SA(sa),SB(sb),
D(d),
nA(na),nB(nb)
81 const std::vector< chisq_tuple > & _chisquareds,
82 const double & _fhat,
const double & _That,
86 : thetas(_thetas),chisquareds(_chisquareds),fhat(_fhat),
87 That(_That),xsq(_xsq),xsqA(_xsqA),xsqB(_xsqB)
112 double sumTheta = 0.;
116 unsigned n=0,sumSb=0;
117 for(
unsigned i=0;i<data.size();++i)
120 cna = Cn(data[i].nA);
121 cnb += (data[i].nB > 1) ? Cn(data[i].nB) : 0.;
122 sumTheta += double(data[i].SA)/cna;
124 n += (data[i].nB>1)?1u:0u;
130 fhat = ( std::isfinite(cnb) && cnb > 0. ) ?
double(sumSb)/(sumTheta*cnb) : 1.;
131 that = double(sumD)/sumTheta - (0.5*(1.+
fhat));
132 std::vector<double>
thetas(data.size());
133 std::vector< HKAresults::chisq_tuple >
chisquareds;
138 for(
unsigned i=0;i<data.size();++i)
140 cna = Cn(data[i].nA);
141 cnb = Cn(data[i].nB);
142 thetas[i] = double(
double(data[i].SA) +
145 (that+0.5*(1+
fhat)+cna+fhat*cnb);
147 double ESA =
thetas[i]*cna;
148 double VSA = ESA +
thetas[i]*
thetas[i]*Cnsq(data[i].nA);
149 double ESB = fhat*
thetas[i]*cnb;
150 double VSB = ESB + fhat*fhat*
thetas[i]*
thetas[i]*Cnsq(data[i].nB);
153 double xsq_t=0.,xsqA_t=0.,xsqB_t=0.;
154 const double spA = (double(data[i].SA)-ESA)*(
double(data[i].SA)-ESA)/VSA;
157 double xsqpoly = xsqA_t;
158 const double sp2 = (double(data[i].SB)-ESB)*(
double(data[i].SB)-ESB)/VSB;
159 if (std::isfinite(sp2))
165 const double d = (data[i].D-ED)*(data[i].D-ED)/VD;
167 chisquareds.push_back( std::make_tuple(xsqpoly,d,xsqA_t,xsqB_t) );
Calculations related to the HKA test.
The namespace in which this library resides.
results of calculations of the HKA test
Data from a single locus for an HKA test.
std::vector< chisq_tuple > chisquareds
HKAresults(const std::vector< double > &_thetas, const std::vector< chisq_tuple > &_chisquareds, const double &_fhat, const double &_That, const double &_xsq, const double &_xsqA, const double &_xsqB)
HKAresults calcHKA(const std::vector< HKAdata > &data)
const std::vector< double > thetas