Consider a standard SIR model (Fig. 1). Transmission of the pathogen occurs via mass action with rate constant β, while pathogen infection causes virulencerelated mortality at a per capita rate α; thus, in what follows, the term ‘virulence’ refers specifically to infectionrelated mortality rather than as a measure of morbidity or symptomatic disease. A positive relationship between virulence and transmission, potentially mediated by withinhost pathogen growth, has been observed for many infectious diseases^{16,17,19,30,31}. To indicate the possibility of such a relationship, we will write β as β[α]. Infections are cleared at rate γ, and recovered hosts are fully protected from future infections through naturally acquired immunity. Although we focus primarily upon a link between virulence and transmission, we later consider a link between virulence and clearance^{9,17}. Hosts enter the population at a fixed rate λ and are removed due to natural causes at a per capita rate d.
A fraction p of the hosts entering the population are vaccinated. The vaccine has five protective effects altering distinct steps of the pathogen’s life cycle (Fig. 1a):

(1)
it reduces the risk of infection by a factor 0≤ρ_{1}≤1;

(2)
it reduces withinhost pathogen growth by a factor 0≤ρ_{2}≤1, affecting both virulence and transmission;

(3)
it reduces infectiousness (without affecting virulence) by a factor 0≤ρ_{3}≤1;

(4)
it reduces virulence (without affecting transmission) by a factor 0≤ρ_{4}≤1 and

