Viewport-Scheduled Enrichment for Interactive Spatial Transcriptomics

Spatial transcriptomics measures the activity of thousands of genes at known positions across a tissue slice. Analysts explore these slices like a map. They pan and zoom, and they keep asking one question: which biological pathways are unusually active in the region I am looking at, compared with the rest of the tissue? Answering that question is functional enrichment analysis, which tests whether curated gene groups from catalogs such as Gene Ontology or KEGG are over-represented in a gene list. When it is done properly, with a null distribution that respects the fact that neighbouring spots on the tissue are correlated, it is slow. Permutation nulls need thousands of reshuffles, and the hierarchical Bayesian version takes about 20 minutes on a 50-sample dataset. An analyst who pans every few seconds therefore gets one of two things: an instant answer that is miscalibrated, or a calibrated answer for a region they have already left.

360° video streaming faces the same shape of problem. A headset viewer sees only about 15–20% of the sphere at once. Bandwidth is too scarce to send everything at full quality, so streaming systems predict where the head will turn next and spend a fixed bit budget on the tiles most likely to be watched, at a quality level chosen per tile. Our proposal transfers that machinery to the analysis side rather than the pixel side. Each candidate region–pathway test becomes a "tile". The number of permutations, or the number of sampling iterations, becomes its "bitrate". A scheduler adapted from 360° streaming spends a compute budget on the tests the analyst is about to look at.

Core Claim

In interactive spatial-omics exploration, the expensive and non-precomputable part of enrichment is the calibrated null for viewport-defined contrasts. That null can be produced at increasing precision, in the way a video tile is encoded at increasing bitrates. A drift-plus-penalty scheduler (the queue-based controller BOLA360 uses for tile bitrates) can allocate this precision across predicted future viewports. We claim it will deliver correct significance calls during a much larger fraction of an analyst's dwell time than two alternatives at equal compute: computing the current view on demand, or prefetching neighbouring regions in fixed rings. The new element is not "streaming for biology images", which pyramidal image servers already do. It is treating statistical precision as the quality ladder, and viewport prediction as the prior over which hypotheses will be needed.

What Each Side Contributes

From the video literature we reuse three ideas.

The first is the controller. BOLA360 chooses per-tile bitrates by Lyapunov optimization: it keeps a virtual queue tracking how far behind the system is, and trades visual utility against stalls without forecasting the channel. Its authors report that it stays within an additive constant of an offline optimum. We keep the controller but swap bits for compute units, and swap playback stalls for viewports that have settled while showing no calibrated result.

The second is the feedback structure. AdaPort showed that viewport delivery has two kinds of feedback. Its prediction feedback is full-information: in hindsight you know, for every candidate, whether it would have covered the true view. Its delivery feedback is bandit: you only observe the outcome of what you actually sent. The same split holds for us. Once the analyst settles on a region, we know retrospectively which of all the speculative jobs would have been useful. Compute completion times, by contrast, are observed only for jobs we actually ran. This tells us to update the viewport predictor with full-information updates and to reserve exploration for latency estimation.

The third is the prediction target. MFTR found that classifying tiles as "will be viewed / won't" is more robust than regressing head coordinates. That suits our setting, because analysts jump between structures such as tumour margins and lymphoid follicles rather than gliding. The research file itself notes that inertial predictors like PARIMA's ARIMA component should fail under this kind of discontinuous navigation. We treat that as a hypothesis to test rather than a given.

From the enrichment literature we take the statistical constraints. To Tweak or Not to Tweak documents how flexible gene-set analysis choices and the assumption that genes are independent produce overoptimistic results. This is why we refuse to ship the instant Fisher-test answer as the final display, and why the null must be a spatial block permutation rather than a gene-label shuffle. Bayesian Gene Set Analysis supplies a second, more expensive quality ladder: its spike-and-slab model handles pathways where some genes go up and others go down, at the cost of MCMC sampling. Its iteration count is a natural precision knob. The gene-set corpus of 12,612 GO, KEGG, Reactome and WikiPathways sets assembled for gtCLIP gives the hypothesis space. gtCLIP's embeddings also give us a way to share precision across related pathways, since its authors found that over 80% of related pathway pairs share no genes, so gene overlap alone cannot tell us which tests inform one another.

Research Program

We first build the precision ladder. For a viewport-versus-rest contrast, per-spot gene statistics can be summed into sufficient statistics, so point estimates of pathway scores are cheap. What is expensive is the null. Ladder level $b$ runs $B_b \in \{100, 1000, 10000\}$ spatial-block permutations, giving a minimum attainable p-value of $1/(B_b+1)$. An optional top rung runs BGSA chains of increasing length. Each level can resume from the previous one, so compute is never wasted when a test is upgraded.

Utility is defined against a reference. For job $j$ (a candidate region–pathway block), $U_j(b)$ is the estimated probability that its significance call at level $b$, after false-discovery-rate control, agrees with the call at a reference budget. We estimate this from the binomial uncertainty of the permutation p-value near the threshold.

At each scheduling step the controller chooses allocations $a_j$ to maximize

$$V\sum_j \hat p_j(t)\,\big[U_j(b_j + a_j) - U_j(b_j)\big] \;-\; Q(t)\sum_j c_j a_j,$$

