Skip to content

Commit

Permalink
trace summary (ge_hetro_flexible.cpp only)
Browse files Browse the repository at this point in the history
  • Loading branch information
bronsonj98 committed Jul 16, 2024
1 parent 2751921 commit 5e5ac29
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/ge_hetro_flexible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1889,18 +1889,23 @@ int main(int argc, char const *argv[]){
outfile << "\t-v (verbose) " << std::to_string(command_line_opts.verbose) << endl;
}
if (trace)
outfile << "\t-tr (trace summaries) " << endl;
outfile << "\t-tr (trace summaries for G only;; if pheno is not specified, dummy phenotype is used) " << endl;

outfile << endl;
outfile << endl;

if (trace){
string trpath=prefix + ".trace";
string trpath=prefix + ".tr";
string mnpath=prefix + ".MN";
trace_file.open(trpath.c_str(), std::ios_base::out);
trace_file << "TRACE,NSNPS_JACKKNIFE" << endl;
stringstream ss;
for (int i=0; i<Nbin; i++){
ss << "LD_SUM_" << i << ",";
}
ss << "NSNPS_JACKKNIFE";
trace_file << ss.str() << endl;
meta_file.open(mnpath.c_str(), std::ios_base::out);
meta_file << "NSAMPLE,NSNP,NBLK,NBIN" << endl << Nindv << "," << Nsnp << "," << Njack << "," << Nbin;
meta_file << "NSAMPLE,NSNPS,NBLKS,NBINS,K" << endl << Nindv << "," << Nsnp << "," << Njack << "," << Nbin << "," << Nz;
meta_file.close();
}

Expand Down Expand Up @@ -1992,16 +1997,22 @@ int main(int argc, char const *argv[]){
Y_r<<c_yky,yy;

if (trace){
trace_file << X_l.block(0, 0, Nbin, Nbin);
if (jack_index < Njack){
for (int j=0; j< Nbin; j++) // TODO: is this the right way to count SNPs in the jn block for partitioned heritability?
trace_file << "," << Nsnp_annot - jack_bin[jack_index][j];
trace_file << endl;
for (int i=0; i< Nbin; i++){
for (int j=0; j < Nbin; j++){
trace_file << (X_l(i, j) - Nindv_mask) * (len[i] - jack_bin[jack_index][i])*(len[j] - jack_bin[jack_index][j])/pow(Nindv_mask, 2)
<< ",";
}
trace_file << len[i] - jack_bin[jack_index][i] << endl;
}
}
else{
for (int j=0; j< Nbin; j++)
trace_file << "," << len[j];
trace_file << endl;
for (int i=0; i< Nbin; i++){
for (int j=0; j < Nbin; j++){
trace_file << (X_l(i, j) - Nindv_mask) * len[i]*len[j]/pow(Nindv_mask,2) << ",";
}
trace_file << len[i] << endl;
}

}
}
Expand Down

0 comments on commit 5e5ac29

Please sign in to comment.