The Evolution of Quorum Sensing as a Mechanism to Infer Kinship

Bacteria regulate many phenotypes via quorum sensing systems. Quorum sensing is typically thought to evolve because the regulated cooperative phenotypes are only beneficial at certain cell densities. However, quorum sensing systems are also threatened by non-cooperative “cheaters” that may exploit quorum-sensing regulated cooperation, which begs the question of how quorum sensing systems are maintained in nature. Here we study the evolution of quorum sensing using an individual-based model that captures the natural ecology and population structuring of microbial communities. We first recapitulate the two existing observations on quorum sensing evolution: density-dependent benefits favor quorum sensing but competition and cheating will destabilize it. We then model quorum sensing in a dense community like a biofilm, which reveals a novel benefit to quorum sensing that is intrinsically evolutionarily stable. In these communities, competing microbial genotypes gradually segregate over time leading to positive correlation between density and genetic similarity between neighboring cells (relatedness). This enables quorum sensing to track genetic relatedness and ensures that costly cooperative traits are only activated once a cell is safely surrounded by clonemates. We hypothesize that under similar natural conditions, the benefits of quorum sensing will not result from an assessment of density but from the ability to infer kinship.


Introduction
Microbes use quorum sensing to regulate a large number of phenotypes. During growth, cells secrete autoinducers, which are small, diffusible compounds that accumulate in the environment. High autoinducer concentration around cells induces expression of many metabolically costly traits, which includes secretions that promote the growth of surrounding cells [1][2][3][4][5][6]. The canonical explanation for the function of quorum sensing is that autoinducer concentrations can be used as a proxy for cell density. Estimating the density of cells in a given environment allows microbes to cooperate in a coordinated manner. Cells can tune the expression of density-dependent phenotypes, like virulence factors or secreted enzymes, so that they are only expressed when there are enough cells to make them useful [1,4,7,8]. The benefits of quorum sensing can also be affected by diffusion conditions [9][10][11], which may favor the evolution of multiple quorum sensing signals [12].
Quorum sensing strains then may outcompete strains that constitutively express cooperative phenotypes. However, this does not guarantee quorum sensing evolution because there is also competition from strains that do not cooperate at all, often known as "cheater" genotypes [4,[13][14][15][16]. For example, Pseudomonas aeruginosa cells with a defective lasR gene preventing them from responding to quorum sensing signals, can outcompete cooperating wild-type cells [4,14]. This is because the mutants have a higher growth rate since they do not produce the costly cooperative secretions, but can benefit from the secretions of wild-type cells. Quorum sensing then has the potential to be evolutionarily unstable in mixed genotype cultures [4,7,8,13,16,17].
Such mixed genotype cultures are expected to be common in microbes, which often live in highly diverse and dense communities where many different genotypes meet and compete [5,[18][19][20][21]. What then maintains cooperative phenotypes in microbes? One explanation is the spontaneous formation of clonal patches within microbial communities by cell division (also see [22]). As cells divide and grow in dense and nutrient-limited conditions, bottlenecks occur that cause genotypes to segregate into large clonal patches. The formation of these patches in initially diverse microbial groups is an empirically well-established phenomenon, having been observed in numerous microbial species including bacteria, yeast and amoeba, and different experimental conditions including agar plates and flow cells [23][24][25][26][27][28][29][30][31][32]. Theoretical work suggests that this patch formation in microbial colonies can stabilize the use of beneficial secretions because benefitting cells are now highly related [33], which has recently been verified experimentally [34,35].
Here we investigate the costs and benefits of quorum sensing controlling the secretion of a public good-a key evolutionary dilemma [49]-in diverse and dense microbial communities. We use a realistic individual-based model of microbes that captures key features of the natural ecology of microbial groups [29,33,[36][37][38][39]. We first recapitulate the most cited function of quorum sensing in single genotype groups: it allows cells to respond to cell density and diffusive conditions. We then consider what happens when quorum sensing cells are surrounded by competing genotypes. These competitors can either be cells that constitutively produce beneficial secretions (cooperators) or non-producers that have the potential to act as cheater genotypes. Our analysis shows how quorum sensing can evolve in dense and diverse microbial communities by enabling quorum sensing genotypes to outcompete both types of competitors.
The benefit of quorum sensing we observe is not directly associated with the inference of cell density. In dense communities containing many different genotypes, quorum sensing additionally, and critically benefits cells by inferring when they are surrounded by clonemates.

Quorum sensing increases performance in clonal groups
According to the canonical view, quorum sensing allows cells to initiate shared beneficial traits only once cells are dense enough for the group to benefit. Shared beneficial traits can take a variety of forms including detoxification, slow growth rate and virulence factors. However, the archetypal shared beneficial trait is a secretion that helps cells acquire nutrients or minerals, like enzymes or chelators [14,40]. We therefore phrase our analysis in terms of secretions here but the basic conclusions should apply for any trait that carries an energetic cost to the cell that expresses it and benefits surrounding cells.
We first test the prediction that density-dependent benefits will allow quorum sensing cells (Q) to have an advantage over both constitutive secretors (C) and non-secretors (N). Density is defined as mass per unit volume: in our case, we take this volume to be constant (the whole simulation space) and simply quantify the total biomass. Starting from a single cell in a wellmixed, "liquid" environment (Materials and Methods), N cells grow and divide, such that the biomass of the population increases exponentially over the course of the simulation (Fig 1, green line). C cells, on the other hand, initially grow slower than N because a fraction of their growth is redirected into the secretion of a factor that helps all cells around them to grow. For example, this could be a protease that breaks down proteins into amino acids or peptides for import into the cell [14,40]. After an initial phase of slow growth, C cells then experience a burst in growth once the concentration of the secreted factor is high enough to have an effect ( Fig 1A, blue line, and Fig 1C). This density-dependent benefit to secretions is consistent with experimental evidence [41][42][43] and is in accordance with previous models [7,33,38].
Q cells perform better than both N and C. In our model, quorum sensing cells secrete a non-costly diffusible autoinducer, sense its concentration, and only begin to produce the costly public good once a threshold concentration of the autoinducer is perceived. Quorum sensing cells grow identically to the N cells initially, and only start to produce public goods once they reach quorum, at which point the public good quickly accumulates to the threshold concentration such that all cells benefit (Fig 1A and 1C, solid red lines). These results confirm that our simulations capture the canonical paradigm of quorum sensing, in which Q cells can prevent wasteful secretion of public goods and maximise the efficiency of public good secretion. We assume that the cells constantly secrete the autoinducer and do not consider positive feedback in its production, which can sometimes occur [44][45][46]. Introducing positive feedback would allow an increased potential to tune and optimise the timing of the quorum sensing response. Our predictions on the evolution of quorum sensing, therefore, are conservative in the sense that adding in additional complexity should only improve the scope for quorum sensing to evolve.
The problem of cheating for the evolution of quorum sensing Our first model assumes that the different genotypes live alone in clonal communities with no direct interactions between genotypes. This assumption favors strains with the maximum yield of biomass: the more cells a colony can generate, the higher the probability that its offspring will colonize new patches. While distinct clonal patches may well capture the biology of some microbial species, the extreme levels of diversity found in nature [18-20, 47, 48] suggest that strains are often surrounded by other genotypes, whether they are of the same species generated through genetic diversification or of distantly-related species. We next implement such competition in the model and recapitulate previous experimental [4,22] and theoretical work [7,10], which shows how quorum sensing can be evolutionarily unstable in genetically diverse and well-mixed environments. Specifically, we next initialize the system with two cells that produce secretions, one cell of either the C or Q genotype together with a non-secretor cell (N), in a well-mixed environment, equivalent to growth in liquid. While both C and Q outcompete non-secretors in the clonal groups (Fig 1A), direct competition results in cells from all genotypes benefiting from the public good while non-secretors do not incur the costs of its secretion. They therefore outcompete both secretor genotypes ( Fig 1B). As predicted by previous theoretical and experimental models [4,7,8,10,22,36], then, our simulations demonstrate how secretors can be exploited by non-secretors in well-mixed groups and our model is an example of a public goods dilemma [13,49]. well-mixed cultures of a constitutively public good secreting genotype (C, blue), a quorum sensing genotype that only begins secreting public goods after a threshold concentration of the autoinducer has been reached (Q, red) and a control genotype that does not produce any public goods (N, green). The arrows on the time axis indicate the onset of public good secretion by the two secretor genotypes, circles indicate the first time point at which the public good has reached above-threshold concentration in the simulation and cells begin to benefit from the public good. B) Relative fitness of C and Q (Materials and Methods) compared with competitors of genotype N when growing alone (filled circles) or in direct competition in well-mixed culture (open squares). The horizontal line represents equal fitness of N and its competitor (either C or Q). Secretion (C and Q) is only favoured over non secretion when genotypes grow alone. C) Comparison of biomass growth for the three genotypes in spatially structured clonal colonies. Time axis labels as in A). On the right: snapshots of the simulated colonies at t = 7 h marked with asterisks in the plot. Constitutive secretors lose when surrounded by competing genotypes While direct competition in liquid favors non-secretors, theoretical and experimental work shows that secretor genotypes can outcompete non-secretor genotypes in direct competition in a spatially structured environment [24,33,38,50]. Therefore, we next map out the effects of spatial structure on direct competitions between secretors and non-secretors [33], before then considering how quorum sensing genotypes will fare under the same conditions (Fig 2). Previous work has shown that when nutrients are limiting, secretors can sometimes outcompete non-secretors in direct competition [33]. The reason is that low nutrient levels lead to population bottlenecks and the emergence of large patches of a single genotype, which prevents N genotypes from using the secretions of C genotypes (Fig 2B, [33][34][35]). These bottlenecks leading from well-mixed to spatially structured populations represent a well-studied phenomenon that has been widely observed in microbial communities [29,30,51,52]. In social evolution terminology, the population bottlenecks drive an increase over time in genetic relatedness-the probability that two individuals are more genetically similar than the population average, or in this context, the probability that a focal cell is surrounded by genetically identical cells compared to other genotypes (Materials and Methods)-which is one of the major predictors of the evolution of cooperation [33,53].
However, secretors are often outcompeted by non-secretors, despite bottlenecking effects that increase relatedness. In particular, whenever constitutive secretors start to grow surrounded by cells of competing genotypes (low genetic relatedness, [33,38]), it is more difficult for them to compete successfully (Fig 2A, 1:4 competitions). Why does a constitutive secretor fare badly when surrounded by non-secretors? The reason is that constitutive secretors are providing secretions that benefit non-secretors as much as secretors but only they are paying the  cost to make them. The result is that faster growing non-secretors can physically overgrow and smother them, preventing secretors from capitalizing on the benefits of their cooperation. Constitutive secretors lose then under conditions of nutrient limitation and high diversity, both of which are thought to often occur in natural microbial communities [5,19,20,38,54]. Indeed, these conditions are expected whenever a focal genotype lands in an environment that has already been populated by other genotypes.