where $\hat p_j(t)$ is the predicted probability that region $j$ is viewed within the next few seconds, $b_j$ is its current level, $c_j$ is the per-unit compute cost, $Q(t)$ is a virtual queue that grows whenever settled viewports lack a calibrated answer, and $V$ trades utility against that backlog. This is the BOLA360 form with our substitutions.

The viewport predictor is an MFTR-style region classifier. It fuses recent pan and zoom history with cheap tissue features: histology appearance and per-region expression summaries. It is updated with AdaPort-style full-information feedback after each settle.

We will collect navigation traces from analysts exploring public spatial transcriptomics slices. Sources include atlases such as the large-scale spatial variable gene atlas and STAr. We need our own traces because no public navigation-trace benchmark for omics viewers appears in our sources. As a stress test only, we will also replay the 360° head traces of Corbillon et al. (59 users, 5 videos) and Wu et al. (48 users, 9 videos), projected onto tissue planes. These provide inertial navigation regimes, which tell us when the classifier helps and when simple inertia already suffices.

Baselines

The naive reference is on-demand computation. Nothing is computed until the viewport settles, and the system then runs the full reference budget for that region. It shows the instant point estimate with a parametric Fisher or z-test p-value while it waits. This is what an analyst gets today. It defines both the latency floor and the miscalibration of the instant answer.

The strongest simple competitor is ring prefetch with adaptive stopping. On settle, the current region is computed first. Spare compute then goes to concentric neighbouring regions, in the spirit of Flare's fixed viewport heuristics. Each permutation test stops early once its p-value is clearly far from the threshold. This baseline captures most of the intuitive gains without any learning, and we expect it to be hard to beat on smooth navigation.

We will also compare against a BOLA360-style controller driven by an inertial predictor (ARIMA as in PARIMA). This isolates whether region classification matters.

There are no reported results on Lacuna for any baseline in this spatial-omics enrichment setting, so the transferable reference points come from video. AdaPort reports 0.5% relative throughput degradation at 150 Mbps, against 5.1% for a two-level bandit Thompson sampling baseline and 16.1% for Flare. BOLA360 reports QoE gains of 6% to 110% over prior baselines. These are evidence that learned scheduling beats fixed heuristics in the analogous problem. They are not targets for our metric.

All methods get the same traces, the same total compute per session, the same spatial-block null, and the same false-discovery-rate procedure. Tuning is restricted to the controller weight $V$ and ring width, with an equal number of trials for each method, all chosen on held-out analysts. We would count the proposal as beating ring prefetch if it raises the fraction of dwell time with a reference-agreeing call by at least ten points at equal compute on discontinuous-navigation traces, without inflating false discoveries.

Two ablations isolate the key ingredients. The first replaces $\hat p_j$ with a uniform prior, keeping the controller but removing prediction. The second removes the precision ladder, so each job is either fully computed or not at all.

Why not just…?

Why not just precompute everything offline? For a fixed tiling, per-tile enrichment against a fixed background could indeed be precomputed. The interactive question, however, is viewport-versus-rest, and arbitrary zooms and pans define a combinatorial family of contrasts. Point estimates can be aggregated from per-tile statistics, but calibrated spatial nulls cannot. We will test this directly by precomputing nulls on a fine grid and approximating each viewport's null by combining per-tile nulls. If that approximation turns out to be calibrated, which we will check with type-I error measured on gene sets reassigned to random genes, then much of the scheduler is unnecessary. We would then report that result and narrow the contribution to the case of viewports that do not align with the grid.

Why not just use the fast parametric test and skip permutations? It is instant, and it is the default in nearly every applied study in this literature. To Tweak or Not to Tweak shows that independence assumptions and analytic flexibility inflate false discoveries, and spatial autocorrelation makes the independence assumption worse. Our on-demand baseline measures exactly how often the instant call disagrees with the calibrated reference on real slices. If that disagreement rate is small, the whole motivation weakens, and we will report it as such.

Why not just ring prefetch with adaptive stopping? This is the real threat. On inertial, smooth panning it may match a learned scheduler, as Flare does at 100 Mbps in AdaPort's experiments before failing at 150 Mbps. Our split of traces into smooth (the replayed 360° traces) and jump-heavy (the recorded analyst traces) is designed to show where, if anywhere, prediction pays off. We will report the smooth regime honestly even if ring prefetch ties there.

Decisive Checks

The first check is calibration. Under gene sets reassigned to random genes, every displayed call must hold the nominal false-discovery rate at every precision level. A method that wins on agreement but leaks false positives fails.

The second check is the main comparison: dwell-time-weighted agreement with the reference, together with time-to-calibrated-answer after each settle, at matched compute, separately for jump-heavy and smooth traces.

The third check is the ablation pair. If the uniform-prior controller matches the full system, the value lies in the precision ladder, not in viewport prediction, and we will say so.

A secondary check runs the BGSA top rung on the p53 dataset. We will ask how many MCMC iterations are needed before the ATM and BAD pathway calls stabilize. This tells us whether a Bayesian rung is affordable within interactive budgets at all.