Skip to main content
Wiley Open Access Collection logoLink to Wiley Open Access Collection
. 2022 Oct 12;76(11):2739–2757. doi: 10.1111/evo.14616

Evolution in fluctuating environments: A generic modular approach

Bnaya Steinmetz 1, Immanuel Meyer 1, Nadav M Shnerb 1,
PMCID: PMC9828023  PMID: 36097355

Abstract

Evolutionary processes take place in fluctuating environments, where carrying capacities and selective forces vary over time. The fate of a mutant type and the persistence time of polymorphic states were studied in some specific cases of varying environments, but a generic methodology is still lacking. Here, we present such a general analytic framework. We first identify a set of elementary building blocks, a few basic demographic processes like logistic or exponential growth, competition at equilibrium, sudden decline, and so on. For each of these elementary blocks, we evaluate the mean and the variance of the changes in the frequency of the mutant population. Finally, we show how to find the relevant terms of the diffusion equation for each arbitrary combination of these blocks. Armed with this technique one may calculate easily the quantities that govern the evolutionary dynamics, like the chance of ultimate fixation, the time to absorption, and the time to fixation.

Keywords: Competition, chance of ultimate fixation, fitness, fluctuations, varying environment


Competition between different types, at whatever scale of organization, is a key driver of evolutionary dynamics. The interplay between selective forces (if exist) and genetic drift governs the chance of adapted phenotypes to reach fixation, the rate in which deleterious alleles disappear through purifying selection and the fate of a neutral (e.g., synonymous) mutation. The simplest and most important scene in which these factors manifest themselves is the competition between a mutant type and a wild type. This case received a lot of theoretical and empirical attention, and many classical works are devoted to the analysis of its characteristics. In particular, attention was given to three important quantities: the chance of ultimate fixation Π, the mean time to absorption (either fixation or loss) TA, and the mean time to fixation TF (Crow et al., 1970; Ewens, 2012; Kimura, 1962).

Most of the existing literature is focused on the case of a fixed environment, where demographic parameters and selective forces are time‐independent. However, all evidence shows that ecological and evolutionary processes are usually subject to wild environmental fluctuations which cause large changes in demographic rates and in the frequency of different types (Adler et al., 2006; Bergland et al., 2014; Fung et al., 2020; Kalyuzhny et al., 2014; Lande et al., 2003; Mellard et al., 2019; Usinowicz et al., 2012; White & Hastings, 2020). Some of these variations affect the selective forces, others change the overall size of a population; of course, these effects may be intertwined. Temporal variations may be periodic (seasonal) or stochastic, and they often yield highly nontrivial outcomes. In particular, in some cases temporal variations act to promote coexistence and protect polymorphism through mechanisms like the storage effect (Bertram & Masel, 2019; Chesson, 2000; Chesson & Warner, 1981; Chesson, 1982b; Usinowicz et al., 2017; Yi & Dean, 2013). By and large, competition in fluctuating environment admits a much richer phenomenology, and at the same time is much more difficult to analyze.

Even in experimental setups, the effective demographic rates vary over time. For example, in the famous Long‐Term Evolutionary Experiment of Lenski and coworkers (Good et al., 2017; Lenski et al., 1991) E‐coli strains compete in an apparently fixed environment: all flasks contain the same medium, nutrient concentration and temperature are kept fixed, and so on. Yet, every day (i.e., every 6‐7 generations) each population is diluted to about 1% of its size, then it undergoes an exponential growth phase and then saturates. Unlike a constant‐size population, in such experiments the chance of a rare mutation to establish depends very much on its chance to survive a few dilution steps while rare.

The importance of temporal variations was acknowledged and analyzed in many (mostly recent, but see Takahata et al. 1975; Takahata & Kimura 1979) theoretical works. Whal and Gerrish (Wahl & Gerrish, 2001), for instance, provided a thorough analysis of the two‐type competition dynamic in Lenski's experiment. Other authors dealt with other specific realizations: fixed population size with varying selection (Ashcroft et al., 2014; Cvijović et al., 2015; Danino & Shnerb, 2018; Hidalgo et al., 2017; Huerta‐Sanchez et al., 2008; Mustonen & Lässig, 2008; Meyer & Shnerb, 2018; Marrec & Bitbol, 2020), fixed selection with varying population size (Wienand et al., 2017, 2018), and so on. Despite all these efforts, a generically implementable methodology is still lacking.

Here, we would like to provide such a generic technique. Our method utilizes the diffusion approximation (DA), which is the standard tool in the analysis of stochastic systems (Karlin & Taylor, 1981). We consider a set of typical demographic processes: growth (logistic or exponential) or decline (logistic, exponential, or sharp dilution) of the total population and various competition scenarios (local or global) when the total population size is fixed. Each of these processes is a “building block,” and we calculate its effect on the frequency of the mutant type and its second moment. We then show how to construct the diffusion equation for an arbitrary sequence of these building blocks.

The general approach suggested in this paper is illustrated in Figures 1 and 2. In what follows we refer to the different panels of these figure, which illustrate the main steps required.

  • 1.

    Panel (a) of Figure 1 is a cartoon of a possible process, which is characterized by two parameters: the total population size N(t) and the selection parameter s(t). Both parameters may vary through time. For example, as resource become more prevalent the total carrying capacity increases, and at the same time the relative fitness of the wild type and the mutant may (or may not) change. For the moment, our information is fully described by two given (but otherwise arbitrary) functions of time N(t) and s(t).

  • 2.

    Panel (b) of Figure 1 describes a “model” of the actual process. Now N(t) and s(t) are not arbitrary functions of time, instead the process is modeled as a collection of growth, decline and fixed population periods. As explained below, we allow a lot of flexibility for these elementary building blocs. For example, growth may be exponential or logistic, where its rate, its duration and the selective forces during growth are still arbitrary. An abstraction of this type is essential, of course, to any mathematical analysis of a real‐life process, and we believe that our collection of elementary building blocks may account for the actual dynamic in most of the relevant scenarios.

  • 3.

    Once a model is established, a “representative segment” of duration T has to be identified (panel c of Figure 1 and Figure 2). Such a segment must provide a fair representation of the whole process, so its building blocks composition and strength (durations, selection and so on) should reflect the main features of the process. If the environment is periodic, the representative segment is a single period. In aperiodic setups the quality of the approximation may be evaluated by examining the robustness of the result to the addition of more blocks.

  • 4.

    Let us focus, now, on the i‐th building block and its parameters (duration τi, selection parameter si(t), Ni(t), and so on, as illustrated in Figure 2). To implement the diffusion equation one would like to calculate two quantities that characterize its effect on the frequency of the mutant type x. First, the “velocity,” which is the mean change in the frequency μi=Δxi/τi¯. Second, the “diffusion” parameter, which is simply the second moment, σi2=Δ2xi/τi¯. In Table 2 below, we provide μi(x) and σi2(x) for each building block in our collection.

  • 5.

    Given μi(x) and σi2(x) for each block, one should find μ(x) and σ2(x) for the entire representative segment. This step in explained in section 4.

  • 6.

    Finally, μ(x) and σ2(x) of a representative segment are given, these quantities are plugged in the diffusion equations for the chance of ultimate fixation, time to absorption and time to fixation (Equations (1), (2), (3) below). The emerging second order (homogenous or inhomogeneous) differential equations are easily solvable, either numerically or analytically, and we provide these solutions in an integral form.

Figure 1.

Figure 1

Selecting a representative segment. A cartoon of a possible environmental process is shown in panel (a): the total population N fluctuates with time, and periods in which the mutant is beneficial (red) are followed by periods of advantageous wild type (blue). The process itself may be very complicated, and as a first approximation one has to replace it by another process made of our building blocks: growth periods (exponential or logistic), decline periods (exponential, logistic or sharp) and fixed population competition periods (global or local competition, periodic or stochastic variations of selective forces), as shown in panel (b). To implement the procedure suggested here a representative segment [panel (b), dashed rectangle, magnified in panel (c)] is chosen and analyzed. The order of these building blocks is arbitrary, any block may be followed by any other block, see Section 6 below. A simple example of a representative segment is provided in Figure 2; a more intricate case is presented in panel (a) of Figure 4.

Figure 2.

Figure 2

A possible representative segment, consists of four ”building blocks”. Here, a constant population competition with Km individuals (red) is followed by exponential growth to Kp (green), a constant population competition phase at Kp (magenta) and a sharp decline (blue). Two types of dynamic that correspond to this cartoon are analyzed in Section 6 (lines 1 and 2 of Table 3). The basic timescale of the problem (say, one day or one month), τ0, is indicated by thin vertical dashed lines. Blocks are numbered in order of occurrence, using the index ℓ, and the duration of each block (in τ0 units) is τ. Finally, the duration of the whole representative segment (again, in units of τ0) is T. In Section 6 below, we read the functions μ(x) and σ2(x) from the relevant lines of Table 2, and calculate the combined parameters of the whole segment, μ(x) and σ2(x), using the procedure presented in Section 4 below.

Table 2.

The contribution of each building block

