## Abstract

Many bacteria are adapted for attaching to surfaces and building complex communities, or biofilms. This mode of life is predominant in microbial ecology. So, too, is exposure of bacteria to viral pathogens, the bacteriophages. It is likely that biofilm-phage encounters are common in nature, but we know very little about how phages might interact with biofilm-dwelling bacteria. Making headway in this relatively unknown area requires new techniques, and here we develop the first biofilm simulation framework that captures key features of biofilm growth and phage infection. We describe the framework in detail and use it to study the population dynamics of lytic phages and susceptible bacterial hosts in biofilms. The system displays a rich array of dynamical steady states, and these are governed largely by nutrient availability to biofilms, phage infection likelihood, and the ability of phages to diffuse through biofilm populations. Interactions between the biofilm matrix and phage particles are likely to be of fundamental importance, controlling the extent to which bacteria and phages can coexist in natural contexts. Our results build on the rich literature exploring bacteria-phage interactions, and open avenues to new questions of host-parasite coevolution in the spatially structured biofilm context.

## Introduction

Bacteriophages, the viral parasites of bacteria, are a predominant agent of bacterial death in nature [1]. Their ecological importance and relative ease of culture in the lab have made bacteria and their phages a centerpiece of classical and recent studies of molecular genetics [2–6] and host-parasite coevolution [7–17]. This is a venerable literature with many landmark papers, the majority of which have focused on bacteria-phage interaction in liquid culture. In addition to living in the planktonic phase, many microbes are adapted for interacting with surfaces, attaching to them, and forming biofilms [18–22]. Relatively little is known about the spatial population dynamics of phages interacting with bacteria in these immobilized, matrix-embedded communities that bacteria often occupy in the natural environment.

Since growth in biofilms and exposure to phages are common features of bacterial life, we can expect biofilm-phage encounters to be fundamental to microbial natural history. Furthermore, using phages as a means to kill unwanted bacteria – eclipsed in 1940 by the advent of antibiotics in Western medicine – has been resurrected in recent years as an alternative antimicrobial strategy [23–28]. Understanding biofilm-phage interactions is thus an important new direction for molecular, ecological, and applied microbiology. Existing work suggests that phage particles may be trapped in the extracellular matrix of biofilms [29–31]; other studies have used macroscopic staining assays to measure changes in biofilm size before and after phage exposure, with results ranging from biofilm death, to no effect, to biofilm augmentation [32]. We have only a limited understanding of the mechanisms responsible for this observed variation in outcome, and there has been no systematic exploration of how phage infections proceed within living biofilms on bacterial cell length scales.

Biofilms, even when derived from a single clone, are heterogeneous in space and time. The extracellular matrix can immobilize a large fraction of biofilm-dwelling cells, constraining movement and the mass transport of soluble nutrients and wastes [20,33]. The spatial structure of populations is of fundamental importance due to its impact on intra- and inter-specific interaction patterns [34]. Furthermore, epidemiological theory predicts qualitative changes in population dynamics when host-parasite incidence rate is not a simple linear function of host and parasite abundance [35], which is certainly the case for phages and biofilm-dwelling bacteria under spatial constraint. It is thus very likely that the population dynamics of bacteria and phages will be altered in biofilms relative to mixed or stationary liquid environments. This alteration could manifest owing to differences in phage diffusivity within biofilms, physical shielding of internal host populations by peripheral cells, differential speed of bacterial division versus phage proliferation, or other features of the biofilm mode of growth. Available literature supports the possibility of altered phage population dynamics in biofilms [14,15, 36–38], but the underlying spatiotemporal details of the phage-bacterial interactions have been difficult to access experimentally or theoretically, due to the lack of suitable experimental model systems and simulation frameworks.

