about summary refs log tree commit diff
path: root/docs
diff options
context:
space:
mode:
authorPjotr <wrk@bosa.lan>2026-11-07 15:25:48 +0000
committerPjotr <wrk@bosa.lan>2026-11-07 15:25:48 +0000
commite5c333959af6675a0d80934c8cf76275d5571ef8 (patch)
treedbd56c23ccca7b92f2f122b88fd99aff16d46c8c /docs
parent4831e5aebb81e7280d017bc57145aa1a7453e661 (diff)
downloadgenenetwork4-e5c333959af6675a0d80934c8cf76275d5571ef8.tar.gz
values: suggest R/qtl and GEMMA in the envelope's `actions`
Fetching one trait's value per strain is usually the step before mapping
that trait, and the API can do the mapping. Those calls are POSTs with a
body, so they cannot go in `next` -- a `next` link is a GET that returns
200, which is what makes `next` safe to follow blindly and what
tests/envelope.rs relies on. Hence a fifth envelope member, `actions`,
holding method + href + description + body, and omitted entirely when
there is nothing to suggest (most responses keep the four-member shape).

The three per-trait values endpoints now carry a `POST /compute/rqtl`
and a `POST /compute/gemma` suggestion with the values already in the
body, in the response's own sample order. Genotype/SNP paths stay
bracketed placeholders: they must exist on the server, which the server
cannot know on the caller's behalf.

The instruction page says, in the same breath, never to run R/qtl or
GEMMA locally -- a local scan would use genotypes that are not the
panel's and would disagree with GeneNetwork's own results -- and that
results are cached, so repeat calls are cheap (measured: ~2 s cached
against ~20 s cold on the BXD fixtures).

Also fixes a flake the new test exposed rather than caused:
config::tests read and write process-global env vars and Config::load()
reads all of them, so the RAVANAN_* tests could fail
search_engine_keys_follow_env_over_default_layering on an unrelated
assertion. One module-level lock serialises them.

* src/response.rs (SuggestedCall, Envelope::actions/with_action/
with_actions): the new member, omitted when empty; unit tests for both.
* src/suggest.rs: new. Builds the two suggestions for either value type
(db::TraitValue, db::ProbeSetValue), with its own unit tests.
* src/routes/{traits,groups,datasets}.rs: the three values handlers.
* tests/compute_suggestions.rs: new. Suggestions present with values in
order, on all three routes; absent elsewhere; `next` still GET-only and
still returns 200.
* src/config.rs (tests): env_guard, taken by the 11 config tests.
* README.md (Success responses): the `actions` member, with an example.
* docs/www/ai-instruction.md (4a): never compute locally, why, caching,
and how to use the suggested bodies.
* docs/www/operator-checklist.md: the caching numbers.
Diffstat (limited to 'docs')
-rw-r--r--docs/www/ai-instruction.md36
-rw-r--r--docs/www/operator-checklist.md7
2 files changed, 40 insertions, 3 deletions
diff --git a/docs/www/ai-instruction.md b/docs/www/ai-instruction.md
index e7390d8..e59ce2a 100644
--- a/docs/www/ai-instruction.md
+++ b/docs/www/ai-instruction.md
@@ -131,6 +131,7 @@ Every response is one envelope:
 | `meta` | `state` (`complete` or `partial`), `took_ms`, `request_id`, plus `columns`/`num_rows` on tabular payloads |
 | `notes` | server-authored remarks; **read them**, they explain partial answers |
 | `next` | links to related endpoints — following them is the cheapest way to walk the data |
+| `actions` | suggested calls that are not plain GETs (e.g. `POST /compute/rqtl`), each with a body; present only where the server has something to suggest — on the per-trait values endpoints, with the values already filled in |
 
 `meta.state: partial` means the answer is usable but something is
 missing, with the reason in `notes`. Do not read `null` enrichment
@@ -242,13 +243,33 @@ a human: that needs an account and a grant, not a different URL.
 
 ## 4a. Running QTL mapping (compute)
 
+**Never run R/qtl or GEMMA yourself.** Do not download a trait's values
+and fit a scan locally — not with R, not with a reimplementation, not
+"just to check". The API does this for you, and doing it yourself gives
+the *wrong answer*: the genome scan needs the genotype and marker files
+that match the strain panel the values came from, and those live with the
+deployment, not in what you can fetch. A local scan would use genotypes
+you do not have, a marker set you guessed, or a kinship you cannot
+compute, and would quietly disagree with GeneNetwork's own results.
+
+So: fetch the values, take the mapping call the API offers you (§ below),
+and **use its returned marker rows for downstream analysis** — fine
+mapping, candidate genes, plots, whatever the task needs. The computation
+itself, and the choice of genotypes, is the server's.
+
 `POST /gn4/compute/rqtl` (R/qtl scanone) and `POST /gn4/compute/gemma`
 (GEMMA, kinship then LOCO GWAS) run **on the server**, against files on
 the server's own filesystem. A valid token is the only requirement: they
 are not dataset-checked, so nothing about §4 applies — but the paths you
-name have to be paths the server can read, which in practice means ones
-you were given or ones under the deployment's own data directory. You
-cannot upload a genotype file.
+name have to be paths the server can read, which means ones the
+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.
+
+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
+locally: repeat calls are cheap here.
 
 ```sh
 curl -s -H "$AUTH" -H 'Content-Type: application/json' \
@@ -263,6 +284,15 @@ curl -s -H "$AUTH" -H 'Content-Type: application/json' \
 (one value per sample, `null` for missing), optionally `lmm`
 (default 9). `/compute/correlation` is a stub that returns canned data.
 
+**You rarely have to write these bodies by hand.** Every per-trait values
+endpoint (`/groups/{g}/traits/{id}/values`, `/datasets/{d}/probesets/
+{p}/values`, `/traits/{d}/{t}/values`) returns an `actions` member
+holding both a `POST /compute/rqtl` and a `POST /compute/gemma` call with
+the values you just fetched already in place — copy one, put in the
+genotype/SNP paths the deployment uses for that panel (ask if you do not
+have them), and send it. Do not hand-roll the values into a local R
+session instead.
+
 These are **synchronous and slow**: seconds on the fixtures, minutes on
 real data, and `/compute/gemma/ravanan` additionally waits on ravanan
 (and on a cluster when it is slurm-backed). So:
diff --git a/docs/www/operator-checklist.md b/docs/www/operator-checklist.md
index 5a2581b..dc02d5a 100644
--- a/docs/www/operator-checklist.md
+++ b/docs/www/operator-checklist.md
@@ -136,6 +136,13 @@ PATH=$P/bin:$PATH R_LIBS_SITE=$P/site-library/ genenetwork4 …other env…
 `PATH`, and with `RAVANAN_BATCH_SYSTEM=slurm-api` a reachable slurmrestd
 (see `docs/ravanan-slurm.md`).
 
+Repeat calls are cached by input (gemma-wrapper's content-hash cache,
+and src/rqtl.rs's own hash of genotype+phenotype), so the second
+identical request is cheap: the same GEMMA run measured ~2 s cached
+against ~20 s cold. Worth telling users, because the alternative they
+reach for — downloading the values and fitting a scan themselves — is
+both slower and wrong (their genotypes are not the panel's).
+
 Verified through the proxy with a token: `POST /gn4/compute/rqtl`
 returned 200 in 0.4 s with the fixture's marker rows, `POST
 /gn4/compute/gemma` 200 in 2.1 s with 7 320 marker rows, and