Wastewater treatment plants depend on bacterial communities that sometimes flip abruptly into bad states. Blooms of filamentous bacteria such as Candidatus Microthrix cause sludge to stop settling ("bulking"). Plants track these communities by 16S rRNA gene sequencing, which reads a barcode-like stretch of a bacterial gene and reports what fraction of the community each taxon makes up. Current models of such data either fit fixed ecological equations or forecast the next few samples. Neither tells an operator where in "community space" the plant sits relative to a tipping point. Systems neuroscience solved a similar problem for neural recordings. There, models learn the velocity field of a low-dimensional latent state, meaning a map of which way and how fast the state moves from any point, with a built-in pull toward the centre that keeps the field stable. These maps reveal "ghost attractors": regions where trajectories slow sharply just before the system switches state. We propose to learn such a map for microbial communities and to test it with a spectral prediction. A system creeping toward a tipping point should shift its fluctuation power toward low frequencies. The learned field predicts how large that shift should be, and wavelet spectrograms of the data can check it.
In two sentences: we fit a stable, low-dimensional velocity field to 16S time series pooled across 24 Danish treatment plants, and use the slow regions it finds to anticipate blooms. Time-frequency analysis is not the input to a vision model. It is an independent check that the slow regions the model claims are real.
Core Claim
A contracting nonlinear velocity field, learned in a shared latent space across many plants, will anticipate Microthrix blooms with longer lead time than two alternatives. The first is generic early-warning statistics computed on the raw series. The second is the strongest existing forecaster. The field's local slowness at each time point should also quantitatively predict the low-frequency reddening seen in wavelet spectrograms of held-out data.
The new element is not "neural networks on microbiome data." That has been done for forecasting by Predicting microbial community structure and temporal dynamics by using graph neural network models and for scalar diversity trajectories by Revealing the temporal dynamics of antibiotic anomalies in the infant gut microbiome with neural jump ODEs. The new element is recovering explicit dynamical geometry from compositional counts, namely fixed points, slow regions and bifurcations under a seasonal control input, and validating that geometry against a falsifiable spectral signature.
Why this combination, and what we deliberately do not do
The obvious idea at this intersection is to turn each taxon's abundance series into a spectrogram and classify it with a pretrained vision model. We reject that idea for this data. Microbiome series give at most a few hundred unevenly spaced points per plant. The cross-modal study Cross-Modal Knowledge Transfer in Time Series AI via Large Vision Models, which benchmarks image encodings of time series for pretrained vision models, itself reports a bias toward periodic structure and weakness on non-periodic trends. A bloom onset is exactly such a non-periodic trend.
So the three directions play unequal roles. Nonlinear neural dynamics supplies the mechanism. Our source is the radial-basis-function velocity field with a global leak from Interpretable Nonlinear Dynamic Modeling of Neural Trajectories, which found ghost attractors on the Wong-Wang decision model, plus the shared-generator "stitching" across sessions from Inferring single-trial neural population dynamics using sequential auto-encoders. 16S sequencing is the application, and it imposes three constraints: compositional counts, many zeros and irregular sampling. Spectrogram analysis is the evaluation lens.
The ecological prior work also shapes the design. MDSINE2 (Learning ecosystem-scale dynamics from microbiome data with MDSINE2) and the Bayesian modular model (Robust and Scalable Models of Microbiome Dynamics) both show that grouping taxa into interaction modules is essential to avoid overfitting. We reuse modules, but learned jointly with the latent space. Compositional Lotka-Volterra (Compositional Lotka-Volterra describes microbial dynamics in the simplex) shows that log-ratio coordinates make proportions usable for dynamics, but it depends on choosing a reference taxon and on log-transforming zeros. We avoid both by putting the log-ratio geometry inside a count likelihood rather than transforming the data.
Research Program
Model. Each sample from plant $p$ is a vector of read counts $y_t$. A latent state $z(t)\in\mathbb{R}^d$, with $d$ between 3 and 5 (the range where velocity fields stay identifiable according to the RBF work), evolves in continuous time:
$$\dot z = \sum_k w_k(u)\,\phi_k(z) \;-\; \lambda\,\sigma(\|z\|-r)\,z, \qquad y_t \sim \mathrm{DirMult}\big(n_t,\ \mathrm{softmax}(C_p z(t) + b_p)\big).$$
In the first equation, $\phi_k$ are normalized radial basis functions. Their weights $w_k$ depend on a seasonal input $u$ (wastewater temperature, with day-of-year as a fallback). The term $\lambda\,\sigma(\|z\|-r)\,z$ is the global leak: a pull toward the origin that switches on beyond radius $r$ and prevents runaway trajectories. In the second equation, $n_t$ is sequencing depth and $C_p, b_p$ are a plant-specific readout. The Dirichlet-multinomial likelihood handles overdispersed counts and zeros directly, so no zero is ever log-transformed. Each row of $C_p$ maps onto taxa through a sparse loading, which yields learned modules.
Between irregular samples, the latent state is integrated by an ODE solver, borrowing the continuous-time treatment of Revealing the temporal dynamics of antibiotic anomalies in the infant gut microbiome with neural jump ODEs. A recurrent encoder in the style of LFADS infers each plant-year's initial condition. Training is end-to-end, which avoids the two-stage "compress, then fit dynamics" error propagation flagged in the RBF paper.
Geometry. From the fitted field we compute three things: fixed points as a function of $u$, the smallest local contraction rate $\kappa(z)$ (the magnitude of the leading Jacobian eigenvalue), and bifurcation values of $u$. The bloom-risk score at time $t$ is the inverse slowness $1/\kappa(z(t))$, combined with the latent distance to a bloom-associated attractor.
Spectral check. Near a slow point, fluctuations around the state behave like a noise-driven relaxation with rate $\kappa$. Their power spectrum is therefore approximately
$$S(\omega) \propto \frac{1}{\kappa^2+\omega^2},$$
where $\omega$ is angular frequency. This form is the standard spectrum of a linearly damped process driven by white noise. As $\kappa$ falls, power concentrates at low $\omega$. We compute Morlet wavelet scalograms of the held-out module log-ratio residuals, using a Lomb-Scargle-style estimator on the irregular sample times. From these we read off the empirical low-to-high-frequency power ratio in sliding windows and compare it with the ratio implied by the model's $\kappa$ trajectory. Agreement is evidence that the slow regions are real. Disagreement means the field is producing spurious attractors, which is the hallucination risk the neural-dynamics literature warns about.
Baselines
Naive reference. Two naive predictors. Persistence forecasting carries the last observed composition forward. A seasonal-climatology bloom predictor flags the calendar months in which a plant historically bloomed. This baseline matters because Danish bulking events are partly seasonal. Any method that fails to beat climatology has learned nothing beyond the calendar.
Strongest existing method. mc-prediction (Predicting microbial community structure and temporal dynamics by using graph neural network models). It is a graph neural network with temporal convolutions over 10-point histories, developed on this same dataset. It reports median per-species mean absolute percentage error between 14.2% and 17.7% and median Bray-Curtis dissimilarity of 0.147 at 10 steps ahead, and it predicts Microthrix blooms qualitatively. We run its released configuration with the same plant and time splits and the same hyperparameter search budget in GPU-hours as our model. For bloom anticipation we threshold its forecast Microthrix abundance. We found no reported result on Lacuna for bloom lead time or bloom area under the precision-recall curve with mc-prediction, so we measure both ourselves. Beating it means two things together: matching its forecasting error (within the reported 14.2–17.7% MAPE band on our reproduction), and improving bloom precision-recall area at lead times of four or more samples by a margin outside bootstrap confidence intervals across plants.
Model-free early warning. Rolling-window variance, lag-1 autocorrelation and wavelet low-frequency power ratio, computed per module directly on the observed log-ratio series. This is the most dangerous competitor for the warning task, because it targets the same critical-slowing phenomenon without any model.
Ecological model. Compositional Lotka-Volterra on the same learned modules, with elastic-net fitting as in Compositional Lotka-Volterra describes microbial dynamics in the simplex. Its bloom score comes from its own Jacobian. This tests whether polynomial dynamics already capture the slow regions. MDSINE2 is not usable here because these plants lack qPCR biomass.
Ablations. Three ablations isolate the key ingredients. The first removes the global leak, leaving an unconstrained neural ODE; this is the analogue of the locally linear comparison where the RBF paper reports 0.244 error against 0.002. The second trains one model per plant without stitching. The third replaces the Dirichlet-multinomial likelihood with a pseudocount-plus-centered-log-ratio Gaussian.
Why not just…?
Why not just compute early-warning statistics on the raw series? This is a real threat. If rolling autocorrelation and spectral reddening match our lead time, then for prediction the velocity field adds only interpretation. Our bet is that pooling across 24 plants matters. Per-plant rolling windows of 10–20 samples give very noisy variance estimates, whereas a shared field borrows strength across plants, much as stitching improved decoding R² by 0.18 in Inferring single-trial neural population dynamics using sequential auto-encoders. The head-to-head comparison at matched false-alarm rates settles the question. We commit to reporting a null if the model-free statistics win.
Why not just use mc-prediction and threshold its forecasts? It already forecasts blooms. However, it is a discrete autoregressive forecaster with no notion of distance to a tipping point. It also degraded on abrupt appearance and disappearance of species in the sparse fungal eDNA stress test reported in the same paper. Our test is whether the slowness score raises an alarm before the forecast abundance crosses threshold. A further test is leave-one-plant-out transfer, where a forecaster trained on other plants' histories has no plant-specific memory to exploit.
Why not just fit compositional Lotka-Volterra, which can also have tipping points? Lotka-Volterra systems can bifurcate, but only through pairwise polynomial terms. cLV also needs a stable reference taxon and log-transformed zeros. Running cLV on identical modules shows whether the extra flexibility matters. If cLV's Jacobian-based slowness predicts reddening and blooms as well as ours, the simpler model should be preferred.
Why not just feed scalograms to a pretrained vision model? With a few hundred points per plant there is too little data. The cross-modal study documents a bias toward periodic structure, and bloom onsets are non-periodic. We include this as a secondary baseline: a small CNN on per-module scalogram windows, trained to classify pre-bloom windows. We expect it to learn the seasonal cycle and match climatology rather than exceed it.
Proposed Experiments
Synthetic check. We first validate on simulated three-module communities with a known fold bifurcation driven by temperature. Simulated counts use realistic depth and zero rates and are sampled 2–5 times per month as in the Danish data. Success means recovering the bifurcation temperature within 10% and finding the ghost-attractor region when training only on pre-bifurcation temperatures. This mirrors the RBF paper's extrapolation result on Wong-Wang.
Main experiment. The main experiment uses the Danish wastewater dataset: 24 plants, 4,709 samples over 3–8 years. We use two splits: chronological (train on early years, test on the final year of every plant) and leave-one-plant-out. A bloom is defined as Microthrix relative abundance above each plant's 90th training percentile. Metrics are the forecasting errors reported by mc-prediction, bloom precision-recall area, and median lead time at a fixed false-alarm rate of one per plant-year.
Decisive check. The decisive check is the spectral consistency test. Across held-out windows, we measure the rank correlation between the model-implied $\kappa$ and the empirical wavelet low-frequency power ratio. Low $\kappa$ should coincide with high low-frequency power; a correlation indistinguishable from zero would mean the learned slow regions are artifacts, even if bloom prediction looks good.
Second regime. A smaller test uses the MDSINE2 humanized mouse cohorts, with about 76 samples per mouse and antibiotic perturbations. It asks whether recovery after vancomycin passes through a slow region the model identifies. Here MDSINE2 serves as the comparison: it reports outperforming gLV-L2 and gLV-net on forecasting, with no single numeric value given in the file.
References
- Predicting microbial community structure and temporal dynamics by using graph neural network models
- Revealing the temporal dynamics of antibiotic anomalies in the infant gut microbiome with neural jump ODEs
- Cross-Modal Knowledge Transfer in Time Series AI via Large Vision Models
- Interpretable Nonlinear Dynamic Modeling of Neural Trajectories
- Inferring single-trial neural population dynamics using sequential auto-encoders
- Learning ecosystem-scale dynamics from microbiome data with MDSINE2
- Robust and Scalable Models of Microbiome Dynamics
- Compositional Lotka-Volterra describes microbial dynamics in the simplex