Quorum sensing is advantageous under strong competition
Our initial analysis shows that when the social environment is highly competitive-nutrients are limiting and there are many genotypes-constitutive secretion can be a disadvantageous strategy. We next explore how a quorum sensing strain performs under such competitive conditions. We competed a Q strain, or a C strain, in pairwise competitions against the non-secretor N strain. Again, our scenario is that the population comprises a number of non-secretor (N) strains and we ask: what is the fitness of a single focal secretor of the Q or C strain, as a function of its initial frequency? We consider biofilms comprised of 1 secretor strain mixed with 1, 2 or 4 non-secretor strains (Q or C: N-1:1, 1:2, and 1:4) to study the effect of increasing evolutionary competition (i.e. increasing local diversity). We also consider a range of quorum sensing strains (Q1 to Q4) that all produce autoinducers at the same, constant rate, but are induced to produce public goods at different, increasing, threshold concentrations of the quorum sensing autoinducer.
When secretors (C or Q1-4) were seeded at a 1:1 proportion (low evolutionary competition), all five strains outcompete the N strain in each of the 100 simulations, with C achieving the highest mean relative fitness, although secretors do not differ much in their relative fitness ( Fig 3A). This changes when we consider strong evolutionary competition with a low initial proportion of secretors. Importantly, Q strains succeed against competing non-secretors where constitutive secretors fail. Quorum sensing then enables cooperation in highly competitive environments where non-secretors would otherwise dominate. What is the cause of the advantage to Q strains over C strains under these conditions? Regulating secretion means that Q strains invest less in secretion overall than constitutive secretors. But in the supplement we reduce the investment of constitutive secretors to remove this difference and show that they still lose where Q strains win (S1 Fig). The key to success of Q then is the timing of secretion (in S2 Fig an artificial time-delay strategy demonstrates this). Quorum sensing allows a newly colonizing strain to compete against non-secretors and establish a clonal patch prior to activating energetically costly secretions, whereas C strains get overgrown and smothered while inefficiently investing into cooperative secretions. In these simulations of competitive, surfaceattached communities then, the critical benefit to quorum sensing comes from the fact that expressing a costly secretion early means that such a genotype will be rapidly overgrown by faster growing genotypes.

