## Abstract

Treatment with antibiotics is one of the most extreme perturbations to the human microbiome. Even standard courses of antibiotics dramatically reduce the microbiome’s diversity and can cause transitions to dysbiotic states. Conceptually, this is often described as a ‘stability landscape’: the microbiome sits in a landscape with multiple stable equilibria, and sufficiently strong perturbations can shift the microbiome from its normal equilibrium to another state. However, this picture is only qualitative and has not been incorporated in previous mathematical models of the effects of antibiotics. Here, we outline a simple quantitative model based on the stability landscape concept and demonstrate its success on real data. Our analytical impulse-response model has minimal assumptions with three parameters. We fit this model in a Bayesian framework to previously published data on the year-long effects of four common antibiotics (ciprofloxacin, clindamycin, minocycline, and amoxicillin) on the gut and oral microbiomes, allowing us to compare parameters between antibiotics and microbiomes. Furthermore, using Bayesian model selection we find support for a long-term transition to an alternative microbiome state after courses of ciprofloxacin and clindamycin in both the gut and salivary microbiomes. Quantitative stability landscape frameworks are an exciting avenue for future microbiome modelling.

## Introduction

### Stability and perturbation in the microbiome

The human microbiome is a complex ecosystem. While stability is the norm in the gut microbiome, disturbances and their consequences are important when considering the impact of the gut microbiome on human health (1). A course of antibiotics is a major perturbation, typically leading to a marked reduction in species diversity before subsequent recovery (2). Aside from concerns about the development of antibiotic resistance, even a brief course can result in long-term effects on community composition, with species diversity remaining lower than its baseline value for up to a year afterwards (3). However, modelling the recovery of the microbiome is challenging, due to the difficulty of quantifying the *in vivo* effects of antibiotics on the hundreds of co-occurring species that make up typical microbial communities within the human body.

Artificial perturbation experiments are widely used to explore the underlying dynamics of macro-ecological systems (4). In the context of the gut microbiome, the effects of antibiotics have previously been investigated descriptively (5–7). However, despite interest in the application of ecological theory to the gut microbiome (8), there has been limited quantitative or mechanistic modelling of this response. In general, the diversity of the microbiome falls before recovering, but the nature of this recovery remains unclear. While responses can appear highly individualized (7) this does not preclude the possibility of generalized models applicable at the population level.

Applying mathematical models to other ecological systems subject to perturbation has given useful insight into their behaviour (9–11). Crucially, it allows the comparison of different hypotheses about the behaviour of the system using model selection. Developing a consistent mathematical framework for quantifying the long-term effects of antibiotic use would facilitate comparisons between different antibiotics and different regimens, with the potential to inform approaches to antibiotic stewardship (12).

### Previous modelling approaches

A great deal of modelling work has focused on the gut microbiome’s response to antibiotic perturbation. We mention a few important examples here. Bucci et al. (13) used a two-compartment density model with species categorised as either antibiotic-tolerant or antibiotic-sensitive, and fitted their model to data from Dethlefsen and Relman (7) to demonstrate that these broad categories were appropriate. In a later review, Bucci and Xavier argued that models of wastewater treatment bioreactors could be adapted for the gut microbiome, with a focus on individual-based models (14). The most commonly used individual-based model is the generalized multispecies Lotka-Volterra model, which describes pairwise interactions between bacterial species (or other groupings). In a pioneering work, Stein et al. (15) extended a generalized Lotka-Volterra model to include external perturbations, and fitted their model to a study where mice received clindamycin and developed *Clostridium difficile* infection (CDI) (16). The same approach was also successfully applied to human subjects in a later paper, which also identified a probiotic candidate for treating CDI (17). Bucci et al. (18) have combined and extended their previous work into an integrated suite of algorithms called MDSINE to infer dynamical systems models from time-series microbiome data.