Existing biofilm simulation frameworks are flexible and have excellent experimental support [39–41], but they become extremely computationally demanding when applied to the problem of phage infection [42]. We therefore developed a novel approach to study phage-biofilm interactions *in silico*, which is presented here in detail. We use our framework to explore population dynamics in a minimal system containing lytic phages and susceptible host cells. Through massively parallelized simulations, we find that nutrient availability and phage infection rates are critical control parameters of phage spread; furthermore, modest changes in the diffusivity of phages within biofilms can cause qualitative shifts toward stable or unstable coexistence of phages and biofilm-dwelling bacteria. This result implies a central role for the biofilm extracellular matrix in phage ecology. Our results suggest that a full understanding of the interactions between bacteria and their phages requires explicit consideration of the biofilm mode of bacterial life.

## Methods and Simulation Framework

When phages are implemented as discrete individuals, the total number of independent agents in a single simulation can rapidly reach many hundreds of thousands. Moreover, the time scale for calculating bacterial growth can be an order of magnitude larger than the appropriate time scale for phage replication and diffusion. These challenges prevent the use of traditional biofilm simulations for studying phage infection, and we therefore developed a new framework customized for this purpose. Our model combines (i) a numerical solution of partial differential equations to determine solute (e.g. nutrient) concentrations in space, (ii) a cellular automaton method for simulating biofilms containing a user-defined, arbitrary number of bacterial strains with potentially different properties, and (iii) an agent-based method for simulating diffusible phages.

### Simulation Space

Following convention [43] and our own previous work [44–47], the new computational system is implemented in a Cartesian space constrained by horizontal periodic boundary conditions and divided into a rectangular grid of *X* by *Y* compartments (leading to computational elements of area *dl* x *dl*). For this 2D system, we also assume a grid depth of *dl*, which is used to calculate volumetric concentrations and periodic boundaries.

After the system is initiated with cells on the substratum, the following steps are iterated until an exit steady-state criterion is met:

Compute nutrient concentration profiles

Compute bacterial biomass dynamics

Redistribute biomass according to cellular automaton rules

Evaluate host cell lysis and phage propagation

Simulate phage diffusion to determine new distribution of phage particles

Assessment of match to exit criteria:

**Coexistence**: simulations reach pre-defined end time with both bacteria and phages still present (these cases are assessed for long-term stability)**Biofilm Death**: biofilms reach a minimum population threshold**Phage Extinction**: no phages or infected biomass remain

A brief description of each of these stages in the iteration cycle is given below. Example frames of a representative simulation time series are shown in Figure 1.

### Computation of nutrient concentration profiles

The framework can incorporate an arbitrary number of user-defined solutes, but here we only model a single limiting nutrient according to a simple reaction-diffusion system *∂*_{t}*N* = *D*_{N}*∇*^{2}*N*+ *R*(*N*), where nutrient consumption by bacteria is defined as a Monod-type kinetic reaction , with *Y* being the growth yield, *μ*_{S} the bacterial maximum growth rate, the half saturation constant, *N* the nutrient density, and S the bacterial active biomass density. The nutrient concentration is held constant at the upper boundary of the system, and there is no nutrient flux permitted through the bottom boundary (substratum). No nutrients are supplied from the substratum (Simulation parameters and their values are given in Table S1). This growth geometry is inspired by the standard flow channel biofilm growth assay, where biofilms are grown on a glass or plastic substratum over which a nutrient medium is flown.

Similarly to previous work [48], we assume that diffusion of the nutrient solute is instantaneous relative to bacterial and phage-related processes, and as such it is solved at quasi-steady state, i.e. ∂_{t}*N* = *D∇*^{2}*N* + *R*(*N*) = 0. Based on this assumption, we compute *N* (*x*, *y*, *t*) by using Newton’s method to linearize *∂ _{t}N* = 0 as:

(*D∇*^{2}+*f*′(*N*)) *Δ*_{N} = −*f*(*N*),
where

, and

*Δ*_{N} = *N*_{i+1} − *N*_{i} (*i* is the iteration counter of Newton’s method).

