about summary refs log tree commit diff
path: root/test/python
diff options
context:
space:
mode:
authorPjotr <wrk@bosa.lan>2026-11-09 18:21:00 +0000
committerPjotr <wrk@bosa.lan>2026-11-09 18:21:00 +0000
commiteb5320d6f51279acf0b65e5bc9755eec927c93ea (patch)
tree9c928ea111cea1151cc96c1d17da0521b831ef79 /test/python
parent971a619fd28e247bf89057c0a72d1b4f51272a31 (diff)
downloadgenenetwork4-eb5320d6f51279acf0b65e5bc9755eec927c93ea.tar.gz
gemma: leave out individuals with no genotypes, which make the kinship singular
Asking whether the singular matrices could be fixed turned out to have two
answers, one of them a real bug on our side.

The bug: a panel can name individuals whose genotype row is empty, and an
empty row makes the kinship matrix singular. GEMMA then reports
"eigenvalues close to zero" and dies in LAPACK with
`LUDecomp ... input domain error` -- a message about linear algebra for a
problem that is a missing genotype. Measured on this deployment's own files:

  BXD-AE.4             136 of 344 individuals have no genotypes
  MDP                   93 of 178
  BXD-Heart-Metals.4   200 of 481
  HET3-ITP.3          2867 of 2867  (the whole file is empty)

Dropping them makes those panels map: BXD-AE.4's GWA step goes from a
failure to 3.2 s, and MDP's kinship step from a failure to success. The
individuals contribute nothing to a scan either way, so nothing is lost;
`notes` counts them, and the "Genotype:" line no longer blames parents/F1s
for them (`prepared.excluded` is "panel minus kept", which now includes
both, so the two counts are separated).

Not the cause, but worth naming: `AXB` fails earlier still, on its
annotation -- `ERROR: Enforce failed for D1Mit296 in src/gemma_io.cpp ...
ReadFile_anno` -- which is a broken `.snps` file, not a matrix. That wants a
pre-flight check of the annotation (report the offending marker) rather
than a GEMMA failure, and is not in this commit.

Considered and rejected: a ridge on K (`K + epsilon*I`) would work
mathematically but GEMMA has no option for it and the wrapper caches K by
content hash, so it would mean patching the wrapper's cached matrix; `-gk 2`
and dropping markers do not add rank; and the non-LOCO path is the one that
does not run at all here.

* src/genotypes.rs: `individuals_with_genotypes`, one pass over the bimbam
  file marking the individuals with any genotype at all.
* src/routes/gemma.rs: filter `keep` by it before alignment (so the trait
  values drop with them), and say so in `notes`.
* tests/gemma.rs: `individuals_with_no_genotypes_are_left_out` -- BXD-AE.4
  maps, the note names the drop and the reason, and the genotype line no
  longer claims 344 individuals.
* README.md: the behaviour and why it exists, under /compute/gemma.

307 tests pass; the same four as before do not.
Diffstat (limited to 'test/python')
0 files changed, 0 insertions, 0 deletions