While all of these models have provided useful insights into microbiome dynamics, to make meaningful inference from real data they require dense temporal sampling and restriction to a small number of species or categories. For example, the examples of application of MDSINE had “26–56 time points” for accurate inference of dynamics, measurements of relative concentrations of bacteria, and frequent shifts of treatment — for these reasons the *in vivo* experiments were conducted in gnotobiotic mice (18). Similarly, Stein et al. restricted their analysis of CDI to the ten most abundant bacterial genera (15). Such restrictions limit the applicability of these methods for the opportunistic analysis of existing 16S rRNA gene datasets from humans, which currently comprise the majority of clinically relevant datasets. The generalized Lotka-Volterra model can undoubtedly be extremely useful for synthetic consortia of small numbers of species, as shown by Venturelli et al. who inferred the dynamics of a 12-species community (19). However, it has been shown that even for very small numbers of species, pairwise microbial interaction models do not always accurately predict future dynamics, suggesting that even pairwise modelling has its own limitations (20).

Starting from broader ecological principles allows quantitative investigation of high-level statements and hypotheses about microbiome dynamics. For example, Coyte et al. built network models based on principles from community ecology to show the counter-intuitive result that competitive interactions in the gut microbiome are associated with stable states of high diversity, whereas cooperative interactions produce less stable states (21). More recently, Goyal et al. took inspiration from the ‘stable marriage problem’ in economics and showed that multiple stable states in microbial communities can be explained by nutrient preferences and competitive abilities (22). There is therefore great value in exploring alternative modelling approaches as well as continuing to refine and extend existing standard models.

### A stability landscape approach

In one popular schematic picture taken from classical ecology, the state of the gut microbiome is represented by a ball sitting in a stability landscape (1,23–25). Perturbations can be thought of as forces acting on the ball to displace it from its equilibrium position (25) or as alterations of the stability landscape (26). While this image is usually provided only as a conceptual model to aid thinking about the complexity of the ecosystem, we use it here to derive a mathematical model.

We model the effect of a brief course of antibiotics on the microbial community’s phylogenetic diversity as the impulse response of an overdamped harmonic oscillator (Figure 1; see Methods), and compare parameters for four widely-used antibiotics by fitting to empirical data previously published by Zaura et al. (3). This model is significantly less complicated than other previous models developed for similar purposes, but still captures some of the essential emergent features of such a system while avoiding the computational difficulties of fitting hundreds of parameters to a sparse dataset. After demonstrating the effectiveness of this modelling approach for the gut and oral microbiomes, we also show that the framework can easily be used to test hypotheses about microbiome states. We compare a model variant which allows a transition to a new equilibrium, and find that this model is better supported for clindamycin and ciprofloxacin, allowing us to conclude that these antibiotics can produce state transitions across different microbiomes. This modelling approach can be easily applied to sparse datasets from different human microbiomes and antibiotics, providing a simple but consistent foundational framework for quantifying the *in vivo* impacts of antibiotics.

## Results

### Ecological theory motivates a simplified representation of the microbiome

Taking inspiration from classical ecological theory, the microbiome can be considered as an ecosystem existing in a stability landscape: it typically rests at some equilibrium, but can be displaced (Figure 1A). Any quantitative model of the microbiome based on this concept requires a definition of equilibrium and displacement. While earlier studies sought to identify a equilibrium core set of ‘healthy’ microbes, disturbances of which would quantify displacement, it has become apparent that this is not a practical definition due to high inter-individual variability in taxonomic composition (25). More recent concepts of a healthy ‘functional core’ appear more promising, but characterization is challenging, particularly as many gut microbiome studies use 16S rRNA gene sequencing rather than whole-genome shotgun sequencing. For these reasons, we choose a metric that offers a proxy for the general functional potential of the gut microbiome: phylogenetic diversity (25). Diversity is commonly used as a summary statistic in microbiome analyses and higher diversity has previously been associated with health (27) and temporal stability (28). Of course, describing the microbiome using only a single number loses a great deal of information. However, if we are seeking to build a general model of microbiome recovery after perturbation, it seems appropriate to consider a simple metric first to see how such a model performs before developing more complicated definitions of equilibrium, which may generalise poorly across different niches and individuals.

