jiteshkprasad commited on
Commit
e4c0886
·
verified ·
1 Parent(s): fa89d6e

BioCell simulator (private preview)

Browse files
Files changed (1) hide show
  1. static/index.html +93 -35
static/index.html CHANGED
@@ -92,7 +92,7 @@ body.mixing .card .cname{padding-right:30px}
92
  .mix{margin:0;background:var(--white);border-radius:28px;box-shadow:var(--lift);padding:20px 22px}
93
  .mix[hidden]{display:none}
94
  .mix-top{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;align-items:baseline}
95
- .mix-cells{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-top:14px}
96
  .mini{background:var(--sage-tint);border-radius:24px;padding:8px 6px 10px;text-align:center}
97
  .mini svg{width:100%;height:auto;display:block}
98
  .mini .cst .stt{display:none}
@@ -115,7 +115,7 @@ body.mixing .card .cname{padding-right:30px}
115
  @media (min-width:901px){body:not([data-mode="researcher"]) .syslist{display:grid;grid-template-columns:1fr 1fr;column-gap:6px}.sysrow{min-height:44px}.systems{padding:12px 12px}}
116
  .colR{display:flex;flex-direction:column;gap:18px;min-width:0}
117
  .cellpanel{position:relative;background:var(--sage-tint);border-radius:44px;padding:20px 18px 18px}
118
- .story{background:var(--white);border-radius:28px;box-shadow:var(--lift);padding:22px 24px;min-height:300px}
119
  .systems{background:var(--white);border-radius:28px;box-shadow:var(--lift);padding:16px 14px}
120
  .cardsblock .cards-head{margin:4px 4px 10px}
121
  .panel-top{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:0 6px 4px}
@@ -144,6 +144,23 @@ body.calm .shp{transition:none}
144
  .syscard p{margin:4px 0;font-size:14.5px}
145
  .syscard .close{position:absolute;top:10px;right:10px;width:36px;height:36px;border-radius:999px;border:1px solid var(--line);background:var(--paper);cursor:pointer;font-size:18px;line-height:1}
146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  /* Story */
148
  .story h2{font:500 26px/1.2 var(--serif);letter-spacing:-.01em;margin:0 0 12px}
149
  .story p{margin:0 0 10px}
@@ -233,12 +250,10 @@ dialog .close{position:absolute;top:18px;right:18px}
233
  .group.lines{flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;max-width:100%}
234
  .clbl,.cst .stt{display:none}
235
  .cst{font-size:22px}
236
- .story{min-height:330px;padding:18px}
237
  .genes{grid-template-columns:1fr}
238
  .twocol{grid-template-columns:1fr}
239
  .mix-cells{grid-template-columns:1fr}
240
- .mix-cells .mini.solo{display:none}
241
- .mix-chips{display:flex}
242
  .cellpanel{border-radius:32px;padding:14px 10px 12px}
243
  dialog{padding:24px 20px;border-radius:32px}
244
  }
@@ -284,11 +299,13 @@ dialog .close{position:absolute;top:18px;right:18px}
284
  <div class="systems">
285
  <div class="panel-top"><span class="t">Cell systems</span><span class="hint">Tap one to see more</span></div>
286
  <ul class="syslist" id="syslist"></ul>
 
287
  </div>
288
  </div>
289
  <div class="colR">
290
  <div class="story" id="story" aria-live="polite">
291
  <p class="idle">Tap a gene. Watch what the model predicts.</p>
 
292
  </div>
293
 
294
  <div class="cardsblock">
@@ -296,8 +313,8 @@ dialog .close{position:absolute;top:18px;right:18px}
296
  <h2 id="cardsTitle">Try a gene</h2>
297
  <span class="hint" id="cardsHint">Tap a card to run it</span>
298
  </div>
 
299
  <div class="cards" id="cards" role="group" aria-labelledby="cardsTitle"></div>
300
- <p class="mixhow" style="margin-top:10px">These examples use genes the model saw in training. Try any other gene to test it.</p>
301
 
302
  </div>
303
  <div class="controls" role="group" aria-label="Settings">