Quorum sensing as a mechanism to infer kinship
The benefit to quorum sensing that we observe is not directly linked to the assessment of cell density or total biomass. Rather, the relevant variable is the extent to which cells of a focal genotype are surrounded by clonemates relative to other cell types, which we compute using the "segregation index". This segregation index is proportional to measures of kinship or relatedness within the range of a social trait [16,33,38] (Materials and Methods). A strain is predicted to be more successful then, if it can match its cooperative secretions not to the cell density or total biomass, but to the appropriate level of local relative cell density or genetic relatedness. Furthermore, as cells in mixed microbial colonies divide and increase in number, Higher genotypic diversity is reflected in lower initial proportions of the secretor genotype. We show results of 100 independent simulations each and plot the resulting mean relative fitness in black. Q genotypes have a higher relative fitness than C because they outgrow N more frequently (more runs fall above the 0 line in the bimodal distribution). This-rather than a higher benefit from the public good-is what allows Q to succeed, and is a result of Q genotypes competing better than C during the early stages of colony growth. B) Direct competition between C, Q4 and N. 80 cells of C and Q4 respectively, and 640 cells of N were seeded the likelihood of being surrounded by clonemates compared to different genotypes increases and average relatedness between neighbouring cells increases [30-32, 51, 52]; relatedness, then, correlates positively with time.
The importance of relatedness over cell density in defining the quorum sensing threshold is demonstrated by Fig 4. We first consider a case where the seeding population is artificially sorted by genotype (Q1 vs N) and population bottleneck effects are removed. This manipulation artificially increases relatedness from the start. Here a Q1 genotype, which has a low quorum threshold and activates secretions immediately (or even a C genotype, S3 Fig), can outcompete non-secretors because they are already surrounded by many clonemates (Fig 4A). However, Q1 (or C, S3 Fig) cannot outcompete non-secretors when we seed the same density of cells and genotypes but without forced sorting of genotypes ( Fig 4B). Here, only a genotype with a higher quorum threshold (Q4) can outcompete non-secretors ( Fig 4C).
Q4 turns on public good production at a 4 times higher autoinducer concentration than Q1, which means that Q4 delays costly secretion further in time (see S1 Table). In competition with the N genotype, Q1 now gets buried under conditions where Q4 can escape burial and form clonal towers. The reason is that Q4 only initiates public good secretion when cells are surrounded by clonemates rather than others (Fig 4E and 4F) thereby amplifying the fitness gain from forming clonal clusters and outperforming non-secretors N on average (Fig 3). While still correlated with cell density, autoinducer concentration is tracking the shift from competitive, genetically-mixed populations to conditions where cells are surrounded by clonemates. Quantitatively, this can be seen from the fact that Q4 starts secretion at a higher segregation index (Fig 4G-4I, Materials and Methods). And while other quorum sensing thresholds may initiate public good secretion at a more optimal moment compared to Q4, this example strategy illustrates that using a quorum sensing threshold to delay cooperation in dense and diverse communities can be advantageous. The optimal threshold will depend not only on cell density but, critically, on the ability to keep track of time and the concomitant change in local genetic relatedness, as the cell group transitions from low relatedness to sufficiently high relatedness under which cooperation becomes favourable.
Our model shows how a rare quorum sensing strain can succeed in a population of nonsecretors, and so quorum sensing is predicted to evolve under these conditions. However, once common, how robust is quorum sensing-controlled public good secretion to potential exploitation by rare non-secretors? In the supplement we ask how a rare non-secretor genotype fares in local competition with Q (S4 Fig), which shows that quorum sensing strains also outcompete non-secretors when the latter are rare.
Overall, our results show how the regulation of public good secretion by quorum sensing can be a more robust strategy than constitutive secretion in competitive environments. Specifically, in our system, quorum sensing strains can outcompete non-secretors where constitutive secretors will not (Fig 5). This is because quorum sensing strains can infer the local relative density of their own kin, and start cooperating once they have reached the appropriate level of genetic relatedness. But what about direct competition between a quorum sensing and a constitutive-secretor genotype? In general, these two genotypes perform similarly in direct competitions although quorum sensing genotypes do maintain a slight advantage (S5 Fig). This is again because Q cells grow faster initially and compete well for bottlenecks and, after simultaneously. Relative fitness from 100 independent simulations was calculated for Q4 and C by considering their fitness against the average competitor fitness (N+Q4 and N+C respectively, see Methods), and the mean values are indicated by bars. C) Snapshots of an individual simulation shown in panel B where Q4 succeeds.
doi:10.1371/journal.pcbi.1004848.g003 establishing a clonal group, Q can benefit from its public good secretion. This initial edge leads to the success of Q over C, which is robust to reciprocal competition where a rare genotype C competes with frequent cells of genotype Q. The dominance of quorum sensing can also be seen in a competition involving all three main genotypes C, Q and N (Fig 3B and 3C), and in the supplement we show that the benefits of quorum sensing are robust to a more complex model where cells in different biofilms disperse and compete globally (S6 and S7 Figs).