We assume the equilibrium position to have higher diversity than the points immediately surrounding it (i.e. creating a potential well) (Figure 1B). However, there may be alternative stable states (Figure 1B) which perturbations may move the microbiome into (Figure 1C). These states may be either higher or lower in diversity; for our purposes, all we assume is that they are separated from the initial equilibrium by a potential barrier of diversity i.e. a decrease of diversity is required to access them, which is what keeps the microbiome at equilibrium under normal conditions.

### The model

Mathematically, small displacements of a mass from an equilibrium point can be approximated as a simple harmonic oscillator (29) for any potential function (continuous and differentiable). This approximation comes naturally from the first terms in the Taylor expansion of a function (30), and can be extremely accurate for small perturbations. By assuming the local stability landscape of the microbiome can be reasonably approximated displacement x from the equilibrium position (–*Kx*) and also a ‘frictional’ force acting as a harmonic potential, we are assuming a ‘restoring’ force proportional to the against the direction of motion (–*bx*). The system is a damped harmonic oscillator with the following equation of motion:

Additional forces acting on the system — perturbations — will appear on the right-hand side of this equation. Consider a course of antibiotics of duration τ. If we are interested in timescales of *T* » τ (e.g. the long-term recovery of the microbiome a year after a week-side long course of antibiotics). we can assume that this perturbation is of negligible duration This assumption allows us to model it as an impulse of magnitude *D* acting at time *t* = 0:.

This second-order differential equation can be solved analytically and reparameterised (see Methods) to give an equation with three parameters for fitting to empirical data (Model 1, Figure 1C):

### Fitting the model to empirical data for four common antibiotics

We fit the model to published data from a paper from Zaura et al. (3) where individuals received a ten-day course of either a placebo or one of four commonly-used antibiotics (Table 1). Faecal and saliva samples were taken at baseline (i.e. before treatment), then subsequently directly after treatment, then one month, two months, four months, and one year after treatment. Zaura et al. conducted pairwise comparisons between timepoints and comprehensively reported statistical associations, but did not attempt any explicit modelling of the time-response over the year.

In summary, this dataset provides an ideal test case for our model. Not only does it allow us to simultaneously model the recovery of both the gut and oral microbiomes after different antibiotics, but it also demonstrates how our modelling framework permits further conclusions beyond the scope of the initial study.

### A stability landscape framework successfully describes initial microbiome dynamics

We used a Bayesian approach to fit the model to each treatment group and microbiome separately. The model successfully captured the main features of the initial response to antibiotics (Figure 2). Diversity decreased (i.e. displacement from equilibrium increased) before a slow return to equilibrium. Despite large variability between samples from the same treatment group, reassuringly the placebo group clearly did not warrant an impulse response model, whereas data from individuals receiving antibiotics was qualitatively in agreement with the model. Even without the model, it is apparent that clindamycin and ciprofloxacin represent greater disturbances to the microbiome than minocycline and amoxicillin, but a consistent model allows comparison of the values of various parameters (see below).

In their original analysis, Zaura et al. noted significantly (*p* <0.05) reduced Shannon diversity in individuals receiving ciprofloxacin comparing samples after a year to baseline using a GLM repeated measure test. This reduced diversity could in principle merely be due to slow reconstitution and return to the original equilibrium under the dynamics we have described. However, by normalising each individual’s data relative to their specific baseline and fitting the model (taking into account the whole continuous temporal response rather than pairwise comparisons of absolute diversity) it appears that slow reconstitution cannot be the whole story. Instead, the skewed distribution of residuals after a year, when the response has flattened off, indicates that the longer-term dynamics of the system do not obey the same impulse response as the short-term dynamics. A scenario involving a long-term transition to an alternative stable state is consistent with this observation (Figure 1). We therefore developed a variant of the model to take into account alternative equilibria, aiming to test the hypothesis that the microbiome had transitioned to an alternative stable state.

