diff options
Diffstat (limited to 'src/lmm.cpp')
| -rw-r--r-- | src/lmm.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/lmm.cpp b/src/lmm.cpp index 1d3b8e0..d13ce3c 100644 --- a/src/lmm.cpp +++ b/src/lmm.cpp @@ -1928,7 +1928,7 @@ void LMM::mdb_analyze(std::function< SnpNameValues2(size_t) >& fetch_snp, statistics (beta, standard errors, p-values) and stores results in sumStat. */ - auto batch_compute = [&](size_t l) { // using a C++ closure + auto batch_compute = [&](size_t l, const Markers &markers) { // using a C++ closure // Compute SNPs in batch, note the computations are independent per SNP debug_msg("enter batch_compute"); assert(l>0); @@ -1986,8 +1986,9 @@ void LMM::mdb_analyze(std::function< SnpNameValues2(size_t) >& fetch_snp, time_opt += (clock() - time_start) / (double(CLOCKS_PER_SEC) * 60.0); + auto markerinfo = markers[i]; // Store summary data. - SUMSTAT2 st = {beta, se, lambda_remle, lambda_mle, p_wald, p_lrt, p_score, logl_H1}; + SUMSTAT2 st = {markerinfo, beta, se, lambda_remle, lambda_mle, p_wald, p_lrt, p_score, logl_H1}; sumstat2.push_back(st); } }; @@ -2001,6 +2002,7 @@ void LMM::mdb_analyze(std::function< SnpNameValues2(size_t) >& fetch_snp, } */ const size_t progress_step = (num_markers/50>d_pace ? num_markers/50 : d_pace); + Markers markers; assert(num_markers > 0); for (size_t t = 0; t < num_markers; ++t) { @@ -2021,6 +2023,8 @@ void LMM::mdb_analyze(std::function< SnpNameValues2(size_t) >& fetch_snp, // auto mpos = get<3>(tup); auto markerinfo = get<1>(tup); auto gs = get<2>(tup); + + markers.push_back(markerinfo); // cout << t << " SNP: " << snp << endl; // check whether SNP is included in gwasnps (used by LOCO) @@ -2066,13 +2070,16 @@ void LMM::mdb_analyze(std::function< SnpNameValues2(size_t) >& fetch_snp, gsl_vector_safe_memcpy(&Xlarge_col.vector, x); c++; // count markers going in + if (c % msize == 0) { - batch_compute(msize); + batch_compute(msize,markers); + markers.clear(); + markers.reserve(msize); } } if (c % msize) - batch_compute(c % msize); + batch_compute(c % msize,markers); ProgressBar("Reading markers", num_markers - 1, num_markers - 1); cout << endl; cout << "Counted markers " << c << " sumStat " << sumstat2.size() << endl; @@ -2092,8 +2099,14 @@ void LMM::mdb_analyze(std::function< SnpNameValues2(size_t) >& fetch_snp, auto sumstats = [&] (SUMSTAT2 st) { outfile << scientific << setprecision(6); - - // outfile << st.marker << "\t"; + auto tup = st.markerinfo; + auto name = get<0>(tup); + auto chr = get<1>(tup); + auto pos = get<2>(tup); + + outfile << chr << "\t"; + outfile << name << "\t"; + outfile << pos << "\t"; if (a_mode != M_LMM2) { outfile << st.beta << "\t"; outfile << st.se << "\t"; |
