Spaces:
Running on Zero

File size: 10,238 Bytes
328fef0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<!DOCTYPE html>
<html lang="en" class="theme-dark">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>CellGemma · Single-Cell Perturbation Studio</title>
  <meta
    name="description"
    content="Interactive visual studio showing how CellGemma (Gemma 4 E4B) predicts single-cell gene expression shifts in response to a small-molecule drug or CRISPR gene knockdown."
  />
  <link rel="preconnect" href="https://fonts.googleapis.com" />
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
  <link
    href="https://fonts.googleapis.com/css2?family=Google+Sans+Mono:wght@500;600;700&family=Google+Sans+Text:wght@400;500;600&family=Google+Sans:wght@500;600;700&display=swap"
    rel="stylesheet"
  />
  <link rel="stylesheet" href="/studio_static/styles.css" />
</head>
<body class="theme-dark">
  <div class="app-frame">
    <!-- 1. Precision Single-Row Top Bar -->
    <header class="top-bar">
      <div class="brand-lockup">
        <h1 class="sr-only">CellGemma Single-Cell Perturbation Studio</h1>
        <img
          id="brand-logo-dark"
          class="brand-wordmark wordmark-for-dark"
          src="/studio_static/cellgemma_logo_dark.png"
          alt="CellGemma"
          width="138"
          height="20"
        />
        <img
          id="brand-logo-light"
          class="brand-wordmark wordmark-for-light"
          src="/studio_static/cellgemma_logo_light.png"
          alt="CellGemma"
          width="138"
          height="20"
        />
        <span class="brand-variant-tag" title="Built on Gemma 4 (E4B)">E4B</span>
      </div>

      <nav class="preset-strip" aria-label="Perturbation presets">
        <span class="preset-group-label">Drugs</span>
        <div id="drug-preset-pills"></div>
        <span class="preset-divider" aria-hidden="true"></span>
        <span class="preset-group-label">CRISPR</span>
        <div id="crispr-preset-pills"></div>
      </nav>

      <div class="run-controls">
        <button
          type="button"
          class="theme-toggle-btn"
          id="theme-toggle-btn"
          aria-label="Toggle dark and light visual theme"
          title="Switch between Bioluminescent Dark and Optical Quartz Light"
        >
          <svg class="theme-icon icon-sun" viewBox="0 0 20 20" fill="none" aria-hidden="true">
            <circle cx="10" cy="10" r="3.8" stroke="currentColor" stroke-width="1.7" />
            <path
              d="M10 2.2v2.1M10 15.7v2.1M2.2 10h2.1M15.7 10h2.1M4.48 4.48l1.48 1.48M14.04 14.04l1.48 1.48M15.52 4.48l-1.48 1.48M5.96 14.04l-1.48 1.48"
              stroke="currentColor"
              stroke-width="1.7"
              stroke-linecap="round"
            />
          </svg>
          <svg class="theme-icon icon-moon" viewBox="0 0 20 20" fill="none" aria-hidden="true">
            <path
              d="M15.6 12.4A6.4 6.4 0 0 1 7.6 4.4a6.4 6.4 0 1 0 8 8Z"
              stroke="currentColor"
              stroke-width="1.7"
              stroke-linejoin="round"
            />
          </svg>
          <span id="theme-toggle-label">Light</span>
        </button>

        <button type="button" class="customize-toggle-btn" id="customize-btn" aria-expanded="false">
          Customize ▾
        </button>

        <button
          type="button"
          class="reset-btn"
          id="reset-btn"
          title="Reset simulation to clean empty starting state"
        >
          <svg class="reset-icon" viewBox="0 0 20 20" fill="none" aria-hidden="true">
            <path
              d="M4.2 7.2A6.5 6.5 0 1 1 5.1 14.3M4.0 3.6v3.9h3.9"
              stroke="currentColor"
              stroke-width="1.75"
              stroke-linecap="round"
              stroke-linejoin="round"
            />
          </svg>
          <span>Reset</span>
        </button>

        <button type="button" class="run-cta-btn" id="run-btn">
          ▶ Run CellGemma
        </button>
      </div>

      <!-- Optional Floating Customize Popover (Closed by Default) -->
      <section class="customize-popover hidden" id="customize-popover" aria-label="Customize perturbation input">
        <div class="popover-top">
          <div class="popover-tabs">
            <button type="button" class="pop-tab-btn active" id="pop-tab-drug">Small-Molecule Drug (A549)</button>
            <button type="button" class="pop-tab-btn" id="pop-tab-crispr">CRISPR Knockdown (K562)</button>
          </div>
          <button type="button" class="popover-close-btn" id="popover-close-btn">Done</button>
        </div>

        <div class="popover-grid">
          <div class="mini-mol-box" id="mini-mol-box" title="Drag to spin 3D structure">
            <canvas class="mini-mol-canvas" id="mini-mol-canvas"></canvas>
          </div>

          <div class="popover-fields">
            <div id="pop-drug-fields">
              <div class="pop-row">
                <label for="smiles-input">SMILES Structure</label>
                <span class="pop-mono" id="mol-meta-readout">RDKit 3D</span>
              </div>
              <input type="text" class="pop-input" id="smiles-input" spellcheck="false" autocomplete="off" />
              <div class="pop-row">
                <label for="dose-slider">Concentration</label>
                <span class="pop-mono" id="dose-readout">0.50 µM</span>
              </div>
              <input type="range" class="pop-slider" id="dose-slider" min="0.05" max="5.0" step="0.05" value="0.50" />
            </div>

            <div class="hidden" id="pop-crispr-fields">
              <div class="pop-row">
                <label for="gene-input">Target Human Gene</label>
                <span class="pop-mono" id="kg-edge-readout">STRING Network</span>
              </div>
              <input type="text" class="pop-input" id="gene-input" maxlength="20" spellcheck="false" autocomplete="off" />
              <div class="pop-gene-chips" id="featured-gene-chips"></div>
            </div>

            <div class="pop-row">
              <label for="cell-idx-slider">Single Control Cell</label>
              <span class="pop-mono" id="cell-idx-readout">Cell #0</span>
            </div>
            <input type="range" class="pop-slider" id="cell-idx-slider" min="0" max="99" step="1" value="0" />

            <div class="pop-row">
              <label for="temp-slider">Sampling Temperature</label>
              <span class="pop-mono" id="temp-readout">0.0 (Deterministic)</span>
            </div>
            <input type="range" class="pop-slider" id="temp-slider" min="0" max="1.0" step="0.1" value="0" />
          </div>
        </div>
      </section>
    </header>

    <!-- 2. Hero Visual Stage -->
    <main class="hero-stage-card">
      <div class="hero-canvas-wrap" id="hero-canvas-wrap">
        <canvas class="hero-canvas" id="hero-canvas"></canvas>
      </div>
    </main>

    <!-- 3. Precision Bottom Equalizer Strip (Fixed Height — Zero Layout Shift) -->
    <section class="bottom-strip" aria-label="Predicted gene expression shifts">
      <div class="error-inline hidden" id="error-banner" role="alert"></div>

      <div class="outcome-strip" id="outcome-strip">
        <div class="outcome-header-block">
          <h2 class="outcome-headline" id="verdict-headline">Awaiting Simulation — Click ▶ Run CellGemma</h2>
          <div class="outcome-meta-line">
            <span class="outcome-sub" id="verdict-sub">A549 Lung Carcinoma · Single Cell #0</span>
            <div class="outcome-badges">
              <button
                type="button"
                class="outcome-action-btn hidden"
                id="view-prompt-btn"
                title="Inspect exact Stage 1 text prompt and raw model tokens"
              >
                Prompt
              </button>
              <button
                type="button"
                class="outcome-action-btn hidden"
                id="download-csv-btn"
                title="Download all predicted single-cell gene shifts as CSV"
              >
                ↓ CSV
              </button>
              <span class="pill-stat-up pill-stat-muted" id="count-up-pill">↑ — UP</span>
              <span class="pill-stat-down pill-stat-muted" id="count-down-pill">↓ — DOWN</span>
            </div>
          </div>
        </div>

        <div class="bars-two-col">
          <div class="bars-column">
            <div class="bars-col-label up">↑ Top Genes Turned UP (% Shift vs Baseline)</div>
            <div id="bars-up-list"></div>
          </div>
          <div class="bars-column">
            <div class="bars-col-label down">↓ Top Genes Turned DOWN (% Shift vs Baseline)</div>
            <div id="bars-down-list"></div>
          </div>
        </div>
      </div>
    </section>

    <!-- Raw Stage 1 Prompt & Model Output Inspector Modal -->
    <div
      class="prompt-modal-backdrop hidden"
      id="prompt-modal-backdrop"
      role="dialog"
      aria-modal="true"
      aria-labelledby="prompt-modal-title"
    >
      <div class="prompt-modal-card">
        <div class="prompt-modal-header">
          <div>
            <h3 class="prompt-modal-title" id="prompt-modal-title">Stage 1 Prompt &amp; Emitted Gene Tokens</h3>
            <p class="prompt-modal-sub" id="prompt-modal-meta">CellGemma E4B Single-Cell Transcriptional Input</p>
          </div>
          <div class="prompt-modal-actions">
            <button type="button" class="pop-btn-secondary" id="copy-prompt-btn">Copy Prompt</button>
            <button type="button" class="popover-close-btn" id="close-prompt-modal-btn">Close</button>
          </div>
        </div>
        <div class="prompt-modal-body">
          <div class="prompt-section-label">Stage 1 Input Prompt (Control Cell + Perturbation + Global Mean)</div>
          <pre class="prompt-code-box" id="prompt-modal-input"></pre>
          <div class="prompt-section-label">Stage 1 Raw Model Output (Ordered Residual Gene Tokens)</div>
          <pre class="prompt-code-box prompt-code-box-compact" id="prompt-modal-output"></pre>
        </div>
      </div>
    </div>
  </div>

  <script src="/studio_static/app.js"></script>
</body>
</html>