(5)
it reduces the duration of infection by increasing the recovery rate by a factor 0≤ρ_{5}.
Vaccine protection is assumed to be lifelong.
The pathogen has two diallelic loci of interest (Fig. 1b). The first locus controls the pathogen’s ability to escape (allele E) vaccine protection or not (allele N) by reducing each of the ρ_{i} by a factor e. Carrying allele E, however, may come with fitness costs reducing transmission (c_{β}) or increasing the rate of clearance (c_{γ}). Although we will primarily treat c_{β} and c_{γ} as costs, our modelling framework is robust to the possibility that the escape allele increases transmission and/or clearance (that is, c_{β}<0 and/or c_{γ}<0) and so is advantageous in both unvaccinated and vaccinated populations. The second locus controls the pathogen’s virulence. Strains carrying allele A express virulence α_{A}, whereas strains carrying allele V express virulence α_{V} and are more virulent and transmissible (that is, α_{V}>α_{A} and β[α_{V}]>β[α_{A}]). There are thus four possible pathogen strains (or variants), ij ∊ NA, NV, EA, EV. Mutations occur at the escape and virulence locus at per capita rates μ_{E} and μ_{V}, respectively, while recombination (or genetic reassortment) between strains occurs at a per capita rate σI_{T}, where I_{T} is the total infection density and σ is a rate constant (Fig. 1b).
Let f_{ij} and f_{k} denote the frequency of strain ij and allele k, respectively, and D the linkage disequilibrium (LD) between alleles E and V, that is, D ≡ f_{EV} − f_{E}f_{V} (ref. ^{32}). Further, denote the additive selection coefficients for vaccine escape and (increased) virulence as s_{E} and s_{V}, respectively, and the epistasis in per capita growth between alleles E and V as s_{EV} (Fig. 1). Then the evolutionary dynamics are
$$\beginarrayrcl\frac\,\mboxdf_\mathrmE\mboxd\,t&=&s_\mathrmEf_\mathrmE(1f_\mathrmE)+s_\mathrmVD+s_\mathrmEV(1f_\mathrmE)f_\mathrmEV+\mu _\mathrmE(12f_\mathrmE),\\ \frac\,\mboxdf_\mathrmV\mboxd\,t&=&s_\mathrmVf_\mathrmV(1f_\mathrmV)+s_\mathrmED+s_\mathrmEV(1f_\mathrmV)f_\mathrmEV+\mu _\mathrmV(12f_\mathrmV),\\ \frac\,\mboxdD\mboxd\,t&=&\left(s_\mathrmE+s_\mathrmV2s\right)D+s_\mathrmEVf_\mathrmEVf_\mathrmNA(2\mu _\mathrmE+2\mu _\mathrmV+\sigma I_\mathrmT)D,\endarray$$
(1)
where t denotes time and s = s_{E}f_{E} + s_{V}f_{V} + s_{EV}f_{EV}. System (1) has the standard interpretation (for example, refs. ^{33,34,35}). The dynamics of allele E (mutatis mutandis allele V) depend upon: (1) the action of direct selection, s_{E}, proportional to the genetic variance, (2) the influence of indirect selection, s_{V}, mediated through LD, (3) epistasis, s_{EV}, and (4) unbiased mutations. Thus the two key emergent quantities when considering the multilocus dynamics are the nonrandom assortment of alleles (LD^{32}) and any gene interactions (epistasis^{36}). Moreover, from (1), these two quantities are linked: LD is generated by epistasis (s_{EV} ≠ 0), which produces same sign LD^{37,38}. Once LD is present in the population, it can be amplified by directional selection and be removed by mutations and recombination^{39,40}.
In addition to the evolutionary dynamics described by (1), there is a system of differential equations describing the epidemiological dynamics (Supplementary Information 1). Importantly, the selection coefficients and epistasis can temporally vary in both magnitude and sign due to the epidemiological dynamics (Fig. 1).
Single locus evolution
First, consider evolution restricted to a single locus due to an absence of accessible mutations at the other locus. For example, smallpox was unable to escape vaccine immunity, leading to its eradication^{41,42}, while for other pathogens, evolutionary changes to virulence may not be possible due to biological constraints.
If evolution is restricted to the escape locus (so μ_{V} = 0 and f_{V} = D = 0), system (1) reduces to
$$\frac\,\mboxdf_\mathrmE\mboxd\,t=s_\mathrmEf_\mathrmE(1f_\mathrmE)+\mu _\mathrmE(12f_\mathrmE).$$
(2)
Thus the single locus dynamics are simply governed by the flux of mutation, μ_{E}, and selection for the escape allele, s_{E}. As the mutation rate is expected to be small, the dynamics of the escape allele will be primarily shaped by selection: if s_{E}>0, allele E is favoured. From consideration of s_{E} (Fig. 1b), increasing the vaccine protection against infection (ρ_{1}), growth (ρ_{2}), transmission (ρ_{3}) and clearance (ρ_{5}) reduces strain NA fitness and so favours allele E. Likewise, decreasing the costs of escape increases transmissibility and duration of carriage of strain EA, favouring allele E (Supplementary Information 3). Vaccine protection against virulence (ρ_{4}) is an exception as it increases the duration of carriage without a concomitant reduction in transmission and so increases strain NA fitness. Generally speaking, however, if the costs of escape are not too high relative to the degree of escape and vaccine protection and coverage are not too low, allele E is favoured over allele N on the genetic background A (s_{E}>0).
If instead evolution is restricted to the virulence locus (so μ_{E} = 0 and f_{E} = D = 0), system (1) reduces to
$$\frac\,\mboxdf_\mathrmV{\mboxd\,t}=s_\mathrmVf_\mathrmV(1f_\mathrmV)+\mu _\mathrmV(12f_\mathrmV).$$
(3)
Thus if the flux of mutations is small (μ_{V}≪s_{V}), the more virulent strain will be favoured by selection if s_{V}>0. Depending upon how much allele V increases transmissibility relative to increasing virulence, it can be unconditionally favoured or disfavoured regardless of vaccination rates. As vaccination plays a limited role in either case, suppose allele V is neither unconditionally favoured nor disfavoured. Then, selection for virulence on the genetic background N is a weighted average of conflicting selective pressures across two environments, unvaccinated and vaccinated hosts; the weights are the fraction of infections of a given strain that are found in either environment (Fig. 1b and Supplementary Information 4). If the vaccine affects virulence mortality (ρ_{2}, ρ_{4}) and/or clearance (ρ_{5}), higher virulence and transmission will be selected for in vaccinated hosts to compensate for the reduced duration of infection^{9,10,11,13}. Whether higher virulence is favoured in the population as a whole, however, is determined by the balance between the two selective environments: increasing coverage (p) and decreasing protection from infection (ρ_{1}) and transmission (ρ_{3}) increases the importance of vaccinated hosts and favours higher virulence^{9,10,11,13}.
Epistasis and the production of linkage disequilibrium
Next, suppose that segregation is occurring at both loci and so both adaptations are mutationally accessible. Here a key quantity is epistasis, s_{EV}, which occurs whenever the fitness of an allele depends upon its genetic background. Epistasis shapes the dynamics of adaptation through the buildup of LD and in our model emerges in two ways. First, whenever vaccines reduce virulence or increase clearance, higher virulence will disproportionately reduce the expected duration of infection in unvaccinated hosts relative to vaccinated hosts. Consequently, a greater proportion of strain iV infections will be found in vaccinated hosts than strain iA infections and so vaccination disproportionately affects allele V relative to allele A. Because escape reduces the effects of vaccination, this difference is magnified on the genetic background N relative to E. The second way epistasis is generated is through any nonadditive interactions between parameters associated with the virulence locus (β, α) and those associated with the escape locus (vaccine protections, costs of escape^{35}). Because α_{V}>α_{A} and β[α_{V}]>β[α_{A}], any such interactions will disproportionately affect infections carrying allele V over A for a given genetic background (E or N).
As epistasis produces same sign LD^{32,37,38}, which in turn shapes the evolutionary dynamics, we are particularly interested in the sign of the epistatic contribution of the different types of vaccine protection. As escape reduces the effects of vaccination, manipulating the vaccine protections disproportionately affects the difference in per capita growth rate (fitness) between strains NA and NV as compared with strains EA and EV. Because epistasis is defined as s_{EV} ≡ r_{EV} − r_{EA} + r_{NA} − r_{NV} (ref. ^{35,43}), where r_{ij} is the fitness of strain ij, and as the difference r_{NA} − r_{NV} will be larger in magnitude than the difference r_{EA} − r_{EV}, the sign of the epistatic contribution of a given vaccine protection can be determined from whether interactions between vaccine protections and virulence disproportionately increase or decrease the fitness of strain NA relative to strain NV (this assumes escape is not too ineffective; Supplementary Information 5). If strain NA experiences an increase (respectively decrease) in fitness relative to strain NV, then positive (respectively negative) epistasis will be produced. With this in mind, the predictions are as follows (Table 1):