@@ -320,7 +337,6 @@ dialog .close{position:absolute;top:18px;right:18px}
320
  <span class="hint" id="mixHint">Pick two cards, or find genes in the search box.</span>
321
  </div>
322
  <div class="mix-cells" id="mixCells"></div>
323
- <div class="mix-chips" id="mixChips"></div>
324
  <p class="mixline" id="mixLine">&nbsp;</p>
325
  <p class="mixhow">Our measure: the total change across the ten systems with both genes, divided by the two single-gene changes added up. <span class="r-only mono" id="mixR"></span></p>
326
  <p class="mixhow">Tested: on 24 gene pairs switched on (Norman et al. 2019), the model's error was 28.5% lower than adding the two single effects, ahead on 18 of 24.</p>
@@ -436,30 +452,71 @@ const rmq = window.matchMedia("(prefers-reduced-motion: reduce)");
436
  const motionOff = () => rmq.matches || state.paused;
437
 
438
  /* ---------- The cell drawing ---------- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
439
  function cellSVG(p, mini){
440
  const o = (id, inner) => `<g class="org" id="${p}org-${id}" data-sys="${id}" ${mini ? "" : `tabindex="0" role="button" aria-label="${SYS[id]}: steady"`}>${inner}</g>`;
441
  const st = (id, x, y, anchor) => `<text class="cst" id="${p}z-${id}" x="${x}" y="${y}" text-anchor="${anchor||"middle"}"><tspan class="arr"></tspan><tspan class="stt"></tspan></text>`;
442
  const lb = (t, x, y, anchor) => mini ? "" : `<text class="clbl" x="${x}" y="${y}" text-anchor="${anchor||"middle"}">${t}</text>`;
443
  const S = 'stroke="#1C1B18" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"';
 
 
444
  return `<svg viewBox="0 0 540 350" ${mini ? 'aria-hidden="true"' : 'role="group" aria-label="The cell"'} xmlns="http://www.w3.org/2000/svg">
445
  <g id="${p}breath">
446
- ${o("stress_alarm", `<ellipse class="shp" data-kind="stroke" id="${p}shape-stress_alarm" cx="270" cy="175" rx="252" ry="163" fill="none" ${S} stroke-dasharray="1 9" stroke-width="3"/>${lb("Stress alarm",516,334,"end")}${st("stress_alarm",516,348,"end")}`)}
447
- ${o("cell_skeleton", `<ellipse class="shp" data-kind="fill" id="${p}shape-cell_skeleton" cx="270" cy="175" rx="228" ry="146" fill="#FFFFFF" ${S}/>
448
- <path d="M96 120 Q180 146 262 104 M120 250 Q236 222 330 262 M352 66 Q400 120 450 150" fill="none" stroke="#1C1B18" stroke-opacity=".18" stroke-width="1.5" stroke-linecap="round"/>${lb("Skeleton and shape",22,14,"start")}${st("cell_skeleton",22,28,"start")}`)}
449
- ${o("protein_factory", `<ellipse class="shp" data-kind="stroke" id="${p}shape-protein_factory" cx="205" cy="168" rx="94" ry="80" fill="none" stroke="#1C1B18" stroke-width="5" stroke-linecap="round" stroke-dasharray="0 11"/>${lb("Protein factories",172,72,"middle")}${st("protein_factory",172,86,"middle")}`)}
450
- ${o("cell_division", `<circle class="shp" data-kind="fill" id="${p}shape-cell_division" cx="205" cy="168" r="60" fill="#FAF6EE" ${S}/>
451
- <path d="M178 150 C190 138, 220 138, 232 150 M178 188 C190 200, 220 200, 232 188" fill="none" stroke="#1C1B18" stroke-opacity=".35" stroke-width="1.6" stroke-linecap="round"/>${lb("Cell division",205,166)}${st("cell_division",205,182)}`)}
452
- ${o("message_editing", `<rect class="shp" data-kind="fill" id="${p}shape-message_editing" x="146" y="256" width="118" height="34" rx="17" fill="#FAF6EE" ${S}/>${lb("Message editing",205,270)}${st("message_editing",205,284)}`)}
453
- ${o("power_plants", `<g transform="translate(362,214) rotate(-14)"><rect class="shp" data-kind="fill" id="${p}shape-power_plants" x="-50" y="-22" width="100" height="44" rx="22" fill="#FAF6EE" ${S}/>
454
- <path d="M-34 0 L-22 -10 L-11 10 L0 -10 L11 10 L22 -10 L34 0" fill="none" stroke="#1C1B18" stroke-opacity=".45" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></g>${lb("Power plants",362,258)}${st("power_plants",362,272)}`)}
455
- ${o("trash_recycling", `<circle class="shp" data-kind="fill" id="${p}shape-trash_recycling" cx="378" cy="108" r="36" fill="#FAF6EE" ${S}/>
456
- <circle cx="402" cy="84" r="5" fill="#FFFFFF" ${S}/><circle cx="412" cy="100" r="3.5" fill="#FFFFFF" ${S}/><circle cx="350" cy="84" r="4" fill="#FFFFFF" ${S}/>${lb("Recycling",378,106)}${st("trash_recycling",378,121)}`)}
457
- ${o("fuel_metabolism", `<rect class="shp" data-kind="fill" id="${p}shape-fuel_metabolism" x="410" y="152" width="80" height="34" rx="17" fill="#FAF6EE" ${S}/>${lb("Fuel",450,166)}${st("fuel_metabolism",450,180)}`)}
 
 
 
 
 
 
 
 
 
 
 
 
458
  ${o("self_destruct", `<rect class="shp" data-kind="fill" id="${p}shape-self_destruct" x="244" y="44" width="136" height="34" rx="17" fill="#FAF6EE" ${S}/>${lb("Self-destruct switch",312,58)}${st("self_destruct",312,72)}`)}
459
- ${o("immune_signals", `<rect class="shp" data-kind="fill" id="${p}shape-immune_signals" x="34" y="152" width="80" height="34" rx="17" fill="#FAF6EE" ${S}/>${lb("Signals",74,166)}${st("immune_signals",74,180)}`)}
460
  </g></svg>`;
461
  }
462
- const IDLE_FILL = {cell_skeleton:"#FFFFFF"};
463
  function colorsFor(dir, strong, kind){
464
  if (kind === "stroke") return dir === "up" ? "#3F6B4C" : "#8A4F2A";
465
  if (kind === "body") return dir === "up" ? (strong ? "#C5DDC7" : "#DFEDDD") : (strong ? "#F8D6C1" : "#FBE4D6");
@@ -768,9 +825,8 @@ function mixSummary(a, b, ab){
768
  return {R, line, sAdd, sTog};
769
  }
770
  function buildMixCells(a, b){
771
- const fig = (p, lab, cls) => `<figure class="mini ${cls}" style="margin:0"><div id="${p}wrap">${cellSVG(p, true)}</div><figcaption><div class="mlabel">${lab}</div><div class="msize" id="${p}size">&nbsp;</div></figcaption></figure>`;
772
- $("#mixCells").innerHTML = fig("ma-", `<span class="sym">${esc(a)}</span> alone`, "solo") + fig("mb-", `<span class="sym">${esc(b)}</span> alone`, "solo") + fig("mt-", "Together", "tog");
773
- $("#mixChips").innerHTML = `<button type="button" class="pill" data-show="a"><span class="sym">${esc(a)}</span> alone</button><button type="button" class="pill" data-show="b"><span class="sym">${esc(b)}</span> alone</button><button type="button" class="pill" data-show="t" aria-pressed="true">Together</button>`;
774
  }
775
  async function runMix(a, b){
776
  const my = ++runToken;
@@ -794,9 +850,15 @@ async function runMix(a, b){
794
  } catch(e){ if (my === runToken) showError(e.message); }
795
  }
796
  function paintMini(p, r){
797
- paintCell(p, r, false);
798
- const el = document.getElementById(p+"size");
799
- if (el) el.textContent = r.missing_priors && r.missing_priors.length ? "No knowledge of this gene" : `The model predicts ${sizeWords(r.effect_rms)}`;
 
 
 
 
 
 
800
  }
801
  function setMix(on){
802
  state.mix = on;
@@ -879,13 +941,6 @@ function init(){
879
  $("#lines").addEventListener("click", e => { const b = e.target.closest("[data-line]"); if (!b) return; setLine(b.dataset.line); rerun(); });
880
  document.querySelectorAll("[data-mod]").forEach(b => b.addEventListener("click", () => { setMod(b.dataset.mod); rerun(); }));
881
  $("#mixBtn").addEventListener("click", () => setMix(!state.mix));
882
- $("#mixChips").addEventListener("click", e => {
883
- const b = e.target.closest("[data-show]"); if (!b || !state.mixRes) return;
884
- document.querySelectorAll("#mixChips [data-show]").forEach(x => x.setAttribute("aria-pressed", String(x === b)));
885
- const r = {a: state.mixRes.ra, b: state.mixRes.rb, t: state.mixRes.rt}[b.dataset.show];
886
- $("#mixCells .tog .mlabel").innerHTML = b.innerHTML;
887
- paintMini("mt-", r);
888
- });
889
  $("#modeSimple").addEventListener("click", () => setMode("simple"));
890
  $("#modeResearch").addEventListener("click", () => setMode("researcher"));
891
  $("#pauseBtn").addEventListener("click", () => {
@@ -959,7 +1014,10 @@ function init(){
959
  window.addEventListener("resize", () => { clearTimeout(window.__rz); window.__rz = setTimeout(drawMap, 150); });
960
 
961
  // Warm the first card so the first tap answers at once, then the rest.
962
- getResult("rpe1",["PSMA3"],"knockdown").catch(()=>{});
 
 
 
963
  setTimeout(() => CARDS.slice(1).forEach(c => getResult(c.line,[c.g],c.mod).catch(()=>{})), 800);
964
 
965
  // Optional start state from the address: #try=line:GENE[,GENE2]:off|on, #play=mix, #mode=researcher (combine with &)
 
92
  .mix{margin:0;background:var(--white);border-radius:28px;box-shadow:var(--lift);padding:20px 22px}
93
  .mix[hidden]{display:none}
94
  .mix-top{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;align-items:baseline}
95
+ .mix-cells{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-top:14px}
96
  .mini{background:var(--sage-tint);border-radius:24px;padding:8px 6px 10px;text-align:center}
97
  .mini svg{width:100%;height:auto;display:block}
98
  .mini .cst .stt{display:none}
 
115
  @media (min-width:901px){body:not([data-mode="researcher"]) .syslist{display:grid;grid-template-columns:1fr 1fr;column-gap:6px}.sysrow{min-height:44px}.systems{padding:12px 12px}}
116
  .colR{display:flex;flex-direction:column;gap:18px;min-width:0}
117
  .cellpanel{position:relative;background:var(--sage-tint);border-radius:44px;padding:20px 18px 18px}
118
+ .story{background:var(--white);border-radius:28px;box-shadow:var(--lift);padding:22px 24px;min-height:380px}
119
  .systems{background:var(--white);border-radius:28px;box-shadow:var(--lift);padding:16px 14px}
120
  .cardsblock .cards-head{margin:4px 4px 10px}
121
  .panel-top{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:0 6px 4px}
 
144
  .syscard p{margin:4px 0;font-size:14.5px}
145
  .syscard .close{position:absolute;top:10px;right:10px;width:36px;height:36px;border-radius:999px;border:1px solid var(--line);background:var(--paper);cursor:pointer;font-size:18px;line-height:1}
146
 
147
+
148
+ .trainline{margin:-2px 4px 10px}
149
+ .sysrow .badge{width:108px;min-width:0}
150
+ #cardsHint{min-width:11.5em;text-align:right;white-space:nowrap}
151
+ .unitline{font-size:13px;color:var(--ink2);margin:8px 10px 2px}
152
+ .story .idle{margin:0 0 10px}
153
+ .example{position:relative;border-top:1px dashed var(--line);padding-top:10px;opacity:.42;pointer-events:none;user-select:none}
154
+ .example .exlabel{display:inline-block;font-size:12px;font-weight:600;letter-spacing:.02em;text-transform:uppercase;color:var(--ink2);margin-bottom:6px}
155
+ .example h2{font-size:20px!important;margin-bottom:6px!important}
156
+ .example .fam{display:none}
157
+ .mcol{background:var(--sage-tint);border-radius:24px;padding:14px 12px 12px;min-height:300px;min-width:0}
158
+ .mcol .mlabel{font-weight:600;font-size:15px}
159
+ .mcol .msize{font-size:13px;color:var(--ink2);margin-bottom:8px}
160
+ .mlist{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:6px}
161
+ .mlist li{display:flex;flex-wrap:wrap;align-items:center;gap:3px 8px;font-size:13.5px;line-height:1.2;min-height:26px}
162
+ .mlist .badge{min-width:68px;padding:3px 8px;font-size:12.5px}
163
+ .mlist .more,.mlist .none{color:var(--ink2);font-size:13px}
164
  /* Story */