i state μi(x) (during τ0) σi2(x) (during τ0) duration τi (in τ0 units)
1 population equilibrium local competition, periodic selection changes
r0Nx(1x)s0
r0N22x(1x). τ
2 population equilibrium local competition, stochastic selection changes
r0Nx(1x)[s0+g(12x)]
2r0x(1x)[1+gNx(1x)]N2. τ
3 population equilibrium global competition, periodic selection changes
r0Nx(1x)[s0+γ22(12x)]
r0N22x(1x). τ
4 population equilibrium global competition, stochastic selection changes
r0Nx(1x)[s0+ηg(12x)]
2r0x(1x)[1+gNx(1x)]N2. τ
5 population growth from Km to Kp exponential
(r1r2)x(1x)1+r1x+r2(1x)
x(1x)[1Km1Kp]xr2+(1x)r1log(Kp/Km)
log(Kp/Km)xr1+(1x)r2
6 population growth from Km to Kp logistic
x(1x)tg(Kp/Km)sg11x+x(Kp/Km)sg
x(1x)tg(x(1x)[(Kp/Km)sg11x+x(Kp/Km)sg]2+1Km1Kp)
tg (Eq. 10)
7 population decline from Kp to Km exponential
(r4r3)x(1x)1r3xr4(1x)
x(1x)[1Km1Kp]xr4+(1x)r3log(Kp/Km)
log(Kp/Km)xr3+(1x)r4
8 population decline from Kp to Km logistic
x(1x)td(Kp/Km)sd11x+x(Kp/Km)sd
x(1x)td(x(1x)[(Kp/Km)sd11x+x(Kp/Km)sd]2+|1Km1Kp|)
td (Eq. 12)
9 population decline from Kp to Km abrupt
sdx(1x)KpKm1tsh
x(1x)[1Km1Kp]1tsh
tsh0

The diffusion approximation is based on a second‐order expansion of the relevant quantities (for example, the chance of ultimate fixation Π(x), where x is the frequency of the mutant type), and the small parameter is Δx, the change in x during each step. Therefore, our technique requires that the changes in x in a single representative segment T are small enough, otherwise the expansion cannot be justified. In the “quenched” limit, that is, when the time to fixation is shorter than the persistence time of the environment, there is no point in averaging over many environmental states, as the fate of most mutants is determined by the environmental condition at the time of its birth (Cvijović et al., 2015; Mustonen and Lässig, 2008). Even when TF is indeed very large, the diffusion approximation may break down because the changes in x per representative segment are too large (Assaf & Meerson, 2017; Elgart & Kamenev, 2004; Kessler & Shnerb, 2007; Ovaskainen & Meerson, 2010; Pande & Shnerb, 2020). Still, in many cases the representative segment appears to be short enough. For example, in Lenski's dilution experiment a segment is one day (about 6.6 generations), but fixation requires about 1000 generations and the changes in frequency during a day are usually small (Good et al., 2017). Even beyond its range of applicability, in some cases the diffusion approximation (DA) produces quite accurate results (Parsons et al., 2010), and in all cases it provides, if not exact numbers, at least an intuitive understanding of the dynamic and its main features.

The expressions we provide for the building blocks are quite flexible. For example, when the logistic growth is considered, the formula covers any initial and final population state and any growth rate (or equivalently any duration of the growth). It also takes into account possible selective features (differences in growth rates). In the saturation phase (constant population) selective forces may vary either stochastically or periodically, competition may be either global or local and so on.

This paper is organized as follows. In the next section, we present the DA formulas for the important quantities considered through this paper. Section 3 is devoted to a description of the dynamic in each of the building block processes and the corresponding functions μi and σi2 are presented in Table 2. In Section 4, we explain how to assemble these building blocks to obtain the coefficients of the diffusion equation. The solutions of these equations are provided in Section 5, along with a few worked examples in Section 6. Finally, we summarize the result and discuss their possible implications.

The Diffusion Approximation in Varying Environments

As mentioned, the three important quantities considered through this paper are,

  • 1.

    The chance of ultimate fixation Π(x), which is the probability that the mutant type (at frequency x) reaches fixation.

  • 2.

    The mean time to absorption TA(x). For a given mutant population of frequency x, this is the mean time until it reaches either fixation or extinction.

  • 3.

    The mean time to fixation TF(x), which is the expected duration before fixation, where the average is taken over all histories that end up in fixation (not over histories in which the mutation is lost).

The diffusion approximation is the standard tool in the analysis of stochastic processes, like those considered here (Ewens, 2012; Karlin & Taylor, 1981; Redner, 2001). Using DA, one translates a discrete difference equation (like the Master equation) into a differential equation by expanding the relevant quantities to second order in frequency or abundance differences. For example, in a population of N individuals one may ask what is Πn, the chance of a mutant type with n individuals to reach fixation at n=N before going extinct. When DA is implemented the object considered is Π(x), where the frequency x=n/N is regarded as a continuum variable. This quantity is plugged into the appropriate discrete equation, and Π(x+Δx) is expanded to second order in Δx, the resulting differential equation and boundary conditions take the form,

μ(x)Π(x)+σ2(x)2Π(x)=0Π(0)=0andΠ(1)=1. (1)

where primes represent derivatives with respect to x. Here, μ(x) is the “velocity” (mean change in x, Δx, per unit time τ0) and σ2(x) is the “diffusion” term (variance of Δx per the same unit time). The choice of an appropriate unit time τ0 is discussed in the next section.

Similarly, the equation for the mean time to absorption TA (time is measured in τ0 units) is,

μ(x)TA(x)+σ2(x)2TA(x)=τ0TA(0)=0andTA(1)=0. (2)

To calculate the mean time to fixation TF(x) one must define Q(x)=TF(x)Π(x), where Q(x) satisfies,

μ(x)Q(x)+σ2(x)2Q(x)=Π(x)τ0,Q(0)=0andQ(1)=0. (3)

Once Q(x) is known, time to fixation is obtained through TF(x)=Q(x)/Π(x).

The problems thus reduces to homogenous (Equation 1) or inhomogeneous (Equations 2 and 3) first order linear differential equations for the derivatives of the required quantities (e.g., Π(x)). These equations may be solved quite easily by two integrations, as explained in Appendix C, see Equations ((19), (20), (21), (22), (23)) below. If the expressions obtained are too complicated [that depends on the form of the functions μ(x) and σ2(x)], simple numerical integration may be implemented. Therefore, the nontrivial task is to find the appropriate expressions for the moments μ(x) and σ2(x) (technically speaking, σ2(x) is the variance of Δx. However the diffusion approximation requires μ2 to be much smaller than the second moment, so the variance and the second moment are almost identical, therefore we refer to this quantity as the second moment).

In a fixed environment, the rates of events (and hence the transition probabilities) do not change in time. Stochasticity in a fixed environment is “demographic”—it reflects the endogenous stochastic characteristics of the birth–death process that are uncorrelated among different individuals. In that case one may calculate μ(x) and σ2(x) via the first two moments of the transition probabilities Wnn±1 for an elementary step, for example, for a single birth–death event.

In a varying environment, demographic rates and transition probabilities are time‐dependent. This reflects large‐scale events, such as variations in temperature or in precipitation levels, that affect at the same time all (or almost all) individuals. Most importantly, environmental variations are typically correlated in time so there are many elementary birth‐death events before the environment changes substantially. In that case, one must calculate μ and σ2 from Wn(t)n(t+T)k, where the index k reflects the state of the environment and T is an intermediate timescale which is longer than the correlation time of the environment. This procedure ensures that all different environmental states are sampled with their appropriate weights, and that correlations are taken into account. As discussed above, T must be also short enough such that Δx during this timescale is small, otherwise the second order expansion required for the diffusion approximation becomes insufficient. Usually, for large N one may find such a timescale. In fact, the existence of this intermediate timescale is what allows us to write equations for Π(x), say, and to neglect the dependence of the chance of ultimate fixation on the initial environmental state. Because the system visits many different environmental states before x changes substantially, we can average over all initial environmental conditions (Danino et al., 2018).

Note that the appropriate Fokker–Planck (forward Kolmogorov) equation, which describes the dynamic of P(x,t)dx, the chance to find the system at the vicinity of x, is,

tP(x,t)=2x2σ2(x)2P(x,t)xμ(x)P(x,t). (4)