The benefit of quorum sensing does not rely on kin discrimination
In our model, only quorum sensing cells respond to autoinducers. Importantly, we also assumed that only the quorum sensing strains produce the autoinducer. This scenario will initiates public good production early while Q4 delays secretion for longer due to its higher quorum sensing threshold (S1 Table). B) and C) show results from the same simulation setup but where cells were positioned randomly at the start (as in simulations in Figs 2 and 3). Now, Q1 (red) cannot outcompete non-secretors (green) in local competition (B), whereas in C) Q4 (red) outcompetes non-secretors (green). D-F) Left y-axis and red/green lines: Biomass over time of non-secretors N and secretor genotypes Q1 and Q4 in the corresponding simulations shown in A-C). Right y-axis and black lines: peak concentration of public good (maximum concentration in anywhere within the colony) in the biofilm over time. G-I) Segregation index which is a measure of relatedness in the simulations over time. Key to a successful strategy is initiating public good secretion only at a sufficiently high segregation index: when cells are sorted from the beginning, secretion can start early (A, G), but if cells are initially well-mixed, only delayed public good secretion leads to success (C, I).
doi:10.1371/journal.pcbi.1004848.g004 occur whenever quorum sensing strains differ from competing strains at both the loci for induction and response. The use of a genotype-specific signal, as observed in strains of Bacillus [47], raises the possibility that a focal genotype can detect the number of clonemate cells in the face of high variability in genetic mixing (a form of kin discrimination [55]). However, such kin discrimination is not needed for the evolutionary benefits to quorum sensing that we observe. In some situations, all genotypes may produce autoinducers even if they do not all respond to them, such as when autoinducers are linked to common metabolic waste products [54,56]. We therefore also consider a system where all competing genotypes make the autoinducer. Under these conditions, Q cells maintain their advantage against non-secretor strains, albeit at different (higher) quorum sensing thresholds (S8 Fig). While a genotype-specific signal is likely to be more robust to variability in strain mixing, therefore, it is not required for the evolutionary benefits to quorum sensing that we observe. Even if the change in autoinducer concentration reflects total cell density, a Q genotype can still use autoinducer concentration as a timer to infer genetic similarity. If the physical and social environment is sufficiently predictable, then, the indirect inference of kinship via autoinducers is sufficient for the effects we see, as opposed to strict kin detection and discrimination. This inference is possible whenever cell density correlates with the genetic similarity of neighbouring cells due to the changing spatial structure of the colony over time (Fig 4).