### A model allowing antibiotic-induced state transitions

In our approach, a transition to an alternative stable state means that the value of diversity displacement from the original equilibrium will asymptotically tend to a non-zero value. There are many options for representing this mathematically; for reasons of model simplicity, we adopt one that requires only one additional parameter (Model 2, Figure 1C):

### Support for the existence of antibiotic-induced state transitions

Qualitatively, this slightly more complex model gave a similar fit (Figure 3) but some treatment groups had a clear non-zero final displacement from equilibrium, corresponding to an alternative stable state. We compared models with the Bayes factor *BF*, where, *BF* > 1 indicates greater support for model 2 i.e. positive evidence for a state transition (Table 2). A state transition was supported (*BF* > 3) in the ciprofloxacin and clindamycin treatment groups for both the gut and oral microbiome. Interestingly, the posterior estimates for the asymptote parameter in the gut microbiome were substantially positively skewed (Figure 4), providing evidence of a transition to a state with lower phylogenetic diversity than the baseline. Contrastingly, in the oral microbiome the asymptote parameter was negatively skewed, suggesting a transition to a state with greater phylogenetic diversity. Strikingly, these are the states associated with poorer health in each of the gut and oral microbiomes.

### Comparison of parameters between antibiotics

Comparing the posterior distribution of parameters for model 2 fits allows quantification of ecological impact of different antibiotics (Table 3, Figure 4). Unsurprisingly, greater perturbation is correlated with the transition to an alternative stable state. We can also consider the ecological implications of the parameters we observe. The damping ratio summarises how perturbations decay over time, and is an inherent property of the system independent of the perturbation itself. Therefore, if our modelling framework and ecological assumptions were valid we would expect to find a consistent damping ratio across both the clindamycin and ciprofloxacin groups in the gut microbiome. This is indeed what we observed with median (95% credible interval) damping ratios of ζ_{clinda}1.07 (1.00-1.65) and ζ_{cipro}=1.07 (1.00-1.66), substantially different from the prior distribution, supporting the view of the gut microbiome as a damped harmonic oscillator.

### A complex, individualized antibiotic response still allows a general model

While it is not our intention to repeat a comprehensive description of the precise nature of the response for the different antibiotics, we note some interesting qualitative observations from our reanalysis that highlight the complexity of the antibiotic response. We discuss here observations at the level of taxonomic family in the gut microbiomes of individuals taking ciprofloxacin or clindamycin (Supplementary File 1). While modelling these precise interactions is far beyond the scope of our model, our approach can still summarise the overall impact of this underlying complexity on the community as a whole.

Despite their different mechanisms of action, both clindamycin and ciprofloxacin caused a dramatic decrease in the Gram-negative anaerobes *Rikenellaceae*, which was most marked a month after the end of the course. However, for ciprofloxacin this decrease had already started immediately after treatment, whereas for clindamycin the abundance after treatment was unchanged in most participants. The different temporal nature of this response perhaps reflects the bacteriocidal nature of ciprofloxacin (32) compared to the bacteriostatic effect of clindamycin, although concentrations *in vivo* can produce bacteriocidal effects (33).

There were other clear differences in response between antibiotics. For example, clindamycin caused a decrease in the anaerobic Gram-positives *Ruminococcaceae* after a month, whereas ciprofloxacin had no effect. There was also an individualized response: ciprofloxacin led to dramatic increases in *Erysipelotrichaceae* for some participants, and for these individuals the increases coincided with marked decreases in *Bacteroidaceae*, suggesting the relevance of inter-family microbial interactions (Supplementary File 1).

