From c1a4e3270e70f91e4e9cd6c7b67a669fbe2f77aa Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Wed, 18 Nov 2026 12:18:09 +0000 Subject: mdb: print the allele labels the store carries The lmdb path wrote '-' in the assoc's allele1/allele0 columns, so a consumer that reads them -- genenetwork4 returns GEMMA's columns verbatim -- could not tell an lmdb scan from a BIMBAM one by the payload. The columns are now taken from the store's marker record, which gemma-wrapper's geno2mdb.py writes as "nameallele1allele0" (BIMBAM's second and third field). Stores built before that hold the name alone, and those two columns still read '-', so an existing store keeps working unchanged. Verified on the BXD fixture through LOCO: pangemma on a Gf store and GEMMA on the same BIMBAM agree on the header, on 636 rows, and on every column -- allele1/allele0 included ('X'/'Y' in both), no differing cell at all. With a Gb store the same comparison differs on 62 beta / 48 se / 32 l_mle / 76 p_lrt of those 636 rows, which is Gb's 0.5-as-63/127 quantisation and not this change: BXD is a mean-genotype panel, and Gb is exact only for integer calls (0/1/2 -> 0/127/254). Choose Gf for mean genotypes. --- src/lmm.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/lmm.cpp') diff --git a/src/lmm.cpp b/src/lmm.cpp index 9c66cc4..36a0361 100644 --- a/src/lmm.cpp +++ b/src/lmm.cpp @@ -2139,7 +2139,11 @@ void LMM::mdb_analyze(std::function< SnpNameValues2(size_t) >& fetch_snp, outfile << chr_s << "\t"; outfile << name << "\t"; outfile << m.pos << "\t"; - outfile << m.n_miss << "\t-\t-\t"; // n_miss column + allele1 + allele0 + // allele1/allele0: from the store's marker record when it carries them + // (stores built by geno2mdb.py do), '-' otherwise -- as before. + outfile << m.n_miss << "\t" + << (m.a_minor.empty() ? "-" : m.a_minor) << "\t" + << (m.a_major.empty() ? "-" : m.a_major) << "\t"; outfile << fixed << setprecision(3) << m.maf << "\t"; outfile << scientific << setprecision(6); if (a_mode != M_LMM2) { @@ -2331,6 +2335,18 @@ void LMM::mdb_calc_gwa(const gsl_matrix *U, const gsl_vector *eval, string_view value2; marker_mdb.get(rtxn,key,value2); auto marker = string(value2); + // "name", or "nameallele1allele0" (see MarkerInfo). + string marker_name = marker, allele1, allele0; + if (auto tab1 = marker.find('\t'); tab1 != string::npos) { + marker_name = marker.substr(0, tab1); + auto tab2 = marker.find('\t', tab1 + 1); + if (tab2 == string::npos) { + allele1 = marker.substr(tab1 + 1); + } else { + allele1 = marker.substr(tab1 + 1, tab2 - tab1 - 1); + allele0 = marker.substr(tab2 + 1); + } + } // 1 rs13476251 174792257 // cout << static_cast(chr) << ":" << pos2 << " line " << rest2 << ":" << marker << endl ; @@ -2370,8 +2386,9 @@ void LMM::mdb_calc_gwa(const gsl_matrix *U, const gsl_vector *eval, } double maf = observed ? geno_total / (2.0 * (double)observed) : 0.0; - markerinfo = MarkerInfo { .name=marker,.chr=chr,.pos=pos,.line_no=num, - .n_miss=n_miss,.maf=maf }; + markerinfo = MarkerInfo { .name=marker_name,.chr=chr,.pos=pos,.line_no=num, + .n_miss=n_miss,.maf=maf, + .a_minor=allele1,.a_major=allele0 }; // -miss if ((double)n_miss / (double)ni_test > miss_level) -- cgit 1.4.1