# A unifying framework for interpreting and predicting mutualistic systems

## Abstract

Coarse-grained rules are widely used in chemistry, physics and engineering. In biology, however, such rules are less common and under-appreciated. This gap can be attributed to the difficulty in establishing general rules to encompass the immense diversity and complexity of biological systems. Furthermore, even when a rule is established, it is often challenging to map it to mechanistic details and to quantify these details. Here we report a framework that addresses these challenges for mutualistic systems. We first deduce a general rule that predicts the various outcomes of mutualistic systems, including coexistence and productivity. We further develop a standardized machine-learning-based calibration procedure to use the rule without the need to fully elucidate or characterize their mechanistic underpinnings. Our approach consistently provides explanatory and predictive power with various simulated and experimental mutualistic systems. Our strategy can pave the way for establishing and implementing other simple rules for biological systems.

## Introduction

Mutualism, where two or more populations provide reciprocal benefit, is an essential type of ecological interaction1. In marine ecosystems, coral reefs are based on mutualistic interactions between coral and algae, and provide ecosystem services for humans and habitats for diverse organisms2. Plant–bacterial mutualism is estimated to generate 60% of the annual terrestrial nitrogen input3. Mutualism also influences microbial community structures and is the cornerstone of various microbial metabolic tasks4,5. Although mutualistic coexistence is beneficial in maintaining the biodiversity, function and stability of ecosystems, under some conditions mutualistic systems can collapse, where one or more mutualistic partners is lost, and the persisting partners also experience a reduction in fitness. This perturbation can further trigger the loss or invasion of other populations and alter ecosystem functions6,7,8,9. A framework to interpret and predict mutualistic outcomes is useful to prevent undesirable system behaviors and provide guidance for modulating and engineering mutualistic systems.

Quantitative rules have been developed to elevate our understanding and provide predictive power for various biological systems10,11,12,13. However, such a framework is not yet available for determining mutualism outcomes. Main barriers in developing such a framework are the diversity of mutualistic interaction mechanisms and the complexity of underlying dynamics. Indeed, even engineered mutualistic systems that are by-design capable of cooperation, may not coexist. For example, it is still difficult to predict a priori whether an engineered microbial auxotrophic pair can persist or not14,15,16. Previously, theoretical criteria in the form of inequalities have been developed for specific mutualistic systems such as cross-feeding mutualisms17, plant–pollinator mutualisms18, seed-dispersal mutualisms19, ant–plant mutualisms20, and plant–mycorrhizal mutualisms21. These criteria depend on the underlying mechanisms assumed in the models and are not applicable to other types of mutualistic systems. General criteria have been developed22,23,24,25, such as the classic criterion which states that intraspecific competition must be greater than mutual benefit for a mutualistic system to be stable26. However, these usually describe transitions between stable coexistence and unbounded growth, and fail to address the transitions between coexistence and collapse and other mutualism dynamics27,28 (Supplementary Figure 1, Supplementary Note 1).

Here, we establish a general framework for predicting and interpreting mutualistic systems. We first generate a wide variety of mutualism mathematical models and identify a general rule that predicts mutualism outcomes for all these models. We then develop a calibration procedure using support vector machines (SVMs) to apply the rule to various simulated and experimental systems with different layers of complexities. The interpretation and predictability provided by our framework demonstrate the feasibility of describing a class of diverse biological systems with a simple quantitative rule.

## Results

### Abstraction reveals a general rule

To reveal any commonality of mutualistic systems, we first summarized the logic of mutualism (Fig. 1a). Mutualism can be defined as the collective action of two or more populations, where each population produces benefit (β) that reduces the other’s stress (δ) at a cost (ε) to itself. β, δ, and ε are universal features of mutualistic systems (Table 1). In addition to benefit and cost, which are conventionally considered as the driving forces of mutualistic outcomes29,30,31, we included stress to capture the reduction of baseline fitness of individual populations from their maxima. Although stress is not always explicitly acknowledged in previous models, evidence indicates that it is a determining factor of mutualistic outcomes32,33,34. Incorporating stress can thus provide a more complete picture of mutualistic behavior (see Supplementary Note 2.1 for the detailed reasoning). Note that, in this study, we aim to capture ecological population dynamics only, and do not explicitly include evolutionary dynamics.

To reflect the diversity of natural mutualistic systems, we systematically generated a total of 52 ordinary differential equation models based on this basic logic of mutualism with various implementation details (see Methods and Supplementary Note 2.2 for model assumptions). These implementation details are designed to comprehensively cover the various common and plausible forms of kinetic models that have been adopted in previous studies (see Supplementary Note 2.3 for a summary). Specifically, the models all revolve around the logistic growth equation but differ in the locations of β, ε, and δ in the logistic growth equations, enabling constant, linear and saturating effects of ε, as well as saturating effects of β. Our models also include complexities such as competition, asymmetry, and turnover rate. We only increased the model complexity to an extent that closed-form steady state solutions are obtainable (see Supplementary Notes 2.32.5 for model construction rationales and details).

We derived coexistence criteria for all 52 models by requiring the coexistence steady state to be real and positive. This allows us to find the inequality that governs the transition between coexistence and collapse. For example, the following simple mutualism model has five fixed points (model 21 in Supplementary Table 1):

$$\frac{{d{ X}_1}}{{d\tau }} = \frac{1}{\varepsilon }{ X}_1\left( {1 - { X}_1} \right) - \frac{\delta }{{\beta { X}_2 + 1}}{ X}_1{.}$$
(1)
$$\frac{{d{ X}_2}}{{d\tau }} = \frac{1}{\varepsilon }{ X}_2\left( {1 - { X}_2} \right) - \frac{\delta }{{\beta { X}_1 + 1}}{ X}_2{.}$$
(2)