Comparing relative abundances at the family level, there were few differences between community states of different treatment groups after a year. Equal phylogenetic diversity can be produced by different community composition, and this suggests against consistent trends in the long-term dysbiosis associated with each antibiotic. However, we did find that *Peptostreptococcaceae*, a member of the order *Clostridiales*, was significantly more abundant in the clindamycin group when compared to both the ciprofloxacin group and the placebo group separately (p < 0.05, Wilcoxon rank sum test). In a clinical setting, clindamycin is well-established to lead to an increased risk of a life-threatening infection caused by another member of *Clostridiales*: *Clostridium difficile* (34). Long-term reductions in diversity may similarly increase the risk of overgrowth of pathogenic species.

### Connection to generalized Lotka-Volterra models

We sought to establish a link between our framework and the conventional ‘bottom-up’ approach of generalized Lokta-Volterra models. We investigated the behaviour of a 3 species Lotka-Volterra system to establish if perturbation to an alternative state was possible in this simple case (see Supplementary File 7). We found that only 0.079% of 3-species Lotka-Volterra systems exhibit the behaviour required by our two-state model, suggesting that this model is unrealistic for small numbers of species (as we assume that diversity is a continuous variable). However, for larger numbers of species, theoretical the number of species *n*increases, the number of fixed points which are stable increases ecology gives a strong justification for our assumptions. It has recently been shown that as independently of population size (35), and the proportion of simulations from random parameters that have multiple fixed points also increases: with, *n*= 400, this proportion is >97% (36). This suggests that the overwhelming majority of *mathematically possible* systems at relevant numbers of species exhibit multiple fixed points; the fraction of *biologically possible* systems exhibiting this behaviour is likely even higher. Furthermore, when resource competition is incorporated — a more realistic assumption in the case of the human microbiome — all these fixed points become stable or marginally stable (36). The gut microbiome is an ecosystem of hundreds of species in the presence of resource competition. Goyal et al. recently showed that multiple resilient stable states can exist in microbial communities if microbes utilize nutrients one at a time (22). We can therefore state confidently that: the gut microbiome exists with multiple stable equilibria; its community composition is history-dependent; and perturbations lead to transitions between the multiple possible stable states. All of these assumptions justify the simplistic coarse-grained model we describe here, which effectively takes these high-level emergent properties of multi-species Lotka-Volterra models to build a substantially simpler model based on a single, commonly-used metric: diversity.

## Discussion

Starting from a common conceptual picture of the microbiome as resting within a stability landscape, we have developed a mathematical model of its response to perturbation by antibiotics. Our framework, based on phylogenetic diversity, successfully captures the dynamics of a previously published dataset for four common antibiotics (3), providing quantitative support for these simplifying ecological assumptions. Using model selection, our framework provides additional insight compared to other methods — we identify a state transition in the oral microbiome with clindamycin, which was not detected by the initial authors using a GLM repeated measures test.

While pairwise comparisons based on diversity can still identify differences in microbiome state, they provide no information on microbiome dynamics. Our dynamical systems approach therefore also gives additional mechanistic insight in this regard. Zaura et al. observed that the lowest diversity in the gut microbiome was observed after a month rather than immediately after treatment stopped (3). This cannot be due to a persistence of the antibiotic effect, as all antibiotics used only have short half-lives of the order of hours (37,38). Within our framework, this is because the full effects of the transient impulse take time to be realised due to the overdamped nature of the system. We found a consistent damping ratio for both ciprofloxacin and clindamycin, supporting this conclusion.

