diff options
| author | Pjotr <wrk@bosa.lan> | 2026-11-09 12:23:53 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-11-09 12:23:53 +0000 |
| commit | c560ce726bc0c45ac87b8f0f9bf83870e25ac195 (patch) | |
| tree | f5514258eb4e79b8503f9323ab3c0e13b59720dd /tests/plot.rs | |
| parent | 29eb1363caea8c0eb13eb91c5a44d4f2967b69da (diff) | |
| download | genenetwork4-c560ce726bc0c45ac87b8f0f9bf83870e25ac195.tar.gz | |
compute: let GEMMA name the trait, so its plot can be titled
Two GEMMA runs over one BXD panel drew genuinely different pictures -- traces differ on all 20 chromosomes, peaks -log10 p 5.48 at chr8 97.0 Mb against 5.43 at chr1 175.6 Mb -- and both came out headed **"trait gemma: GEMMA association along the genome"**, because GEMMA's request had no trait label at all: `/compute/gemma` fell back to `<group>::gemma`, and `/plot/gemma` fell back to "gemma". The plot of each trait was told apart by its annotation and nothing else. `trait_name` is now an optional field on `GemmaRequest`, used for the `Trait: ...` note (first in `notes`, as on `/compute/rqtl`), for the PheWAS and R/qtl suggestions, and for the `/plot/gemma?trait=` suggestion -- so a posted response titles its own plot, and `?trait=` still overrides. Without it nothing changes: the label stays `<group>::gemma`. * src/routes/gemma.rs: the field, the label resolution, the note, the plot href. * tests/gemma.rs: the covariate run names its trait and asserts the note is first; tests/plot.rs: a GEMMA plot titles itself from the note, and an explicit `?trait=` wins over it. * README.md (`/compute/gemma`, and the plot section), docs/www/SKILL.md (the GEMMA options list, and what the plot title comes from). 281 tests pass; the same four as before do not.
Diffstat (limited to 'tests/plot.rs')
| -rw-r--r-- | tests/plot.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/plot.rs b/tests/plot.rs index 0788ce9..123784b 100644 --- a/tests/plot.rs +++ b/tests/plot.rs @@ -67,7 +67,7 @@ fn canned_gemma_result() -> Value { [1.0, "rs2", 8.2, 0.0, "X", "Y", 0.2, 1.0, 2.0, 3.0, 0.001], [2.0, "rs3", 12.0, 0.0, "X", "Y", 0.2, 1.0, 2.0, 3.0, 0.3] ], - "notes": [] + "notes": ["Trait: BXD::20010"] }) } @@ -160,7 +160,28 @@ async fn a_posted_gemma_result_is_drawn() { .to_string(); assert!(summary.contains("rs2"), "the smallest p_lrt: {summary}"); let svg = response.into_body().collect().await.unwrap().to_bytes(); - assert!(String::from_utf8_lossy(&svg).starts_with("<svg")); + let text = String::from_utf8_lossy(&svg); + assert!(text.starts_with("<svg")); + // An explicit ?trait= wins over the response's own note. + assert!(text.contains("BXDPublish::10001"), "?trait= labels the plot"); + + // Without one, the response's note labels it -- so a GEMMA plot of two + // traits is not titled "gemma" twice. + let response = post_json_with_token( + "POST /plot/gemma (note as label)", + "/plot/gemma", + &token, + &canned_gemma_result(), + ) + .await; + assert_eq!(response.status(), StatusCode::OK); + let svg = response.into_body().collect().await.unwrap().to_bytes(); + let text = String::from_utf8_lossy(&svg); + assert!( + text.contains("BXD::20010"), + "the title names the trait from the response's own note, not \"gemma\": {}", + &text[..text.len().min(400)] + ); } #[tokio::test] |