The fixed point that represents coexistence is:

$$\begin{array}{c}\left( {{ X}_1^ \ast ,{ X}_2^ \ast } \right) = \left( {\frac{{\beta - 1 + \sqrt {\left( {\beta + 1} \right)^2 - 4\beta \varepsilon \delta } }}{{4\beta }}} \right.,\\ \left. {\frac{{\beta - 1 + \sqrt {\left( {\beta + 1} \right)^2 - 4\beta \varepsilon \delta } }}{{4\beta }}} \right)\end{array}{.}$$
(3)

For this fixed point to be real and positive, the following inequality must hold (see Supplementary Note 3.1 for details):

$$\frac{{\left( {\beta + 1} \right)^2}}{{4\beta \varepsilon }} \ge \delta \,\left( {\beta \ge 1} \right){.}$$
(4)

Using this approach, our derived criteria exhibit diverse structures (Fig. 1b, Supplementary Tables 1 and 2, also see Supplementary Note 3 and Supplementary Software 1). The diversity of our criteria is consistent with the diversity of criteria that already exist in the literature17,18,19,20,21. This diversity highlights the need to have a general rule, since the appropriate model formulation for a specific system is often unknown a priori and its selection can also be nontrivial35.

Despite the diversity, at an appropriate abstraction level, however, all criteria follow a simple general form (Fig. 1c):

$$B\left( {\boldsymbol{\theta }} \right) > \delta{,}$$
(5)

where θ denotes model parameters including β, ε, asymmetry, turnover rate, and other model complexities. B(θ) represents the effective benefit produced through mutualistic interaction. Quantitatively, B(θ) increases with increasing β and decreasing ε and its structure differs depending on the specific model. δ represents stress; it is determined as 1 − rm, where rm is the growth rate of the population in the absence of its mutualistic partner and normalized by its maximum growth rate. The interpretation of our criterion is intuitive: mutualistic partners can coexist if the effective benefit exceeds stress, and the system collapses when the inequality is violated (Fig. 1d). Note that although alternative forms of the criterion may exist, Eq. (5) is the most intuitive and parsimonious form.

When both asymmetry and competitive interactions are incorporated, the models can also exhibit transitions between coexistence and competitive exclusion besides the transition between coexistence and collapse. Although both transitions are characterized by the loss of one or more populations, our model dynamic shows that collapse corresponds to lowered fitness of persisting partners, but competitive exclusion corresponds to an increased fitness of persisting populations. While many mutualistic systems also have competitive interactions36,37,38, the transition to competitive exclusion cannot be generated by a mutualism interaction alone (see Supplementary Note 3.3.7 for more detailed discussion). Thus, we did not derive our criterion to predict competitive exclusion.

Beyond determining qualitative system outcomes (coexistence versus collapse), B/δ defines a general metric that is also positively related to quantitative mutualistic outcomes (Fig. 1e), such as final population density, probability of coexistence, and resistance to cheater exploitation. The predictive power of the metric is robustly maintained for both symmetric and asymmetric systems, including obligate and facultative mutualistic systems (Supplementary Figure 2a–f, Supplementary Note 4). Further, the theoretical prediction accuracy of our criterion is also robustly maintained in the presence of noise (Supplementary Figure 2g). The generality of the metric indicates that it is a general property of the class of mutualism models we have constructed and is a quantitative description of a core characteristic of mutualism. If so, B is a high-level feature that, along with δ, provides a unifying framework for interpreting and predicting diverse mutualistic systems.

### A calibration approach to use the metric

Quantification of both B and δ are required to use the metric. Although δ is often easy to measure since it is a property of individual populations (see Supplementary Figure 3 for the general quantification procedure), quantification of B, which describes the interactions, is often challenging. Beyond the difficulties of selecting an appropriate structure for B(θ), quantification of its underlying parameters often requires nontrivial mechanistic characterizations, such as parameter fitting and specific biochemical assays. These mechanistic characterizations are especially challenging for cooperative traits, even in well-defined synthetic systems39,40,41. Applications of the criterion would thus be difficult for individual systems, let alone enabling streamlined applications for diverse mutualistic systems.

To bypass these challenges, we developed a calibration procedure to use qualitative outcomes to directly quantify B as an empirical function of experimentally controllable variables (v), denoted by B(v) (Fig. 2a). Specifically, v consists of variables that modulate system outcomes directly or indirectly, such as temperature, nutrient availability, genetic variation, initial seeding distance, and the extent of intermixing. v measurements are often readily available, especially in laboratory settings where they are experimentally controlled independent variables. Thus, using simple measurements, we can approximate the true B(θ(v)) that describes the diverse and complex interaction mechanisms without characterizing the specific mechanistic details. The calibrated B(v) along with δ, will serve as the basis for interpretation and prediction beyond initial data. Although the procedure requires initial measurements of qualitative outcomes, B(v)/δ can also provide predictive power for quantitative outcomes (Fig. 1e). Based on our theoretical analyses, we then expect B(v)/δ to be positively related to the final density, probability of coexistence, and cheater resistance. Further, B(v) can be used to reveal how multiple system variables collectively alter the effectiveness of the interaction, which is a major challenge in studying context dependency of mutualistic outcomes42.

