Esempio n. 1
0
void gcta::makex_eigenVector(int j, eigenVector &x, bool resize, bool minus_2p)
{
    int i=0;
    if(resize) x.resize(_keep.size());
    for(i=0; i<_keep.size(); i++){
        if(!_snp_1[_include[j]][_keep[i]] || _snp_2[_include[j]][_keep[i]]){
            if(_allele1[_include[j]]==_ref_A[_include[j]]) x[i]=(_snp_1[_include[j]][_keep[i]]+_snp_2[_include[j]][_keep[i]]);
            else x[i]=2.0-(_snp_1[_include[j]][_keep[i]]+_snp_2[_include[j]][_keep[i]]);
        }
        else x[i]=_mu[_include[j]];
        if(minus_2p) x[i]-=_mu[_include[j]];
    }
}
Esempio n. 2
0
// input P, calculate tr(PA)
void gcta::calcu_tr_PA(eigenMatrix &P, eigenVector &tr_PA)
{
	int i=0, k=0, l=0;
    double d_buf=0.0;

	// Calculate trace(PA)
	tr_PA.resize(_r_indx.size()+1);
	for(i=0; i<_r_indx.size(); i++){
		d_buf=0.0;
		for(k=0; k<_n; k++){
			for(l=0; l<_n; l++) d_buf+=P(k,l)*(_A.block(0,_r_indx[i]*_n,_n,_n))(k,l);
		}
		tr_PA(i)=d_buf;
	}
	tr_PA(_r_indx.size())=P.trace();
}