Discussion
Two key issues have been identified as central to the evolution of quorum sensing to regulate the secretion of public goods. The first is a benefit over constitutive secretion. This is typically thought to come from the ability to infer cell density and perhaps diffusion rates. The second issue is that quorum sensing cells must resist competition from non-secreting cheater mutants. Here we show that, under conditions of strong competition, these two issues combine to provide a critical benefit to quorum sensing that is not simply due to the assessment of cell density. With nutrient limitation and high numbers of competing genotypes, the key benefit to quorum sensing in our system comes from the ability to delay public good secretion and grow quickly when first in a new environment. This allows quorum sensing cells to outgrow constitutive secretors while keeping up with fast growing non-secretors until clonal patches have formed in a microbial group. In particular, the delay in cooperative secretion in quorum sensing genotypes increases their chances of forming clonal clusters compared with constitutive secretors, and outcompeting them. Positive feedback from cooperation then amplifies the gain from forming a clonal cluster, which allows quorum sensing genotypes to outcompete non-secretors as well (Fig 5).
Our model makes some simplifying assumptions. Firstly, auto-inducer production carries no cost in our simulations. While this may not always be the case in reality, many quorum sensing molecules, such as autoinducer-2 (AI-2) carry little to no cost [57,58]. Secondly, some modeling choices and parameter values, such as the quorum sensing thresholds, were determined based on previous work or by parameter sweeps rather than experimentally measured values. This approach then demonstrates that wide and realistic parameter ranges exist in which quorum sensing is adaptive. Finally, the importance of the predicted effect, whereby quorum sensing can delay cooperation until relatedness has increased will, of course, depend on how often microbes find themselves in highly competitive environments, which transition from diverse mixtures of strains to clonal clusters as they grow. In cases where cells grow in isolation as microcolonies, the benefits of quorum sensing are likely to come from the inference of cell density and diffusion as is typically assumed [10,12,13,16]. However, there is a growing recognition of the importance of competition for understanding microbial phenotypes [5,6,54]. A focal microbial genotype may often land in a dense community where other genotypes are already present; in fact, most of microbial life is assumed to take place under these conditions [20]. And although our model here assumes that competing genotypes differ only in a few loci with all else being equal, higher background diversity will not alter our conclusions. Our model suggests then that quorum sensing can be particularly advantageous when competition between many different genotypes is fierce. This leads to a testable hypothesis: when surrounded by foreign genotypes, a strain that uses quorum sensing to control public good secretion can grow as fast as non-secretors and only activate secretions once it is safely surrounded by its own genotype.