We first defined the input–output relationship of the calibration procedure (Fig. 2b). Measurements of qualitative outcomes are denoted as Y = [y1,y2,y3,…yn] (yi = 1 for coexistence and −1 for collapse; i represents the index of an observation; n represents the total number of observations). Measurements of δ for the same observations are denoted as δ = [δ1,δ2,δ3,…δn]. Note that theoretically, quantification of δ for any partner is sufficient. However, choosing the partner with a larger dynamic range of δ is preferable since it can contain more information content. The context variables are denoted by v = [v1,v2,v3,…vn], where vi is a vector that contains the values of all system variables for observation i. With inputs Y, δ and v, we can establish a smooth boundary between coexistence and collapse described by F(δ,v) = 0. To ensure B > δ for coexistence and B < δ for collapse, we constrain F(δ,v) > 0 for coexistence and F(δ,v) < 0 for collapse. Because B = δ is true at the boundary, we can deduce that F(B,v) = 0. According to the implicit function theorem, if F(B,v) = 0 is continuously differentiable, the output B(v) is implied. A calibrated B(v) can then enable downstream interpretation and prediction.

To implement the calibration, we used the support vector machine (SVM), a machine-learning algorithm for supervised classification (see Supplementary Notes 5.15.4 and Supplementary Software 1). Assuming continuity of B(v), we used kernels that are separable in δ and v to obtain F(δ,v) = 0. We implemented linear, quadratic, cubic, and sigmoidal kernels to describe possible shapes of B(v). Because there are infinite number of B(v) that can provide equivalently high-classification accuracy, we ranked the B(v) obtained from different kernels and different kernel parameters to find the B(v) that are closer to the true B(θ(v)) (Supplementary Figure 4a). The ranking method is established using simulated data where the true B(θ(v)) is known, so that each B(v) can be evaluated against B(θ(v))by coefficient of determination (R2). We found that our procedure consistently optimizes for R2 (Supplementary Figure 4b, c; see Supplementary Note 5.5 for figure details). The proper sample size for the calibration can be evaluated using the exponential decay of bias with increasing sample size43 (Supplementary Figure 4d).

Using this procedure, we first tested whether B(v)/δ can be applied to mutualism models in which no explicit form exists for B(θ). To do so, we constructed an overwhelmingly complex two-population model with competition, partner-density-dependent cost, high Hill coefficient and asymmetric function structures (see Supplementary Note 5.6, Supplementary Figure 5a). Model parameters are functions of v1 and v2 (Supplementary Figure 5b). Using an input data set of 100 points (Supplementary Figure 5c), B(v)/δcorrectly predicts coexistence versus collapse for 97.2% of test data beyond the initial 100 data points. Detailed step-by-step calibration procedure is shown in Supplementary Note 5.7. As expected, B(v)/δ provides predictive power for quantitative outcomes including total population size (Fig. 2c), probability of coexistence (Supplementary Figure 5d) and resistance to cheater exploitation (Supplementary Figure 5e).

### Experimental applications in pairwise systems

We next applied our framework to three experimental systems to test its applicability. As the first example, we engineered two synthetic mutualistic partners in Top10F’ strain of Escherichia coli, denoted by M1 and M2 (Fig. 3a, Supplementary Figure 6a). In this system, stress is modulated by the concentration of Isopropyl β-D-1-thiogalactopyranoside (IPTG), which induces the expression of CcdB (a toxin). Independent from IPTG, anhydrotetracycline (aTc) induces quorum sensing (QS) modules in both strains to each produce a unique QS signal that triggers the production of CcdA (the antitoxin of CcdB) in the partner population. The production of aTc-induced expression of the QS module is responsible for the mutual benefit and can impose cooperation cost to both strains. Consistent with the circuit design, our experimental results demonstrated IPTG-mediated growth suppression and aTc-mediated mutual rescue (Supplementary Figure 6b).

We cocultured the two strains starting from the same initial density with different concentrations of IPTG and aTc, which are the two dimensions of v. The outcomes of coexistence and collapse are evident in the bimodal distribution of optical density (OD) at 32 h of culturing (Supplementary Figure 6c). δ can be quantified by treating monocultures with the same set of [IPTG] and [aTc]. We used δ for M2 since it has a wider dynamic range (Supplementary Figure 6d). Using these data (Fig. 3b), we obtained a calibrated B(v) (Fig. 3c). The confidence of B(v) is evaluated by the consistency of the top five B(v) and relative standard deviation of each B(v) (Supplementary Figure 6e). Consistent with the circuit logic, B(v) increases with increasing [aTc]. The calibration reveals that [IPTG] also modulates B(v), which indicates unintended system complexities, such as QS cross-talk and unequal fitness of the two populations. We used cross-validation to evaluate how well new observations can be predicted. We found that B(v)/δ provides an average cross-validation accuracy of 96.8% for coexistence versus collapse and it is also predictive of total final density (Fig. 3d).

We then applied our procedure to data on a pair of Saccharomyces cerevisiae auxotrophs that is previously published37. In this system, one strain cannot produce tryptophan (Trp) and the other cannot produce leucine (Leu). The mutualistic interaction of this system is realized by the exchange of the two amino acids in cocultures (Fig. 3e). Because [Leu] is maintained as eight times of [Trp], we used [Trp] as one dimension of v to represent overall concentration of supplemented amino acid. The authors also varied the ratio of initial densities which composes the other dimension of v (Fig. 3f, Supplementary Figure 7a). All top five B(v) reveal that intermediate ratios of initial density and increasing amino acid concentrations elevate B(v) (Fig. 3g). However, at the highest level of supplemented amino acid ([Trp] = 16 nM, [Leu] = 128 nM), top-ranked B(v) have qualitatively different trends, indicating a low confidence of B(v) at high concentration (Supplementary Figure 7b). Although our criterion does not apply to the transition between coexistence and competitive exclusion, this high variability coincides with the system transitioning into competitive exclusion37. Nevertheless, B(v)/δ is still predictive of final densities with an average cross-validation accuracy of 95.0% (Fig. 3h). Furthermore, we explored using the concentration of supplemented amino acid as a single system variable. B(v)/δ in this case can also predict the probability of coexistence as the ratio of initial densities varied (Supplementary Figure 7c).