165
  .story h2{font:500 26px/1.2 var(--serif);letter-spacing:-.01em;margin:0 0 12px}
166
  .story p{margin:0 0 10px}
 
250
  .group.lines{flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;max-width:100%}
251
  .clbl,.cst .stt{display:none}
252
  .cst{font-size:22px}
253
+ .story{min-height:420px;padding:18px}
254
  .genes{grid-template-columns:1fr}
255
  .twocol{grid-template-columns:1fr}
256
  .mix-cells{grid-template-columns:1fr}
 
 
257
  .cellpanel{border-radius:32px;padding:14px 10px 12px}
258
  dialog{padding:24px 20px;border-radius:32px}
259
  }
 
299
  <div class="systems">
300
  <div class="panel-top"><span class="t">Cell systems</span><span class="hint">Tap one to see more</span></div>
301
  <ul class="syslist" id="syslist"></ul>
302
+ <p class="unitline">Numbers show how strongly a system moved compared with the rest of the cell's genes (a z-score).</p>
303
  </div>
304
  </div>
305
  <div class="colR">
306
  <div class="story" id="story" aria-live="polite">
307
  <p class="idle">Tap a gene. Watch what the model predicts.</p>
308
+ <div class="example" id="example" aria-hidden="true"></div>
309
  </div>
