| Age | Commit message (Collapse) | Author |
|
The pangemma endpoint is to agree with R/qtl2, not with GEMMA, so the store's
genotypes now come from qtl2's HMM rather than from a marker mean: maxmarg on
the genotype probabilities /compute/qtl2 already computes and caches, at
minprob 0 so every cell is called. GEMMA's own endpoints are untouched.
scripts/make-mdb.sh --impute qtl2 --cross <qtl2 cross dir> --probs <probs.rds>
writes a BIMBAM from the HMM's calls (marker, X, Y, genotypes -- the annotation
mdb carries the positions, as the makers expect), the snps file from the cross's
physical map, and then the store as before: lock file deleted, .mdb made
read-only, renamed into place. Measured on BXD.8: 7 s for the HMM over 20 453
markers x 235 individuals, 4.7 s for geno2mdb, 28.9 MB as Gf, no gaps left.
Three things found while wiring it, each now handled:
* maxmarg returns individuals x markers -- the transpose of a BIMBAM -- and a
first version wrote 4 465 lines with individuals where markers belong;
* both makers name their output after their argument and write it in the
current directory, so they now run inside the work directory with bare names.
A hand run with absolute paths had put a 2 MB .mdb inside gn4-data;
* pangemma's startup smoke test wants the working directory to be its own
source root. Run from anywhere else it exits in 0.03 s having done nothing,
which looks like a very fast scan rather than a failure.
Comparison, three BXD traits, 20 451 markers, each engine with its own kinship
matrix, positional phenotype in the cross's individual order:
trait same top marker Spearman rho top-50 overlap median |d(-log10 p)|
10001 yes (rs27829136) 0.99732 48/50 0.008
16627 yes (rs29388476) 0.98415 43/50 0.029
16769 yes (rs29388476) 0.98339 32/50 0.029
K 0.13 s against gemma's 0.84 s; the LMM scan 2.5 s against 3.0 s.
|
|
pangemma's mdb path has no missing-data handling -- mdb_calc_kin in
src/gemma_io.cpp still carries the comment "[ ] handle missing data" -- and one
NA poisons the whole matrix. Measured on BXD.8 (235 individuals, 21 056
markers, 0.1% missing): a store built straight from the BIMBAM gave a 235x235
matrix of -nan in 0.1 s with "**** INFO: Done." and exit 0; the same data with
NAs replaced by each marker's mean gave a clean 235x235 matrix, and -lmm 9 on
one chromosome then produced 1 452 markers matching GEMMA's on 1 171 of them.
So the script imputes per marker (awk, one streaming pass, no Python needed) by
default and --keep-missing turns that off for anyone who wants the raw store.
NOT what GEMMA does, measured afterwards: GEMMA keeps the missing genotype and
reports it (n_miss=1 in its .assoc.txt) while analysing one individual fewer
for that marker -- 286 of 1452 markers on chromosome 1 carry a missing value,
and their p-values differ from the imputed run (0.732 against 0.698 for
rsm10000000731) because n goes 235 -> 234. So imputation is a deliberate
deviation the mdb path forces, not a reproduction of the direct path: on the
286 markers with a missing genotype, pangemma+mdb and gemma+BIMBAM are
answering slightly different questions, and the endpoint has to say so.
Also measured while checking: a File input is what ravanan hashes, and the
store's LMDB lock is a sibling (<name>.mdb-lock), not a file inside it -- the
.mdb's sha1 is identical before and after a read while the lock's bytes change
on every open. So deleting the lock after writing gives a stable identity and
the lock that comes back when a reader opens the store costs nothing.
|
|
pangemma picks an LMDB genotype store by looking for ".mdb" in the -g path
(src/param.cpp:943), so the store's name is part of the interface. Two of
gemma-wrapper's helpers make it -- anno2mdb.rb then geno2mdb.rb -- and this
script does the three things they leave to the caller:
* the lock file. Measured on a real store: these environments are single
files (MDB_NOSUBDIR), and the lock is a *sibling*, <name>.mdb-lock, which
every open recreates with different bytes (8d3d268b after writing, another
sha1 after one read-only open, another after a read-write open) while the
.mdb itself never changes. Since the .mdb is what gets hashed and interned,
the lock is deleted after writing and the .mdb is made read-only.
* the name: <name>.geno.mdb, so `-g' recognises it and the outer name says
which translation it holds (Gf, Gb, G0_1, G0_2).
* atomicity: the makers write beside their input, so they are given links in a
temporary directory and the finished store is renamed into place; nothing is
written next to the caller's files (an earlier hand run of anno2mdb.rb put a
2 MB .mdb into gn4-data, which is exactly the mistake this prevents).
Measured on BXD.8 (21 056 markers, 235 individuals): 0.17 s for the annotation
half, 4.7 s for the genotypes, 29 MB as Gf.
Two things found while testing it, both for the plan rather than this script:
the anno mdb is an intermediate that pangemma does not need (it takes the snps
file with -a), so it is not kept; and a store built from a BIMBAM whose chr/pos
columns are the "X"/"Y" placeholders makes pangemma produce an all-NaN K
silently -- 235 individuals read, no error, a 235x235 matrix of -nan -- because
geno2mdb keys genotypes by (chr,pos) and nothing matches the annotation.
|