In the third example, we applied our framework to previously published measurements of 14 engineered auxotrophic E. coli strains that compose 91 pairwise mutualistic systems44 (Fig. 3i). The genetic context of the two partners varies while the growth environment was kept the same. The classification of coexistence versus collapse is based on the bimodal distribution of total density (Supplementary Figure 8a). δ of each auxotroph is determined based on final cell densities of monocultures when supplemented with different concentrations of its corresponding amino acid (Supplementary Figure 8b). We sorted the auxotrophs by the number of partners they coexist with to convert categorical indices into an ordinal scale. Thus, v is composed of ordinal rankings of the two strains and measurements of coexistence versus collapse and δ are both arranged accordingly (Fig. 3j). We used strain 1 as the reference strain for the calibration. The calibrated B(v) generated a cross-validation accuracy of 91.8% and we verified that B(v)/δ is predictive of final total density (Fig. 3k, Supplementary Figure 8c). We noticed a relatively high level of variability of total density when B(v)/δ > 1, which can be due to system-specific properties that are not fully accounted for by mutualistic interactions.

### Applications in more complex settings

In nature, mutualism can occur among three or more partners45. Thus, we tested our framework with simulations and experimental measurements of N-mutualist systems. Here, we show the calibration procedure with simulated data from a 5-mutualist system and found that the quality of the calibration results is well-maintained (Fig. 4a, Supplementary Figure 9a, Supplementary Note 6.1). The study that constructed the 14 auxotrophs44 also presented all possible three-member double-auxotroph systems with the same set of amino acid deficiencies. Using the same procedure with a three-dimensional v, where each dimension represents one amino acid the triplets are sharing, we found the predictor B(v)/δ provides an 89.3% cross-validation accuracy and remains predictive of the total density, which indicates the scalability of the framework in experimental settings (Fig. 4b, Supplementary Note 6.2). Additionally, we hypothesized that B(v) calibrated for pairwise interactions can be used to directly construct a metric for three-member systems, since theoretical analysis shows that n-member B(θ) can be approximated by pairwise B(θ) (Supplementary Table 2). We assume B of a three-member system is the average of B for all three combinations of its underlying two-population systems and the same is true for δ. The constructed B/δ for three-member systems can explain 80.8% of system outcomes (Supplementary Figure 9b). This result suggests the possibility of directly extending B and δ from simple systems to more complex systems without further calibration.

Beside static environments, mutualistic systems can also inhabit dynamic environments where they experience fluctuating physical and chemical cues or cohabitate with other populations. We verified that the theoretical criterion generally holds in both cases (Supplementary Figure 10a). However, the transition between collapse and coexistence does not strictly occur at 1, which further advocates for the necessity of the calibration procedure. With simulated data, we carried out the calibration procedure and verified that the applicability of our framework is well-maintained (Fig. 4c, d, Supplementary Figure 10b, Supplementary Notes 6.3 and 6.4). The robustness of the framework suggests that it can be used to study microbial communities, of which advancements in both interpretation and prediction are in demand46.

Mutualistic systems can generate complex temporal dynamics. For example, a mutualistic system that exhibits limit cycles has been previously reported47. The system is comprised of two E. coli strains that one is resistant to ampicillin and the other is resistant to chloramphenicol. When mixed together, the two strains deactivate the antibiotic they are resistant to and provide protection to the other sensitive strain (Supplementary Figure 11a). With periodic dilution, the relative abundance of the two strains oscillate over time. We used the model published in this previous study to simulate the growth dynamics at different antibiotic concentrations (Supplementary Figure 11b). Despite the oscillatory dynamics (Supplementary Figure 11c), our calibration procedure still reliably predicts coexistence versus collapse and provides an average cross-validation accuracy of 96.8% (Supplementary Figure 11d, e).

## Discussion

The immense complexity and diversity of biological systems is intriguing and inspires the exploration of mechanistic details. However, these details can distract us from simple rules that emerge at a higher level. By abstracting away from low-level details, many simple rules for biological systems have been developed to enhance our understanding and provide predictive power. A classic example is the Hamilton’s rule, which states that a cooperative trait will persist if $$\frac{c}{b} < r$$, where r is the relatedness of the recipient and the actor; b is the benefit gained by the recipient; and c is the cost to the actor. More recent examples include linear correlations underlying cell-size homeostasis in bacteria48,49,50, ranking of quorum sensing modules according to their sensing potential51,52, and the growth laws resulting from dynamic partitioning of intracellular resources53,54.

Beyond establishing another simple rule, by focusing on mutualistic interactions, we also demonstrated that one can purposefully seek an appropriate abstraction level where a simple unifying rule emerges over system diversity. If this rule anchors in the basic definition of a type of system, it can then be applied to diverse systems of the same type. Beyond microbial systems that we tested, our criterion in principle can also be applied to other systems of larger or smaller scales that share the same logic.

In our demonstrations, we have focused on the analysis of homogenous systems. To account for the spatial dimension55,56, one can incorporate spatial variables into our framework as context variables (v). For example, the context variable can be the seeding distance of two partners or the degree of intermixing of the seedings. Calibrated B(v) will then be dependent on these spatial variables. Alternatively, the criterion can be applied to local segments where the homogeneity assumption is appropriate. In general, it remains an open question whether and to what extent our approach would be applicable if the mutualistic system becomes much more complex than what we have tested, such as systems consisting of multiple attractors that all correspond to coexistence.