Once linearized, we use an algebraic multigrid solver [49] to compute the change in nutrient concentration at each Newton-iteration. Initial conditions for nutrient concentration are , with y ∈ (0,*y*_{max}) corresponding to the vertical coordinate of the system.

### Computation of bacterial biomass dynamics

The model variables that describe bacterial population dynamics over space and time are the active susceptible biomass (S), the infected biomass (*I*), and the inert biomass (*D*). From the active biomass, S, the number of active bacteria *n*_{S} (used in single cell-dependent processes) is calculated as *n*_{s}(*x*, *y*) = *S*(*x*, *y*)×*dl*^{3}/*m*_{s}, where *m*_{S} denotes the specific mass of a bacterium. The order of operations for biofilm computations is the following:

**Biomass growth and decay.**Solve the bacterial growth equations for the active biomass, , and the conversion from active to inert biomass,

*∂*_{t}*D*=*δ*_{d}*S*, where*δ*_{d}is the biomass decay rate.Update active and inert biomass values in each grid element accordingly.

**Shoving.**For every grid element that meets the condition*S*≥*S*_{max}(with*S*_{max}being the maximum active biomass concentration allowed in a grid element):Find the nearest empty grid point satisfying (

*S*+*I*+*D*<*θ*)Compute a line towards the grid point determined in step (2-a)

Shift intervening biomass along the line defined in step (2-b) such that biomass in the focal grid node can be split between the current node and a newly empty neighbor node.

**Erosion**.Calculate an erosion force proportional to the square of the distance from the substratum,

*F*_{e}=*k*_{e}*y*^{2}, then solve for the time to erosion (*t*_{e}) using the fast marching method [50]. The amount of eroded biomass is proportional to the time to erosion divided by the simulation time step,*t*_{e}/*dt*. This rule implements shear-dependent erosion that is strongest for biomass on the biofilm exterior.Any grid element with total biomass is set to an empty state.

**Sloughing**For every grid point, determine if there is a chain of neighboring biomass-occupied nodes continuous with the substratum. If any biomass is found unattached to the rest of the biofilm in this manner, it is removed.

### Host cell lysis and phage propagation

After biofilms have grown for a defined period of time (1.5 days in physical units for results presented in the main text), we implement phage exposure in a single pulse, introducing one phage particle to each empty grid element above the outer edge of the biofilm. The framework tracks infected bacteria and phages *via* infected bacterial biomass (*I*), the number of phages (*n*_{p}) and the remaining incubation time for each infected cell (*τ*_{r}).

After infection, the order of operations for phage processes is the following:

**Infected cell lysis**. Decrement*τ*_{r}by*dt*for each infected cell. If a cell lyses (those with*τ*_{r}≤ 0.), the corresponding infected biomass is subtracted from the grid element and*β*phages (the burst size) are added to that element.**Phage diffusion**(see details below)**Phage localization**. This step involves phage-cell adsorption, phage dispersal by advection, and phage decay.For each phage in a grid element with active biomass, calculate whether or not it is adsorbed to a host cell. The adsorption probability is determined as 1 −

*e*^{−γnSdt}, where the rate is given by the product of infectivity*γ*, the local number of active susceptible bacteria*n*_{S}, and the integration time step*dt*. Adsorptions cause a conversion of active bacterial biomass (*S*) to infected bacterial biomass (*I*), equal to the ratio of phage adsorptions to the node bacterial count, with a maximum of unity. The infected biomass is assigned an incubation period*τ*_{r}=*τ*.Phages not adsorbed to biomass are immediately considered ‘detached’ and are removed from the system; this rule implements strong advective removal of phages that are not biofilm-attached.

Phages decay by natural mortality, with probability 1 −

*e*^{−δpdt}, with*δ*_{p}being the phage decay rate.

### Phage diffusion

To compute the movement of phages via Brownian motion, we use the analytical solution to the diffusion equation of a Dirac delta function at each grid node to build a probability distribution from which to resample the phage locations.

First, we calculate the distance

*p*_{ij}to each grid element*i*from each grid element*j*that contains at least one phage. To model implicitly the effect of bacterial matrix on phage movement, the effective distance between two neighboring elements is assumed to depend on the presence of bacterial biomass. Specifically, when moving from:an empty grid node into a neighboring empty grid node, the effective distance is equal to

*dl*;an empty grid node into a biomass-occupied grid node, the effective distance is equal to

*dl*;a biomass-occupied node into an empty node, the effective distance is equal to

*dl*×*Z*_{P};a biomass-occupied grid node into another biomass-occupied node, the effective distance is equal to

*dl*× 2 ×*Z*_{P}.

The term

*Z*_{P}, which we call the phage impedance, captures the degree to which biofilms block diffusion of phage particles.For each grid element

*j*that contains at least one phage, we perform the following steps:Estimate the probability of diffusion into each neighboring grid element

*i*by computing the analytical solution of the diffusion equation of a Dirac function [51], using distances calculated in step (1).Multiply the resulting distribution by the number of phages that are present in element

*j*.Sum the phage distributions obtained by performing step (2a-b) in each grid element, element-wise, and then normalize across all grid elements.

Sample the total number of phages in the system from the distribution calculated in (c) and deposit phages in the system accordingly.

### Computation

Our hybrid framework was written in the Python programming language, drawing from numerical methods developed in the literature [49, 52, 53]. All data analysis was performed using the R programming language (see Supplementary Data). Simulations were performed *en mass* in parallel on the UMass Green High Performance Computing Cluster. Each simulation requires 4-8 hours to run, and more than 150,000 simulations were performed for this study, totaling over 100 CPU-years of computing time.

## Results

### (a) Stables states of bacteria and phages in biofilms

Intuitively, the population dynamics of bacteria and lytic phages should depend on the relative strength of bacterial growth and bacterial removal, including erosion and cell death caused by phage infection and proliferation. We initially explored the behavior of the simulation framework by varying the relative magnitude of bacterial growth versus phage proliferation. In this manner we could observe three broad stable state classes in the bacteria/phage population dynamics. We summarize these classes before proceeding to a more systematic characterization of the simulation parameter space in the following section (Figure 2).

#### (i) Biofilm death

If phage infection and proliferation sufficiently out-pace bacterial growth, then the bacterial population eventually declines to zero as it is consumed by phages and erosion (Figure 2A). Phage infections progressed in a relatively homogeneous wave if host biofilms were flat (Supplementary Video SV1). For biofilms with uneven surface topology, phage infections proceeded tangentially to the biofilm surface and “pinched off” areas of bacterial biomass, which were then sloughed away after losing their connection to the remainder of the biofilm (Supplementary Video SV2).

#### (ii) Coexistence

In some cases both bacteria and phages remained present for the entire simulation run time. We found that coexistence could occur in several different manners, most commonly including rounded biofilm clusters that were maintained by a balance of bacterial growth and death on their periphery (Supplementary Video SV3). When phage infection rate and nutrient availability were high, biofilms entered cycles in which tower structures that were pinched off from the rest of the population by phage propagation then re-grew into new clusters, which were again partially removed by phages (Figure 2B and Supplementary Video SV4). We confirmed the stability of these coexistence conditions numerically by running simulations for extended periods of time (starting from different initial conditions) to ensure that host and phage population sizes either approached constant values or entrained in oscillation regimes (see below, and Supplementary Figure S1).

#### (iii) Phage extinction

We observed many cases in which phages either failed to establish a spreading infection, or phages declined to extinction after briefly propagating in the biofilm (Figure 2C). This occurred when phage infection probability was very low, but also, less intuitively, when nutrient availability and thus bacterial growth were low. Visual inspection of the simulations showed that when biofilms were sparse and slow-growing, newly released phages were more likely to be swept away into the liquid phase than to encounter new host cells to infect (Supplementary Video SV5). At a conservatively realistic maximum bacterial growth rate (see next section for details), biofilms could not outgrow a phage infection and shed phages into the surrounding liquid. However, if bacterial growth was increased beyond this conservative maximum, we found that biofilms could effectively expel phage infections by out-growing them and shedding phages into the liquid phase above them (Supplementary Video SV6). This result, and those described above, heavily depended on the ability of phages to diffuse through the biofilms, a topic to which we turn our attention in the following section.

### (b) Governing parameters of phage spread in biofilms

Many processes can contribute to the balance of bacterial growth and phage propagation in a biofilm system [44, 50]. To probe our simulation framework more systematically, we first chose key control parameters with strong influence on the outcome of phage-host population dynamics. We then performed sweeps of parameter space to build up a general picture of how the population dynamics of the biofilm-phage system depends on underlying features of phages, host bacteria, and biofilm spatial structure.

Building on previous work [44], we identified three key parameters with major effect on how phage infections spread through biofilms. The first of these is environmental (i.e., bulk) nutrient concentration, *N*_{bulk}, an important ecological factor that heavily influences biofilm growth rate. Importantly, varying *N*_{bulk} not only changes the overall biofilm growth rate but also the emergent biofilm structure. When nutrients are sparse, for example, biofilms grow with tower-like projections and high variance in surface height, whereas when nutrients are abundant, biofilms tend to grow with smooth fronts and low variance in surface height [44,46, 54]. We computationally swept *N*_{bulk} to vary biofilm growth from near zero to a conservative maximum allowing for biofilm growth to a height of 250 µm in 24 hours (without phage exposure). The second governing parameter is phage infection probability, which we varied from 0.1% to 99% per host encounter. As noted in the previous section, our initial observations suggested that a third factor, the relative diffusivity of phages within biofilms, also plays a fundamental role. We therefore varied phage movement within the biofilm by changing the phage impedance *Z*_{P}; the larger values of this parameter correspond to lower values of phage diffusivity within biofilms relative to the surrounding liquid. We performed thousands of simulations in parallel to study the combined influence of these three parameters on population dynamics. In Figure 3 the results are visualized as sweeps of nutrient concentration versus phage infectivity for three values of phage impedance. For each combination of these three parameters, we show the distribution of simulation exit condition states in the form of stacked bar charts; these indicate how often simulations terminated with the following three distinct states: biofilm death, phage extinction, or phage-bacteria coexistence. In some cases, biofilms grew to the ceiling of the simulation space, such that the biofilm front could not longer be simulated accurately. To be conservative, the outcome of these cases was designated as undetermined, but they likely correspond to phage extinction or coexistence.

We first considered the extreme case in which phage diffusion is unaltered inside biofilms. In these conditions, bacterial populations do not survive phage exposure unless infection probability is nearly zero, or if nutrient availability is so low that little bacterial growth occurs. In these cases, as we described above, phages either cannot establish an infection at all or are unlikely to encounter new hosts after departing from an infected host after it bursts. Coexistence did not occur in this case (Figure 3a).

When phage diffusivity is reduced within biofilms relative to the surrounding liquid phase (*Z*_{P} = 10), biofilm-dwelling bacteria survive infection for a wider range of phage infection likelihood (Figure 3b). Additionally, a region of parameter space arises in which phages and host bacteria coexist with each other at low to moderate infection probability and high nutrient availability for bacterial growth. Within this region of coexistence, we could find cases of convergence of phage and host populations to stable fixed equilibria, and others in which bacterial and phage populations entered stable oscillations (Figure 2b). The former corresponds to stationary biofilm clusters with a balance of bacterial growth and phage proliferation on their periphery, while the latter corresponds to cycles of biofilm tower projection growth and sloughing after phage proliferation. For low nutrient availability, slow-growing biofilms could avoid phage epidemics by providing too few host cells for continuing infection.

As phage diffusivity within biofilms is decreased further (Figure 3c), coexistence occurs for a broader range of nutrient and infectivity conditions, and biofilm-dwelling bacteria are more likely to survive phage exposure. Interestingly, for *Z*_{P} = 15 there was a substantial expansion of the parameter range in which biofilms survive and phages go extinct. For *Z*_{P} = 10 and *Z*_{P} = 15, we also found cases of unstable coexistence regimes in which bacteria and phages persisted together transiently after phages were introduced to the system, but then either the host or the phage population declined to extinction stochastically over time (Figure 3d-e). Depending on the relative magnitudes of bacterial growth (low vs. high nutrients) and phage infection rates (low vs. high infection probability), this unstable coexistence regime was shifted toward biofilm survival or phage extinction in the long run.

The stochasticity inherent to the spatial simulations provides an automatic test of stability to small perturbations. However, because we are working with fairly intricate simulations that do not lend themselves to analytical simplification, we could not assess the global stability of our predicted system equilibria using conventional means. In order to assess our simulations for their tendency to converge to a given stable state, or stable state distribution, we repeated the parameter sweeps, but varied the time at which phages were introduced. We found that the outcomes were qualitatively identical when compared with the data described above (Figure S1).

Overall, the landscape of different system stable states in parameter space can be quite complex. For example, in Figure 3E-F, at intermediate phage infectivity, low nutrient availability resulted in biofilm survival. Increasing nutrient input leads to biofilm death as biofilms become large enough for phages to take hold and spread through the population. Further increasing nutrient availability leads to a region of predominant coexistence as higher bacterial growth compensates for phage-mediated death. And, finally, increasing nutrient input further still leads to stochastic outcomes of biofilm survival and biofilm death, with the degree of biofilm sloughing and erosion imposing strong chance effects on whether biofilms survive phage exposure.

### (c) Population stable states as a function of phage diffusivity

The findings summarized in Figure 3 suggest dramatic shifts in the distribution bacteria/phage population stable steady states as phage diffusivity is altered within biofilms. These results suggest that phage diffusivity is a critical parameter controlling population dynamics in biofilms. We assessed this idea systemically by varying phage impedance at high resolution and determining the effects on phage/bacteria stable states spectra within biofilms. For each value of phage impedance (*Z*_{P} = 1 − 18), we performed parameter sweeps for the same range of nutrient availability and phage infection probability as described in the previous section, and quantified the fraction of simulations resulting in biofilm death, phage-bacteria coexistence, and phage extinction (Figure 4). With increasing *Z*_{P} we found an increase in the fraction of simulations ending in long-term biofilm survival, either via phage extinction or via coexistence, and a corresponding decrease in conditions leading to biofilm extinction. We expected the parameter space in which phages eliminate biofilms to contract to nil as phage impedance was increased. However, this was not the case; the stable states distribution, which saturated at approximately *Z*_{P} = 15, always presented a fraction of simulations in which bacteria were eliminated by phages.

## Discussion

Biofilm-phage interactions are likely to be ubiquitous in the natural environment and, increasingly, phages are drawing attention as the basis for designing new antibacterial strategies [55]. Due to the complexity of the spatial interplay between bacteria and their phages in a biofilm context, simulations and mathematical modeling will serve a critical role for identifying important features of phage-biofilm interactions. The biofilm mode of growth possesses numerous features that require specific treatment for modeling phage infections. For example, the interactions between nutrient gradients, cell proliferation, biofilm erosion, and phage movement all distinguish the biofilm environment from broader classes of agent based models for studying the spatial spread of disease [56–58]. We therefore developed a new simulation framework that captures these essential processes of biofilm growth and phage infection.

The interaction of bacterial growth, phage infection, and biofilm heterogeneity creates a rich landscape of different population dynamical behavior. At the outset of this work, we hypothesized that bacteria might be able to survive phage attack when nutrients are abundant and bacterial growth rate is high. The underlying rationale was that if bacterial growth and biofilm erosion are fast enough relative to phage proliferation, then biofilms could simply shed phage infections from their outer surface into the passing liquid. This result was not obtained when nutrient input and thus bacterial growth were set at conservatively high values. We speculate that in order for biofilms to shed phage infections in this manner, phage incubation times must be long in relation to bacterial growth rate, and/or biofilm erosion must be exceptionally strong, such that biomass on the biofilm exterior is rapidly and continuously lost into the liquid phase. Our results do not eliminate this possibility entirely, but they do suggest that this kind of spatial escape from phage infection does not occur under a broad range of conditions.

Biofilms were able to repel phage epidemics in our simulations when nutrient availability was low, resulting in slow bacterial growth and widely spaced biofilm. When biofilms are sparse, phage-bacteria encounters are less likely to occur, and thus a higher probability of infection per phage-host contact event is required to establish a phage epidemic. Even if phages do establish an infection in a biofilm cluster, when bacterial growth rates are low, the nearest biofilm cluster may be far enough away from the infected cluster that phages simply are not able to spread from one biofilm to another before being swept away by fluid flow. This result is directly analogous to the concept of threshold host density as it applies in wildlife disease ecology [56, 59–61]. If host organisms, or clusters of hosts, are not distributed densely enough relative to the production rate and dispersal of a parasite, then epidemics cannot be sustained. Note that in our system, this observation depends on the scale of observation [62]. In a meta-population context, phage proliferation and subsequent removal into the passing liquid may lead to an epidemic on a larger spatial scale, for example, if other areas are well populated by susceptible hosts.

Our simulations suggest that coexistence of lytic phages and susceptible host bacteria can occur more and more readily as the ability of phages to diffuse through biofilms decreases. In two important early papers on phage-bacteria interactions under spatial constraint, Heilmann et al. [38, 63] also suggested that coexistence occurs under a broad array of conditions as long as bacteria could produce refuges, that is, areas in which phage infectivity is decreased. An important distinction of our present work is that bacterial refuges against phage infection emerge spontaneously as a result of the interaction between biofilm growth, phage proliferation and diffusion, and erosion of biomass into the surrounding liquid phase. Furthermore, we emphasize that reducing phage infectivity and reducing phage diffusivity through biofilms are two alternative but complementary means by which biofilm-dwelling bacteria can enhance the chances for survival during phage exposure. Another important result of our simulations is that coexistence of biofilm-dwelling bacteria and lytic phages can be rendered dynamically unstable by modest changes in nutrient availability or phage infection likelihood. In these cases, the host bacterial population or the phages go extinct stochastically, with the balance between these two outcomes resting on the relative magnitudes of biofilm growth and phage infection probability.

The extracellular matrix is central to the ecology and physiological properties of biofilms [20, 33, 64–67]. In the simulations explored here, biofilm matrix was modeled implicitly and is assumed to cause changes in phage diffusivity; our results support the intuition that by altering phage mobility and their physical access to new hosts, the biofilm matrix is likely to be of fundamental importance in the ecological interplay of bacteria and their phages. There is very little work thus far on the spatial localization and diffusion of phages inside experimental biofilms, but the available literature is consistent with the idea that the matrix interferes with phage movement [29, 30, 68]. Furthermore, experimental evolution work has shown that bacteria and their phages show different evolutionary trajectories in biofilms versus planktonic culture [15, 36, 69]. Especially notable here is the fact that *Pseudomonas fluorescens* evolves matrix hyper-production in response to consistent phage attack [36]. The molecular and ecological details by which the biofilm matrix influences phage proliferation are important areas for future study.

In this study, we have introduced a new approach to studying phage-biofilm interactions *in silico*, which required us to consider many unique features of bacterial growth in communities on surfaces. Using this framework we have identified important parameters and spatial structures of biofilms that govern the population dynamics of phage infections. An important area for future study will be to use these simulation techniques to investigate bacterial resistance and phage host range coevolution. We envision that bacteria-phage coevolution in the biofilm context may present an important expansion upon the history of work on this classical area of microbial ecology.

## Author Contributions

CDN and VB conceived the project; MS, VB, and CDN designed simulations; MS wrote and performed simulations and scripts for the raw figures; MS, CDN, VB, and KD analyzed data; CDN coordinated the figure assembly and manuscript drafting; CDN, VB, MS, and KD wrote the paper.

## Funding

CDN is supported by the Alexander von Humboldt Foundation. V.B. acknowledges support from the National Institute of Allergy and Infectious Disease (grant R15-AI112985-01A), and the National Science Foundation (grant 1458347). KD is supported by the Max Planck Society, the Human Frontier Science Program (CDA00084/2015-C), the Behrens Weise Foundation, and the European Research Council (716734).

**Supplementary Video Files**

**Video SV1:** A simulation corresponding to biofilm eradication when the biofilm is growing as a uniform front. Uninfected bacteria are shown in red, infected bacteria are shown in blue, and phages are shown in black.

**Video SV2:** A simulation corresponding to biofilm eradication after biofilms have produced tower-like structures and a spatially heterogeneous front. This pattern of biofilm morphology occurs more readily as nutrients become scarce; here phage-induced death occurs mostly at the flanks of these towers, which are sloughed from the biofilm front. Red = bacterial biomass, black = phages.

**Video SV3:** A simulation corresponding to long-term coexistence of bacteria and phages, in which both populations remain at constant or nearly unchanging size. Uninfected bacteria are shown in red, infected bacteria are shown in blue, and phages are shown in black.

**Video SV4:** A simulation corresponding to long-term coexistence of bacteria and phages, with oscillating population size for bacteria and phages. This pattern corresponds to growth, phage-induced sloughing, and re-growth of biofilm towers over time. Uninfected bacteria are shown in red, infected bacteria are shown in blue, and phages are shown in black.

**Video SV5:** A simulation corresponding to phage extinction due to low bacterial growth and consequent low likelihood of phage-bacterial encounter. Uninfected bacteria are shown in red, infected bacteria are shown in blue, and phages are shown in black.

**Video SV6:** A simulation corresponding to phage extinction due to extremely rapid biofilm growth and phage expulsion from the biofilm biomass; this result occurred only when biofilm growth rate was increased to a point that is empirically unrealistic. Uninfected bacteria are shown in red, infected bacteria are shown in blue, and phages are shown in black.

## Acknowledgements

We are grateful to Ann Tate, Petra Klepac, and Adrian de Froment for comments on the manuscript.

## References

- [1].↵
- [2].↵
- [3].
- [4].
- [5].
- [6].↵
- [7].↵
- [8].
- [9].
- [10].↵
- [11].
- [12].
- [13].
- [14].↵
- [15].↵
- [16].
- [17].↵
- [18].↵
- [19].
- [20].↵
- [21].
- [22].↵
- [23].↵
- [24].
- [25].
- [26].
- [27].
- [28].↵
- [29].↵
- [30].↵
- [31].↵
- [32].↵
- [33].↵
- [34].↵
- [35].↵
- [36].↵
- [37].
- [38].↵
- [39].↵
- [40].
- [41].↵
- [42].↵
- [43].↵
- [44].↵
- [45].
- [46].↵
- [47].↵
- [48].↵
- [49].↵
- [50].↵
- [51].↵
- [52].↵
- [53].↵
- [54].↵
- [55].↵
- [56].↵
- [57].
- [58].↵
- [59].↵
- [60].
- [61].↵
- [62].↵
- [63].↵
- [64].↵
- [65].
- [66].
- [67].↵
- [68].↵
- [69].↵