So this equation is also given once μ(x) and σ2(x) are known. Since we would like to take demographic stochasticity into account, P(x) never admits a normalizable steady‐state solution, so we do not elaborate on this equation. However, for some quantities of interest (Green's functions, quasi‐stationary solutions) implementation of the Fokker–Planck equation is required, in which case our results are applicable as well.

The Building Blocks

In this section we describe our building blocks: a set of elementary processes that typically appear in competition dynamics. We consider situations where the population (total number of individuals) grows or declines, as well as equilibrium dynamics where the total population size is fixed and competition is a zero‐sum game. A glossary of the parameters used is provided in Table 1. The results are shown in Table 2 and the detailed calculations that lead to these results are presented in Appendix A. Some examples are given in Appendix A.

Table 1.

Glossary

Term Description
N total number of individuals in the community at a given time.
n number of mutant individuals.
x frequency of the mutant type, x=n/N (1x is the wild type frequency).
τ0 an arbitrary (conveniently chosen) time. Times and rates are defined in units of τ0.
s 0 time‐independent component of the fitness (competition at constant population).
γ amplitude of fitness fluctuations (competition at constant population).
δ mean number of birth‐death events before selection changes (competition at constant population).
gδγ2/(2N)
the strength of selection fluctuations (competition at constant population).
τ duration (in units of τ0) of a constant population state.
r 0 rate of events in the constant population state, the mean number of events per τ0.
λ,r1..r4
growth and decline rates, measured in units of 1/τ0
sg
selection parameter for logistic population growth.
sd
selection parameter for logistic decline and abrupt population decline
tg,d
growth (decline) time in the logistic growth (decline) scenario, in units of τ0
η=1+N/δ
useful parameter
T
The duration of a representative segment (in units of τ0)
Kp,Km
high and low target carrying capacities, used to describe growth and decline events.

In Section 4, we will show how to incorporate these building blocks into the diffusion equation. To do that one needs not only the formulas for μi and σi2 for each block type, but also their durations that determine the relative contribution of each block to the functions that govern the diffusion equation, μ(x) and σ2(x).

Our fundamental time unit is τ0, that may be a day, a year, or any other convenient time interval. All rates in the system must be defined with respect to τ0. In Table 2, we used a set of rate constants: {r0,r1..r4,λ}. Below we explain how each of these constants is related to the rate of elementary birth‐death events. Of course the final diffusion equation is independent of the choice of the elementary timescale τ0, but once τ0 is defined, the rate constants must be consistent with this choice.

CONSTANT POPULATION

When the total population is fixed with N individuals, we consider four different competition scenarios. We distinguish between two competition modes, local and global, and between two modes of environmental (and corresponding relative fitness) variations, stochastic and periodic. These four scenarios may yield different dynamical behaviors, and the derivation of the results presented in lines 1–4 of Table 2 is provided in Meyer et al. (2022).

The distinction between local and global competition is quite important. Environmental variations may facilitate coexistence (protect polymorphism) via the storage effect (Bertram & Masel, 2019; Chesson & Warner, 1981), but this effect does not manifest itself under local competition, as in that case there is no covariance between competition and environment (Meyer et al., 2022). In intermediate cases, when competition is restricted to a single deme or a single patch, the storage effect may provide a mechanistic explanation for balancing selection, so these cases have to be modeled with global competition.

Local competition

Local competition scenarios are typical in animals populations, where individuals wander around searching for food or territory, and an encounter between two individuals may end up struggling for these goods. To model that, we implement the pairwise comparison scheme suggested in Volkov et al. (2003); Traulsen et al. (2007). Two individuals are chosen at random in each time step for a duel, the loser dies and the winner reproduces so the total number of individuals is kept fixed. For two species competition, when the frequency of the mutant type is xn/N, the chance of an interspecific duel is 2x(1x). We use s as the selection parameter, so an individual's fitness is exp(s). If es1(t) is the fitness of the mutant type and es2(t) is the fitness of the wild type, the chance of the mutant to win an interspecific duel is,

f+=es1(t)es1(t)+es2(t), (5)

and the chance of the wild type is 1f+. Without loss of generality we assume the dynamic of the relative selection to satisfy s(t)s1(t)s2(t)=s0+ζ(t), where s 0 is the mean relative selection and ζ(t) is a zero‐mean stochastic process.

Given the (arbitrarily chosen) elementary time interval τ0, we define the overall rate of events as r 0, so the mean number of duels in each τ0 interval is r 0. After every elementary birth‐death event, with probability 1/δ we pick ζ at random, so the dwell times of the environment are distributed geometrically and its mean corresponds to δ elementary events. Accordingly, in τ0 units the dwell time is δ/r0. When the environment changes, ζ is picked from a uniform distribution with zero mean and variance γ2. In periodic systems ζ flips its sign after δ steps.

To provide a numerical example, let's consider a population of N=100 individuals for which a duel happens every two days, environment switches every 14 days and the length of the whole block is 50 weeks. If τ0 is chosen to be a single day, then r0=1/2, δ=7 and the number of τ0 intervals in this segment is τ=50×7=350.

The effect of these dynamics on the “velocity” per τ0,

μΔx¯τ0, (6)

and on the associated second moment

σ2(Δx)2¯τ0, (7)

are given in rows 1 (for periodic dynamic) and 2 (stochastic dynamic) of Table 2. For a duration τ the total change in x is μiτ and the expected value of (Δx)2 is σi2τ.

Global competition

In many populations individuals produce seeds (or larvae etc.) that disperse over long distances, or otherwise the relevant resources undergo fast diffusion. When an individual dies the competition for the released resource (room occupied by an adult tree, say, or the free nutrients in bacterial colonies) is more or less distance independent or global. Global competition is the scenario considered in the standard models of Wright‐Fisher and Moran (Ewens, 2012).

Here we implement a Moran process  (Moran, 1958): one individual is chosen at random to die, and its slot is recruited by an offspring of another individual with a chance proportional to its fitness. Accordingly, the chance of the mutant type (of frequency x) to increase its abundance by one is the chance that a wild type was chosen to die, 1x, multiplied by the probability of the mutant to capture the empty slot,

f+=xes1(t)xes1(t)+(1x)es2(t). (8)

Similarly, the chance of the mutant type to lose one individual is x(1f+).

The dynamics of s(t) (periodic or stochastic) are identical to those considered in case of local competition, and the numerical example provided above (for r 0, τ0 etc.) is applicable in this case as well. The relevant μi and σi2 are presented in rows 3 (periodic) and 4 (stochastic) of Table 2.

VARYING POPULATION

During the evolutionary process the total population may grow or decline. This reflects improvement, or deterioration, of the environmental conditions that increase or decrease the overall carrying capacity. Such events may have different influence on the mutant and on the wild type: one type may admit features that allow it to utilize the new opportunities better than its opponent, or may be less vulnerable to periods of increased stress. Selective forces during growth and decline may differ from the selective forces during periods of constant population. Therefore, we define other independent parameters (r1,r2,r3,r4,sg and sd), to denote the selective differences during growth and decline.

When resources become more abundant, or when an external event (like an epidemic) puts extra stress on populations, the steady‐state competition described above plays only a minor role in the dynamic. Other features, like maximum fecundity or resistance to pathogens, are more important. Therefore, we neglect steady‐state competition processes during the periods in which the total population changes.

Growth and decline may be characterized by three sets of parameters: population initial and final sizes, the rates of growth and decline and the length of growth and decline periods. Once two of these parameters are set, they determine the third one. Here we parameterize the process using the first two sets of parameters, namely growth or decline rates and the initial and final population size. From these, we derive the corresponding timescale associated with the (growth or decline) block. When the processes are exponential, the calculation of the relevant timescale τi is trivial. When a population grows or declines logistically it approaches exponentially its asymptotic value (the new carrying capacity), so the time required is formally infinite. Here we used the standard engineers convention and define the end of the growth process when the population size is within ε from the target capacity, with ε=exp(5)0.67% of the target capacity.

Population growth

When the environmental conditions suddenly or gradually improve (more food, increase in habitat size) the carrying capacity increases. The overall growth rate (total birth minus total death) becomes positive until the population reaches the new equilibrium. We denote the low carrying capacity as Km and the high value as Kp.

Two characteristic cases were analyzed. When the growth is logistic, the growth rate declines linearly as the population approaches Kp and vanishes at Kp. In many other systems the growth rate is almost independent of the population size and drops sharply to zero once the total population reaches Kp. In the logistic growth case, the fitness difference is defined as sg. Logistic growth is a prototype of processes in which the carrying capacity grows gradually and the two types compete for the new recruitment events. Exponential dynamic characterizes the cases in which the two types grow independently until the total population reaches a new upper bound.

Our model for exponential” growth with growth rate r 1 (for mutant) and r 2 (for wild type) is as follows. In every time interval τ0 the number of offspring produced by n mutant individuals is picked from a binomial distribution with n trials where the chance of success is r 1, B(n,r1), so nn+B(n,r1). The same procedure is applied to the Nn wild type individuals, so NnNn+B(Nn,r2). Time intervals τ0 must be taken small enough, such that r 1 and r 2 (the number of offspring per individual per τ0) are much smaller than one. The resulting formulas for μi(x) and σi(x)2 are provided in line 5 of Table 2.

When the growth is “logistic,” N(t) satisfies

dN(t)dt=λN1NKpN(0)=Km. (9)

In our simulations, some small enough Δt is chosen (we implemented Δt=0.1/N), N(t) is incremented according to Eq. (9) using a simple Euler integration technique and the number of new recruits, ΔN=N(t+Δt)N(t), is rounded to the nearest integer greater than or equal to it. ΔN is then divided between the mutant and the wild type based on their abundance and fitness: the mutant population increases according to nn+B(ΔN,x+sgx(1x)) and all other new recruits are wild‐type individuals. The relevant formulas are presented in line 6 of Table 2.

As explained, the duration of the process is defined as the time in which the logistically growing population that satisfies Eq. (9) reaches Kp[1ε]. A simple solution yields,

tg=ln(c1[Kp/Km1]λ, (10)

where c1=(1ε)/ε150. λ is the number of new slots opened per individual per τ0, and thus tg is given, again, in units of τ0.

Population decline

The decline of a population may be the result of a sudden catastrophe (earthquake, the impact of a meteor, hunting, epidemic, dilution in transfer experiments), or of gradual resource depletion. Here, we consider three characteristic cases: a sudden drop (as in transfer experiments), exponential decrease, and logistic decline.

Exponential decrease is parameterized by r 3 (the decay rate of the mutant, which is the chance of an individual to die during τ0) and r 4 (the decay rate of the wild type population). In every time step nnB(n,r3) and NnNnB(Nn,r4). The outcomes are presented in line 7 of Table 2.

In case of logistic decline, the total population satisfies,

dN(t)dt=λN1NKmN(0)=Kp. (11)

The total death toll per Δt is ΔN=N(t)N(t+Δt), (rounded to the nearest integer lower than it). The mutant population declines by a random number picked from a binomial distribution with ΔN trails and a chance of success xsdx(1x), all other death event occur in the wild type population. Results are presented in line 8 of Table 2.

Again, the duration of the process is the time required for the population in Eq. (11) to reach Km[1+ε]. Therefore,

td=ln(c1[1Km/Kp]λ, (12)

Finally, in case of sharp decline (such as an abrupt dilution) from Kp to Km, the number of mutant survivors is taken from B(n,sd+Km/Kp) and the number of wild type survives is B(Nn,Km/Kp). Here we assumed sdKp1, otherwise the number of mutants has a strong effect on the result of the dilution. Results for that case are presented in line 9 of Table 2. The time required for the decline is by definition negligible; for consistency we denote it by tsh, but the contribution of the dilution to Δx and to its moments is independent of tsh.

From the Building Blocks to the Diffusion Equation

Once a representative segment is identified, it typically contains a few different blocks (growth, constant population, and so on, see Figure 1). Some of these building blocks may appear more than once. We would like to distinguish between the specific indices associated with different block types (i=6, for example, is the logistic growth, as in Table 2) and indices associated with a given occurrence of a block in the representative segment, ℓ. For example, if we have in a representative segment five blocks—constant population (local, periodic), exponential growth, constant population (local, periodic), logistic decline and finally global‐stochastic constant population block—then the i indices are 1,5,1,8,4, but the ℓ index refers to blocks in the order in which they appear in the segment, =1,2,3,4,5. The maximum value that ℓ takes in a given segment, m, is simply the number of blocks in the representative segment.

Once μ(x) and σ2(x) of each building block ℓ are given, we can ensemble them to calculate the functions that govern the diffusion equation, namely μm(x) and σm2(x). The derivations for the following expressions are presented in Appendix B.

First, let us define the total duration of the representative segment. For a segment with m blocks,

Tm==1..mτ. (13)

The function, σm2(x), is simply an additive weighted sum of all the σ2s,

σm2(x)=1Tm=1..mσ2(x)τ. (14)

The mean displacement μm(x) is obtained from the μ functions of the individual blocks through a recursive formula (here we assume that different blocks are uncorrelated, otherwise one cannot take the average over Δx for each block separately). For a single block i, μm(x)=μi(x). For two blocks (m=2, e.g., logistic growth i=6 followed by sharp decline i=9),

μ1..2(x)=μ=1(x)τ=1+μ=2(x)τ=2+τ=1μ=1(x)τ=2dμ=2(x)dxτ=1+τ=2. (15)

In this specific example μ=1=μi=6 and μ=2=μi=9.

In general, adding a block ℓ after 1 other blocks yields,

μ1..(x)=μ1..1(x)T1+μ(x)τ+T1μ1..1(x)τdμ(x)dxT. (16)

After taking into account all m blocks inside the representative segment, μm(x) and σm2(x) are the μ(x) and the σ2(x) one has to put into Eqs. (13).

The μ terms, as detailed in Table 2, all vanish when the relevant relative selection parameter (s0,sg,sd,r1r2 etc.) vanishes. In many cases one consider a scenario with weak selective forces, neglecting high order terms in these parameters. When third order (proportional to s02 or s0sd etc.) and higher order terms are negligible, Eq. (16) simplifies to the time averaged value for μ(x),

μm(x)=1Tm=1..mμ(x)τ. (17)

Solutions of the Diffusion Equations

Once Eqs. (13) are given, with an explicit form for the functions μ(x) and σ(x), the problem may be solved, either analytically or numerically, by introducing an appropriate integrating factor (Karlin & Taylor, 1981). This approach is explained in Appendix C.

We first define I(x),

I(x)=exp0x2μ(t)σ2(t)dt. (18)

The solution for the chance of ultimate fixation then takes the form,

Π(x)=0xI(q)dq01I(q)dq (19)

One can easily see that the boundary conditions Π(0)=0 and Π(1)=1 are satisfied.

With two other definitions,

G(x)=2τ0σ2(x)I(x)andcA=01I(q)0qG(k)dkdq01I(q)dq, (20)

the mean time to absorption (either fixation or loss) becomes,

TA(x)=0xI(q)0qG(k)dkdqcA0xI(q)dq. (21)

At x=0 both terms in the above equation vanish, at x=1 they cancel each other, so TA(0)=TA(1)=0.

For the time to fixation we define two other quantities,

H(x)=Π(x)G(x)andcF=01I(q)0qH(k)dkdq01I(q)dq, (22)

and obtain,

TF(x)=1Π(x)0xI(q)0qH(k)dkdqcF0xI(q)dq. (23)

For some specific cases of μ(x) and σ2(x), one may find analytic solutions or large‐N asymptotic approximations for Π(x), TA(x) and TF(x), see  Danino et al. (2018); Danino and Shnerb (2018); Meyer and Shnerb (2018). However, in general scenarios μ(x) and σ2(x) are complicated and the analytic approach may become tedious. Here our aim is to present a general methodology, not to deal with a specific case, and therefore we implement numerical solutions for (1923). These numerical solutions are very simple and may be executed easily in all available programming languages such as Matlab, Mathematica, Maple, Python and so on.

Results

In this section we demonstrate the capabilities of our approach. We first implement Monte‐Carlo simulations in which the environment alternate periodically between different states, and then consider stochastic (random order) cases.

PERIODIC ENVIRONMENTAL STATES

The simulation results of Figure 3 were obtained from dynamics that are similar to the one presented in Figure 2. Two of the simulations involve four building blocks (constant population, exponential growth, constant population, sharp decline) and one involves only three (constant population, logistic growth, sharp decline) as detailed in Table 3. The order in which these blocks appear is periodic, but the details (for example, the value of γ or the value of N when a constant population block started) are not periodic. Figure 3 shows the correspondence between the theoretical prediction [Numerical solutions of Eqs. (1923)] and the outcomes of Monte‐Carlo simulations.

Figure 3.

Figure 3

Π(x) (panel a), TA(x) (panel b) and TF(x) (panel c) as a function of x for various scenarios. Red lines are the relevant numerical solutions of Eqs. (1923) for scenario 1 of Table 3. Cyan lines are solutions for scenario 2 and the green lines were obtained for scenario 3. Blue circles are the results of Monte‐carlo simulations in all nine cases (three scenarios, three quantities) and their agreement with the theoretical full lines is evident. Because the chance of fixation of small mutant populations (x0) is extremely small, the left edge of the TF graphs is quite noisy and we cut some of it. Note that the only difference between scenario 1 and 2 is the type of competition (global or local) in the fixed population low‐abundance case (column =1 of Table 3), still the results are completely different and our approach manage to predict the outcomes of the numerical experiment.

Table 3.

Different scenarios considered in Figure 3

number block =1 block =2 block =3 block =4
1 global‐stochastic (i=4) s0=0.001, r0=1, γ=0.175, τ=200, δ=100, N=5,000 exponential growth (i=5) r1=0.01, r2=0.00999 Kp=10,000, Km=5,000 global‐stochastic (i=4) s0=0.001, r0=1, γ=0.175, τ=300, δ=100, N=10,000 sharp decline (i=9) sd=0.0015, tsh=1 Kp=10,000, Km=5,000
2 local‐stochastic (i=2) s0=0.001, r0=1, γ=0.175, τ=200, δ=100, N=5,000 exponential growth (i=5) r1=0.01, r2=0.00999 Kp=10,000, Km=5,000 global‐stochastic (i=4) s0=0.001, r0=1, γ=0.175, τ=300, δ=100, N=10,000 sharp decline (i=9) sd=0.00015, tsh=1 Kp=10,000, Km=5,000
3 logistic growth (i=6) sg=0.015, λ=0.05 Km=5,000, Kp=10,000 global‐stochastic (i=4) s0=0.3, r0=1, γ=0.175, τ=300, δ=100, N=10,000 sharp decline (i=9) sd=0.001, tsh=1 Kp=10,000, Km=5,000

RANDOM ORDER OF ENVIRONMENTAL STATES

In our “stochastic” simulations, the building blocks order is random. Here we implement four different scenarios, each with its own building block (or blocks), parameters and duration. In Appendix A.4 each of these scenarios: local periodic competition Fig A.1 global periodic competition Fig A.2, global stochastic Fig A.3, or exponential growth followed by exponential decline Fig A.4 is addressed separately. In each iteration, our Monte‐Carlo algorithm chooses at random a given scenario out of these four options, until fixation or extinction is achieved. As a result, the order on which these blocks appear is random and aperiodic. One specific history, for example, is shown in the two left panels of Fig 4. The mean velocity and variance were calculated according to Eqs. (17) and (14), and the theoretical prediction is compared with simulation in the two right panels of Fig. 4.

Figure A.1.

Figure A.1

Scenario A: a single block of type i=1. The duration of this block is τ=200τ0, where τ0 corresponds to the mean time required for an elementary birth‐death events (duel), so r=1. The total population size (mutant plus wild type) is stable at N=6000 (panel A1), and the chance of the mutant type to win a duel is given by Eq. (5) where s=s1s2 jumps periodically between two values, as indicated in panel (A2). The mean displacement as a function of x (panel A3), as well as the second moment (panel A4), as obtained from numerical simulations of the process (red), are compared with the results presented in the first line of Table 2.

Figure A.2.

Figure A.2

Scenario B: a single block of type i=3. The duration of this block is τ=150τ0, where τ0 corresponds to the mean time required for an elementary birth‐death events of global competition (Moran process), so r=1. The total population size (mutant plus wild type) is stable at N=6000 (panel B1), and the chance of the mutant type to win an empty slot is given by Eq. (8) where s=s1s2 jumps periodically between two values, as indicated in panel (B2). The mean displacement as a function of x (panel B3), as well as the second moment (panel B4), as obtained from numerical simulations of the process (cyan), are compared with the results presented in the third line of Table 2.

Figure A.3.

Figure A.3

Scenario C: a single block of type i=4. The duration of this block is τ=200τ0, where τ0 corresponds to the mean time required for an elementary birth‐death events of global competition (Moran process), so r=1. The total population size (mutant plus wild type) is stable at N=6000 (panel C1), and the chance of the mutant type to win an empty slot is given by Eq. (8) where s=s1s2 jumps stochastically between two values, as indicated in panel (C2). The mean displacement as a function of x (panel C3), as well as the second moment (panel C4), as obtained from numerical simulations of the process (green), are compared with the results presented in the forth line of Table 2.

Figure A.4.

Figure A.4

Scenario D is a combination of two building blocks. First, the population grows exponentially, with r 1 for the mutant, r 2 for the wild type, until Kp is reached. This corresponds to line i=5 of Table 2. Then, the population decreases exponentially, with r 3 for the mutant and r 4 for the wild type, in a way that corresponds to line i=7 of Table 1. The overall duration of the process depends on the initial x value, and panels D1 (total population size) and D2 (fitness differences, expressed by r1r2 in the growth phase and by r3r4 in the decline phase) correspond to the case of x=1/2. Our theoretical predictions for Δx (panel D3) and its second moment (panel D4) are based on Eqs. (17) and (14), using the elementary expressions in lines 5 and 7 of Table 2.

Figure 4.

Figure 4

A representative segment made of random combination of the elementary scenarios detailed in Appendix A.4. The four scenarios that were considered in Figures A.1A.4 appear at random order. Population size (panel a) and selection parameter (panel b) are colored differently for each scenario, using the color scheme of Appendix A.4. Our theoretical predictions for Δx (panel c) and its second moment (panel d) are based on Eqs. (17) and (14), using the elementary expressions in lines 1,3,5,7 of Table 2.

Once μ(x) and σ2(x) were calculated, we substitute these quantities into Eqs. (1923)]. Numerical solutions of the corresponding integrals are compared with the outcomes of long runs of our Monte‐Carlo simulations in Figure (5).

Figure 5.

Figure 5

Π(x) (panel a), TA(x) (panel b) and TF(x) for a random combination of elementary building blocks. The building blocks are those used in Figure 4, but the simulation is much longer and stochastic, after each step the next building block is picked at random from scenarios AD of Appendix A.4 with equal probability. The agreement between the outcomes of long Monte‐Carlo simulations (blue) and the theoretical predictions based on the representative segment (green) is quite good.

Discussion

For many years, the diffusion approximation serves as the standard tool in the analysis of stochastic processes in general and population genetics in particular (Wakeley, 2005). Despite its limitations, it yields surprisingly accurate results when the relevant rates are slow enough and provides qualitative or semi‐quantitative insights even beyond its range of applicability (Danino et al., 2018; Parsons et al., 2010).

In the classical works of Kimura and co‐workers, the diffusion approximation was applied to processes in fixed environments, but until recently only a few cases of fluctuating environments were considered (Takahata et al., 1975; Takahata & Kimura, 1979). The interest in the effects of environmental variations on population processes grows substantially during the last decade, and many authors dealt with fluctuating selective forces or with variations in population size (Ashcroft et al., 2014; Cvijović et al., 2015; Danino and Shnerb, 2018; Huerta‐Sanchez et al., 2008; Hidalgo et al., 2017; Mustonen and Lässig, 2008; Meyer and Shnerb, 2018; Marrec & Bitbol, 2020; Wienand et al., 2017, 2018). Again the diffusion approximation was implemented, but this has been done in an ad‐hoc manner and the relevant terms σ2(x) and μ(x) were calculated from scratch in each case.

This paper aims at providing a simple mechanistic algorithm that allows one to produce and solve DA equations. It is based on the reduction of any complicated history into a sequence of basic building blocks. This approximation is supposed to work when the fine details of the dynamic are not crucial. If these fine details are crucial, the problem is less interesting, as its solution requires accurate knowledge of the history and cannot provide any general insights. We believe that the arsenal of simple building blocks considered here—local and global competition, logistic and exponential growth and decline, stochastic and periodic fluctuations and sharp decline— is wide enough so one may replace the observed or predicted process by a representative segment made of these building blocks. Once such a segment is defined, the μi(x) and σi2(x) terms for each block may be read from Table 2 and then combine, using the method presented in Section 4, to yield the relevant diffusion equation, whose numerical (and sometimes even analytic) analysis is quite trivial.

As explained, the main restriction on our approach is the requirement that x changes only slightly in the duration of a single representative segment. When this is not the case the diffusion approximation breaks down. Clearly, when the timescale of environmental variations is much larger than the fixation time the fate of the mutant depends mainly on the environmental state when the mutation occurs. This is the “quenched” limit considered by Mustonen and Lässig (2008); Cvijović et al. (2015). In particular, when the dynamics allow for bottlenecks and the total population size N drops to a small number, one expects the diffusion approximation to fail. Another scenario in which this problem manifests itself is when the environmental variations are superimposed on trends that are longer than TF.

In  Meyer and Shnerb (2020), schematic model of competition in varying environment was analyzed, and the same quantities were considered (Π(x), TA(x) and TF(x)). Here, we expand this work in two important manners. First, we included Table 2 that provided the relevant information for many building blocks, only a few of them were considered in Meyer and Shnerb (2020). More importantly, the analysis of Meyer and Shnerb (2020) is limited to the first‐order effect in selection parameters (neglects terms like s02,g,sgs0 and so on). Here we included second order terms both in the calculations of the building block contribution (for example the term g=γ2δ/(2N) in line 4 of Table 2) and in the equations used to combine the effect of individual blocks (Eqs. 16 and 17). To the first order in selection parameters μm(x) and σ2(x) are both simple additive sums of the contributions of all building blocks; only when higher orders are considered the non‐commutative characteristics of building blocks (Eq. 16) must be taken into account.

Keeping second order terms in the selection parameters is crucial to the analysis of fluctuating environments. When only linear terms are kept, dynamic is governed by the mean selective force. In that case [as done in Meyer and Shnerb (2020)] the original fixed environment expressions describe the long‐term behavior of the system. Environmental variations may affect the mean values of the effective selection parameters, they cannot yield dynamics that differ qualitatively from the dynamics in fixed environment. Only when higher order terms are taken into account, new qualitative behaviors like the storage effect and relative nonlinearity (Chesson & Warner, 1981; Chesson, 1982a, 2000; Dean & Shnerb, 2020; Ellner et al., 2016; Letten et al., 2018; Usinowicz et al., 2017) manifest themselves. These effects have to do with the covariance between selection parameters and population size, or with nonlinear terms stabilize coexistence and protects polymorphism, but they are essentially nonlinear so to capture their influence one must include s 2 terms. In principle, the analysis presented here may be extended to include third‐order and higher‐order terms in the selection parameter, but we are not familiar with important effects that appear only at this level. Moreover, if higher‐order terms are really important then selection terms have to be relatively large and in that case the diffusion approximation itself may break down.

The distinction between stochastic and periodic environmental variations is relevant to two distinct points. First, in the constant population dynamics (blocks 1 − 4 of Table 2) we distinguished between periodic and stochastic selection variations. As explained in  Meyer et al. (2022), periodic systems are more stable (admit higher TA) than their stochastic counterparts, as they do not allow for rare sequences of bad years (long periods of negative selection). Second, in the assembly of many building blocks into a representative segment one must take periodicity into account. If the dynamic is periodic (i.e., if the order and duration of building blocks is periodic) then the natural candidate for a representative segment is one period. On the other hand when building blocks appear in a stochastic order and/or duration there is no natural recipe like that, and one must identify a reasonable representative segment for the dynamics (see Figure 1). The chosen segment does not have to be periodic. Note that the two aspects of stochasticity and periodicity, the one within block and the one involves the blocks themselves, are completely independent: the representative segment may include periods of constant population with stochastic variations even if the order of blocks is periodic and periodic constant population blocks even if the order of blocks is stochastic.

As pointed out by Wakeley  (Wakeley, 2005), the role of the diffusion approximation in the theory of population genetic is much more than just a technical tool. As the only generally applicable analytic technique, it played an important role in shaping the conceptual framework of the field. Since environmental fluctuations and variations in population size and selective forces are so common in nature and even in experimental systems, a simple and generic procedure that allows one to implement the diffusion approximation in these cases is definitely required. We believe that the scheme presented here provides such a platform, and hope it will contribute to further developments in this important research field.

AUTHOR CONTRIBUTIONS

N.M.S was the originator of the concept, and supervised the work of B.S and I.M.. B.S derived the analytical approximations, presented in the appendix (A,B) and section (IV ) of the main text. I.M performed the numerical simulations and provided the figures. The writing was done mostly by N.M.S and I.M.

Associate Editor: S. Charlat

Handling Editor: T. Chapman

ACKNOWLEDGMENTS

This research was supported by the ISF‐NRF Singapore joint research program (grant number 2669/17).The work of I.M. was supported by an Eshkol Fellowship of the Israeli Ministry of Science.

Appendix A. Calculating the μi(x) and the σi2(x) for the Different Scenarios

In this appendix we derive the expressions presented in Table 2 of the main text. Before doing that we would like to present two technical remarks.

First, in what follows Bn(p) is a random number drawn from a binomial distribution with n trials and success probability p.

Second, in some cases we would like to divide a random variable f (whose mean is f¯) by another random variable g (mean g¯). In general one may write the expected value of the quotient as:

Efg=Ef¯+(ff¯)g¯+(gg¯)=E11+(gg¯)g¯f¯+(ff¯)g¯. (A.1)

If the distribution of g around its mean is such that |gg¯|<g¯ (at least with high enough probability), a Taylor series expansion yields,

EfgEf¯+(ff¯)g¯1(gg¯)g¯+(gg¯)2g¯2
f¯g¯1+E(gg¯)2g¯21g¯2E(ff¯)(gg¯), (A.2)

such that the quotient of the means is a first approximation for the mean of the quotient. The validity of this approximation may be verified by estimating the variance of g and the correlation between f and g.

Table 2 provides the results for nine scenarios. The first four are constant population cases (periodic and stochastic, global and local competition) and the derivation of the appropriate expressions is presented in Meyer et al. (2022). In the other five cases total population varies and we consider them here. First the easiest problem (sharp decline) followed by the logistic and the exponential growth or decline cases.

SHARP DECLINE (LINE 9 OF TABLE 2)

Let us consider first the simplest case, a sharp decline (dilution) of the total population from Kp to Km individuals. In that case the new population of the mutant type (1) and the wild type (2) are given by the random variables:

n1=BxKpsd+KmKpand:n2=B(1x)KpKmKp (A.3)

and the effect of the decline on the mutant type frequency is:

xn1n1+n2. (A.4)

Therefore,

Δx=(1x)n1xn2n1+n2. (A.5)

Now we implement Eq. A.2 with f=(1x)n1xn2 and g=n1+n2. Notice that g¯Km is suppose to be a very large number, and the fluctuations gg¯ are proportional to Km which is much smaller. Accordingly we may neglect the other terms and estimate,

μi=9(x)1tshx(1x)(sdKp+Km)KmKm=sdx(1x)KpKm1tsh (A.6)

where tsh is the duration of the abrupt decline in τ0 units. This duration time goes to zero, but (as explained in the main text) the actual parameter in the diffusion equation is μi=9(x) multiplied by tsh, so tsh cancels out and plays no role in the analysis. The approximation of large Km would also allow us to ignore the variance of n1+n2 when calculating the second moment:

σi=92(x)(1x)2x(sdKp+Km)(KpsdKpKm)+x2(1x)Km(KpKm)tshKpKm2=

and since sdx(1x)2(2KmKp(1sd)) is usually smaller than μ2(x), we may simplify and write the variance as:

σi=92(x)1tshx(1x)1Km1Kp (A.7)

EXPONENTIAL GROWTH AND DECLINE (LINES 5 AND 7 OF TABLE 2)

We consider a birth‐only (death only) process where each timestep dt is measured in units of τ0. In case of growth,

Δn1BxN(r1dt),Δn2B(1x)N(r2dt), (A.8)

and an exponential decline yields,

Δn1BxN(r3dt),Δn2B(1x)N(r4dt). (A.9)

From now on we consider only growth, the case of exponential decline is completely symmetric.

The change in mutants frequency x is,

xx+Δn1/N1+Δn1/N+Δn2/N. (A.10)

where N is the instantaneous population size. Therefore the displacement in each step is:

Δx=x+Δn1/N1+Δn1/N+Δn2/Nx=(1x)Δn1/NxΔn2/N1+Δn1/N+Δn2/N. (A.11)

Taking f=(1x)Δn1/NxΔn2/N and g=1+Δn1/N+Δn2/N in Eq. A.2, and assuming that the process is smooth enough, i.e. ridt1, then g¯1 and |gg¯| is much smaller than g¯. Therefore we may approximate the mean displacement by:

μi=5(x)=(r1r2)x(1x)1+r1x+r2(1x), (A.12)

as presented in Table 2.

To find the second moment we can expand the expression for the displacement, Eq. A.11, in a Taylor series (up to the second order in both the Δni/N):

x+Δn1/N1+Δn1/N+Δn2/Nx2((1x)Δn1/N)2+(xΔn2/N)22x(1x)Δn1Δn2N2 (A.13)

The contribution of the mixed terms to the variance vanishes, as they are uncorrelated. Assuming 1ridt1, the second moment during a single step dt is,

Δx2¯=Δx¯2+1N(t)r1x(1x)2+r2x2(1x). (A.14)

We now have to sum (or integrate) over 1/N(t). N grows exponentially and its growth rate is rr1x+r2(1x). Starting from N(t=0) (Km for growth) and integrating up to N(t) (Kp for growth) one finds:

1N(t)0tdtertN(t=0)=1r1Km1Kp (A.15)

When the diffusion approximation holds μ2(x) is usually negligible, otherwise:

σi=52(x)μi=52(x)+KpKmKpKmrτr1x(1x)2+r2x2(1x) (A.16)

when τ is the duration which we can estimate from the previous approximation: if Kp=Kmexp[rτ] than τlog(Kp/Km)/r.

LOGISTIC GROWTH AND DECLINE (LINES 6 AND 8 OF TABLE 2)

In the model of exponential growth discussed in the last section there are two populations that grow exponentially in time, the only interaction between them is imposed by the fact that the growth halts when the total population reaches a given ceiling. Logistic growth takes place differently: first the carrying capacity is incremented, and then both populations compete for the newly open slots. Logistic decline implies that carrying capacity decreases, and then competition between nutant and the wild type increases in strength until the population reaches the new carrying capacity. We assume the rate in which the carrying capacity changes λ, to be the rate determining (slow) process, whereas competition is much faster. Therefore, only λ determines the overall growth (decline) time tg (td).

When carrying capacity grows by ΔN individuals, the share of the mutant type is picked from a binomial distribution BΔN(x+sgx(1x)), and the wild type population grows by ΔNB. Upon decline by ΔN individuals, the mutant type population decreases by BΔN(xsdx(1x)), and the wild type population death toll is ΔNB. Note that in both cases, a positive value of sg,sd represents a beneficial mutant. To make the calculations simple we consider from now on only growth process, the calculations in the decline case are completely symmetric.

Accordingly, after an increase by ΔN,

xxN+BΔN(x+sgx(1x))N(t)+ΔNor:ΔxBΔN(x+sgx(1x))N(t), (A.17)

so,

Δx¯=ΔNsgx(1x)/N(t). (A.18)

For small steps we implement the differential form,

dxx(1x)=sgdNN(t). (A.19)

Integrating both sides, when the initial value of x is x 0 and N is integrated from Km to Kp, one obtains,

logx/x0(1x)/(1x0)=sglogKpKmΔx=x0KpKmgs1x0+x0KpKmgsx0. (A.20)

The first moment would be:

μi=6(x)=x(1x)KpKmgs11x+xKpKmgs1tg. (A.21)

The time tg is estimated in Eq. (10) of the main text.

To calculate the second moment we notice that at each step:

Δx2¯=Δx¯2+ΔNx+sgx(1x)1xsgx(1x)/N2 (A.22)

The 1/N2 factor makes the whole expression rather small, and by integrating over time we obtained,

σi=62(x)1tgμi=62(x)+x(1x)1Km1Kp. (A.23)

EXAMPLES

In what follows we provide a few examples. In each of the following figures the two left panels show N(t) and s(t) for a given building block (in the last figure ‐ a combination of two building blocks) whereas the two right panels show Δ(x) and (Δx)2, as obtained from Monte‐Carlo simulations vs. the prediction that are based on Table 2. In subsection 6.2 of the main text these results are used for the analysis of a stochastic environment model.

Appendix B. Addition of Building Blocks

Addition of the building blocks is related to some elementary features of stochastic dynamics. Let us consider a processes with “velocity” f(x) and x‐dependent diffusion constant D(x), both these quantities may be time‐dependent. The value of x satisfies the difference equation,

xt+1=xt+ft+1(xt)+ξtDt+1(xt), (B.1)

where ξt is a zero‐mean random variable with unit variance. After T steps one gets:

Δx(T)=t=1T[ft(xt1)+ξtDt(xt1)]. (B.2)

Expanding ft and Dt in a Taylor series around x0=x(t=0) we get:

Δx(T)=t=1T[ft(x0)+ξtDt(x0)+{ft(x0)+ξtDt(x0)}Δx(t1)] (B.3)

Now we assume that the period T is divided into m intervals, indexed by =1..m. Each interval lasts for t steps, during which the functional form of f(x) and D(x) is fixed. Dropping the zero subscript, one can write

Δx(T)==1..mj=1t[f(x)+ξjD(x)+{f(x)+ξjD(x)}Δx(t1)] (B.4)

If j is the j‐th step in the qs interval then the time after that step is t==1q1t+j.

At this point we would like to take the mean of Δx. Doing that all ξ terms vanish, and one gets

Δx(T)¯=E=1..mj=1t[f(x)+f(x)Δx(t1)] (B.5)

We would like to distinguish between the within‐block and the between‐block dynamic of Δx(t1) . The mean displacement within block (i.e., the mean displacement of x between t=0 and t=t, where the values of f and D are fixed) is given by the inner sum in B.5, so,

EΔx(t)=Ef(x)t+t=1tf(x)j=1i1f(x)f(x)¯t+t22f(x)f(x)¯. (B.6)

Therefore, the first order approximation for the mean displacement, Δxfo (here the subscript implies first order), is given by summing over the contribution of each block, neglecting the displacement of the initial frequency due to former blocks. This will be a simple weighted sum over the effect of each block,

Δxfo¯=E=1mtf(x)+t22f(x)f(x). (B.7)

To proceed, one has to specify the distribution from which a given t is picked. We have studied two cases:

  • Fixed t, so
    t22¯=t¯22
  • t is drawn from exponential distribution with mean t¯ :
    t22¯=t¯2

Therefore, we can conclude (here τt¯:

  • If t is fixed: μ(x)=f(x)+f(x)f(x)τ/2

  • If t is drawn from an exponential distribution: μ(x)=f(x)+f(x)f(x)τ

Now let us return to Eq. (B.7) and try to improve the approximation. Eq. (B.7) assumes that all blocks have the same starting point. In reality, the second block =2 starts at the end point of the =1 block. To account for that, we implement again the series expansion: The mean change in x after two consecutive blocks is,

Δx1..2=x2x0=μ1(x)τ1+μ2(x)τ2+μ2(x)τ2μ1(x)τ1 (B.8)

The first two terms were present in the first order expression Δxfo¯, the last term accounts for the effect of the displacement during the first block on the displacement due to the second block. Therefore,

μ1..2=Δx1..2τ=μ1(x)τ1+μ2(x)τ2+μ2(x)τ2μ1(x)τ1τ1+τ2 (B.9)

and Eq. (16) of the main text is a generalization of this expression.

The derivation of the second moment, (Δx)2¯, starting from Eq. (B.4), is based on the same arguments. However, in the limits discussed in this paper (when diffusion approximation holds), the variance is a simple weighted addition, as in 14. As we show below, all other terms are negligible.

By definition,

Δx2(T)=1=1..m,2=1..mj1=1t1[f1(x)+ξj1D1(x)+{f1(x)+ξj1D1(x)}Δx(t1)]×j2=1t2[f2(x)+ξj2D2(x)+{f2(x)+ξj2D2(x)}Δx(t1)] (B.10)

Taking the expectation value, terms that are linear in ξ disappear and ξiξj=δi,j. Therefore,

Δx2(T)¯=E=1..mj=1t[D2(x)+D(x)D(x)Δx(t1)]+E1=1..m,2=1..mj1=1t1j2=1t2[f1(x)f2(x)+2f2(x)f1(x)Δx(t1)] (B.11)

For the cases discussed in this paper, for each x DΔxD and fΔxf (Δx is the small parameter in the expansion that yields the diffusion approximation). Since our models assume no correlation between blocks, mixed terms like fifj contribute only if i and j are at the same block. Eq. (B.11) then reduces to,

EΔx2(T)=E=1..mj=1tD2(x)+tf2(x)¯==1..mt¯D2(x)+t2¯·f2(x)¯ (B.12)

Where t2¯ is either t¯2 (fixed) or 2t¯2 (stochastic), as discussed above.

Finally, dividing by the total duration of all blocks:

σ1m2(x)==1..mt¯D2(x)+t2¯·f2(x)¯=1..mτ, (B.13)

and taking into account that σ2μ2, one recovers Eq. (14) of the main text,

σm2(x)=1Tm=1..mσ2(x)τ. (B.14)

Appendix C. Solutions for the Diffusion Equation

Here we would like to show the integral‐solution for the equation

σ2(x)2F(x)+μ(x)F(x)=G(x). (C.1)

when calculating the chance of fixation, F(x)=Π(x) and G(x)=0, for the time to absorption F(x)=TA(x) and G(x)=τ0, while for the time to fixation we define Q(x)=TF(x)Π(x). In this case, F(x)=Q(x) and G(x)=Π(x)τ0. We add an integrating factor, such that,

F(x)ex2μ(t)σ2(t)dt=2G(x)σ2(x)ex2μ(t)σ2(t)dt. (C.2)

Integrating both sides yields,

F(x)ex2μ(t)σ2(t)dt=x2G(t)σ2(t)et2μ(q)σ2(q)dqdt+C1F(x)=x2G(t)σ2(t)et2μ(q)σ2(q)dqdt+C1ex2μ(t)σ2(t)dt. (C.3)

Finally,

F(x)=xk2G(t)σ2(t)et2μ(q)σ2(q)dqdt+C1ek2μ(t)σ2(t)dtdk+C2 (C.4)

All that is left is to find the constants of integration using the boundary conditions (TA(0)=TA(1)=Q(0)=Q(1)=Π(0)=0, and Π(1)=1). This yields the expressions presented in the main text.

DATA AVAILABILITY STATEMENT

All data generated or analyzed during this study are included in this published article (and its supplementary information files).

LITERATURE CITED

  1. Adler, P.B. , HilleRisLambers, J. , Kyriakidis, P.C. , Guan, Q. & Levine, J.M. (2006) Climate variability has a stabilizing effect on the coexistence of prairie grasses. Proceedings of the National Academy of Sciences, 103(34), 12793–12798. [DOI] [PMC free article] [PubMed] [Google Scholar]
  2. Ashcroft, P. , Altrock, P.M. & Galla, T. (2014) Fixation in finite populations evolving in fluctuating environments. Journal of The Royal Society Interface, 11(100), 20140663. [DOI] [PMC free article] [PubMed] [Google Scholar]
  3. Assaf, M. & Meerson, B. (2017) WKB theory of large deviations in stochastic populations. Journal of Physics A: Mathematical and Theoretical, 50(26), 263001. [Google Scholar]
  4. Bergland, A.O. , Behrman, E.L. , O'Brien, K.R. , Schmidt, P.S. & Petrov, D.A. (2014) Genomic evidence of rapid and stable adaptive oscillations over seasonal time scales in drosophila. PLoS Genetics, 10(11), e1004775. [DOI] [PMC free article] [PubMed] [Google Scholar]
  5. Bertram, J. & Masel, J. (2019) Different mechanisms drive the maintenance of polymorphism at loci subject to strong versus weak fluctuating selection. Evolution, 73(5), 883–896. [DOI] [PubMed] [Google Scholar]
  6. Chesson, P.L. (1982a) The stabilizing effect of a random environment. Journal of Mathematical Biology, 15(1), 1–36. [Google Scholar]
  7. Chesson, P.L. (1982b) The storage effect in stochastic competition models. Mathematical ecology: Proceedings, Trieste, 76–89. [Google Scholar]
  8. Chesson, P.L. (2000) Mechanisms of maintenance of species diversity. Annual Review of Ecology and Systematics, 31(1), 343–366. [Google Scholar]
  9. Chesson, P.L. & Warner, R.R. (1981) Environmental variability promotes coexistence in lottery competitive systems. The American Naturalist, 117, 923–943. [Google Scholar]
  10. Crow, J.F. , Kimura, M. , et al. (1970) An Introduction to Population Genetics Theory. New York, Evanston and London: Harper & Row, Publishers. [Google Scholar]
  11. Cvijović, I. , Good, B.H. , Jerison, E.R. & Desai, M.M. (2015) Fate of a mutation in a fluctuating environment. Proceedings of the National Academy of Sciences, 112(36), E5021–E5028. [DOI] [PMC free article] [PubMed] [Google Scholar]
  12. Danino, M. , Kessler, D.A. & Shnerb, N.M. (2018) Stability of two‐species communities: drift, environmental stochasticity, storage effect and selection. Theoretical Population Biology, 119, 57–71. [DOI] [PubMed] [Google Scholar]
  13. Danino, M. & Shnerb, N.M. (2018) Fixation and absorption in a fluctuating environment. Journal of Theoretical Biology, 441, 84–92. [DOI] [PubMed] [Google Scholar]
  14. Dean, A. & Shnerb, N.M. (2020) Stochasticity‐induced stabilization in ecology and evolution: a new synthesis. Ecology, 101(9), e03098. [DOI] [PubMed] [Google Scholar]
  15. Elgart, V. & Kamenev, A. (2004) Rare event statistics in reaction‐diffusion systems. Physical Review E, 70(4), 041106. [DOI] [PubMed] [Google Scholar]
  16. Ellner, S.P. , Snyder, R.E. & Adler, P.B. (2016) How to quantify the temporal storage effect using simulations instead of math. Ecology Letters, 19(11), 1333–1342. [DOI] [PubMed] [Google Scholar]
  17. Ewens, W.J. (2012) Mathematical Population Genetics 1: Theoretical Introduction, volume 27. Springer Science & Business Media. [Google Scholar]
  18. Fung, T. , Chisholm, R.A. , Anderson‐Teixeira, K. , Bourg, N. , Brockelman, W.Y. , Bunyavejchewin, S. , Chang‐Yang, C.H. , Chitra‐Tarak, R. , Chuyong, G. , Condit, R. , et al. (2020) Temporal population variability in local forest communities has mixed effects on tree species richness across a latitudinal gradient. Ecology letters, 23(1), 160–171. [DOI] [PubMed] [Google Scholar]
  19. Good, B.H. , McDonald, M.J. , Barrick, J.E. , Lenski, R.E. & Desai, M.M. (2017) The dynamics of molecular evolution over 60,000 generations. Nature, 551(7678), 45–50. [DOI] [PMC free article] [PubMed] [Google Scholar]
  20. Hidalgo, J. , Suweis, S. & Maritan, A. (2017) Species coexistence in a neutral dynamics with environmental noise. Journal of theoretical biology, 413, 1–10. [DOI] [PubMed] [Google Scholar]
  21. Huerta‐Sanchez, E. , Durrett, R. & Bustamante, C.D. (2008) Population genetics of polymorphism and divergence under fluctuating selection. Genetics, 178(1), 325–337. [DOI] [PMC free article] [PubMed] [Google Scholar]
  22. Kalyuzhny, M. , Schreiber, Y. , Chocron, R. , Flather, C.H. , Kadmon, R. , Kessler, D.A. & Shnerb, N.M. (2014) Temporal fluctuation scaling in populations and communities. Ecology, 95(6), 1701–1709. [DOI] [PubMed] [Google Scholar]
  23. Karlin, S. & Taylor, H.E. (1981) A Second Course in Stochastic Processes. Elsevier. [Google Scholar]
  24. Kessler, D.A. & Shnerb, N.M. (2007) Extinction rates for fluctuation‐induced metastabilities: a real‐space WKB approach. Journal of Statistical Physics, 127(5), 861–886. [Google Scholar]
  25. Kimura, M. (1962) On the probability of fixation of mutant genes in a population. Genetics, 47(6), 713. [DOI] [PMC free article] [PubMed] [Google Scholar]
  26. Lande, R. , Engen, S. & Saether, B.E. (2003) Stochastic Population Dynamics in Ecology and Conservation. Oxford University Press. [Google Scholar]
  27. Lenski, R.E. , Rose, M.R. , Simpson, S.C. & Tadler, S.C. (1991) Long‐term experimental evolution in escherichia coli. i. adaptation and divergence during 2,000 generations. The American Naturalist, 138(6), 1315–1341. [Google Scholar]
  28. Letten, A.D. , Dhami, M.K. , Ke, P.J. & Fukami, T. (2018) Species coexistence through simultaneous fluctuation‐dependent mechanisms. Proceedings of the National Academy of Sciences, 115(26), 6745–6750. [DOI] [PMC free article] [PubMed] [Google Scholar]
  29. Marrec, L. & Bitbol, A.F. (2020) Resist or perish: fate of a microbial population subjected to a periodic presence of antimicrobial. PLoS computational biology, 16(4), e1007798. [DOI] [PMC free article] [PubMed] [Google Scholar]
  30. Mellard, J.P. , Audoye, P. & Loreau, M. (2019) Seasonal patterns in species diversity across biomes. Ecology, 100(4), e02627. [DOI] [PubMed] [Google Scholar]
  31. Meyer, I. & Shnerb, N.M. (2018) Noise‐induced stabilization and fixation in fluctuating environment. Scientific Reports, 8, 9726. [DOI] [PMC free article] [PubMed] [Google Scholar]
  32. Meyer, I. & Shnerb, N.M. (2020) Evolutionary dynamics in fluctuating environment. Physical Review Research, 2(2), 023308. [Google Scholar]
  33. Meyer, I. , Steinmetz, B. & Shnerb, N.M. (2022) How the storage effect and the number of temporal niches affect biodiversity in stochastic and seasonal environments. PLOS Computational Biology, 18(3), e1009971. [DOI] [PMC free article] [PubMed] [Google Scholar]
  34. Moran, P.A.P. (1958) Random processes in genetics. In Mathematical proceedings of the cambridge philosophical society, volume 54, (pp. 60–71). Cambridge University Press. [Google Scholar]
  35. Mustonen, V. & Lässig, M. (2008) Molecular evolution under fitness fluctuations. Physical Review Letters, 100(10), 108101. [DOI] [PubMed] [Google Scholar]
  36. Ovaskainen, O. & Meerson, B. (2010) Stochastic models of population extinction. Trends in Ecology & Evolution, 25(11), 643–652. [DOI] [PubMed] [Google Scholar]
  37. Pande, J. & Shnerb, N.M. (2020) Taming the diffusion approximation through a controlling‐factor wkb method. Physical Review E, 102(6), 062410. [DOI] [PubMed] [Google Scholar]
  38. Parsons, T.L. , Quince, C. & Plotkin, J.B. (2010) Some consequences of demographic stochasticity in population genetics. Genetics, 185(4), 1345–1354. [DOI] [PMC free article] [PubMed] [Google Scholar]
  39. Redner, S. (2001) A Guide to First‐Passage Processes. Cambridge University Press. [Google Scholar]
  40. Takahata, N. , Ishii, K. & Matsuda, H. (1975) Effect of temporal fluctuation of selection coefficient on gene frequency in a population. Proceedings of the National Academy of Sciences, 72(11), 4541–4545. [DOI] [PMC free article] [PubMed] [Google Scholar]
  41. Takahata, N. & Kimura, M. (1979) Genetic variability maintained in a finite population under mutation and autocorrelated random fluctuation of selection intensity. Proceedings of the National Academy of Sciences, 76(11), 5813–5817. [DOI] [PMC free article] [PubMed] [Google Scholar]
  42. Traulsen, A. , Pacheco, J.M. & Nowak, M.A. (2007) Pairwise comparison and selection temperature in evolutionary game dynamics. Journal of theoretical biology, 246(3), 522–529. [DOI] [PMC free article] [PubMed] [Google Scholar]
  43. Usinowicz, J. , Chang‐Yang, C.H. , Chen, Y.Y. , Clark, J.S. , Fletcher, C. , Garwood, N.C. , Hao, Z. , Johnstone, J. , Lin, Y. , Metz, M.R. , et al. (2017) Temporal coexistence mechanisms contribute to the latitudinal gradient in forest diversity. Nature, 550(7674), 105. [DOI] [PubMed] [Google Scholar]
  44. Usinowicz, J. , Wright, S.J. & Ives, A.R. (2012) Coexistence in tropical forests through asynchronous variation in annual seed production. Ecology, 93(9), 2073–2084. [DOI] [PubMed] [Google Scholar]
  45. Volkov, I. , Banavar, J.R. , Hubbell, S.P. & Maritan, A. (2003) Neutral theory and relative species abundance in ecology. Nature, 424(6952), 1035–7. [DOI] [PubMed] [Google Scholar]
  46. Wahl, L.M. & Gerrish, P.J. (2001) The probability that beneficial mutations are lost in populations with periodic bottlenecks. Evolution, 55(12), 2606–2610. [DOI] [PubMed] [Google Scholar]
  47. Wakeley, J. (2005) The limits of theoretical population genetics. Genetics, 169(1), 1–7. [DOI] [PMC free article] [PubMed] [Google Scholar]
  48. White, E.R. & Hastings, A. (2020) Seasonality in ecology: Progress and prospects in theory. Ecological Complexity, 44, 100867. [Google Scholar]
  49. Wienand, K. , Frey, E. & Mobilia, M. (2017) Evolution of a fluctuating population in a randomly switching environment. Physical Review Letters, 119(15), 158301. [DOI] [PubMed] [Google Scholar]
  50. Wienand, K. , Frey, E. & Mobilia, M. (2018) Eco‐evolutionary dynamics of a population with randomly switching carrying capacity. Journal of The Royal Society Interface, 15(145), 20180343. [DOI] [PMC free article] [PubMed] [Google Scholar]
  51. Yi, X. & Dean, A.M. (2013) Bounded population sizes, fluctuating selection and the tempo and mode of coexistence. Proceedings of the National Academy of Sciences, 201309830. [DOI] [PMC free article] [PubMed] [Google Scholar]

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Data Availability Statement

All data generated or analyzed during this study are included in this published article (and its supplementary information files).


Articles from Evolution; International Journal of Organic Evolution are provided here courtesy of Wiley

RESOURCES