Although simple general rules in biology can be powerful tools, their applicability to experimental systems can be limited by the difficulties in associating the abstracted parameters to lower-level mechanistic details and quantifying these details experimentally. This is evident in the application of Hamilton’s rule to experimental systems39,40,41. For many inequality-based simple rules that have been proposed and established10,57,58, our calibration procedure provides a generally applicable tool to apply these rules directly to experimental systems. If one side of the inequality and some final outcomes can be measured or have been observed historically, the other side can be calibrated as an empirical function. Although our procedure cannot further dissect the empirical function into specific mechanistic parameters, the function can serve as an overall summary of the underlying mechanistic details while bypassing the requirement of characterizing them individually. Our approach thus can enable the downstream interpretation and prediction by these simple rules with readily accessible measurements.

## Methods

### Model development

We built mutualism models based on four key assumptions:

1. (a)

Benefit shall increase growth rate or carrying capacity and is positively dependent on partner density.

2. (b)

Cost shall decrease growth rate or carrying capacity.

3. (c)

Stress shall produce negative growth of populations at some parameter combinations.

4. (d)

Negative growth of a population shall be potentially counteracted by benefit provided by a partner, but further strengthened by cost.

See Supplementary Note 2 for detailed reasoning and implementation of each assumption.

### Criteria derivation

We calculated the analytical solutions of fixed points of the 52 models using MATLAB R2017a. Then we identified the fixed points that represent stable coexistence. The coexistence criteria are derived by ensuring the fixed points are real positive numbers. We can then rearrange the inequality to have δ on one side. The other side of the inequality is then an expression of other parameters, which is expressed as B(θ). All criteria were verified using time course simulations. More details are presented in Supplementary Note 3. The MATLAB code of the models and the derivation and testing process is included in the Supplementary Software 1.

### Calibration procedure using SVM

We used SVM algorithms in MATLAB to implement the calibration. The input data are formulated as following:

$${\mathrm{Label}}\,{\mathrm{of}}\,{\mathrm{coexistence}}\,{\mathrm{versus}}\,{\mathrm{collapse:}}\quad {\boldsymbol{Y}} = [y_1, \cdots ,y_i, \cdots ,y_n]{.}$$
(6)
$${\mathrm{System}}\,{\mathrm{variables:}}\quad {\boldsymbol{v}} = \left[ {{\boldsymbol{v}}_1, \cdots ,{\boldsymbol{v}}_{\boldsymbol{i}}, \cdots ,{\boldsymbol{v}}_{\boldsymbol{n}}} \right]{.}$$
(7)
$${\mathrm{Stress}}\,{\mathrm{of}}\,{\mathrm{the}}\,{\mathrm{reference}}\,{\mathrm{population:}}\quad {\boldsymbol{\delta }} = [\delta _1, \cdots ,\delta _i, \cdots ,\delta _n]{.}$$
(8)

In Eqs. (6)–(8), n represents total number of observations and each index represents one observation. Y takes values of 1 or −1, which represent coexistence versus collapse for each observation. v contains the coordinates where observations are obtained and vi is a vector of which each element represents a context variable. For a system with two system variables,vi = (vi1,vi2). δ contains the stress level of the reference population for each observation i. v and δ are first standardized to vs and δs that have mean of 0 and standard deviation of 1. For simplicity of presentation, the following v and δ are standardized.

We designed kernels that have additive separability between v and δ, which can be expressed in a general form:

$$K\left\langle {\left[ {{\boldsymbol{v}}_{\boldsymbol{i}},\delta _j} \right],\left[ {{\boldsymbol{v}}_{\boldsymbol{j}},\delta _j} \right]} \right\rangle = K_v\left\langle {{\boldsymbol{v}}_{\boldsymbol{i}},{\boldsymbol{v}}_{\boldsymbol{j}}} \right\rangle + k_\delta \left( {\delta _i \cdot \delta _j} \right).$$
(9)

Kv is the kernel that dictates the shape of the empirical function of B and kδ is a kernel parameter. The predictor trained using SVM is:

$$f\left( {[{\boldsymbol{v}},\delta ]} \right) = \mathop {\sum }\limits_i \alpha _iy_iK_v\left\langle {{\boldsymbol{v}}_i,{\boldsymbol{v}}} \right\rangle + k_\delta \delta \mathop {\sum }\limits_i \alpha _iy_i\delta _i + \lambda _0.$$
(10)

αi is the weight of observation i, and λ0 is the bias term. Both αi and λ0 are optimized by the SVM algorithm. yi, vi, and δi are input values for observation i.

According to our criterion, we know that B = δ when f([v,δ]) = 0. We can then derive B0(v), a primitive function of B, from Eq. (10):

$$B_0\left( {\boldsymbol{v}} \right) = \delta = \frac{{ - \mathop {\sum }\nolimits_i \alpha _iy_iK_v\left\langle {{\boldsymbol{v}}_i,{\boldsymbol{v}}} \right\rangle - \lambda _0}}{{k_\delta \mathop {\sum }\nolimits_i \alpha _iy_i\delta _i}}.$$
(11)

To obtain B(v), B0(v) is then adjusted for directionality and rescaled back according to mean and standard deviation of the original δ measurements.