(1)
Vaccines that block infection (ρ_{1}) and reduce transmission (ρ_{2}, ρ_{3}) produce positive epistasis. Because allele V is more transmissible than allele A and as a larger fraction of NV infections are in vaccinated hosts than NA infections, vaccination will disproportionately reduce strain NV transmissibility as compared with strain NA. Thus vaccines blocking infection or reducing transmission produce positive epistasis.

(2)
Vaccines that reduce virulence mortality (ρ_{2}, ρ_{4}) produce negative epistasis. Ignoring any concomitant effects to transmission, reducing virulence mortality increases pathogen fitness. Because allele V corresponds to more virulent infections and as a larger fraction of NV infections are in vaccinated hosts as compared with NA infections, allele V will disproportionately benefit from any reductions in virulence. Thus vaccines reducing virulence mortality produce negative epistasis.

(3)
Vaccines that increase clearance (ρ_{5}) produce positive epistasis. Because a larger fraction of NV infections are in vaccinated hosts than NA infections, on the genetic background N, allele V will be disproportionately negatively affected by increased clearance due to vaccination. Consequently, vaccines increasing clearance produce positive epistasis.
Note that vaccines which block growth (ρ_{2}) have two opposing contributions: by reducing transmission, ρ_{2} produces positive epistasis and by reducing virulence mortality, ρ_{2} produces negative epistasis. Thus, depending upon the epidemiology and the difference between α_{A} and α_{V} and/or β[α_{A}] and β[α_{V}], the epistatic contribution of ρ_{2} can be positive or negative. More generally, the relative importance of the different factors contributing to epistasis can temporally vary; for example, if susceptible hosts are abundant, the contribution of transmission to epistasis is likely to be more important (Supplementary Information 5).
In the next two sections, we consider the dynamic implications of the sign of epistasis by focusing upon a scenario in which the epidemiological dynamics have reached an endemic equilibrium before mutations are introduced. However, our theoretical framework allows the exploration of alternative scenarios in which transient epidemiological dynamics feedback on pathogen evolution^{44} (Supplementary Information 2).
Negative epistasis and evolutionary bistability
First, suppose the vaccine protections produce negative epistasis (that is, vaccines reduce virulence mortality, ρ_{2}, ρ_{4}; Fig. 2a) and there is positive directional selection (that is, s_{E}>0 and s_{V}>0) at the strain NA endemic equilibrium. In this circumstance, strains EA and NV will initially increase at a rate dictated by the strength of selection for allele E and V, respectively. As negative epistasis disfavours strain EV, the increase in strains EA and NV will cause an increase in negative LD until f_{E} + f_{V} = 1 and D = −f_{E}f_{V}. At this point and assuming mutations and recombination are sufficiently infrequent, system (1) reduces to
$$\frac{\,{\mboxd}f_\mathrmE}{{{\mboxd}}\,t}\approx (s_\mathrmEs_\mathrmV)f_\mathrmE(1f_\mathrmE).$$
(4)
From equation (4), epistasis no longer directly impacts the dynamics of allele frequencies. Instead, whichever of alleles E or V is more strongly selected for will increase in frequency at the expense of the other (clonal interference), causing the population to evolve along the curve Γ(f_{E}) in (f_{E}, f_{V}, D)space (Fig. 3).
Recombination affects these dynamics; by removing LD from the population, recombination prevents LD from increasing in magnitude^{39,40}. Consequently, the combination of strain competition and recombination means that it no longer need be true that the ‘fitter’ strain ultimately reaches fixation if doing so requires the population to first pass through an intermediate state with a large amount of LD. As such, recombination can create a bistability between the NV and EAstrain equilibria (Fig. 3b and Supplementary Information 10). The evolutionary implications of this bistability is that being ‘first’ is more important than being ‘fitter’. Specifically, if either allele E or V is more mutationally accessible or is associated with more rapid growth initially, even if this allele is competitively inferior to the other in the long term (in the absence of recombination), it is likely to reach fixation and exclude the other (Fig. 3 and Table 1).
Positive epistasis and the evolution of virulence
Next, suppose epistasis is positive (that is, vaccines reduce infection/transmission, ρ_{1}, ρ_{3} and/or increase clearance, ρ_{5}; Fig. 2b) and s_{E}>0 and s_{V}>0 at the strain NA equilibrium. When does strain EV (and so positive LD) transiently increase in the population? If the selection coefficients are of comparable magnitude, s_{E} ≈ s_{V}, alleles E and V increase in the population at a similar speed and so positive epistasis transiently favours strain EV (Fig. 4a). On the other hand, if one selection coefficient is much larger than the other (say, s_{E}≫s_{V}), then allele E will rapidly increase, favouring whichever virulence allele it is initially associated with (that is, the virulence allele hitchhikes^{45}). Consequently, if mutations at each locus are independent, strain EA will transiently dominate as it is more mutationally accessible from strain NA (Fig. 4a). If instead double mutations (for example, NA mutates to EV) occur with comparable frequency to single mutations, or strains EA and EV are initially equally abundant, strain EV will transiently dominate as it benefits from both the positive epistasis and selection on allele V. One key determinant of the relative magnitude of s_{E} and s_{V} will be the costs and degree of vaccine escape. If costs are low and vaccine escape is easily accessible, typically s_{E}≫s_{V}, whereas costly and/or limited escape can lead to s_{V}≫s_{E}.
By breaking up LD, recombination can prevent the transient selection for strain EV. Moreover, if strain EV is favoured both transiently and in the long term, since recombination breaks up positive LD evolution occurs sequentially such that either allele E or V will fix first, depending upon which allele is more strongly selected for, before evolution proceeds at the other locus (Fig. 4b and Table 1).
Epistasis and alternative life history tradeoffs
The previous results assumed a link between virulence and transmission (that is, a virulence–transmission tradeoff or VTT). Therefore are the epistatic contributions of the different vaccine protections contingent upon the specific life history tradeoff?
To answer this, suppose higher virulence is associated with lower clearance α_{V}>α_{A} and γ_{A}>γ_{V} (a virulence–clearance tradeoff, or VCT^{9,17}). Under a VCT, vaccines that reduce transmission (ρ_{2}, ρ_{3}) and virulence mortality (ρ_{2}, ρ_{4}) produce positive and negative epistasis, respectively, in agreement with the predictions obtained under a VTT (Supplementary Information 8). Vaccines reducing infection (ρ_{1}), however, do not generate epistasis under a VCT; instead, reducing infection (increasing ρ_{1}) dampens the epistatic contribution of vaccines reducing transmission (ρ_{2}, ρ_{3}) by decreasing the influence of the selective environment of vaccinated hosts (Supplementary Information 8). More importantly, vaccines hastening clearance (ρ_{5}) can generate either positive or negative epistasis under a VCT. This is because, on the one hand, a greater fraction of NV infections are found in vaccinated hosts as compared with NA infections, producing positive epistasis (this was also observed under a VTT). On the other hand, the nonadditive interaction between clearance rate and ρ_{5} disproportionately impacts infections with a higher clearance rate (strain NV over NA), producing negative epistasis. The balance between these two forces determines the sign of epistasis produced by vaccines increasing the clearance rate (under a VCT; Table 1). Note the dynamical consequences of the sign of epistasis are unchanged under a VCT.
link