310
 
311
  <div class="cardsblock">
 
313
  <h2 id="cardsTitle">Try a gene</h2>
314
  <span class="hint" id="cardsHint">Tap a card to run it</span>
315
  </div>
316
+ <p class="mixhow trainline">These examples use genes the model saw in training. Try any other gene to test it.</p>
317
  <div class="cards" id="cards" role="group" aria-labelledby="cardsTitle"></div>
 
318
 
319
  </div>
320
  <div class="controls" role="group" aria-label="Settings">
 
337
  <span class="hint" id="mixHint">Pick two cards, or find genes in the search box.</span>
338
  </div>
339
  <div class="mix-cells" id="mixCells"></div>
 
340
  <p class="mixline" id="mixLine">&nbsp;</p>
341
  <p class="mixhow">Our measure: the total change across the ten systems with both genes, divided by the two single-gene changes added up. <span class="r-only mono" id="mixR"></span></p>
342
  <p class="mixhow">Tested: on 24 gene pairs switched on (Norman et al. 2019), the model's error was 28.5% lower than adding the two single effects, ahead on 18 of 24.</p>
 
452
  const motionOff = () => rmq.matches || state.paused;
453
 
454
  /* ---------- The cell drawing ---------- */
455
+ function blobPath(cx, cy, rx, ry, k){
456
+ // A soft, organic closed outline: an ellipse with a few gentle bumps, smoothed with Catmull-Rom curves.
457
+ const n = 36, pts = [];
458
+ for (let i = 0; i < n; i++){
459
+ const t = i / n * Math.PI * 2;
460
+ const r = 1 + k * (0.030 * Math.sin(3*t + 0.6) + 0.018 * Math.sin(5*t + 2.1) + 0.010 * Math.sin(7*t + 0.3));
461
+ pts.push([cx + rx * r * Math.cos(t), cy + ry * r * Math.sin(t)]);
462
+ }
463
+ const f = v => v.toFixed(1);
464
+ let d = `M${f(pts[0][0])} ${f(pts[0][1])}`;
465
+ for (let i = 0; i < n; i++){
466
+ const p0 = pts[(i-1+n)%n], p1 = pts[i], p2 = pts[(i+1)%n], p3 = pts[(i+2)%n];
467
+ d += ` C${f(p1[0]+(p2[0]-p0[0])/6)} ${f(p1[1]+(p2[1]-p0[1])/6)} ${f(p2[0]-(p3[0]-p1[0])/6)} ${f(p2[1]-(p3[1]-p1[1])/6)} ${f(p2[0])} ${f(p2[1])}`;
468
+ }
469
+ return d + "Z";
470
+ }
471
+ function erPath(cx, cy, rx, ry){
472
+ // A wavy ring (the protein-factory network round the nucleus).
473
+ const n = 120; let d = "";
474
+ for (let i = 0; i <= n; i++){
475
+ const t = i / n * Math.PI * 2, w = 1 + 0.045 * Math.sin(9*t);
476
+ d += (i ? " L" : "M") + (cx + rx*w*Math.cos(t)).toFixed(1) + " " + (cy + ry*w*Math.sin(t)).toFixed(1);
477
+ }
478
+ return d + "Z";
479
+ }
480
+ const CELL_PATHS = {body: blobPath(270, 175, 226, 144, 1), halo: blobPath(270, 175, 250, 162, 0.8), er: erPath(205, 168, 92, 80)};
481
+ const RIBOSOMES = [[120,120],[138,232],[300,120],[316,200],[290,236],[110,200],[160,80],[330,92],[262,262],[420,128],[440,206],[396,262],[96,150],[318,154]];
482
  function cellSVG(p, mini){
483
  const o = (id, inner) => `<g class="org" id="${p}org-${id}" data-sys="${id}" ${mini ? "" : `tabindex="0" role="button" aria-label="${SYS[id]}: steady"`}>${inner}</g>`;
484
  const st = (id, x, y, anchor) => `<text class="cst" id="${p}z-${id}" x="${x}" y="${y}" text-anchor="${anchor||"middle"}"><tspan class="arr"></tspan><tspan class="stt"></tspan></text>`;
485
  const lb = (t, x, y, anchor) => mini ? "" : `<text class="clbl" x="${x}" y="${y}" text-anchor="${anchor||"middle"}">${t}</text>`;
486
  const S = 'stroke="#1C1B18" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"';
487
+ const T = 'stroke="#1C1B18" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"';
488
+ const dots = RIBOSOMES.map(([x,y]) => `<circle cx="${x}" cy="${y}" r="2.2" fill="#1C1B18" fill-opacity=".55"/>`).join("");
489
  return `<svg viewBox="0 0 540 350" ${mini ? 'aria-hidden="true"' : 'role="group" aria-label="The cell"'} xmlns="http://www.w3.org/2000/svg">
490
  <g id="${p}breath">
491
+ ${o("stress_alarm", `<path class="shp" data-kind="stroke" id="${p}shape-stress_alarm" d="${CELL_PATHS.halo}" fill="none" ${S} stroke-dasharray="1 9" stroke-width="3"/>${lb("Stress alarm",516,334,"end")}${st("stress_alarm",516,348,"end")}`)}
492
+ ${o("cell_skeleton", `<path class="shp" data-kind="fill" id="${p}shape-cell_skeleton" d="${CELL_PATHS.body}" fill="#FFFCF6" ${S}/>
493
+ <path d="M96 120 Q180 146 262 104 M120 250 Q236 222 330 262 M352 66 Q400 120 450 150 M300 300 Q360 286 420 272" fill="none" stroke="#3F6B4C" stroke-opacity=".22" stroke-width="1.5" stroke-linecap="round"/>
494
+ <g fill="#F6EFE2" ${T}><path d="M436 222 q18 -8 36 0"/><path d="M432 232 q22 -9 44 0"/><path d="M436 242 q18 -8 36 0"/></g>
495
+ ${lb("Skeleton and shape",22,14,"start")}${st("cell_skeleton",22,28,"start")}`)}
496
+ ${o("protein_factory", `<path d="${CELL_PATHS.er}" fill="none" stroke="#E4EEE0" stroke-width="16" stroke-linejoin="round"/>
497
+ <path class="shp" data-kind="stroke" id="${p}shape-protein_factory" d="${CELL_PATHS.er}" fill="none" stroke="#1C1B18" stroke-width="5" stroke-linecap="round" stroke-dasharray="0 11"/>
498
+ ${dots}${lb("Protein factories",172,72,"middle")}${st("protein_factory",172,86,"middle")}`)}
499
+ ${o("cell_division", `<circle class="shp" data-kind="fill" id="${p}shape-cell_division" cx="205" cy="168" r="60" fill="#F3ECDF" ${S}/>
500
+ <path d="M174 146 C186 134, 214 136, 224 146 M176 196 C186 204, 206 206, 216 198" fill="none" stroke="#1C1B18" stroke-opacity=".3" stroke-width="1.6" stroke-linecap="round"/>
501
+ <circle cx="238" cy="198" r="10" fill="#E6D9C2" ${T}/>
502
+ ${lb("Cell division",205,166)}${st("cell_division",205,182)}`)}
503
+ ${o("message_editing", `<rect class="shp" data-kind="fill" id="${p}shape-message_editing" x="146" y="256" width="118" height="34" rx="17" fill="#FAF6EE" ${S}/>
504
+ <path d="M268 262 q6 -6 12 0 t12 0" fill="none" stroke="#1C1B18" stroke-opacity=".5" stroke-width="1.6" stroke-linecap="round"/>${lb("Message editing",205,270)}${st("message_editing",205,284)}`)}
505
+ ${o("power_plants", `<g transform="translate(362,214) rotate(-14)"><rect class="shp" data-kind="fill" id="${p}shape-power_plants" x="-50" y="-22" width="100" height="44" rx="22" fill="#FCEFE4" ${S}/>
506
+ <rect x="-42" y="-14" width="84" height="28" rx="14" fill="none" stroke="#1C1B18" stroke-opacity=".35" stroke-width="1.4"/>
507
+ <path d="M-30 -14 v14 M-18 14 v-16 M-6 -14 v16 M6 14 v-16 M18 -14 v16 M30 14 v-14" fill="none" stroke="#1C1B18" stroke-opacity=".45" stroke-width="1.6" stroke-linecap="round"/></g>
508
+ <g transform="translate(118,250) rotate(18)"><rect x="-17" y="-8" width="34" height="16" rx="8" fill="#FCEFE4" ${T}/><path d="M-8 -8 v9 M0 8 v-9 M8 -8 v9" fill="none" stroke="#1C1B18" stroke-opacity=".45" stroke-width="1.3" stroke-linecap="round"/></g>
509
+ ${lb("Power plants",362,258)}${st("power_plants",362,272)}`)}
510
+ ${o("trash_recycling", `<circle class="shp" data-kind="fill" id="${p}shape-trash_recycling" cx="378" cy="108" r="36" fill="#EAF2E7" ${S}/>
511
+ <circle cx="356" cy="90" r="3.5" fill="#FFFCF6" ${T}/><circle cx="398" cy="133" r="3" fill="#FFFCF6" ${T}/>
512
+ <circle cx="404" cy="72" r="6" fill="#EAF2E7" ${T}/><circle cx="420" cy="92" r="4.5" fill="#EAF2E7" ${T}/><circle cx="344" cy="78" r="5" fill="#EAF2E7" ${T}/>
513
+ ${lb("Recycling",378,106)}${st("trash_recycling",378,121)}`)}
514
+ ${o("fuel_metabolism", `<rect class="shp" data-kind="fill" id="${p}shape-fuel_metabolism" x="410" y="152" width="80" height="34" rx="17" fill="#F7F0E0" ${S}/>${lb("Fuel",450,166)}${st("fuel_metabolism",450,180)}`)}
515
  ${o("self_destruct", `<rect class="shp" data-kind="fill" id="${p}shape-self_destruct" x="244" y="44" width="136" height="34" rx="17" fill="#FAF6EE" ${S}/>${lb("Self-destruct switch",312,58)}${st("self_destruct",312,72)}`)}
516
+ ${o("immune_signals", `<rect class="shp" data-kind="fill" id="${p}shape-immune_signals" x="34" y="152" width="80" height="34" rx="17" fill="#F2F6EE" ${S}/>${lb("Signals",74,166)}${st("immune_signals",74,180)}`)}
517
  </g></svg>`;
518
  }