We have also demonstrated how our modelling framework could be used to compare different hypotheses about the long-term effects of antibiotic perturbation by fitting different models and using Bayesian model selection. Our modelling work provides an additional line of evidence that while short-term restoration obeys a simple impulse response model, the underlying long-term community state can be fundamentally altered by a brief course of antibiotics, as suggested previously by others (7), raising concerns about the long-term impact of antibiotic use on the gut microbiome. While this state transition may not necessarily equate to any negative health impacts for the host (none of the participants involved in the original study reported any gastrointestinal disturbance), in the gut microbiome the transition to a new state with reduced diversity may increase the risk of colonisation and overgrowth of pathogenic species. Interestingly, in the salivary microbiome the transition appeared to be to a state with increased diversity, which is associated with a greater risk of disease in the oral cavity (39). This observation was not noted by Zaura et al. — a significant difference was detected in diversity in one antibiotic but was relegated to a supplementary figure and not discussed (3) — perhaps because it appeared contradictory to their other conclusions. However, we believe it makes sense within a stability landscape framework. Even if only marginal, when considered at a population level these effects may mean that antibiotics have substantial negative health consequences which could support reductions in the length of antibiotic courses, independently of concerns about antibiotic resistance (40). Modelling the long-term impact on the microbiome of different doses and courses could help to influence the use of antibiotics in routine clinical care. Our sample size is small, so the precise posterior estimates for parameters that we obtain should not be over-interpreted, but comparing antibiotics using these parameter estimates represents another practical application.

Our framework lends itself naturally to comparing different dynamical models. We see our two variant models as a starting point for a stability landscape approach, and would hope that better models can be constructed. Hierarchical mixed effects models may offer an improved fit, particularly if they take into account other covariates; however, we lacked the necessary metadata on the participants from the original study (Table 1) to explore the performance of such models. Furthermore, diversity as a single metric clearly fails to capture all the complexity of the microbial community and its interactions, and there are multiple issues with calculating it accurately. Nevertheless, the observation that treating phylogenetic diversity as the key variable in the stability landscape captures microbiome dynamics supports observations of functional redundancy in the gut microbiome (27). An interesting extension of this work would be to systematically fit the model to a variety of diversity metrics or other summary statistics and assess the model fit to see which metric (or combination of metrics) is most appropriately interpreted as the state variable parameterising the stability landscape. A possible complementary approach could consider or incorporate the resistome, which should conversely rise in diversity after antibiotic treatment (41).

We would not expect the behaviour of the microbiome after longer or repeated courses of antibiotics to be well-described by an impulse response model which assumes the course is of negligible duration. Nevertheless, it would be possible to use the mathematical framework given here to obtain an analytic form for the possible system response by convolving any given perturbation function with the impulse response. It remains to be seen whether this simple model would break down in such circumstances.

As we have demonstrated, while the individualized nature of the gut microbiome’s response to antibiotics can be highly variable, a general model still captures important microbiome dynamics. We believe it would be a mistake to assume that our model is ‘too simple’ to provide insight on a complex ecosystem. At this stage of our understanding, creating a comprehensive inter-species model of the hundreds of members of the gut microbiome appears intractable; it may also not be necessary for building simple models to inform clinical treatment based on limited and sparse data. We believe there is a place for both fine-grained models using pairwise interactions — particularly for systems of reduced complexity — and coarse-grained models built from high-level ecological principles, as we have demonstrated here. We have argued that this ‘top-down’ framework with multiple stable states of different diversities is consistent with the emergent behaviour of a multispecies Lotka-Volterra model. Further mathematical work to connect these two extremes would be worthwhile.

## Authors’ contributions

LPS conceived the model, performed analyses, and wrote the paper. LPS, CPB, HB, and FB conceived the analysis of the Lotka-Volterra system, which was performed by HB. All authors contributed to the discussion and development of the model, gave comments, and read and approved the final manuscript.

## Data availability

