File size: 2,651 Bytes
0fff343
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# OncoDSL Lab β€” React/Next.js front end (Stage 1 MVP)

Interactive front end for the genetic-programming engine. Talks to the
FastAPI backend over JSON + Server-Sent Events. Reuses the same DSL,
airgap harness, GP engine, and data the Streamlit viewer reads β€” but
shows the GP **evolving live**, with a button-gated reveal at the end.

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    POST /runs        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚             β”‚ ───────────────────▢ β”‚  FastAPI worker    β”‚
β”‚  Lab page   β”‚  GET /runs/{id}/streamβ”‚  thread runs the  β”‚
β”‚ (Next.js)   β”‚ ◀─── SSE per-gen ────│  engine + permut. β”‚
β”‚             β”‚  POST /evaluate      β”‚                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ───────────────────▢ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

The Lab is **client-side** (App Router `"use client"`) because it
manages SSE, sliders, and reveal state.

## Run

```bash
# 1) Backend (Python) β€” needs data/processed/{clinical,expression}.parquet
cd ..
source .venv/bin/activate
uvicorn api.app:app --reload          # :8000

# 2) Frontend (Node β‰₯ 20)
cd web
npm install
npm run dev                           # :3000
```

Open <http://localhost:3000>.

Override the API base URL with `NEXT_PUBLIC_API_URL`:

```bash
NEXT_PUBLIC_API_URL=http://localhost:8001 npm run dev
```

The Streamlit viewer (`streamlit run app/viewer.py`) is unaffected β€” it
still reads the persisted MSI artefacts via the legacy `/run /result /reveal`
endpoints.

## What's on the page

5 sections, top to bottom:

1. **Objective** β€” pick MSI separation (AUROC) or Mutation burden
   (negative correlation). Survival and Unsupervised are Stage 2.
2. **Parameters** β€” generations, population, genes-per-set, Ξ», seed,
   prefilter top-N, permutations. Sensible defaults.
3. **Run** β€” POST `/runs`, open SSE.
4. **Live view** β€” Recharts line chart of best & median fitness per
   generation, updated as events arrive; population grid showing the
   top candidates with survivors in the accent and discarded ones
   faded.
5. **Result + Reveal & evaluate** β€” once the GP finishes, the winning
   program's metrics show. Click "Reveal & evaluate" against a
   reference gene set (MMR or immune) to translate the opaque IDs
   back to symbols and highlight the overlap.

## What's NOT here (Stage 2 territory)

- React Flow program diagram. Animations. Free-text objective.
  Survival / unsupervised paths. Cross-cohort validation.