Materials and Methods
We are extending an individual based simulation framework developed and tested over the last 15 years [28,[59][60][61]. Cells are modelled individually and diffusion and reaction of chemical species are calculated by solving the reaction-diffusion equations. Briefly, cells take up and secrete chemical species, grow and divide once a certain threshold size is reached. Growth and division leads to overlapping cells. This overlap is relaxed by moving cells individually which leads to an expansion of the biofilm. There is no active movement and this relaxation mechanism is the only way cells can change their positions. Further, the substratum on which cells grow is impenetrable and cells cannot move into this area. We assume that reaction and diffusion of solutes happen on a much faster time scale than cell growth, division and biofilm expansion. The solute concentrations are, therefore, the steady state concentrations of the reaction-diffusion system for any particular biofilm conformation as in previous models [28,61]. The framework is written in the Java programming language and the reaction-diffusion system is solved numerically to steady state with the relaxation method. For "well-mixed" simulations, cell positions were shuffled after each iteration and secretions such as autoinducers and extracellular secreted products were allowed to accumulate in the system by imposing dynamically changing boundary condition.
Here we adopt the same basic conventions and parameters as used in previous work on the evolution of public good secretion in biofilms [33,38]. We extended them to include quorum sensing genotypes. The biofilm is represented in 2D. Cells grow on top of a hard, smooth surface that does not absorb or release any solutes. Above the biofilm, a diffusion layer separates cells from a region with constant nutrient concentrations (0.125 g/L, if not otherwise stated) and we impose periodic boundary conditions on the sides of the simulation area.
Our simulations include three types of cells: non-secretors (N), constitutive secretors (C) and quorum sensors (Q). C have exactly the same properties as N except that they divert a constant fraction of the nutrient uptake to the secretion of public good (here 20%). When the local public good concentration exceeds a threshold, the yield (i.e. cell growth per nutrient invested) increases by a factor of 3. This increase is the same for all three genotypes, i.e. all genotypes can benefit from the public good. Q are identical to C with the difference that they constantly secrete costless autoinducer molecules and only spend energy on public good production if the local auto-inducer concentration exceeds a certain threshold. This threshold varies for different types of Q genotypes. The exact rates and stoichiometry of all these processes can be found in S2 Table. The description and numeric value of all parameters are shown in S1 Table. In each simulation a chosen number of cells of each genotype were seeded at random positions on the bottom surface. The cells were then allowed to grow as described above. The simulation was terminated once a fixed amount of nutrients had been absorbed by the biofilm and the final biomass was recorded for each genotype.

Calculating fitness
We define fitness of each genotype (for example, x and y) as the mean number of rounds of cell division per unit time that cells of a focal genotype achieve during the interval between initial seeding at t 0 and t end when a maximum amount of nutrients were consumed. Fitness w, therefore, is calculated as where N x, t is the number of cells of genotype x present within the cell group at time t. The relative fitness of a genotype x in local competition with another genotype y is defined as:

Invasion analysis
A simple meta-population analysis was conducted following the same approach as in [33]. This determines whether a rare mutant strain would succeed in a metapopulation of cell groups with reoccurring dispersal and colonisation events. We assume a very large number of cell groups where the great majority of groups are of a single dominant strain and only a small minority will contain the mutant. Under these conditions, a genotype x (rare mutant) can invade a meta-population of genotype y (majority resident) if the fitness of x in local competition with y is greater than the average fitness of the whole metapopulation, denoted hw y i. For each invasion analysis, w x was computed in 100 replicates of the simulations (with varying inoculation frequencies of the two genotypes and a total of 800 cells initially, see relevant figures). Because the great majority of cell groups in the meta population consist purely of the majority genotype y, hw y i is approximately the mean fitness of the majority genotype, y, when growing on its own. To calculate hw y i, the mean of w y over 100 simulations is computed, where the cells of genotype x inoculated initially are replaced with y cells and a mono-culture of the majority genotype is simulated. The invasion index I x ! y of a rare mutant x into a metapopulation with majority genotype y was calculated for each of the 100 replicates as Under the assumptions of our model, we conclude that x can invade a metapopulation of y when I x ! y > 1.

Statistical analysis
Simulation results are from 100 independent replicates. Fitness data is non-normal and often bimodal distributed where the bimodality differs between simulations with different initial frequencies and/or initial cell densities meaning it is difficult to apply standard statistics. In some figures we show box plots and test the median fitness value with non-parametric sign tests. This is only an indicator as from an evolutionary perspective, the mean relative fitness is the determining parameter of evolutionary success. Therefore, we further conducted convergence analyses that show how the mean fitness converges after about 100 simulations (S7 Fig).

Genetic relatedness and the segregation index
The segregation index used here is identical to that used in previous work [38].
Segregation with respect to a focal cell, s(c i ), was calculated as the mean product of the g and m functions for every cell in its neighbourhood: Finally, we define the segregation index σ for the entire cell group as the mean value of s(c i ) across the population of cells: The segregation index measures the degree to which co-localised cells are clonally related to each other. Relatedness in social evolution is defined as the probability that two individuals are more genetically similar than the population average. The segregation index is equal to a form of the relatedness coefficient from social evolution theory under the following assumptions: (i) A cell expressing the cooperative phenotype equally benefits all other individuals within a 10 cell-length radius; and (ii) Cell groups are seeded randomly from a large population pool [33]. In this meta-population, the frequency of a given focal strain is constant and small. To seed our simulations, then, we sample a number of strains (between 2 and 5, one of which is our focal strain) randomly from this population. The likelihood of a cell of the focal strain interacting with its clone in the meta-population is negligibly small. The segregation index then computes the likelihood of the focal cell interacting (presence over a 10 cell-length radius-this radius is somewhat arbitrary, and was kept identical to previous studies) with its clone relative to the null expectation in the metapopulation (close to 0). Supporting Information S1 Fig. Relative fitness of secretor genotypes (C: constitutive, C Ã : constitutive with reduced investment, Q4: quorum sensing secretor) in competition with non-secretor genotypes (N) in spatially structured communities. Q4 succeeds against N whereas C loses. We then calculated the average amount of energy invested in public good secretion by the quorum sensing genotype that delays secretion (Q4) and matched the secretion rate of C Ã to ensure identical total investments (R E = 0.8123). This does not reverse the fate of constitutive secretors: C Ã is still outcompeted by non-secretors. This demonstrates that the advantage of quorum sensing is not due to less investment in cooperation. The simulations are initialised with a 1:4 initial proportion of secretors to non-secretors. The results shown are from 100 independent simulations for each condition, the respective mean relative fitness is indicated by bars, and ÃÃÃ indicate pvalues >0.001 from two-sided sign tests against a median of zero. (EPS) S2 Fig. Introducing a simple time-delay to genotype C public good secretion recapitulates Q strategy. To demonstrate that the success of the Q genotype is due to a time delay in public good secretion, we implement such a delay in the C genotype and call this new strategy Q T where T represents the duration of the delay before public good secretion is initiated. Q 0 is thus equivalent to C. We then compete Q T against N at a 1:4 initial proportion of secretors to non-secretors. Blue dots show the fitness of Q T relative to N in each of 100 runs, while red dots shown the mean fitness of those runs. The figure shows that delaying public good secretion by 20 hours is equivalent to the strategy Q4 (compare with Fig 3A,  Relative fitness of a rare constitutive secretor (C) in competition with quorum sensing genotypes. Right: a rare quorum sensing genotype (Q) in competition with constitutive secretors. Individual simulation results and mean (bold) in circles. p-values from non-parametric twosided sign tests against zero median. While the mean relative fitness of a rare Q genotype is only slightly above 0, we show convergence of the mean in our simulations in S7 Here, arrows denote the direction of invasion with the rare genotype at the origin of the arrow. I.e., + next to the arrow from quorum sensing genotypes (Q, red arrows) to N denotes that Q can invade a metapopulation of non-secretors (N). On the other hand, constitutive secretors cannot invade non-secretors (C, blue arrows). Both secretor genotypes, however, resist reciprocal invasion by a rare non-secretor (green arrows), see also S7 Fig. Further, Q resists invasion by C but can itself invade C. The data from the perspective of Q is shown in B). Mean invasiveness values of 100 (200 for Q ! C) independent simulations that are >1 indicate successful invasion of a metapopulation by the rare genotype (two-sided sign tests against medians of 1, Ã : p < 0.05; ÃÃ : p < 0.01; ÃÃÃ : p < 0.0001). We verified that the mean of the invasion Q ! C whose median is least significantly different from 1 converges to a value >1 and that, therefore, Q can invade C (S7 Fig). (EPS) S7 Fig. Invasion analysis of competitions between quorum sensing genotypes, constitutive secretor genotypes, and non-secretors in spatially structured simulations. Invasiveness values >1 indicate that a focal genotype can invade a metapopulation of the competitors under high competition (0.2 initial frequency) or low competition (initial frequency of rare genotype: 1, this assumes that patches of genotypes grow separated from each other), results of 100 independent simulations, mean values connected by the red line. A-C) Pairwise reciprocal invasion analysis of constitutive secretor (C), quorum sensing genotypes (Q) and non-secretors (N) into metapopulations the other genotypes. Q can invade metapopulations of N and C while itself resisting invasion from both. Against C, the differences are small but significant. Some of the data is bimodally distributed meaning it is difficult to use standard statistics (we show the results of two-sided sign tests against medians of 1, Ã : p < 0.05; ÃÃ : p < 0.01; ÃÃÃ : p < 0.0001). We, therefore, further show an example of a convergence plot of the mean invasiveness value of Q4 invading C over 200 simulations in D). The rolling mean invasiveness shows that after about 100 simulations additional simulations do not have a strong effect and the mean converges to a value slightly above 1 (blue line). Inset: histogram of bootstrapped means (solid vertical line at 1.01) and confidence intervals (dashed vertical lines at 0.98 and 1.04) indicate good accuracy of the original simulation data (10 6 resampling events). (EPS) S8 Fig. Relative fitness of a secretor genotype in competition with non-secretor genotypes (N) when all genotypes produce quorum sensing in spatially structured simulations. C is constitutive, N is non-secretor control, and Q4-6 are quorum sensing genotypes with increasing quorum sensing thresholds, see S1 Table. Simulations assume 1:4 proportions of secretor to non-secretor genotypes, results of 100 independent simulations each, mean relative fitness in red. While C cannot outcompete its N competitors, delaying public good secretion conveys a competitive advantage to Q genotypes. (EPS) S1 Table. List of parameters and the values used in our simulation models. M E represents mass of extracellular enzyme, M I represents mass of extracellular inducer, M G represents mass of growth substrate, M X represents cell biomass, L represents length, and T represents time. (PDF) S2 Table. Stoichiometry of cell metabolism used in the simulation models. (PDF)