To find the optimal B(v), we used linear, quadratic, cubic, and sigmoidal kernels with a range of kernel parameters to train many different B(v). The optimal B(v) has the lowest overall cross-validation classification loss and bootstrapped variance. A final B(v) is then used along with δ measurements for interpretation and prediction. See Supplementary Note 5 for the detailed calibration method. For graphical representations of the step-by-step procedure see Supplementary Figure 4a and specifically Supplementary Note 5.7. We also have included in the Supplementary Software 1 the calibration procedure and sample data sets.

### QS-based mutualism strains

The two strains were constructed based on circuit components from a synthetic predator-prey system59,60. Both populations carry two plasmids. Briefly, M1 carries plasmids identical to the predator plasmids, denoted A1 for the module carrying ccdA (tet promoter61 driving luxR and lasI followed by lux promoter driving ccdA) and B1 for the module carrying ccdB (Lac promoter61 upstream of ccdB followed by tet promoter upstream of gfp). To construct M2, A1 was used as backbone. To obtain orthogonal communication, KpnI and NotI restriction digest cloning was used to replace luxR/lasI genes from A1 with lasR/luxI genes from the previously published prey plasmid (consisting of pLac lasRluxI CcdB (KanR, p15A ori)). Reporter plasmid B1 is from59. To construct B2, enzymes XhoI and KpnI were used to replace the tet promoter on prey plasmid with the ccdB module from B1. All M1 and M2 plasmids were verified using restriction digest and sequencing.

### Growth conditions of QS-based synthetic system

The experiments of QS-based mutualistic system were done in 96-well microtiter plates. PH-buffered M9 medium (M9 salt supplemented with 1 mM thiamine, 0.2% casamino acid, 0.4% glucose, 2 mM MgSO4, 0.1 mM CaCl2 and buffered with 100 mM MOPS with PH adjusted to 7.0) was used. Totally, 50 μg/ml kanamycin and 100 μg/ml chloramphenicol were added to the culture to maintain plasmids.

To measure circuit function, 4 ml LB media in a 14 ml culture tube was inoculated from single colony and incubated overnight at 37 °C at 250 r.p.m. The optical density is adjusted to 0.5 in M9 media (measured at 600 nm with TECAN microplate reader) before use. Cocultures are created by mixing both strains in a 1:1 volume ratio. The culture is then diluted 106-fold and cultured in 200 μL batch culture at 30 °C in TECAN plate reader to record OD for 32 h with 10 min between each reading. The inducers were added to the media at the beginning with cell culture.

### Code availability

The code used for data generation and/or analysis in the study are available as Supplementary Software 1.

## Data availability

The datasets generated during and/or analyzed during the study are available in the Supplementary Materials.

## References

1. 1.

Boucher, D. H., James, S. & Keeler, K. H. The ecology of mutualism. Annu. Rev. Ecol. Syst. 13, 315–347 (1982).

2. 2.

Moberg, F. & Folke, C. Ecological goods and services of coral reef ecosystems. Ecol. Econ. 29, 215–233 (1999).

3. 3.

Zahran, H. H. Rhizobium–legume symbiosis and nitrogen fixation under severe conditions and in an arid climate. Microbiol Mol. Biol. Rev. 63, 968-989 (1999).

4. 4.

Stolyar, S. et al. Metabolic modeling of a mutualistic microbial community. Mol. Syst. Biol. 3, https://doi.org/10.1038/msb4100131 (2007).

5. 5.

Sieber, J. R., McInerney, M. J. & Gunsalus, R. P. Genomic insights into syntrophy: the paradigm for anaerobic metabolic cooperation. Annu. Rev. Microbiol. 66, 429–452 (2012).

6. 6.

Christian, C. E. Consequences of a biological invasion reveal the importance of mutualism for plant communities. Nature 413, 635–639 (2001).

7. 7.

Soulé, M. E. & Wilcox, B. A. Conservation Biology: An Evolutionary-Ecological Perspective. (Sinauer Associates, 1980).

8. 8.

Traveset, A. & Richardson, D. M. Mutualistic interactions and biological invasions. Annu. Rev. Ecol. Evol. Syst. 45, 89–113 (2014).

9. 9.

Aslan, C. E., Zavaleta, E. S., Tershy, B. & Croll, D. Mutualism disruption threatens global plant biodiversity: a systematic review. PLoS ONE 8, https://doi.org/10.1371/journal.pone.0066993 (2013).

10. 10.

Hamilton, W. D. The genetical evolution of social behaviour. I. J. Theor. Biol. 7, 1–16 (1964).

11. 11.

Ohtsuki, H., Hauert, C., Lieberman, E. & Nowak, M. A. A simple rule for the evolution of cooperation on graphs and social networks. Nature 441, 502–505 (2006).

12. 12.

Nowak, M. A. Five rules for the evolution of cooperation. Science 314, 1560–1563 (2006).

13. 13.

Scott, M. & Hwa, T. Bacterial growth laws and their applications. Curr. Opin. Biotech. 22, 559–565 (2011).

14. 14.

Mee, M. T. & Wang, H. H. Engineering ecosystems and synthetic ecologies. Mol. Biosyst. 8, 2470–2483 (2012).

15. 15.

Wintermute, E. H. & Silver, P. A. Emergent cooperation in microbial metabolism. Mol. Syst. Biol. 6, https://doi.org/10.1038/msb.2010.66 (2010).

16. 16.

Shou, W., Ram, S. & Vilar, J. M. Synthetic cooperation in engineered yeast populations. Proc. Natl Acad. Sci. USA 104, 1877–1882 (2007).

17. 17.

Meyer, J. S. & Tsuchiya, H. M. Dynamics of mixed populations having complementary metabolism. Biotechnol. Bioeng. 17, 1065–1081 (1975).

