diff options
| author | Pjotr <wrk@bosa.lan> | 2026-11-07 20:31:24 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-11-07 20:31:24 +0000 |
| commit | ee939a246a5b67f6650e0759e23fe2731124f8c3 (patch) | |
| tree | 78b978fcf79ffb3b47505ca4a1c7a925a97bc17b /test/python/test_traits.py | |
| parent | 1371328a7e36571dd92c5564c7d22c3c40789b9c (diff) | |
| download | genenetwork4-ee939a246a5b67f6650e0759e23fe2731124f8c3.tar.gz | |
compute/rqtl: fit covariates, by case-attribute name or as numbers
R/qtl has always been able to fit covariates; the API now passes them
through. `covariates` takes one or more specs, each either a case
attribute of the group by name -- which the server reads, aligns onto the
panel and codes -- or explicit per-sample numbers:
{"case_attribute": "Sex"}
{"case_attribute": "Diet", "map": {"HFD": 0, "LFD": 1}}
{"name": "age_days", "kind": "numerical", "values": [...]}
The coding is the server's job because the phenotype file is numeric:
text with 2-20 levels is coded 0..k-1 in sorted order and declared
`categorical` (the wrapper dummy-expands more than two levels), numeric
text goes through as `numerical`, and one level, more than 20 levels, or
an explicit map that misses a value is a 422 asking for a map rather than
an invented ordering. An attribute the group does not define is a 422
that lists the ones it has. Missing values become `x`/NA and R/qtl drops
those individuals.
Everything that decides the model goes into the cache key -- covariate
names *and* kinds, since a categorical covariate's dummy expansion is not
the same model as a numeric one -- and the response says what happened:
Covariate Sex: categorical coded F=0, M=1, 3281 of 3281 samples have a
value, 3281 with both the trait and the covariate
Measured on BXD-Longevity AgeAtDeath (3281 animals, WGS panel, 21056
markers): LOD 23.100 without the covariate, 23.522 with Sex, same peak
(rs30847416, chr 1, 5.0 Mb), ~15s more for the covariate run.
* src/rqtl.rs (Covariate, CovariateKind, code_case_attribute,
write_covarstruct_file): the coding rules, the extra pheno columns, the
covarstruct file, `--addcovar --covarstruct`, and the model's cache key;
five unit tests.
* src/routes/rqtl.rs (RqtlCovariate): the request shape, resolution
through the group's case attributes, duplicate/limit/ambiguity checks
(8 covariates at most), and the per-covariate note.
* tests/rqtl.rs: a real covariate run on UM-HET3 (894 markers, so the
test stays a test) asserting the coding note and the `--addcovar` line,
plus the unknown-attribute 422.
* README.md, docs/www/ai-instruction.md (4a): how to pass them, and that
the note's coding and complete-case count are the things to read.
Diffstat (limited to 'test/python/test_traits.py')
0 files changed, 0 insertions, 0 deletions
