about summary refs log tree commit diff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorPjotr Prins <pjotr.public01@thebird.nl>2026-11-16 17:17:11 +0000
committerPjotr Prins <pjotr.public01@thebird.nl>2026-11-16 17:17:11 +0000
commitea3dd926211e8db4a0d7d3739a606440b888e8b0 (patch)
tree31b58cd0126960e70a76e45dc2c3b7c9a1c6d0b6 /src/lib.rs
parent33e837e771e07936c808fb3aeb3540525691718c (diff)
downloadgenenetwork4-main.tar.gz
correlation matrix: clustered heatmap and its plot HEAD main
`"cluster": true` adds `heatmap: {order, merges, max_height}` to the matrix
reply and `POST /plot/heatmap` draws it: the r matrix in that order, the
dendrogram that produced it, and a diverging scale with blue negative and red
positive. A reader can see *why* two traits are neighbours instead of trusting
an ordering.

Clustering decisions, all recorded because an unrepeatable clustering is worse
than none:

* distance `1 - r` -- the usual choice for correlations, and it keeps
  anti-correlated traits apart, which is what a heatmap of correlations should
  show;
* **average linkage (UPGMA)** -- single linkage chains along a gradient and
  complete linkage makes one flat blob out of noisy traits; average is the
  compromise GN1's R heatmaps used too;
* **deterministic ties and leaf order** (lower index first), so two runs on one
  matrix produce the same picture and plots stay diffable;
* a matrix with a **gap is refused** rather than clustered: an unknown distance
  treated as 1 would invent a structure, and the reply's note says to drop
  those traits and ask again.

Pairing with the PCA work this is the visual half of a collection: scree plot
for how much structure there is, clustered heatmap for where it is.

Monitor, as asked: `compute-correlation-heatmap` (order must be a permutation
with n-1 merges), `plot-heatmap`, and the plot endpoints that had no check at
all -- `plot-gemma` and `plot-bnw`, each posting a real compute result back.
Plots tier is now five checks, all ok; full run 47 ok, 0 failed, 1 skipped.
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 1973652..976b2f1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -22,6 +22,7 @@ pub mod fitqtl;
 pub mod frequencies;
 pub mod genoupload;
 pub mod genotypes;
+pub mod heatmap;
 pub mod normalize;
 mod plot;
 mod error;
@@ -260,6 +261,7 @@ pub fn app() -> Router {
         .routes(routes!(routes::plot::plot_bulklmm))
         .routes(routes!(routes::plot::plot_bnw))
         .routes(routes!(routes::plot::plot_pca))
+        .routes(routes!(routes::plot::plot_heatmap))
         .routes(routes!(routes::phewas::group_phewas))
         .routes(routes!(routes::frequencies::group_version_frequencies))
         .routes(routes!(routes::frequencies::group_marker_frequencies))