GAMoE: Geometry-Aware Mixture of Experts (GaMoE) for cell-type-specific factorization of hippocampal ripples
GaMoE provides a framework for factorizing how distinct input sources contribute across the geometry of a complex data space. Here, we apply GaMoE to hippocampal ripples, using cell-type-resolved population activity as experts to evaluate their contribution to their variability. The framework is general and can be adapted to other datasets in which heterogeneous input sources contribute differentially across a structured output space. We first introduce the general method using a synthetic dataset [here], and then apply GaMoE to factorize cell-type contributions to hippocampal ripple variability [here].
GAMoE factorizes complex high-dimensional systems by allocating an independent, constrained bottleneck expert network
where the gating distribution is normalized across all
In the hippocampal application shown below, individual ripples are represented by their waveforms and embedded into a low-dimensional space using UMAP. Cell-type-specific activity then provides the inputs to the GaMoE experts.
---To assess how individual inputs or functional modules contribute to data reconstruction, ablations are executed strictly at test time, keeping the trained expert parameters fixed. GAMoE tests three distinct perturbation mechanisms:
Completely isolates and disables an expert or subset of experts
This test measures the absolute necessity of the ablated components for reconstructing the manifold trajectory.
Randomly permutes the gating values of selected experts across all events,
This preserves each expert's overall marginal activation distribution while abolishing its spatial alignment with the manifold coordinates. It isolates whether the model depends on geometry-specific routing or simply on unaligned capacity.
Directly clamps standardized input channels to zero (
To verify that manifold reconstruction depends on geometric alignment rather than raw parameter capacity, GAMoE benchmarks against:
-
Agnostic MoE (
$\mathbf{aMoE}$ ): Evaluates trained experts under globally permuted gates across all samples, destroying manifold coordination while preserving marginal gating statistics. -
Feature-Space MoE (
$\mathbf{fMoE}$ ): Reconstructs auxiliary continuous system variables directly from weighted inputs. -
$k$ -Nearest-Neighbors Regressor ($\mathbf{KNN}$ ): Direct non-parametric baseline predicting manifold coordinates from raw inputs without modular bottlenecking or geometric priors. Parallel feature-drop and feature-shuffle ablations are performed at the input layer.
To evaluate how localized reconstruction errors correlate with continuous system states (e.g., speed, energy, frequency, or order parameters
where
All models are evaluated via
-
Per-Dimension
$R^2$ : Squared Pearson correlation between true and predicted manifold coordinates along each latent dimension$d \in {1, \dots, D}$ : $$R^2_d = \left( \frac{\text{Cov}(\mathbf{u}_d, \hat{\mathbf{u}}d)}{\sigma{\mathbf{u}d} \sigma{\hat{\mathbf{u}}_d}} \right)^2$$ -
Global Variance-Weighted
$R^2$ : Overall score weighting each dimension by its true variance: $$R^2_{\text{global}} = \sum_{d=1}^{D} w_d R^2_d, \quad \text{where } w_d = \frac{\text{Var}(\mathbf{u}d)}{\sum{k=1}^D \text{Var}(\mathbf{u}_k)}$$ -
Point-wise Euclidean Error: Residual manifold displacement
$e_i = \Vert{}\hat{\mathbf{u}}_i - \mathbf{u}_i\Vert{}_2$ . - Topological Structure Index (SI): Quantifies whether continuous features, gating probabilities, or residual errors exhibit non-random clustering along the manifold surface.
gamoe_model/
├── configs/
│ └── ablation_config.py # Feature definitions, module groupings, ablation conditions
├── src/
│ ├── models/
│ │ ├── moe.py # ExpertLinearProj, GatedMoE architectures
│ │ └── knn.py # KNN baseline models (feature drop & shuffle)
│ ├── geometry/
│ │ ├── prior.py # Gaussian density prior & gate computation
│ │ └── structure_index.py # Structure Index (SI) graph routines
│ ├── stats/
│ │ ├── parametric.py # One-way/Two-way ANOVA + Bonferroni post-hoc
│ │ └── non_parametric.py # Kruskal-Wallis + pairwise Mann-Whitney U tests
│ └── utils/
│ ├── data_loaders.py # Generic dataset readers & covariate aligners
│ └── metrics.py # Variance-weighted R², RMSE, error weighting
├── experiments/
│ ├── run_gamoe_kfold.py # K-fold training and dual-mode ablation pipeline
│ └── run_knn_kfold.py # K-fold KNN regression baseline benchmark
├── analysis/
│ ├── compute_statistics.py # Automated parametric & non-parametric statistical reports
│ └── compute_si_metrics.py # Post-hoc Structure Index processing
├── visualization/
│ ├── plot_performance.py # Global R² and error boxplots
│ ├── plot_latent_maps.py # Manifold overlays and residual error heatmaps
│ └── plot_covariates.py # State variable summaries across conditions
├── notebooks/
│ └── gamoe_simulated_example.ipynb # Interactive tutorial with synthetic data
├── docs/
│ └── images/ # Architecture schematics & figures
└── requirements.txt
If you use this codebase or model in your research, please cite:
@software{gamoe_model2026,
author = {Teresa Jurado-Parras#, Melisa Maidana-Capitan#, Candela Sanchez-Bellot*, Eloy Parra-Barrero*, Elena Cid, Enrique R. Sebastian, and Liset M. de la Prida},
title = {Cell-type-resolved microcircuit dissection reveals inhibitory modules underlying ripple variability},
url = {[https://github.com/PridaLab/gamoe_model](https://github.com/PridaLab/gamoe_model)},
year = {2026}
}python -m experiments.run_gamoe_kfold
python -m experiments.run_knn_kfold
python -m analysis.compute_statistics
python -m visualization.plot_performance python -m visualization.plot_latent_maps python -m visualization.plot_covariates