519
+ const IDLE_FILL = {cell_skeleton:"#FFFCF6", cell_division:"#F3ECDF", power_plants:"#FCEFE4", trash_recycling:"#EAF2E7", fuel_metabolism:"#F7F0E0", immune_signals:"#F2F6EE"};
520
  function colorsFor(dir, strong, kind){
521
  if (kind === "stroke") return dir === "up" ? "#3F6B4C" : "#8A4F2A";
522
  if (kind === "body") return dir === "up" ? (strong ? "#C5DDC7" : "#DFEDDD") : (strong ? "#F8D6C1" : "#FBE4D6");
 
825
  return {R, line, sAdd, sTog};
826
  }
827
  function buildMixCells(a, b){
828
+ const col = (p, lab) => `<div class="mcol"><div class="mlabel">${lab}</div><div class="msize" id="${p}size">&nbsp;</div><ul class="mlist" id="${p}list"></ul></div>`;
829
+ $("#mixCells").innerHTML = col("ma-", `<span class="sym">${esc(a)}</span> alone`) + col("mb-", `<span class="sym">${esc(b)}</span> alone`) + col("mt-", "Together");
 
830
  }
831
  async function runMix(a, b){
832
  const my = ++runToken;
 
850
  } catch(e){ if (my === runToken) showError(e.message); }