The original sequencing dataset from Zaura et al. (3) used in this paper is available in the Short Read Archive (SRA Accession: SRP057504). Full code and reanalyzed datasets supporting the conclusions of this article are included as Supplementary Information (Supplementary Files 2—8). A full archive of analyses including cached model fits is available in figshare (https://figshare.com/s/d62d6e90f96dc63c2769.)

## Materials and methods

### Mathematical model of trajectories in the potential landscape

Treating the microbiome as a unit mass resting in a stability landscape parameterised by phylogenetic diversity leads to a second-order differential equation. To solve this equation, we assume that b^{2} > 4*k* (the ‘overdamped’ case) based on the lack of any oscillatory subject to the initial conditions *x*(0^{+}) = 0 and , we obtain the following equation behaviour previously observed in the microbiome, to the best of our knowledge. Then, describing the system’s trajectory:

Fitting the model therefore requires fitting three parameters: *b* (the damping on the system), *k* (the strength of the restoring force), and *D*(how strong the perturbation is). For the purposes of fitting the model, we choose to reparameterise the model using the following definitions:

Resulting in the following model (Model 1, Figure 1C):

Antibiotics may lead not just to displacement from equilibrium, but also state transitions to new equilibria (2). To investigate this possibility, we also consider a model where the value of equilibrium diversity asymptotically tends to a new value *A* (Model 2, Figure 1C). As we are aiming to minimise model complexity, we do this by adding a single parameter and a term that asymptotically grows as time increases:

### Experimental data

To validate our model and test whether antibiotic perturbation caused a state transition we fitted both models to an empirical dataset and compared the results. Zaura et al. (3) conducted a study on the long-term effect of antibiotics on the gut microbiome which provides an ideal test dataset. As part of this study, individuals were randomly assigned to one of five treatment groups: placebo, clindamycin, ciprofloxacin, minocycline, amoxicillin. The antibiotics and placebo were administered for at most τ =10days (150 mg clindamycin four times a day for ten days; 500 mg ciprofloxacin twice a day for ten days; 250 mg amoxicillin three times daily for seven days; 100mg minocycline twice daily for five days) and longitudinal faecal and saliva samples collected until *T*=1year afterwards i.e., so the approximation of the antibiotics as an impulse perturbation should be valid. Samples were collected at baseline, after treatment, one month, two months, four months, and one year. Samples underwent 16S rRNA gene amplicon sequencing, targeting the V5-V7 region (SRA Accession: SRP057504). We reanalysed this data, performing de novo clustering into operational taxonomic units (OTUs) at 97% similarity with VSEARCH v1.1.1 (42) with chimeras removed against the 16S gold database (http://drive5.com/uchime/gold.fa). Taxonomy was assigned with RDP (43). For more details see Supplementary File 2. The reanalyzed datasets are available as R phyloseq objects (Supplementary Files 3 and 4). We found no association between sequencing depth and timepoint.

### Phylogenetic diversity

There are many possible diversity metrics that could be used to compute the displacement from equilibrium. Because of our assumption that phylogenetic diversity approximates functional potential, which is itself a proxy for ecosystem ‘health’ (see ‘Ecological assumptions’), we chose to use Faith’s phylogenetic diversity (44) calculated with the pd ( ) function in the ‘picante’ R package v1.6-2 (45). Calculating this branch-weighted phylogenetic diversity requires a phylogeny, which we produced with FastTree v2.1.10 (46) after aligning 16S rRNA V5-V7 OTU sequences with Clustal Omega v1.2.1 (47). To obtain values for fitting the model, we used mean bootstrapped values (*n*=100,sampling depth *r* = 1000) of phylogenetic diversity *d*_{i} relative to the baseline phylogenetic diversity *d*_{0}for each individual (Supplementary File 1), representing the displacement from equilibrium in our model:

### Bayesian model fitting

We used a Bayesian framework to fit our basic model 1 (eq. 3) using Stan (48) and Rstan (49) to the gut and oral microbiome samples for the five separate groups: placebo, ciprofloxacin, clindamycin, minocycline, and amoxicillin (i.e. *n=*2×5=10 fits). In brief, our approach used 4 chains with a burn-in period of 1 000 iterations and 9 000 subsequent iterations, verifying that all chains converged and the effective sample size for each parameter was sufficiently large (neff > 1 000). We additionally fitted model 2 with a possible state transition (eq. 4) to all non-placebo groups (*n=*2×4=8 fits).

We used non-informative priors for all parameters in the original model 1 without a state transition (eq. 3). For all groups, we used the same uniformly distributed prior for D (positive i.e. decrease in diversity) and uniform priors for Ø_{1}, Ø_{2}, For fitting model 2, we used an additional uniform prior centred at zero for the new equilibrium value and the same priors for other parameters. In summary, the priors are as follows:

We compared models 1 and 2 (Supplementary Files 5 and 6). for each antibiotic treatment group using the Bayes factor (31,50) after extracting the model fits using bridge sampling with the bridgesampling R package v0.2-2 (51). A prior sensitivity analysis (not shown) showed that choice of priors did not affect our conclusions about model selection, although the strength of the Bayes factor varied.

Full code for fitting the models to empirical data and reproducing figures is available with this article (Supplementary Files 2—6).

### Lotka-Volterra simulations

We numerically simulated 5_{9}1 953 125parameter sets of the Lotka-Volterra model with *n=*3 species and investigated their behaviour and stable states. For more details see the corresponding supplementary discussion (Supplementary File 7) and Mathematica notebook (Supplementary File 8).

## Supplemental Information: Legends

**Supplementary File 1: Supplementary-Figure-1.pdf. Differences in individual response over time for the top twelve most abundant taxonomic families for placebo, clindamycin, and ciprofloxacin.** Relative abundances (log-scale) of the top twelve most abundant bacterial families plotted at each sampled timepoint. Observations are linked by coloured lines for each individual. Despite some consistency in changes between antibiotics across individuals, there is inter-individual variability and evidence of possible interactions between bacterial families.

**Supplementary File 2: Shaw-et-al-analysis.Rmd. All main analyses.** R markdown notebook for reproduction of the results in this paper, containing all analysis code. If run using Supplementary Files 3—6 this notebook produces: data files of bootstrapped phylogenetic diversity for all individuals; model fits; and resulting figures. A full archive including cached model fits and results is available on FigShare: https://figshare.com/s/d62d6e90f96dc63c2769 (doi available pending publication).

**Supplementary File 3: gut-data-phyloseq.rds. R phyloseq object containing reanalyzed gut microbiome data.**

**Supplementary File 4: oral-data-phyloseq.rds. R phyloseq object containing reanalyzed oral microbiome data.**

**Supplementary File 5: model1.stan. Stan code for defining and fitting Model 1.**

**Supplementary File 6: model2.stan. Stan code for defining and fitting Model 2.**

**Supplementary File 7: Lotka-Volterra-supplementary.pdf. Details of Lotka-Volterra model simulations.** Detailed text and discussion reporting numerical simulations investigating behaviour predicted from the stability landscape framework using a Lotka-Volterra model in 3 dimensions.

**Supplementary File 8: Lotka-Volterra-notebook.nb. Mathematica notebook of Lotka-Volterra simulations.** Interactive notebook containing code necessary to reproduce the analysis and figures in Supplementary File 7.

## Acknowledgements

LPS was supported by the Engineering and Physical Sciences Research Council [EP/F500351/1] and the Reuben Centre for Paediatric Virology and Metagenomics. CPB is supported by the Wellcome Trust [097319/Z/11/Z]. We are grateful to the authors of the original study (3) for making their data openly available, enabling the reanalysis with our modelling framework presented here.

## Footnotes

(liam.philip.shaw{at}gmail.com)

(hassan.bassam.17{at}ucl.ac.uk)

(christopher.barnes{at}ucl.ac.uk)

(rmjlasw{at}ucl.ac.uk)

(n.klein{at}ucl.ac.uk)

(f.balloux{at}ucl.ac.uk)

**Competing interests:**The authors declare that they have no competing interests.