about summary refs log tree commit diff
path: root/docs
diff options
context:
space:
mode:
authorPjotr <wrk@bosa.lan>2026-11-07 18:15:37 +0000
committerPjotr <wrk@bosa.lan>2026-11-07 18:15:37 +0000
commitf9ba0f12e3bf52919fc363c037fbf0a0deda8c17 (patch)
treef8ba4f4de75ffe45dd05183d066dc9e079ba6450 /docs
parentb6c5538bc2bf1166ba176a0d80966c04229854ad (diff)
downloadgenenetwork4-f9ba0f12e3bf52919fc363c037fbf0a0deda8c17.tar.gz
plot: draw a mapping, and suggest it from the mapping
The two plotters Pjotr added (scripts/plot-rqtl.py, plot-gemma.py) turn a
saved mapping response into an SVG Manhattan panel. They are now
endpoints, and the mapping that produces the response suggests them:

  POST /plot/rqtl    same body as /compute/rqtl   -> image/svg+xml
  POST /plot/gemma   same body as /compute/gemma  -> image/svg+xml

Taking the mapping's own body rather than the mapping's output means one
call gets you the picture, and the plot cannot describe a run you did not
do: the handlers call the compute handlers and hand the resulting
envelope to the script, exactly as the scripts' docstrings describe
(they read `data.markers`, `data.permutation` and the notes' strain
counts). The mapping is re-run, but through the engines' own caches --
seconds on BXD.

The reply is an SVG, not the JSON envelope: an image is not JSON, and the
plotter's one-line peak summary rides back in `x-plot-summary` so a
caller that cannot see the picture still learns where the peak is.

Both compute responses gain the matching suggestion: `actions` carries
"the same request, plotted" (built from the request that ran, like the
permutation suggestion), so an assistant can map, look, and only then
decide whether the peak is worth the 100-permutation run.

* src/plot.rs: run the configured script over the envelope, read the
SVG back, clean up; a missing script is a 502 naming interpreter and
script, not a panic.
* src/routes/plot.rs: the two handlers (token-gated), delegating to
compute_rqtl/compute_gemma so validation and alignment stay in one
place; `x-plot-summary` sanitised into a header.
* src/routes/{rqtl,gemma}.rs: the plot suggestion, before the
permutation one.
* src/config.rs: PLOT_PYTHON, RQTL_PLOTTER, GEMMA_PLOTTER.
* tests/plot.rs: the suggestion resolves to a complete SVG with a peak
  summary, and an invalid mapping request is the mapping's own 422.
* tests/{rqtl,phewas}.rs: find suggestions by href rather than position.
* README.md, docs/www/ai-instruction.md (4a), docs/www/operator-checklist.md
(new "Plotting": python3 must be on the server's PATH).
Diffstat (limited to 'docs')
-rw-r--r--docs/www/ai-instruction.md6
-rw-r--r--docs/www/operator-checklist.md11
2 files changed, 17 insertions, 0 deletions
diff --git a/docs/www/ai-instruction.md b/docs/www/ai-instruction.md
index 3109d2a..8ef54f7 100644
--- a/docs/www/ai-instruction.md
+++ b/docs/www/ai-instruction.md
@@ -316,6 +316,12 @@ A mapping's response ends with what to do next:
 
 * **`next`: a PheWAS at the peak** the run found โ€” a `GET` that returns
   200, so follow it (ยง4b). Present when the request named a `group`.
+* **`actions`: the same request, plotted** โ€” `POST /plot/rqtl` or
+  `/plot/gemma`, whose reply is an **SVG document** (`image/svg+xml`),
+  not JSON: a Manhattan plot of what you just computed, with the
+  permutation thresholds as dashed lines (R/qtl) or a Bonferroni line
+  (GEMMA). The plotter's one-line peak summary rides back in the
+  `x-plot-summary` header. Send the suggested body as it stands.
 * **`actions`: the same scan with 100 permutations** (`nperm: 100`), when
   you did not already ask for permutations. It is a `POST`, which is why
   it is not a `next` link. Those 100 shuffles are what turn "this peak
diff --git a/docs/www/operator-checklist.md b/docs/www/operator-checklist.md
index 5cd203f..308d717 100644
--- a/docs/www/operator-checklist.md
+++ b/docs/www/operator-checklist.md
@@ -195,6 +195,17 @@ is CPU-bound on the box, so rate-limit per token or keep the audience
 small โ€” `limit_req` in the config is one way, but it keys on address,
 not token.
 
+## Plotting
+
+`POST /plot/rqtl` and `/plot/gemma` run the corresponding mapping and then
+the deployment's plotter: `scripts/plot-rqtl.py` / `scripts/plot-gemma.py`,
+executed by `PLOT_PYTHON` (default `python3`) -- so **python3 must be on
+the server process's `PATH`**, alongside `Rscript`/`gemma-wrapper` for the
+mapping itself. They return `image/svg+xml` rather than an envelope, and
+the plotter's peak summary in `x-plot-summary`. Point `RQTL_PLOTTER` /
+`GEMMA_PLOTTER` elsewhere if the scripts move; a missing script is a
+`502 plot_failed` naming the interpreter and script it tried.
+
 ## PheWAS
 
 `GET /groups/{group}/phewas` reads `PublishXRef` only -- the peak marker,