diff options
| author | Pjotr <wrk@bosa.lan> | 2026-11-12 17:15:53 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-11-12 17:15:53 +0000 |
| commit | d9e1bf7fd9da4e0bae6579b95fd0028296b997ac (patch) | |
| tree | 450ea1eb5642227f4859e9941edc7d8910f90032 /README.md | |
| parent | 7a78dce4bf6db058f1ac12a4176c2702debff798 (diff) | |
| download | genenetwork4-d9e1bf7fd9da4e0bae6579b95fd0028296b997ac.tar.gz | |
compute/bnw: a Bayesian network over traits, called out to BNW's driver
POST /compute/bnw learns a network over a set of variables and returns one row
per candidate edge: from, to, posterior, in_structure. Inputs are published
traits of a group (group + traits) or an explicit matrix (values: one entry per
variable with per-sample values), which covers the case the database cannot --
a basket's columns, a handful of probe sets.
BNW's knowledge stays in the gn-bnw repository. GN4 writes a variables x
samples matrix, runs `bnw learn` (BNW_CMD, BNW_BIN_DIR, BNW_CACHE_DIR) and
parses the reply: nothing about the three C programs, the private work
directory or the type line in the input file lives here, so BNW's pipeline can
change without a GN4 release. The driver's failures map onto the API's own:
bad input 422, a missing driver 502 bnw_not_installed (its exit 77), a failed
computation 502 bnw_failed in the driver's words.
Decisions worth recording:
* parameters are BNW's own defaults -- maxparents 4, k 1, tiers 3, threshold
0.5, read from its create_tiers_gom_part1.php rather than chosen here --
and the reply names the values used, because a network at 0.5 and one at
0.9 are different answers to the same question;
* at most 40 variables and at least 3 samples complete across every variable.
The first is the structure search's exponential in-degree; the second is
BNW modelling a complete multivariate normal, so a sample missing any value
is dropped -- and the note says how many survived rather than silently
shrinking the panel;
* its own gate, always claimed (threshold 0): there is no such thing as a
small BNW run, the cost is the search, not the number of individuals;
* the notes say plainly that a posterior is not a p-value and that a network
is not a QTL, because that is the easiest thing to over-read.
tests/bnw.rs compares the endpoint against the answer the BNW *web
application* gives for its own six-trait example (the same fixture as the
driver's parity check, gn-bnw/test/golden/): the five edges must match, and the
notes must name the parameters and carry the caveat. It skips when the driver
or its binaries are absent.
Not deployed to production.
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/README.md b/README.md index 4577192..a5b90b6 100644 --- a/README.md +++ b/README.md @@ -2027,6 +2027,60 @@ is small: 79 packages, 139 MB, no GPU/CUDA stack — BulkLMM's closure is CSV, DataFrames, Distributions, Optim and what those need. Every request runs with `JULIA_PKG_OFFLINE=true`, so a scan can never download anything. +### `/compute/bnw` + +A Bayesian network over a set of variables, learned by BNW (the Bayesian +Network Webserver): which traits belong together under a causal ordering. The +computation runs in BNW's own headless driver — the `bnw` program in the +`gn-bnw` repository — so this endpoint only prepares a matrix, calls out, and +parses the reply (`BNW_CMD`, `BNW_BIN_DIR`, `BNW_CACHE_DIR`). + +```json +{ + "group": "BXD", "traits": [10001, 10003, 10038], + "maxparents": 4, "k": 1, "tiers": 3, "threshold": 0.5 +} +``` + +or, for a matrix the database does not hold (a basket's columns, a handful of +probe sets): + +```json +{ + "values": [ + {"name": "Trait1", "samples": [{"name": "BXD1", "value": 1.2}, …]}, + {"name": "Trait2", "samples": [{"name": "BXD1", "value": 0.4}, …]} + ] +} +``` + +Rows are positional with `meta.columns`: + +``` +from, to, posterior, in_structure +``` + +One row per candidate edge (variables²−variables of them: self-edges are +dropped), strongest posterior first. `posterior` is the share of the *k*-best +networks that contain the edge; `in_structure` says whether it survived +`threshold`. The four parameters default to BNW's own (`maxparents` 4, `k` 1, +`tiers` 3, `threshold` 0.5 — from `create_tiers_gom_part1.php`), and the reply +names the values used, because a network at threshold 0.5 and one at 0.9 are +different answers. + +**A posterior is not a p-value.** It says how often the search put that arrow +there in *this sample* — a statement about correlation under a causal +ordering, not about surprise, and not an effect size. At most 40 variables +(the search is exponential in in-degree) and at least 3 samples complete across +every variable: BNW models a complete multivariate normal, so a sample missing +any value is dropped and the reply says how many survived. + +The driver's contract is documented in +[gn-bnw/info_files/gn4-integration-plan.md](../gn-bnw/info_files/gn4-integration-plan.md); +`tests/bnw.rs` checks the endpoint against the answer the BNW *web +application* gives for its own six-trait example, so "it works" means the same +edges, not merely a 200. + ### `/compute/fitqtl` `/compute/rqtl` says *where* a QTL is (a LOD per marker); this says *how |
