Probabilistic Mutation-Selection

Exploring the Fundamental Theorem of Natural Selection with Mutations using Bayesian probabilistic programming with parameter inference.

About this project

Basener & Sanford (2018) extended Fisher’s Fundamental Theorem of Natural Selection to rigorously account for the effects of mutations. Whether a population adapts or undergoes mutational meltdown depends on the precise interplay of mutation rate, the distribution of fitness effects, and environmental noise. This collection applies five Bayesian inference methods to recover those parameters from simulated fitness trajectories, compares their results head-to-head, and maps the phase transition boundary between adaptation and decline.

Notebook 01
Simulator Demo — The Basener-Sanford Mutation-Selection Model
An individual-based simulator for finite populations with stochastic effects: genetic drift, Muller’s ratchet, and demographic noise. Establishes the forward model used by all subsequent inference methods.
Notebook 02
ABC-SMC Inference
Approximate Bayesian Computation with Sequential Monte Carlo. A likelihood-free method that iteratively narrows a cloud of particles toward the posterior by comparing simulated and observed summary statistics.
Notebook 03
Bayesian Synthetic Likelihood (BSL)
A second likelihood-free approach that fits a multivariate normal to summary statistics from repeated simulations, producing a synthetic likelihood for MCMC sampling without an analytic likelihood function.
Notebook 04b
Neural SBI — Neural Posterior Estimation & Flow Matching (sbijax)
Amortized neural simulation-based inference: a neural network is trained once on many simulated datasets, then produces posterior distributions instantly for any new observation via Neural Posterior Estimation (NPE) and Flow-Matching Posterior Estimation (FMPE).
Notebook 04c
Neural Ratio Estimation (NRE)
Learns a likelihood-ratio classifier that distinguishes parameter–data pairs, enabling both parameter inference and model comparison. Posterior samples are drawn via MCMC guided by the learned ratio.
Notebook 05
Inference Comparison & Parameter Space Mapping
Head-to-head comparison of all five inference methods. When independent approaches with different computational assumptions converge on the same answer, confidence in that answer grows far beyond what any single method could justify.
Notebook 06
Phase Transition Boundary Analysis
Maps the exact boundary in parameter space where selective variance and mutational drag balance — the computational analog of the error threshold from quasispecies theory. Identifies where adaptation gives way to mutational meltdown.