From d9e1bf7fd9da4e0bae6579b95fd0028296b997ac Mon Sep 17 00:00:00 2001 From: Pjotr Date: Thu, 12 Nov 2026 17:15:53 +0000 Subject: 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. --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 1df4151..2675c6b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,6 +8,7 @@ use utoipa_axum::routes; pub mod auth; pub mod baskets; +pub mod bnw; pub mod bulklmm; pub mod compute_gate; pub mod covariates; @@ -162,6 +163,7 @@ pub fn app() -> Router { .routes(routes!(routes::genotypes::group_marker_location)) .routes(routes!(routes::genotypes::unlisted_genotype_markers)) .routes(routes!(routes::genotypes::unlisted_marker_location)) + .routes(routes!(routes::bnw::compute_bnw)) .routes(routes!(routes::bulklmm::compute_bulklmm)) .routes(routes!(routes::gemma::compute_gemma)) .routes(routes!(routes::gemma::compute_gemma_ravanan)) -- cgit 1.4.1