851
  }
852
  function paintMini(p, r){
853
+ const size = document.getElementById(p+"size"), ul = document.getElementById(p+"list");
854
+ if (!size || !ul) return;
855
+ if (r.missing_priors && r.missing_priors.length){ size.textContent = "No knowledge of this gene"; ul.innerHTML = ""; return; }
856
+ size.textContent = `The model predicts ${sizeWords(r.effect_rms)}`;
857
+ const moved = r.systems.filter(reacts).sort((x, y) => Math.abs(y.z_score) - Math.abs(x.z_score));
858
+ const show = moved.slice(0, 4);
859
+ ul.innerHTML = show.map(s => { const d = dirOf(s); return `<li><span class="badge ${d}">${d === "up" ? ARROW_UP : ARROW_DOWN} ${word(d)} ${Math.abs(s.z_score).toFixed(1)}</span><span>${SYS[s.id]}</span></li>`; }).join("")
860
+ + (moved.length > 4 ? `<li class="more">and ${moved.length - 4} more</li>` : "")
861
+ + (moved.length ? "" : `<li class="none">No group of genes moves clearly.</li>`);
862
  }
863
  function setMix(on){
864
  state.mix = on;
 
941
  $("#lines").addEventListener("click", e => { const b = e.target.closest("[data-line]"); if (!b) return; setLine(b.dataset.line); rerun(); });
942
  document.querySelectorAll("[data-mod]").forEach(b => b.addEventListener("click", () => { setMod(b.dataset.mod); rerun(); }));
943
  $("#mixBtn").addEventListener("click", () => setMix(!state.mix));
 
 
 
 
 
 
 
944
  $("#modeSimple").addEventListener("click", () => setMode("simple"));
945
  $("#modeResearch").addEventListener("click", () => setMode("researcher"));
946
  $("#pauseBtn").addEventListener("click", () => {
 
1014
  window.addEventListener("resize", () => { clearTimeout(window.__rz); window.__rz = setTimeout(drawMap, 150); });
1015
 
1016
  // Warm the first card so the first tap answers at once, then the rest.
1017
+ getResult("rpe1",["PSMA3"],"knockdown").then(res => {
1018
+ const ex = document.getElementById("example");
1019
+ if (ex && !state.last) ex.innerHTML = `<span class="exlabel">Example result, real model output</span>` + storyHTML(res);
1020
+ }).catch(()=>{});
1021
  setTimeout(() => CARDS.slice(1).forEach(c => getResult(c.line,[c.g],c.mod).catch(()=>{})), 800);
1022
 
1023
  // Optional start state from the address: #try=line:GENE[,GENE2]:off|on, #play=mix, #mode=researcher (combine with &)