*Pseudomonas aeruginosa* is a widespread opportunistic pathogen that thrives in a range of different environments, including hospitals, where it is a common source of nosocomial infections. In particular, it frequently colonises the lungs of cystic fibrosis patients, in whom it is the leading cause of morbidity and mortality^[@R9]^. In part fuelled by a renewed interest in the therapeutic use of bacteriophages as antimicrobials (phage therapy)^[@R10],[@R11]^, many studies have examined if and how *P. aeruginosa* evolves resistance to phage (reviewed in ref. [@R12]). The clinical isolate *P. aeruginosa* strain PA14 has been reported to predominantly evolve resistance against its phage DMS3*vir* by the modification or complete loss of the phage receptor (Type IV pilus) when grown in nutrient-rich medium^[@R5]^, despite carrying an active CRISPR-Cas adaptive immune system ([C]{.ul}lustered [R]{.ul}egularly [I]{.ul}nterspaced [S]{.ul}hort [P]{.ul}alindromic [R]{.ul}epeats; [C]{.ul}RISPR-[as]{.ul}sociated). Conversely, under nutrient-limited conditions, the same strain relies on CRISPR-Cas to acquire phage resistance^[@R5]^. These differences are due to higher phage densities during infections in nutrient-rich compared to nutrient-limited conditions, which in turn determines whether surface-based resistance (with a fixed cost of resistance) or CRISPR-based resistance (infection-induced cost) is favoured by natural selection^[@R5],[@R13]^. While these observations suggest abiotic factors are critical determinants of the evolution of phage resistance strategies, the role of biotic factors has remained unclear, even though *P. aeruginosa* commonly co-exists with a range of other bacterial species in both natural and clinical settings^[@R14],[@R15]^. We hypothesised that the presence of a bacterial community could drive increased levels of CRISPR-based resistance evolution for mainly two reasons. Firstly, reduced *P. aeruginosa* densities in the presence of competitors may limit phage amplification, favouring CRISPR-based resistance^[@R5]^. Secondly, pleiotropic costs associated with phage receptor mutation may be amplified during interspecific competition.