18. 18.

Revilla, T. A. & Encinas-Viso, F. Dynamical transitions in a pollination-herbivory interaction: a conflict between mutualism and antagonism. PLoS ONE 10, https://doi.org/10.1371/journal.pone.0117964 (2015).

19. 19.

Harada, Y. & Iwasa, Y. Lattice population-dynamics for plants with dispersing seeds and vegetative propagation. Res Popul Ecol. 36, 237–249 (1994).

20. 20.

Rai, B., Freedman, H. I. & Addicott, J. F. Analysis of 3 species models of mutualism in predator–prey and competitive-systems. Math. Biosci. 65, 13–50 (1983).

21. 21.

Hoeksema, J. D. & Kummel, M. Ecological persistence of the plant-mycorrhizal mutualism: a hypothesis from species coexistence theory. Am. Nat. 162, S40–S50 (2003).

22. 22.

Allesina, S. & Tang, S. Stability criteria for complex ecosystems. Nature 483, 205–208 (2012).

23. 23.

Coyte, K. Z., Schluter, J. & Foster, K. R. The ecology of the microbiome: networks, competition, and stability. Science 350, 663–666 (2015).

24. 24.

May, R. M. Stability and complexity in model ecosystems.​ (Princeton University Press, 1973)

25. 25.

Bascompte, J., Jordano, P. & Olesen, J. M. Asymmetric coevolutionary networks facilitate biodiversity maintenance. Science 312, 431–433 (2006).

26. 26.

Goh, B. S. Stability in models of mutualism. Am. Nat. 113, 261–275 (1979).

27. 27.

Addicott, J. F. Stability properties of 2-species models of mutualism: simulation studies. Oecologia 49, 42–49 (1981).

28. 28.

Momeni, B., Xie, L. & Shou, W. Lotka–Volterra pairwise modeling fails to capture diverse pairwise microbial interactions. eLIFE  6, https://doi.org/10.7554/eLife.25051 (2017).

29. 29.

Boucher, D. H. The Biology of Mutualism: Ecology and Evolution. (Oxford University Press, 1985).

30. 30.

Morris, W. F., Vazquez, D. P. & Chacoff, N. P. Benefit and cost curves for typical pollination mutualisms. Ecology 91, 1276–1285 (2010).

31. 31.

Keeler, K. H. in The Biology of Mutualism, Ecology and Evolution 100–127 (1985).

32. 32.

Kiers, E. T., Palmer, T. M., Ives, A. R., Bruno, J. F. & Bronstein, J. L. Mutualisms in a changing world: an evolutionary perspective. Ecol. Lett. 13, 1459–1474 (2010).

33. 33.

Harrison, R. D. Repercussions of El Nino: drought causes extinction and the breakdown of mutualism in Borneo. Proc. Biol. Sci. 267, 911–915 (2000).

34. 34.

Lever, J. J., van Nes, E. H., Scheffer, M. & Bascompte, J. The sudden collapse of pollinator communities. Ecol. Lett. 17, 350–359 (2014).

35. 35.

Johnson, J. B. & Omland, K. S. Model selection in ecology and evolution. Trends Ecol. Evol. 19, 101–108 (2004).

36. 36.

Palmer, T. M. et al. Breakdown of an ant-plant mutualism follows the loss of large herbivores from an African Savanna. Science 319, 192–195 (2008).

37. 37.

Hoek, T. A. et al. Resource availability modulates the cooperative and competitive nature of a microbial cross-feeding mutualism. PLoS Biol. 14, https://doi.org/10.1371/journal.pbio.1002540 (2016).

38. 38.

Bastolla, U. et al. The architecture of mutualistic networks minimizes competition and increases biodiversity. Nature 458, 1018–1020 (2009).

39. 39.

Chuang, J. S., Rivoire, O. & Leibler, S. Cooperation and Hamilton’s rule in a simple synthetic microbial system. Mol. Syst. Biol. 6, 398 (2010).

40. 40.

Smith, J., Van Dyken, J. D. & Zee, P. C. A generalization of hamilton’s rule for the evolution of microbial cooperation. Science 328, 1700–1703 (2010).

41. 41.

Xavier, J. B. Social interaction in synthetic and natural microbial communities. Mol. Syst. Biol. 7, 483 (2011).

42. 42.

Bronstein, J. L. Mutualism. (Oxford University Press, 2015).

43. 43.

Mukherjee, S. et al. Estimating dataset size requirements for classifying DNA microarray data. J. Comput. Biol. 10, 119–142 (2003).

44. 44.

Mee, M. T., Collins, J. J., Church, G. M. & Wang, H. H. Syntrophic exchange in synthetic microbial communities. Proc. Natl Acad. Sci. USA 111, E2149–E2156 (2014).

45. 45.

Stanton, M. L. Interacting guilds: moving beyond the pairwise perspective on mutualisms. Am. Nat. 162, S10–S23 (2003).

46. 46.

Widder, S. et al. Challenges in microbial ecology: building predictive understanding of community function and dynamics. ISME J. 10, 2557–2568 (2016).

47. 47.

Yurtsev, E. A., Conwill, A. & Gore, J. Oscillatory dynamics in a bacterial cross-protection mutualism. Proc. Natl Acad. Sci. USA 113, 6236–6241 (2016).

48. 48.

Tanouchi, Y. et al. A noisy linear map underlies oscillations in cell size and gene expression in bacteria. Nature 523, 357–360, https://doi.org/10.1038/nature14562 (2015).

49. 49.

Campos, M. et al. A constant size extension drives bacterial cell size homeostasis. Cell 159, 1433–1446 (2014).

