diff options
| author | Pjotr <wrk@bosa.lan> | 2026-11-11 14:49:16 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-11-11 14:49:16 +0000 |
| commit | 8bb9c54d2eb7b4ae2d330a588eff32feceb4324f (patch) | |
| tree | 80cfb0bd569ca02452538b7a3c7b6f5733c6faf8 | |
| parent | 492e0c5e8988fda87d361cef4f29639c5f0d0b72 (diff) | |
| download | genenetwork4-8bb9c54d2eb7b4ae2d330a588eff32feceb4324f.tar.gz | |
plot/bulklmm: the 0.05 and 0.01 lines, never 0.10 unless asked
Checked what the plot actually draws: it has never drawn the alpha 0.10
line -- the plotter matches 0.05 and 0.01 only. What lists all three is the
reply's notes ("alpha 0.01: LOD 4.58, alpha 0.05: 3.65, alpha 0.1: 3.50"),
which is where the 0.10 came from.
Still, the point stands on its own: 0.10 is the loosest bar in the set and
drawing it invites reading it as the line to clear. So the defaults are
stated and pinned -- 0.05 and 0.01 on the plot, 0.10 only on request
(?all_thresholds=true, or an explicit ?thresholds=) -- alongside GEMMA's
Bonferroni, which is opt-in for the same reason: a reference line is an
annotation, not a result.
tests/bulklmm.rs counts the lines: exactly two by default, and no
alpha 0.10 label.
| -rw-r--r-- | README.md | 7 | ||||
| -rw-r--r-- | docs/bulklmm.md | 5 | ||||
| -rwxr-xr-x | scripts/plot-bulklmm.py | 14 | ||||
| -rw-r--r-- | src/routes/plot.rs | 19 | ||||
| -rw-r--r-- | tests/bulklmm.rs | 11 |
5 files changed, 52 insertions, 4 deletions
diff --git a/README.md b/README.md index b0cd052..fc1bbba 100644 --- a/README.md +++ b/README.md @@ -1906,6 +1906,13 @@ asked for — so a plot shows exactly the lines someone chose, each named. `/compute/bulklmm`'s reply already offers that href with its α = 0.05 threshold filled in, so the picture is one link away. +`/plot/bulklmm` draws two reference lines for it: the genome-wide α = 0.05 and +the stricter α = 0.01. The reply also reports α = 0.10, but that is the loosest +bar in the set — drawing it invites reading it as the line to clear — so it +appears only on request (`?all_thresholds=true`, or an explicit +`?thresholds=3.50&threshold_labels=alpha 0.10`). GEMMA's Bonferroni line is +opt-in in the same spirit: a reference line is an annotation, not a result. + **About cores.** BulkLMM's single-trait `scan()` — what this endpoint calls — is **serial in Julia by design**: the package threads `bulkscan()` (many traits) and its helpers, not `scan()` (checked in its source: `Threads.@threads` appears diff --git a/docs/bulklmm.md b/docs/bulklmm.md index 86b08dd..fbb3b37 100644 --- a/docs/bulklmm.md +++ b/docs/bulklmm.md @@ -83,6 +83,11 @@ matrices of this shape. `scripts/bulklmm_scan.jl` therefore: * **caches the parsed matrix and the kinship** per panel (`read 1.3 → 0.4 s`, kinship `0.9 → 0`); * **caps BLAS** at 4 threads when serial, 1 per block when parallel; +* draws two reference lines: the genome-wide alpha 0.05 and the stricter + alpha 0.01. The reply reports alpha 0.10 as well, but that is the loosest + bar in the set, so it is drawn only on request (`?all_thresholds=true`, or an + explicit `?thresholds=`), and GEMMA's Bonferroni line on `/plot/gemma` is + opt-in in the same spirit; * reports what ran in the reply: `julia threads 4, blocks 4, BLAS threads 96 | read 1.5 s, scan 10.5 s`. diff --git a/scripts/plot-bulklmm.py b/scripts/plot-bulklmm.py index 51c24f8..67ef418 100755 --- a/scripts/plot-bulklmm.py +++ b/scripts/plot-bulklmm.py @@ -22,6 +22,11 @@ def main(): ap.add_argument("-o", "--out", default="bulklmm_lod.svg") ap.add_argument("--trait", default="", help="trait label for the title") ap.add_argument("--title", default=None, help="override the title text") + ap.add_argument("--all-thresholds", action="store_true", + help="also draw the loosest line the reply reports (alpha 0.10); the default " + "is the genome-wide 0.05 and the stricter 0.01") + ap.add_argument("--threshold", action="append", default=[], + help="extra reference line as VALUE[:LABEL]") a = ap.parse_args() doc = json.load(open(a.result)) @@ -36,6 +41,10 @@ def main(): # Thresholds: the endpoint writes them into `notes` as "alpha 0.05: LOD 3.81". notes = " ".join(doc.get("notes", [])) + # Two lines by default: the genome-wide 0.05 and the stricter 0.01. The + # reply also reports 0.10, but that is the loosest bar in the set and + # drawing it invites reading it as the one to clear -- it is available on + # request (--all-thresholds) and as an explicit --threshold. thresholds = [] for match in re.finditer(r"alpha ([0-9.]+): LOD ([0-9]+(?:\.[0-9]+)?)", notes): alpha, lod = float(match.group(1)), float(match.group(2)) @@ -43,6 +52,11 @@ def main(): thresholds.append((lod, "genome-wide (alpha 0.05)", "6 3")) elif abs(alpha - 0.01) < 1e-9: thresholds.append((lod, "alpha 0.01", "3 3")) + elif a.all_thresholds and abs(alpha - 0.1) < 1e-9: + thresholds.append((lod, "alpha 0.10", "1 4")) + for spec in a.threshold: + value, _, label = spec.partition(":") + thresholds.append((float(value), label.strip() or "threshold", "2 4")) seed = re.search(r"seed (\d+)", notes) h2 = re.search(r"heritability h2 = ([\d.eE+-]+)", notes) nperm = re.search(r"from (\d+) rotations", notes) diff --git a/src/routes/plot.rs b/src/routes/plot.rs index cf73637..8bcbd5b 100644 --- a/src/routes/plot.rs +++ b/src/routes/plot.rs @@ -48,6 +48,9 @@ pub struct PlotParams { /// Labels for those lines, comma separated and in the same order, e.g. /// "bulklmm alpha 0.05". Anything missing defaults to "bulklmm threshold". pub threshold_labels: Option<String>, + /// BulkLMM only: also draw the loosest line the reply reports + /// (alpha 0.10). The default is the genome-wide 0.05 and the stricter 0.01. + pub all_thresholds: Option<String>, } /// The reference lines a caller passed, validated: `(value, label)`. @@ -254,7 +257,7 @@ pub async fn plot_rqtl( member) and get the plot scripts/plot-gemma.py draws from it: -log10(p_lrt) per marker. \ **No reference line is drawn unless one is asked for** -- a line is an annotation, not part of \ the result, and each is labelled with where it came from: `?bonferroni=true` for GEMMA's own \ --Bonferroni (0.05 over the analysed markers, computed by the plotter, conservative under \ +Bonferroni (0.05 over the analysed markers, computed by the plotter, conservative under \ linkage and unrelated to relatedness), and `?thresholds=` for a threshold another engine \ computed on the same values (e.g. /compute/bulklmm's rotation thresholds). Nothing is \ recomputed. image/svg+xml, not the JSON envelope; `x-plot-summary` carries the plotter's \ @@ -574,6 +577,20 @@ pub async fn plot_bulklmm( extra.push("--title".to_string()); extra.push(title.to_string()); } + if matches!( + plot_params.all_thresholds.as_deref(), + Some("true") | Some("1") | Some("yes") | Some("all") + ) { + extra.push("--all-thresholds".to_string()); + } + for (value, label) in external_thresholds( + plot_params.thresholds.as_deref(), + plot_params.threshold_labels.as_deref(), + &rid, + )? { + extra.push("--threshold".to_string()); + extra.push(format!("{value}:{label}")); + } let borrowed: Vec<&str> = extra.iter().map(String::as_str).collect(); let rendered = plot::render( &config.plot_python, diff --git a/tests/bulklmm.rs b/tests/bulklmm.rs index eeec09c..b823b6c 100644 --- a/tests/bulklmm.rs +++ b/tests/bulklmm.rs @@ -232,11 +232,16 @@ async fn a_scan_plots_and_gemmas_refusal_points_here() { assert!(svg.trim_start().starts_with("<svg"), "an SVG"); // Both thresholds the endpoint reports are drawn: alpha 0.05 (the // genome-wide line) and alpha 0.01, when there are enough permutations. - assert!( - svg.matches("class=\"thr").count() >= 1, - "the permutation thresholds are drawn" + // Two lines by default -- the genome-wide 0.05 and the stricter 0.01 -- + // and never the loosest one unless it is asked for. + assert_eq!( + svg.matches("class=\"thr").count(), + 2, + "the 0.05 and 0.01 thresholds are drawn, and not 0.10" ); assert!(svg.contains("genome-wide (alpha 0.05)"), "the 5 % line is labelled"); + assert!(svg.contains("alpha 0.01"), "and the 1 % line"); + assert!(!svg.contains("alpha 0.10"), "the loosest line is not drawn by default"); assert!(svg.contains("rsm10000000888"), "the summary names the peak"); // A GEMMA permutation request now says where the thresholds are. |
