about summary refs log tree commit diff
path: root/test/python/test_envelope.py
diff options
context:
space:
mode:
authorPjotr <wrk@bosa.lan>2026-11-09 16:04:45 +0000
committerPjotr <wrk@bosa.lan>2026-11-09 16:04:45 +0000
commitc642f87fb33a41032c4af5fda38e6434c2251aae (patch)
tree7888fbead2d7de28d12f3fecef24d859316d87ee /test/python/test_envelope.py
parent002cdc41a54f6b398933f9e536217ec433a17eac (diff)
downloadgenenetwork4-c642f87fb33a41032c4af5fda38e6434c2251aae.tar.gz
compute: fit covariates in /compute/fitqtl too
`fitqtl` takes a `covar` argument, so the effect it reports can be the one
*after* conditioning -- which is usually the number worth quoting for a peak
that overlaps a known confounder. `covariates` now works on /compute/fitqtl
exactly as on /compute/rqtl: the same `covariates::resolve` (case attribute
by name, inline values, explicit map, same coding and same note), so the two
endpoints report a covariate identically.

The R side does what R/qtl needs: the phenotype file carries one column per
covariate after the trait, `--covarstruct` says which are categorical, and
the script dummy-expands those (k-1 against the first sorted level, missing
values left missing). Two things it has to get right:

* `model.matrix()` drops rows with a missing value, which silently misaligns
  the covariate frame against the cross -- so the dummies are built directly
  (`ifelse(is.na(x), NA, x == level)`), not through `model.matrix`;
* a covariate can be perfectly spread across the panel and **constant among
  the individuals a trait covers** -- BXD's `Status` is exactly that -- and
  R/qtl then stops with `Lapack routine dgesv: system is exactly singular`.
  Columns that do not vary among the phenotyped individuals are left out,
  and the reply names them, the same rule the GEMMA covariate file applies.

Measured on BXD trait 10001 at its peak, `BXD.4`:

  no covariate                    LOD 2.9310  additive +2.394  32.8% var
  with Status                     LOD 3.3602  additive +2.463  36.6% var
  with an inline numeric covariate LOD 2.9373  additive +2.361

The LOD is no longer the scan's once a covariate is fitted -- it is a
different model -- which the docs now say, next to the no-covariate parity
check that still holds.

* scripts/qtl_fitqtl.R: `--covarstruct`, dummy expansion, the degenerate
  column rule, and the dropped names in the summary line.
* src/fitqtl.rs: writes the covariates into the phenotype file and the
  struct file, and passes both.
* src/routes/fitqtl.rs: the `covariates` field, resolved after alignment so
  the coding and the complete-case count match /compute/rqtl.
* tests/fitqtl.rs: a covariate run (the note, the fitted row, a changed LOD)
  and an unknown attribute refused with the list of valid ones.
* README.md, docs/www/SKILL.md: covariates on this endpoint, and why its LOD
  stops matching the scan's.

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