50. 50.

Taheri-Araghi, S. et al. Cell-size control and homeostasis in bacteria. Curr. Biol. 25, 385–391 (2015).

51. 51.

Pai, A. & You, L. C. Optimal tuning of bacterial sensing potential. Mol. Syst. Biol. 5, https://doi.org/10.1038/msb.2009.43 (2009).

52. 52.

Pai, A., Tanouchi, Y. & You, L. C. Optimality and robustness in quorum sensing (QS)-mediated regulation of a costly public good enzyme. Proc. Natl Acad. Sci. USA 109, 19810–19815 (2012).

53. 53.

Scott, M., Gunderson, C. W., Mateescu, E. M., Zhang, Z. G. & Hwa, T. Interdependence oF Cell Growth and Gene Expression: Origins and Consequences. Science 330, 1099–1102 (2010).

54. 54.

Scott, M., Klumpp, S., Mateescu, E. M. & Hwa, T. Emergence of robust growth laws from optimal regulation of ribosome synthesis. Mol. Syst. Biol10https://doi.org/10.15252/msb.20145379 (2014).

55. 55.

Blanchard, A. E. & Lu, T. Bacterial social interactions drive the emergence of differential spatial colony structures. BMC Syst. Biol. 9, https://doi.org/10.1186/s12918-015-0188-5 (2015).

56. 56.

Kovacs, A. T. Impact of spatial distribution on the development of mutualism in microbes. Front. Microbiol. 5, https://doi.org/10.3389/fmicb.2014.00649 (2014).

57. 57.

Lopatkin, A. J. et al. Persistence and reversal of plasmid-mediated antibiotic resistance. Nat. Commun. 8, https://doi.org/10.1038/s41467-017-01532-1 (2017).

58. 58.

Tsoi, R. et al. Metabolic division of labor in microbial systems. Proc. Natl Acad. Sci. USA 115, 2526–2531 (2018).

59. 59.

Balagadde, F. K. et al. A synthetic Escherichia coli predator–prey ecosystem. Mol. Syst. Biol. 4, https://doi.org/10.1038/msb.2008.24 (2008).

60. 60.

Song, H., Payne, S., Gray, M. & You, L. C. Spatiotemporal modulation of biodiversity in a synthetic chemical-mediated ecosystem. Nat. Chem. Biol. 5, 929–935 (2009).

61. 61.

Lutz, R. & Bujard, H. Independent and tight regulation of transcriptional units in Escherichia coli via the LacR/O, the TetR/O and AraC/I-1-I-2 regulatory elements. Nucleic Acids Res. 25, 1203–1210 (1997).

62. 62.

Christian, C. E. & Stanton, M. L. Cryptic consequences of a dispersal mutualism: seed burial, elaiosome removal, and seed-bank dynamics. Ecology 85, 1101–1110 (2004).

63. 63.

Pyke, G. H. What does it cost a plant to produce floral nectar. Nature 350, 58–59 (1991).

64. 64.

Heil, M. & McKey, D. Protective ant-plant interactions as model systems in ecological and evolutionary research. Annu Rev. Ecol. Evol. Syst. 34, 425–453 (2003).

65. 65.

Muscatine, L. & Porter, J. W. Reef corals—mutualistic symbioses adapted to nutrient-poor environments. Bioscience 27, 454–460 (1977).

66. 66.

McCook, L. J., Jompa, J. & Diaz-Pulido, G. Competition between corals and algae on coral reefs: a review of evidence and mechanisms. Coral Reefs 19, 400–417 (2001).

67. 67.

Wooldridge, S. A. Is the coral-algae symbiosis really ‘mutually beneficial’ for the partners? Bioessays 32, 615–625 (2010).

## Acknowledgments

We thank Tim Hoek and Jeff Gore for providing data used for analysis in Fig. 3f–h and Michael Mee and Harris Wang for sharing the data used for analysis in Fig. 3j, k. We also thank Yu Tanouchi, Lawrence David, Wenying Shou, Nan Luo, Yangxiaolu Cao, Carolyn Zhang, Ryan Tsoi, Teng Wang, and Shangying Wang for constructive inputs. This work is partially supported by grants from US National Institutes of Health (L.Y.: R01GM098642 and R01GM110494), National Science Foundation (L.Y.: MCB-1412459, C.L.: DEB 1257882, S.M.: DMS 17-13012, S.M.: ABI 16-61386, and S.M.: DMS 16-13261), Office of Naval Research (L.Y.: N00014-12-1-0631), Army Research Office (L.Y.: W911NF-14-1-0490), Human Frontier Science Program (S.M.: RGP0051), and a David and Lucile Packard Fellowship (L.Y.).

## Author information

F.W. conceived the research, designed and performed both modeling and experiments, interpreted the results, and wrote the manuscript. A.J.L. constructed the synthetic circuit, assisted with experimental design and manuscript revisions. D.N. assisted with modeling, results interpretation, and manuscript revisions. C.L. assisted with establishing the general relevance of the criterion and manuscript revisions. S.M. assisted with establishing the calibration process and manuscript revisions. L.Y. conceived the research, assisted in research design, data interpretation, and wrote the manuscript.

Correspondence to Lingchong You.

## Ethics declarations

### Competing interests

The authors declare no competing interests.

Journal peer review information: Nature Communications thanks the anonymous reviewers for their contribution to the peer review of this work. Peer reviewer reports are available.

Publisher’s note: Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

## Rights and permissions

Reprints and Permissions

• ### Emerging strategies for engineering microbial communities

• Ryan Tsoi
• , Zhuojun Dai
•  & Lingchong You