Bacterial biodiversity drives CRISPR evolution {#S1}
==============================================

To explore these hypotheses, we co-cultured *P. aeruginosa* PA14 with three other clinically relevant opportunistic pathogens that can co-infect with *P. aeruginosa*, namely *Staphylococcus aureus*, *Burkholderia cenocepacia*, and *Acinetobacter baumannii*^[@R14]--[@R17]^, none of which can be infected by or interact with phage DMS3*vir* ([Extended Data Fig. 1](#F4){ref-type="fig"}). We applied a "mark-recapture" approach using a *P. aeruginosa* PA14 mutant carrying streptomycin resistance in order to monitor the bacterial population dynamics and phage resistance evolution in the focal subpopulation at 3 days post infection (d.p.i.). This revealed that in nutrient-rich Lysogeny Broth, PA14 evolved significantly higher levels of CRISPR-based resistance following infection with 10^6^ plaque forming units (p.f.u.) of phage DMS3*vir* when co-cultured with other bacterial species compared to when grown in isolation or co-cultured with an isogenic surface mutant ([Fig. 1a](#F1){ref-type="fig"}). Additionally, we found that these effects were dependent on the identity of the species that were present in the mixed culture, with the strongest effects being observed in the presence of *A. baumannii* or a mix of the three bacterial species, and an absence of any effect when PA14 was co-cultured with an isogenic surface mutant that lacked the phage receptor ([Fig. 1a](#F1){ref-type="fig"}, Deviance test: Relationship between community composition and CRISPR; Residual deviance(30, n = 36) = 1.81, p = 2.2 x 10^-16^; Tukey contrasts: Monoculture v Mixed; z = -5.99, p = 3.02 x 10^-8^; Monoculture v *A. baumannii*; z = -4.33, p = 0.00023; Monoculture v *B. cenocepacia*; z = -3.76, p = 0.0026; Monoculture v *S. aureus*; z = -2.38, p = 0.26; Monoculture v surface mutant; z = 2.26, p = 0.35). Interestingly, *P. aeruginosa* densities were strongly reduced in the presence of *A. baumannii*, *B. cenocepacia* and the mixed community, while on the other hand it dominated the community during competition with *S. aureus* despite the presence of phage DMS3*vir* ([Fig. 1b](#F1){ref-type="fig"}), suggesting a positive relationship between the strength of interspecific competition and the levels of CRISPR-based resistance evolution.

Next, to explore the clinical relevance of this observation, we performed a similar experiment in artificial sputum medium (ASM), which is a nutrient rich medium that mimics the abiotic environment of sputum from cystic fibrosis patients^[@R18]^. This revealed a similar pattern as that observed in Lysogeny Broth, with *A. baumannii* and the community as a whole resulting in a drastic increase in CRISPR-based resistance ([Extended Data Fig. 2](#F5){ref-type="fig"}). To further explore the generality of these findings, we also manipulated the microbial community composition by varying the proportion of *P. aeruginosa* versus the other pathogens. This revealed that increased CRISPR-based resistance evolution occurred across a wide range of microbial community compositions, with a maximum effect size when *P. aeruginosa* made up 50% of the initial mixture ([Extended Data Fig. 3](#F6){ref-type="fig"}). An exception to this trend was when the *P. aeruginosa* subpopulation made up only 1% of the total community; in this case sensitive bacteria persisted alongside resistant bacteria because of the reduced size of the phage epidemic and hence relaxed selection for resistance ([Extended Data Fig. 3](#F6){ref-type="fig"}). Collectively, these data suggest that greater levels of interspecific competition contribute to the evolution of CRISPR-based resistance.

Biodiversity amplifies costs of surface-based resistance {#S2}
========================================================

We hypothesised that reduced *P. aeruginosa* population sizes in the presence of competitors might explain the increased evolution of CRISPR-based resistance, as this leads to smaller phage epidemics, which is known to favour CRISPR over surface-based resistance^[@R5]^. However, variation in the force of infection did not seem to play a strong role in the observed effects, since even though phage epidemic sizes varied depending on the microbial community composition ([Extended Data Fig. 4](#F7){ref-type="fig"}), this did not correlate with the levels of evolved CRISPR-resistance ([Extended Data Fig. 5](#F8){ref-type="fig"}). Moreover, when manipulating the DMS3*vir* starting phage titres, we observed no differences in the levels of evolved CRISPR-based resistance when *P. aeruginosa* was co-cultured in the presence of the microbial community ([Extended Data Fig. 6](#F9){ref-type="fig"}). An alternative explanation for the observed effects may therefore be that the fitness cost of surface-based resistance is amplified in the presence of other bacterial species, for example due to cell surface molecules playing a part in interspecific competition^[@R19]^, which again would result in stronger selection towards bacteria with CRISPR-based resistance. To test this hypothesis, we competed the two phage resistant phenotypes (i.e. CRISPR-resistant and surface mutant) in the presence or absence of the microbial community, and across a range of phage titres. In the absence of the microbial community and phage, CRISPR-resistant bacteria had a small fitness advantage over bacteria with surface-based resistance, but this advantage disappeared when phage was added and as titres increased ([Fig. 2a](#F2){ref-type="fig"}, and ref. [@R5]). In the presence of the biodiverse microbial community however, the relative fitness of bacteria with CRISPR-based resistance was consistently higher, demonstrating that mutation of the Type IV pilus is more costly when bacteria compete with other bacterial species ([Fig. 2a](#F2){ref-type="fig"}, Linear model: Effect of community absence; t = -5.54, p = 1.49 x 10^-7^; Effect of increasing phage titre; t = -2.41, p = 0.017; Overall model fit; Adjusted R^2^ = 0.41, F~4,139~= 25.48, p = 7.65 x 10^-16^). The increased fitness trade-off associated with surface-based resistance was also observed when the CRISPR- and surface-resistant phenotypes competed in the presence of only a single additional species ([Fig. 2b](#F2){ref-type="fig"}, Two-way ANOVA with Tukey contrasts: Overall difference in fitness; F~4,2~ = 8.151 p = 6.31 x 10^-6^; Monoculture v Mixed; p = 0.011; Monoculture v *A. baumannii;* p = 0.016; Monoculture v *B. cenocepacia*; p = 0.022), with the exception of *S. aureus* ([Fig. 2d](#F2){ref-type="fig"}. Monoculture v *S. aureus*; p = 0.80), concordant with this species being the weakest competitor and inducing the lowest levels of CRISPR-based resistance ([Fig. 1](#F1){ref-type="fig"}). These fitness trade-offs therefore explain why *P. aeruginosa* evolved greater levels of CRISPR-based resistance in the presence of the other pathogens, and why this varied depending on the competing species ([Fig. 1](#F1){ref-type="fig"}).

Type of phage-resistance affects *P. aeruginosa* virulence {#S3}
==========================================================

Evolution of phage resistance by bacterial pathogens is often associated with virulence trade-offs when surface structures are modified^[@R20]^, whereas similar trade-offs have not yet been reported in the literature for CRISPR-based resistance. We therefore hypothesised that the community context in which phage resistance evolves may have important knock-on effects for *P. aeruginosa* virulence. To test this, we used a *Galleria mellonella* infection model, which is commonly used to evaluate virulence of human pathogens^[@R21],[@R22]^. We compared *in vivo* virulence of *P. aeruginosa* clones that evolved phage resistance against phage DMS3*vir* in different community contexts by injecting larvae with a mixture of clones that had evolved phage-resistance in either the presence or absence of the mixed bacterial community ([Extended Data. Fig. 3c](#F6){ref-type="fig"}). Taking time to death as a proxy for virulence, we found that evolution of phage resistance in the presence of a microbial community was associated with greater levels of *P. aeruginosa* virulence compared to when phage-resistance evolved in monoculture, and remained similar to that of the ancestral PA14 strain ([Fig. 3a](#F3){ref-type="fig"}, Cox proportional hazards model with Tukey contrasts: Community present v absent; z = 5.85, p = 1 x 10^-4^; ancestral PA14 v community absent; z = 4.42, p = 1 x 10^-4^; ancestral PA14 v community present; z = -1.30, p = 0.38. Overall model fit; LRT~3~ = 51.03, n = 376, p = 5 x 10^-11^). These data, in combination with the fact that the Type IV pilus is a well-known virulence factor^[@R23]^, are consistent with the notion that the mechanism by which bacteria evolve phage resistance has important implications for bacterial virulence. To more directly test this, we next infected larvae with each individual *P. aeruginosa* clone for which we had previously determined the mechanism underlying evolved phage resistance ([Extended Data Fig. 3c](#F6){ref-type="fig"}), again using time to death as a measure of virulence. This showed that bacterial clones with surface-based resistance - unlike those with CRISPR-based resistance - both had drastically reduced swarming motility (as expected for mutations in the Type IV pilus^[@R23]^) ([Fig. 3b](#F3){ref-type="fig"}, One-way ANOVA with Tukey contrasts: Overall effect; F~2,977~= 472.5, p = 2.2 x 10^-16^; Sensitive v CRISPR; p = 0.87; CRISPR v Surface mutant ; p = 1 x 10^-5^) and impaired virulence compared to phage sensitive bacteria ([Fig. 3c](#F3){ref-type="fig"}, Cox proportional hazards model with Tukey contrasts: Surface mutant v CRISPR; z = -2.37, p = 0.045; Sensitive v CRISPR; z = 2.10, p = 0.10; Surface mutant v Sensitive; z = -4.23, p = 1 x 10^-3^. Overall model fit; LRT~3~ = 48.66, n = 981, p = 2 x 10^-10^). Similar virulence trade-offs were also observed when larvae were injected with *P. aeruginosa* PA14 clones that had evolved surface-based resistance against phage LMA2, which uses LPS (lipopolysaccharide) as a receptor ([Extended Data Fig. 7](#F10){ref-type="fig"}).

Discussion {#S4}
==========

We have shown that the evolutionary outcome of bacteria-phage interactions can be fundamentally altered by the microbial community context. While traditionally studied in isolation, these interactions are usually embedded in complex biotic networks of multiple species, and it is becoming increasingly clear that this can have key implications for the evolutionary epidemiology of infectious disease^[@R24]--[@R28]^. Our work shows that the community context can shape the evolution of different host resistance strategies. Specifically, we find that the interspecific interactions between four bacterial species in a synthetic microbial community can have a large impact on the evolution of phage resistance mechanisms by amplifying the constitutive fitness cost of surface-based resistance^[@R5]^. The finding that biotic complexity matters complements previous work on the effect of abiotic variables and force of infection on phage resistance evolution^[@R5]^. The data presented here suggests that the impact of biotic complexity on the evolution of CRISPR-based resistance is stronger than that of variation in phage abundance, which is consistent with the observation that in the presence of the polymicrobial community, bacteria with CRISPR-based resistance outcompeted bacteria with surface-based resistance at all phage titres ([Fig. 2](#F2){ref-type="fig"}). The amplified fitness cost of surface mutation also suggest that the type Type IV pilus plays an important role in interspecific competition. While future work will be critical to understand the detailed molecular mechanism that underpins these effects, and to further generalise the findings described here to other bacterial species and strains, we speculate that the way in which the microbial community composition drives the evolution of phage resistance strategies may be important in the context of phage therapy. Primarily, the absence of detectable trade-offs between CRISPR-based resistance and virulence, as opposed to when bacteria evolve surface-based resistance, suggests that evolution of CRISPR-based resistance can ultimately influence the severity of disease. Moreover, evolution of CRISPR-based resistance can drive more rapid phage extinction^[@R29]^, and may in a multi-phage environment result in altered patterns of cross-resistance evolution compared to surface-based resistance^[@R30]^. The identification of the drivers and consequences of CRISPR-resistance evolution might help to improve our ability to predict and manipulate the outcome of bacteria-phage interactions in both natural and clinical settings.

Methods {#S5}
=======

All statistical analyses were done using R version 3.5.1. (R Core Team, 2018), and the Tidyverse package version 1.2.1. (Wickham, 2017). All *Galleria mellonella* mortality analyses were done using the Survival package version 2.38 (Therneau, 2015).

Bacterial strains and viruses {#S6}
-----------------------------

We used a marked *P. aeruginosa* UCBPP-PA14 mutant carrying a streptomycin resistant gene inserted into the genome using pBAM1^[@R31]^ (referred to as the ancestral PA14 strain). The WT PA14 bacteriophage-insensitive mutant with 2 CRISPR spacers (BIM2), the surface mutant derived from the PA14 *csy3::LacZ* strain, and phage DMS3*vir* and DMS3*vir*+*acrF1*(carrying an anti-CRISPR gene) have all been previously described (refs. [@R5] and [@R29] and references therein). The bacteria used as the microbial community were *Staphylococcus aureus* strain 13 S44 S9, *Acinetobacter baumannii* clinical isolate FZ21 and *Burkholderia cenocepacia* J2315, and were all isolated from patients at Queen Astrid Military Hospital, Brussels, Belgium.

Adsorption and infection assays {#S7}
-------------------------------

Phage infectivity against each of the bacterial species used in this study was assessed by spotting serial dilutions of virus DMS3*vir* on lawns of the individual community bacteria, followed by checking for any plaque formation after 24 hours of growth at 37°C. Adsorption assays (as shown in [Extended Data Fig. 1](#F4){ref-type="fig"}) were performed by monitoring phage titres over time, for up to an hour (At 0, 2, 4, 6, 8, 10, 15 and 20 minutes post infection for PA14, and at 0, 5, 10, 20, 40 and 60 minutes post infection for the other bacteria species. For the no-bacterial control, sampling was done at 0 and 60 minutes post infection), after inoculating the individual bacteria in mid-log phage at approximately 2 x 10^8^ c.f.u. with phage DMS3*vir* at 2 x 10^6^ p.f.u. (final MOI = 0.001). Adsorption assays were carried out in falcon tubes containing 15ml LB medium, incubated at 37°C while shaking at 180 r.p.m. (three independent replicates per experiment). At each timepoint, 50μl of sample was transferred to pre-cooled eppendorfs on ice, containing 900μl LB medium and 50μl chloroform, before vortexing for 10 seconds. After sampling was completed, all eppendorfs were centrifuged at full speed at 4 °C for \>5 minutes after which 300μl of the supernatant was extracted, diluted and spotted onto lawns of *P. aeruginosa* before checking for plaque formation after 24h of growth at 37 °C.

Coevolution experiments {#S8}
-----------------------

The streptomycin resistant mutant of the ancestral strain of *P. aeruginosa* was used for all coevolution experiments. Evolution experiments (shown in [Fig. 1](#F1){ref-type="fig"}, and [Extended Data Figs. 2](#F5){ref-type="fig"} and [3](#F6){ref-type="fig"}) were performed by inoculating 60μl from overnight cultures (containing approximately 10^6^ colony-forming units (c.f.u.)) into glass microcosms containing 6ml LB medium ([Fig. 1](#F1){ref-type="fig"} and [Extended Data Fig. 3](#F6){ref-type="fig"}), or artificial sputum medium^[@R18]^ (ASM) ([Extended Data Fig. 2](#F5){ref-type="fig"}). 1 litre of ASM was made by mixing 5g mucin from porcine stomach (Sigma), 4g low molecular-weight salmon sperm DNA (Sigma), 5.9mg diethylene triamine pentaacetic acid (DTPA) (Sigma), 5g NaCL (Sigma), 2.2g KCl (Sigma), 1.81g Tris base (Thermo Fisher Scientific), 5ml egg yolk emulsion (Sigma), and 250mg of each of 20 amino acids (Sigma), as described in ref. [@R18]. Inoculation was followed by incubation at 37°C while shaking at 180 r.p.m. (n = 6 per treatment). The polyculture mixes either consisted of approximately equal amounts of all four bacterial species or mixes of *P. aeruginosa* with just one additional species where *P. aeruginosa* made up 25% of the total volume used for inoculation (i.e. 15 μl of 60μl), unless otherwise indicated (i.e. [Extended Data Fig. 3](#F6){ref-type="fig"}). Before inoculation, phage DMS3*vir* was added at 10^6^ p.f.u. ([Fig. 1](#F1){ref-type="fig"} and [Extended Data Fig. 2](#F5){ref-type="fig"}), or at 10^4^ p.f.u. ([Extended Data Fig. 3](#F6){ref-type="fig"}). Transfers of 1:100 into fresh broth were done daily for a total of three days. Additionally, phage titres were monitored daily by spotting chlorophorm-treated lysate dilutions on a lawn of *P. aeruginosa csy3::LacZ*. Downstream analysis to determine if and how bacteria evolved phage resistance was done by cross-streak assays and PCR on 24 randomly selected clones per replicate experiment, as described in ref. [@R5].

DNA extraction and qPCR {#S9}
-----------------------

For the experiment shown in [Fig. 1](#F1){ref-type="fig"}, the densities of the different bacterial species in the microbial communities over time were determined using qPCR. DNA was extracted from all replicas using the DNeasy UltraClean Microbial Kit (Qiagen), following the manufacturer instructions. Prior to DNA extraction, to ensure lysis of *S. aureus*, 15μl lysostaphin (Sigma) at 0.1 mg/ml was added to 500μl of sample followed by incubation at 37°C for at least one hour. For *P. aeruginosa*, *A. baumannii*, and *B. cenocepacia*, the 16S gene was chosen as the target for the qPCR primers and were as follows: the PA14 forward primer (PA14-16s-F), AGTTGGGAGGAAGGGCAGTA; the PA14 reverse primer (PA14-16s-R), GCTTGCTGAACCACTTACGC; the *A. baumannii* forward primer (AB-16s-F), ATCAGAATGCCGCGGTGAAT; the *A. baumannii* reverse primer (AB-16s-R), ACCGCCCTCTTTGCAGTTAG; the *B. cenocepacia* forward primer (BC-16s-F), ATACAGTCGGGGGATGACGG; the *B. cenocepacia* reverse primer (BC-16s-R), TCACCAATGCAGTTCCCAGG. For *S. aureus*, we used qPCR primers previously described in ref. [@R32]. The amplification reactions were performed in triplicates, with Brilliant SYBR Green reagents (Agilent) in 20μl reactions made up of 10μl master mix, 2μl primer pair, 0.4μl dye, and sterile nuclease free water to a total volume of 15μl before adding 5μl diluted DNA sample. The qPCR program was as follows: 95°C for 3 minutes, 40 cycles at 95°C for 10 seconds and 60°C for 30 seconds. All qPCR's and results were analysed using the Applied Biosystems QuantStudio 7 Flex Real-Time PCR system.

Competition experiments {#S10}
-----------------------

For both competition experiments shown in [Fig. 2](#F2){ref-type="fig"}, the BIM2 clone was competed against the surface mutant derived from the PA14 *csy3::LacZ* strain^[@R5]^. Bacteria were grown for 24 hours in glass microcosms containing 6ml LB medium, in a shaking incubator at 180 r.p.m. and at 37°C. For the experiment shown in [Fig. 2a](#F2){ref-type="fig"}, the two phenotypes were competed in the presence or absence of the mixed microbial community, either without the addition of phage (n = 36), or infected with phage DMS3*vir* at 10^4^, 10^6^, and 10^8^ p.f.u. (n = 12 per treatment). For the experiment shown in [Fig. 2b](#F2){ref-type="fig"}, the two phage resistant phenotypes were again competed either in the presence or absence individual bacterial species or a mixed community of all species. *P. aeruginosa* made up 25% of the total volume of 60μl that was used to inoculate the 6ml of LB medium (n = 24 per treatment). Samples were taken at 0 and 24 hours post infection., and the cells were serial diluted in M9 salts and plated on cetrimide agar (Sigma) supplemented with ca. 50μg ml^-1^ X-gal (to select for *P. aeruginosa*, while also differentiating between the CRISPR-resistant clones (white) and the surface mutant (blue)). Relative fitness was calculated as described in refs. [@R5] and [@R29].

Virulence assays {#S11}
----------------

All infection experiments were done using *Galleria mellonella* larvae (UK WaxWorm Ltd). Throughout the experiments, the larvae were stored in 12-well plates, with one larva per well, and were all checked for mortality and melanisation before injection. Bacterial inoculums were prepared depending on experiment, and were as follows; For the experiment shown in [Fig. 3a](#F3){ref-type="fig"}, all 24 evolved clones from each replicate from the 25% (community present) and 100% (community absent) treatments ([Extended Data Fig. 3](#F6){ref-type="fig"}) were pooled together by replica (n = 6 per treatment) and mixed in 6mL of LB medium. Each mixture of clones was injected into ten individual larvae, with time to death measured as a proxy for virulence. This procedure was performed in three independent repeats by injecting the same mixtures of bacterial clones into independent batches of larvae in separate experiments (total no. of larvae = 420). To assess virulence of all evolved clones ([Fig. 3c](#F3){ref-type="fig"}), infections were done independently using all the individual PA14 clones from 3 d.p.i. from the experiment shown in [Extended Data Fig. 3](#F6){ref-type="fig"} (n = 1008). Here ([Fig. 3c](#F3){ref-type="fig"}), the bacterial inoculums were prepared individually for each clone by inoculating 200μl LB medium with 5μl bacterial sample from freezer stock, repeated for all individual clones in 96-well plates. Finally, to measure whether surface-based resistance against an LPS-specific phage was associated with similar virulence trade-offs ([Extended data fig. 7](#F10){ref-type="fig"}), we isolated *P. aeruginosa* clones from 6 independent infection experiments with phage LMA2. A total of 10 clones per replicate experiment, isolated from 3 d.p.i., were phenotypically characterised to confirm resistance, and examined by PCR to exclude that resistance was CRISPR-based. All 10 clones with LPS-based resistance from the same replicate experiment were pooled together in 6ml of LB medium (n = 6), and infections of *G. mellonella* larvae were carried out as described above, with each mixture of clones injected into ten individual larvae, performed in three independent repeats (total no. of larvae = 240). Prior to infection, all bacterial inoculums were grown overnight at 37°C on an orbital shaker (180 r.p.m.) before being diluted by adding 20μl to 180μl of M9 salts. Cell density was then assayed by measuring OD~600~ absorbance, with 0.1OD being \~1 x 10^8^ cfu/ml, before being further diluted down to approximately 10^4^cfu/ml, which was subsequently used for infection by injecting 10μl into the rear proleg of individual *G. mellonella* using a sterile syringe as further described in ref. [@R22]. OD measurements and experimental repeats were taken into account during formal data analysis. Following infection, larvae were incubated at 28°C, with mortality monitored hourly for up to 48 hours. For all independent experiments, a control where larvae were injected with just M9 salts was included. All work conforms to ethical regulations regarding the use of invertebrates, with approval from The University of Exeter ethics committee.

Motility assays {#S12}
---------------

Swarming motility of all evolved bacterial clones from the experiment shown in [Extended Data Fig. 3c](#F6){ref-type="fig"} (n = 1008) was assayed by using a 96-well microplate pin replicator to stamp the individual clones on 1% agar before overnight growth at 37°C. The diameters of the individual clones were then taken as a measure of motility (three replicas per clone).

Extended Data {#S13}
=============

![Only *P. aeruginosa* adsorbs phage DMS3*vir*.\
Phage levels, given in plaque-forming units per millilitre, in minutes post infection of *P. aeruginosa* PA14 and three other bacterial species (n = 252 biologically independent samples). Controls were carried out in the absence of bacteria. Here, the lines are regression slopes with shaded areas corresponding to 95% confidence intervals. Linear model: Effect of *P. aeruginosa* on phage titre over time; t = -3.37, p = 0.0009; *S. aureus*; t = 1.63, p = 0.11; *A. baumannii*; t = 1.20, p = 0.23; *B. cenocepacia*; t = -0.27, p = 0.79; Overall model fit; F~9,235~= 4.33, adjusted R^2^ = 0.11, p = 3.17 × 10^-5^.](EMS84425-f004){#F4}

![Enhanced CRISPR resistance evolution in artificial sputum medium.\
Proportion of *P. aeruginosa* that acquired surface modification (SM) or CRISPR-based immunity (or remained sensitive) at 3 days post infection with phage DMS3*vir* when grown in artificial sputum medium (6 replicates per treatment, with 24 colonies screened from each replicate, n = 720 biologically independent samples). Deviance test: Relationship between community composition and CRISPR; Residual deviance(25, n = 30) = 1.26, p = 2.2 × 10^-16^; Tukey contrasts: Monoculture v Mixed; z = -5.30, p = 1 × 10^-4^; Monoculture v *A. baumannii*; z = -5.60, p = 1 × 10^-4^; Monoculture v *B. cenocepacia*; z = -2.80, p = 0.02; Monoculture v *S. aureus*; z = -0.76, p = 0.93. Error bars correspond to ± one standard error, with the mean as the measure of centre.](EMS84425-f005){#F5}

![Increased CRISPR-based resistance evolution across a range of microbial community compositions over time.\
Proportion of *P. aeruginosa* that acquired surface modification (SM) or CRISPR-based immunity (or remained sensitive) at up to 3 days post infection (d.p.i.) with phage DMS3*vir* when grown either in monoculture (100%), or in polyculture mixtures consisting of the mixed microbial community but with varying starting percentages of *P. aeruginosa* based on volume. (6 replicates for most samples, with 24 colonies per replicate, n = 2784 biologically independent replicates). (**a**) Resistance evolution at 1 d.p.i. Error bars correspond to ± one standard error, with the mean as the measure of centre. Deviance test: Relationship between CRISPR and *P. aeruginosa* starting percentage at timepoint 1; Residual deviance(34, n = 41) = 4.42, p = 0.004; 1%; z = -3.27, p = 0.002; 10%; z = 1.21, p = 0.23; 25%; z = 1.62, p = 0.11; 50%; z = 2.20, p = 0.034; 90%; z = 2.07, p = 0.046; 99%; z = 0.47, p = 0.65; 100%; z = 1.47, p = 0.15. (**b**) Resistance evolution at 2 d.p.i. Error bars correspond to ± one standard error, with the mean as the measure of centre. Deviance test: Relationship between CRISPR and *P. aeruginosa* starting percentage at timepoint 2; Residual deviance(25, n = 32) = 3.86, p = 2.51 × 10^-6^; 1%; z = -2.14, p = 0.04; 10%; z = 1.19, p = 0.25; 25%; z = 2.07, p = 0.049; 50%; z = 1.89, p = 0.07; 90%; z = 1.12, p = 0.27; 99%; z = 1.21, p = 0.24; 100%; z = 1.11, p = 0.28. (**c**) Resistance evolution at 3 d.p.i. Error bars correspond to ± one standard error, with the mean as the measure of centre. Deviance test: Relationship between CRISPR and *P. aeruginosa* starting percentage at Timepoint 3; Residual deviance(35, n = 42) = 8.24, p = 0.0004; 1%; z = -3.38, p = 0.002; 10%; z = 2.12, p = 0.04; 25%; z = 2.77, p = 0.009; 50%; z = 3.07, p = 0.004; 90%; z = 2.46, p = 0.019; 99%; z = 1.55, p = 0.13; 100%; z = 0.87, p = 0.39.](EMS84425-f006){#F6}

![Microbial community composition impacts phage epidemic size.\
The DMS3*vir* phage titres (in plaque-forming units per millilitre) over time up to 3 days post infection of *P. aeruginosa* grown either in monoculture (100%), or in polyculture mixtures as shown in [Extended Data Fig. 3](#F6){ref-type="fig"}. Each data point represents the mean, with error bars corresponding to ± one standard error (n = 171 independent biological samples). Two-way ANOVA: Overall effect of *P. aeruginosa* starting percentage on phage titre; F~6,105~ = 14.84, p = 1.1 × 10^-12^.](EMS84425-f007){#F7}

![No correlation between phage epidemic size and evolution of CRISPR resistance.\
The correlation between the proportion evolved phage resistant clones with CRISPR-based resistance and the phage epidemic sizes (in plaque-forming units per millilitre) in the presence of other bacterial species, using data taken from experiments shown in [Fig. 1](#F1){ref-type="fig"}, [Extended Data Fig. 2](#F5){ref-type="fig"}, [Extended Data Fig. 3c](#F6){ref-type="fig"} and [Extended Data Fig. 6](#F9){ref-type="fig"} (n = 137 biologically independent samples per timepoint). Correlations are separated by day, as phage titres were measured daily. Here, the lines are regression slopes, with shaded areas corresponding to 95% confidence intervals. Pearson's Product-Moment Correlation tests between phage titres (at each day post infection) and levels of CRISPR-based resistance: T = 1; t~136~ = -0.02, p = 0.98, R2 = -0.002; T = 2; t~136~ = 0.59, p = 0.55, R2 = 0.05; T = 3; t~136~ = -0.90, p = 0.37, R2 = -0.08.](EMS84425-f008){#F8}

![Starting phage titre does not affect CRISPR evolution in the presence of a microbial community.\
Proportion of *P. aeruginosa* that acquired CRISPR-based resistance at 3 days post infection with varying starting titres of phage DMS3*vir* when grown in polyculture (n = 127 biologically independent samples). Deviance test: Start phage and CRISPR; Residual deviance(20, n = 24) = 2.00, p = 0.13; Tukey contrasts: 10^2^ v 10^4^; z = -1.52, p = 0.42; 10^4^ v 10^6^; z = -0.76, p = 0.87; 10^6^ v 10^8^; z = 1.31, p = 0.56; 10^2^ v 10^6^; z = -2.24, p = 0.11; 10^2^ v 10^8^; z = -0.99, p = 0.75; 10^4^ v 10^8^; z = 0.56, p = 0.94. Error bars correspond to ± one standard error, with the mean as the measure of centre.](EMS84425-f009){#F9}

![LPS-based phage resistance also affects in vivo virulence.\
Time to death (given as the median ± one standard error) for *Galleria mellonella* larvae infected with PA14 clones that evolved phage resistance through LPS modification, compared to the phage-sensitive ancestral (n = 209 biologically independent samples). Cox proportional hazards model with Tukey contrasts: Sensitive (ancestral) v LPS ; z = 4.81, p = 1.49 × 10^-6^. Overall model fit; LRT~3~ = 44.94, p = 1 × 10^-9^](EMS84425-f010){#F10}

The authors thank Prof. A. Buckling for critical reading of the manuscript, J. Common, E. Hesse and S. Meaden for comments on the manuscript, and Prof. JP Pirnay and D. de Vos for sharing clinical isolates of *S. aureus*, *A. baumannii*, and *B. cenocepacia*. This work was supported by grants from the ERC (ERC-STG-2016-714478 - EVOIMMECH) and the NERC (NE/M018350/1), which were awarded to E.R.W.

**Data Availability Statement**

All data used in this study is available on figshare at [10.6084/m9.figshare.9752903](http://dx.doi.org/10.6084/m9.figshare.9752903).

**Author Contributions**

Conceptualisation of the study was done by E.O.A. and E.R.W. Experimental design was carried out by E.O.A., A.M.L., C.R. and E.R.W. Adsorption and infection assays were done by E.O.A. All coevolution experiments were performed by E.O.A., E.P. and I.M.. E.O.A. did the DNA extractions and qPCRs, while the competition experiments, virulence assays, and motility assays were performed by E.O.A. and E.P.. Formal analysis of results was done by E.O.A., E.P., C.R. and E.R.W. The original draft was written by E.O.A., with later edits and reviews done by E.O.A. and E.R.W.

The authors declare no competing interests.

![Biodiversity affects the evolution of phage resistance.\
(**a**) Proportion of *P. aeruginosa* that acquired surface- (SM) or CRISPR-based resistance, or remained sensitive at 3 d.p.i. with phage DMS3*vir* when grown in monoculture or polycultures, or with an isogenic surface mutant (6 replicates per treatment, with 24 colonies per replicate, n = 864 biologically independent samples). Error bars ± one SE, with the mean as centre. (**b**) Microbial community composition over time for the mixed-species infection experiments. Legend abbreviations: PA14 = *P. aeruginosa*, SA = *S. aureus*, AB = *A. baumannii*, and BC = *B. cenocepacia*.](EMS84425-f001){#F1}

![Biodiversity amplifies fitness costs associated with surface-based resistance.\
Relative fitness of a *P. aeruginosa* clone with CRISPR-based resistance after competing for 24h against a surface modification clone at (**a**) varying levels of phage DMS3*vir* in the presence or absence of a mixed microbial community. Regression slopes with shaded areas corresponding to 95% CI (n = 144 biologically independent samples). (**b**) Relative fitness after competition in the absence of phage, but in the presence of other bacterial species individually or as a mixture. Error bars 95% CI and the mean as centre (n = 144 biologically independent samples).](EMS84425-f002){#F2}

![Evolution of phage resistance affects *in vivo* virulence.\
(**a**) Time to death (given as the median ± one standard error) following infection with PA14 clones that evolved phage resistance either in the presence or absence of a mixed microbial community (n = 376 biologically independent samples, analysed using a Cox proportional hazards model with Tukey contrasts). Type of evolved phage resistance (CRISPR- or surface-based (SM)) drastically impacted (**b**) bacterial motility (n = 981 biologically independent samples). Boxplots show the median with the upper and lower 25th and 75th percentiles, the inter-quartile range, and outliers shown as dots. (**c**) Type of resistance also affected *in vivo* virulence (time to death, given as the median ± one standard error, n = 981, analysed using a Cox proportional hazards model with Tukey contrasts).](EMS84425-f003){#F3}
