diff options
| author | Pjotr Prins <pjotr.public01@thebird.nl> | 2026-11-18 12:18:09 +0000 |
|---|---|---|
| committer | Pjotr Prins <pjotr.public01@thebird.nl> | 2026-11-18 12:18:09 +0000 |
| commit | c1a4e3270e70f91e4e9cd6c7b67a669fbe2f77aa (patch) | |
| tree | 5199ff6f15df93b36aa1f10fc3db894a3f8b31a8 /src | |
| parent | f026a7b808fd2d61e64d4d53c540fd66fffcff81 (diff) | |
| download | pangemma-c1a4e3270e70f91e4e9cd6c7b67a669fbe2f77aa.tar.gz | |
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
"name<TAB>allele1<TAB>allele0" (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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lmm.cpp | 23 | ||||
| -rw-r--r-- | src/lmm.h | 5 |
2 files changed, 25 insertions, 3 deletions
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 "name<TAB>allele1<TAB>allele0" (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<int>(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) diff --git a/src/lmm.h b/src/lmm.h index 86b16c4..b3b19b3 100644 --- a/src/lmm.h +++ b/src/lmm.h @@ -51,6 +51,11 @@ struct MarkerInfo { uint8_t chr; size_t pos, line_no, n_miss; double maf; + // Allele labels, when the lmdb store carries them: the marker record is + // "name<TAB>allele1<TAB>allele0" in stores built by gemma-wrapper's + // geno2mdb.py. Stores built before that hold the name alone, and the assoc + // then prints '-' in those columns, which is what it always did. + string a_minor, a_major; } ; typedef vector<MarkerInfo> Markers; |
