diff options
| author | Pjotr <wrk@bosa.lan> | 2026-11-07 15:33:28 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-11-07 15:33:28 +0000 |
| commit | 2fcb57a627ed261b6650522b256cc509ebd65ddd (patch) | |
| tree | dc356cc6fa962a3ec89eb393dbd9a0f4b15ca2fd | |
| parent | e5c333959af6675a0d80934c8cf76275d5571ef8 (diff) | |
| download | genenetwork4-2fcb57a627ed261b6650522b256cc509ebd65ddd.tar.gz | |
rqtl: refuse a phenotype whose sample count is not the cross's
Asked to map a 9-strain trait, the wrapper scanned it against the 6-individual fixture cross and returned six markers with LOD scores and `state: complete` -- a plausible answer belonging to nobody. R recycled and truncated the values silently, and nothing downstream could tell. GeneNetwork3's copy of this script has the same hole. The cross-file format carries no per-sample names, so the count is the only check available; order remains the caller's responsibility (and the reason values and genotype file must come from the same panel). With the check, the same request is a 502 rqtl_failed quoting both counts, and the correctly-shaped request still returns the documented LODs. * scripts/rqtl_wrapper.R: compare the pheno file's rows with nind() of the cross, and stop. * README.md (/compute/rqtl): the second fix relative to gn3, and what stays the caller's job. * docs/www/ai-instruction.md (4a): values and genotypes must describe the same individuals, one for one, in the same order. * docs/www/operator-checklist.md (Compute): what genotype files actually exist on this box (test fixtures, 198 BXD individuals) and why a database trait, with its own strain subset, cannot be mapped against them.
| -rw-r--r-- | README.md | 13 | ||||
| -rw-r--r-- | docs/www/ai-instruction.md | 9 | ||||
| -rw-r--r-- | docs/www/operator-checklist.md | 12 | ||||
| -rw-r--r-- | scripts/rqtl_wrapper.R | 14 |
4 files changed, 45 insertions, 3 deletions
diff --git a/README.md b/README.md index c57b567..024759b 100644 --- a/README.md +++ b/README.md @@ -1120,9 +1120,16 @@ cached result there; fixed here by always hashing both files' contents. **Important:** R/qtl's cross file format has no per-sample name matching of its own -- `samples` must list values in exactly the -genotype file's sample-column order, or results are silently -misassigned to the wrong individual. This wrapper can't check that for -you. +genotype file's sample-column order, and it must have as many entries +as the genotype file has individuals. The second half of that used to go +unchecked (as it does in GeneNetwork3): nine values scanned against a +six-individual cross came back as a complete, plausible-looking set of +LOD scores belonging to nobody. `scripts/rqtl_wrapper.R` now stops with +"the phenotype file has 9 samples but the genotype file has 6 +individuals" instead, which surfaces as a `502 rqtl_failed`. It still +cannot tell whether the *order* is right -- that is the caller's +responsibility, and the reason a trait's values and its genotype file +have to come from the same panel. ```json { diff --git a/docs/www/ai-instruction.md b/docs/www/ai-instruction.md index e59ce2a..0c8bfb4 100644 --- a/docs/www/ai-instruction.md +++ b/docs/www/ai-instruction.md @@ -266,6 +266,15 @@ deployment already holds. You cannot upload a genotype file, and you should not go looking for one: ask the operator which paths the deployment uses for the panel you are working on. +The values and the genotype file have to describe the **same +individuals, in the same order, one for one**. Both engines match them by +position, not by name. Get that wrong and the computation is meaningless; +GEMMA refuses outright, and R/qtl now refuses too rather than returning +plausible-looking numbers for the wrong strains. So: use the values from +the values endpoint and the genotype file the deployment pairs with that +panel — never a genotype file from a different panel, and never a +hand-built trait vector. + Results are **cached** by input, so running the same request twice costs little the second time (a cached GEMMA run on the BXD fixtures comes back in ~2 s against ~20 s cold). That is another reason not to compute diff --git a/docs/www/operator-checklist.md b/docs/www/operator-checklist.md index dc02d5a..6d4e18d 100644 --- a/docs/www/operator-checklist.md +++ b/docs/www/operator-checklist.md @@ -132,6 +132,18 @@ PATH=$P/bin:$PATH R_LIBS_SITE=$P/site-library/ genenetwork4 …other env… fails with `rqtl_failed` and `there is no package called 'optparse'` — an environment problem, not a token or proxy problem. +What genotype files exist is a deployment question, and today the only +ones on this box are the test fixtures in `tests/test_data/`: +`BXD_geno.txt.gz` (198 BXD individuals × 7 320 markers), `BXD_snps.txt` +(the marker map) and `rqtl_sample1.geno` (a 6-individual cross). They are +fixtures, not a panel-matched dataset: a database trait has its own +strain subset (BXD traits typically ~10–35 of the 198), and both engines +match values to individuals **by position**, so mapping such a trait +against the full 198-individual file is wrong by construction. Until the +deployment ships genotype files subset to a trait's strains (or the team +says which panel file pairs with which trait), real mappings should not +be offered — the fixtures are for smoke tests and for the test suite. + `/compute/gemma/ravanan` additionally needs `ravanan` and `ccwl` on `PATH`, and with `RAVANAN_BATCH_SYSTEM=slurm-api` a reachable slurmrestd (see `docs/ravanan-slurm.md`). diff --git a/scripts/rqtl_wrapper.R b/scripts/rqtl_wrapper.R index a2b4403..5c67d88 100644 --- a/scripts/rqtl_wrapper.R +++ b/scripts/rqtl_wrapper.R @@ -179,6 +179,20 @@ verbose_print('Generating cross object\n') scale_col <- if (toupper(opt$scale) == "CM") "cM" else "Mb" cross_object = geno_to_csvr(geno_file, trait_names, trait_vals, cross_file, type, mapping_scale = scale_col) +# Fail loudly when the phenotype and genotype disagree about how many +# individuals there are. The cross file format has no per-sample name +# matching (see README), so the only thing that ties the two together is +# position: a trait covering 9 strains scanned against a 6-individual +# cross otherwise comes back with a full, plausible-looking set of LOD +# scores that belong to nobody. (GeneNetwork3's copy of this script has +# the same hole.) +if (length(sample_names) != nind(cross_object)) { + stop(sprintf(paste("The phenotype file has %d samples but the genotype file has %d", + "individuals. Values are matched to individuals by position, so the", + "two must be one for one, in the genotype file's column order."), + length(sample_names), nind(cross_object)), call.=FALSE) +} + # Calculate genotype probabilities if (!is.null(opt$pairscan)) { verbose_print('Calculating genotype probabilities for pair-scan\n') |
