Horizontal gene transfer: numerical comparison between stochastic and deterministic approaches

Horizontal gene Transfer (HT) denotes the transmission of genetic material between two living organisms, while the vertical transmission refers to a DNA transfer from parents to their offspring. Consistent experimental evidence report that this phenomenon plays an essential role in the evolution of certain bacterias. In particular, HT is believed to be the main instrument of developing the antibiotic resistance. In this work, we consider several models which describe this phenomenon: a stochastic jump process (individual-based) and the deterministic nonlinear integrod-ifferential equation obtained as a limit for large populations. We also consider a Hamilton-Jacobi equation, obtained as a limit of the deterministic model under the assumption of small mutations. The goal of this paper is to compare these models with the help of numerical simulations. More specifically, our goal is to understand to which extent the Hamilton-Jacobi model reproduces the qualitative behavior of the stochastic model and the phenomenon of evolutionary rescue in particular.


Introduction
Accurate mathematical description of the evolutionary mechanism is an open question in biology, medicine, and industry.In particular, transmission of pathogens, or antibiotic resistance of bacteria is directly linked to the ability of the bacteria population to mutate and exchange genetic material either vertically (from parents to offspring), or horizontally (from the interaction between non-parental individuals).
Horizontal Gene Transfer was first described in bacteria when the antibiotic resistance was discovered.This resistance occurs when one bacterial cell becomes resistant to an antibiotic due to mutation, and then transfers resistance genes to other species of bacteria.However the Horizontal Transfer of biologic information is not restricted to genes, it also describes the transfer of plasmids and endosymbionts, see for example M Henry et al. (2013), Lili et al. (2007).Some artificial applications of horizontal transfer include forms of genetic engineering (Gene Delivery) that result in an organism with its genes changed in some way, and, consequently, possessing new properties or functions (see for instance Kamimura et al. (2011)).These applications are particularly useful for "Gene Therapy", which is an experimental procedure that may help treat or prevent genetic disorders and some types of cancer.
The primary goal of our work is to describe the mechanism of the transfer itself and explain how it affects the population dynamics.Throughout the paper we abbreviate the Horizontal Transfer to HT.
Our study starts with finding a good model of a bacteria population.Several mathematical models for describing a population dynamics were proposed in literature.The first model we consider is a stochastic birth and death process (see, for reference, Billiard et al. (2015), Fournier and Méléard (2004)), which describes the dynamics of reproduction, competition, and exchange of genetic material between individuals in a population.The phenotype of each individual is described by a numerical parameter, called trait.Numerical experiments show that the effect of a unilateral horizontal gene transfer may lead to a cyclic behavior of the population.Roughly speaking, while HT drives individuals towards a non-fit phenotype -and, consequently, to extinction, very few not affected by transfer fit individuals may eventually repopulate the environment, before being driven again to deleterious phenotypes.This phenomenon is called an evolutionary rescue of a small population.
However, within a framework of stochastic jump processes, it is hard to define and study the observed cycling phenomena accurately.The second drawback of the stochastic system is that it is costly to compute, especially for a large time scale and population size.Thus, in the case of a large population, it is more practical to work with a deterministic PDE model, describing the limiting behaviour of a stochastic system when the population size goes to infinity Billiard et al. (2018Billiard et al. ( , 2016)), Ferrière and Tran (2009).In certain settings, the population dynamics involve concentration phenomena (i.e., the convergence of the population density to singular solutions, such as Dirac masses).In that case, the PDE formulation is not suitable.Thus, applying a limiting procedure for small mutations and time rescaling to the PDE model, we pass to a Hamilton-Jacobi type equation.
The primary goal of our work is thus to conduct a numerical analysis of the population dynamics on a macroscopic individual-based model and to compare it with the deterministic system which is obtained as a limit for a large population.We are especially interested in determining to which extent the limiting Hamilton-Jacobi equation can grasp qualitative properties of the stochastic model.This framework has already been successfully used to understand the concentration phenomena, and the location of the dominant trait (see for instance Lorz et al. (2011), Perthame and Barles (2008)).We aim to understand if the Hamilton-Jacobi approach is also well suited to describe the evolutionary rescue phenomena which crucially rely on an accurate description of the small populations.
On this step, the choice of an approximation scheme for simulating solutions of the PDE model is of tremendous importance.As we further explain in Section 2, classical explicit schemes do not preserve the asymptotic behavior of the solution if the time rescaling step goes to 0. From a numerical point of view, it involves operations with exponentially big values, which lead to non-negligible errors for explicit numerical schemes.We address this question by proposing an asymptotic preserving scheme for a Hamilton-Jacobi equation, adapting an approach proposed in Crandall and Lions (1984).More generally, the numerical approximation problem for solutions of Hamilton-Jacobi equations is treated in Achdou et al. (2013).
This paper is structured as follows: in Section 1 we introduce the model both in a stochastic and deterministic setting, and formally derive the limiting Hamilton-Jacobi equation.Then, we simulate a jump process, describing the bacteria population, and study its properties for different values of parameters.Numerical experiments are gathered in Section 2. We aim to numerically determine the critical HT rate, which leads to an almost sure extinction of the whole population.On the next step, we conduct the same analysis for a Hamilton-Jacobi equation with the help of an asymptotic preserving scheme and compare it with the stochastic model on an appropriate timescale, and explain why the classical scheme fails to work.We end our study with conclusions and discussion of yet unsolved numerical and theoretical questions.

Stochastic model
We consider a stochastic model describing the evolution of a population structured by phenotype.In a general case it is described at each time t by the point measure where parameter K is a scaling parameter, referred to as the carrying capacity.
It stands for the maximal number of individuals that the underlying environment is able to host (K can represent, for example, the amount of available resources).
is the size of the population at time t, and X i (t) ∈ R n is the trait of i-th individual living at t, which summarizes the phenotype information.In this work we assume n = 1, that is, the trait is given by a point on a real line.
The demography of the population is regulated, first of all, by its birth and death rates.An individual with a trait x gives birth to a new individual with rate b(x).The trait y of the offspring is chosen from a probability distribution m(x − y)dy (by that we mean that R m(x − y)dy = 1).We will refer to it as the mutation kernel.An individual with a trait x dies according to an intrinsic death rate d(x) plus an additional death rate C N K t K (independent of x) which stands for the competition between individuals.
Finally, an individual with a trait x can induce a unilateral HT to an individual with trait y at rate h K (x, y, ν), such that the pair (x, y) becomes (x, x).
In literature this kind of transfer is sometimes referred to as a conjugation.For simplicity, we assume h K (x, y, ν) to be in the particular form where N = K R ν(dx) is the number of individuals, τ 0 > 0 is a constant and α is either a Heaviside, or a smooth bounded function, such that for a small δ > 0: where δ is the stiffness parameter.We introduce δ to have the advantage of working with a smooth function (which will be useful in the following parts), while mimicking the binary nature of the Heaviside function.
For a population ν = 1 K N i=1 δ xi and a generic measurable bounded function F , the generator of the process is then given by: It is standard to construct the measure-valued process ν K as the solution of a stochastic differential equation driven by Poisson point measures and to derive moment and martingale properties (see for instance Fournier and Méléard (2004)).

The PDE model
It is proven (see in particular Billiard et al. (2018), Champagnat et al. (2008)) that for K → +∞ the stochastic process defined by a sequence of point measures given by (1.1) converges in probability to the unique solution of a non-linear integro-differential equation.This equation is given by: where f (t, x) is the macroscopic density of the population with trait x at time t and, accordingly to the previous section, b(x), d(x) and C are the birth, death and competition rate respectively, m is the mutation kernel, and is the horizontal transfer flux.Now our goal is to pass from micro-to a macroscopic scale with the help of a rescaling.On the one hand, we consider the case of small mutations: for a small parameter ε > 0 we define With a change of variable z = x−y ε we can rewrite the mutation term at (t, x) as On the other hand, when ε is small, the effect of mutations can only be observed in a larger time scale.Thus, we rescale time with t → t ε .We end up with the following system, for ε > 0, and (t, (5)

The Hamilton-Jacobi limit
We now derive the limiting problem (1.2) when ε → 0. As we will see, the limiting problem allows us to give a rigorous mathematical framework and to perform useful formal calculations.Equations in the form of (1.2) often give rise to a concentration phenomenon, i.e the convergence of f ε towards a Dirac mass when ε → 0 (see Perthame and Barles (2008), Diekmann et al. (2005)).The usual way to deal with these asymptotics is to perform a Hopf-Cole transformation (or WKB ansatz), i.e to consider u ε (t, x) This change of variable comes from the intuition that a Dirac mass is no more than a narrow Gaussian, and more precisely that f ε should behave like a Gaussian of variance ε when ε → 0. Accordingly, we expect u ε to have a non singular limit when ε → 0. Incidentally, this substitution also gives insights on the convenient scheme to use for numerical simulations, as we will see in the following section.Now our goal is to identify and derive the asymptotic properties of u ε when ε → 0, which will be used for discussions in the sequel.The following computations are only formal, since rigorous proofs are often intricate in this context.Substituting (1.3) into (1.2) we deduce that u ε satisfies Formally, at the limit ε → 0, u ε converges to a continuous function u which satisfies the following Hamilton-Jacobi equation in the "viscosity" sense: where ρ(t) ≥ 0 is the weak limit of ρ ε (t) and We formally assume here and in the following that the definition of x(t) is unambiguous, i.e that u reaches its maximum in a single point.Note that the limiting function u is not expected to be C 1 for all time.We thus need to deal with a generalized notion of solutions, namely viscosity solution (see Barles (1994)).
This framework is convenient because most of the information is contained in the dynamics of x(t).See the next section for further analysis.

Formal analysis on the Hamilton-Jacobi equation
Hamilton-Jacobi equations are particularly known in mathematical biology to be a good model to describe how a population concentrates around the dominant trait(s) when the mutations are small.However, here we are interested to use this model to describe a phenomenon of evolutionary rescue.In this subsection we attempt an analysis of the equation (1.3).We point out that the calculations are only formal, since rigorous proofs are intricate and beyond the scope of this paper.

Generality
From an integration of (1.2) with respect to x and classical computations (under the assumptions of bounded functions for the birth, death and transfer rates), we deduce that our model satisfies a saturation property, i.e. ρ ε (t) is bounded from above, uniformly in t ≥ 0 and ε > 0. From this and ρ ε (t) = R n e uε(t,x) ε dx, we deduce that ∀t > 0, sup x∈R n u(t, x) ≤ 0 and the following constraint holds: Note that our model allows the population to get extinct, thus we cannot expect ρ to be always positive.As a byproduct, we derive the concentration property, i.e the formal weak convergence of measures where δ x(t) denotes, as usually, the Dirac measure centered in x(t).From (1.4.1) it is possible to formally derive a formula for ρ.Indeed, either ρ(t) = 0 or ρ(t) > 0 and ∂ t u(t, x(t)) = 0, which implies for τ defined in (1.2).
Having above definitions in hand, we can now perform a formal analysis on the dynamics of x(t), defined below in (1.4.1).Our aim is to show how the behaviour of the system can be analyzed within the framework of a Hamilton-Jacobi equation (1.3).To fix ideas, we fix all constants but τ 0 and we assume (1.4.1)-(1.4.1) as follows: and the transfer function h K (x, y, ν) is defined in (1.1).Moreover we work under the following assumptions: •) reaches its maximum on a single point x(t), x(t) is a non-degenerate maximum, i.e ∇ 2 x u(t, x) < 0, x(t) is smooth with respect to t. (15) Finally we assume that the initial condition f 0 is a given function of x which reads: 1.4.2Smooth dynamics x(t).
The following statement deals with the smooth dynamics of x(t), i.e in the regime where no jump occurs in the dynamics of x(t).
Statement 1.Under assumptions (1.4.1)-(1.4.1), the function t → x(t) is an increasing function which satisfies the following inequality ∀t ≥ 0: More precisely, x(t) satisfies the canonical equation where r(x) and ∇ 2 x u denotes the Hessian of u with respect to the x variable.Proof.Under the above assumptions we can derive the dynamics of x(t), referred to as the canonical equation in the literature (see for instance Mirrahimi and Roquejoffre (2016)).Indeed, starting from ∇ x u(t, x(t)) = 0, a differentiation with respect to t gives (1).Equation (1) has a unique singular point x , which satisfies r (x ) + τ (0) = 0, with τ defined in (1.1) and r in (1).We find Note that t → x(t) is increasing when x(t) < x and decreasing when x(t) > x .
In general, the canonical equation ( 1) does not hold in every point of time.Indeed, a new maximum of u can arise in a finite time, which would cause a "jump" in the dynamics of x(t): this is what we call an evolutionary rescue.
Formally, this is what happens (periodically in time) in the case of cycles, see Figure 5b.We thus expect x(t) to possibly jump periodically, and to follow (1) between two jumps.We now try to characterize the possible jumps.For T > 0, we denote x(T − ) := lim t→T t<T x(t), x(T + ) := lim t→T t>T x(t).
Statement 2. We assume that (1.4.1)-(1.4.1) hold until a time T > 0, such that u(T, •) reaches its maximum on x(T − ) and on another point x.Then x = 0 and x(t) will jump towards 0 at time T , i.e x(T + ) = 0.
Proof.From assumption (1.4.1), we have ∀t ∈ For simplicity, we further assume δ ≤ θ, where δ is defined in (1.1).First, let us show that x = 0. We define the fitness function of trait x in a population concentrated in x: where r and τ are respectively defined in (1) and (1.2).Note that we have The second step is to prove that there will be an actual jump towards 0, i.e x(T + ) = 0. First, note that there exists a small η > 0 such that ∀t ∈ (T − η, T ), u(t, x(t)) = 0 and u(t, 0) < 0. Let us fix t ∈ (T − η, T ).We have F x(t) (0) ≥ F x(t) (x(t)), and we claim that the inequality is strict.Indeed, since t → x(t) is increasing, F x(t) (x(t)) is decreasing, whereas F x(t) (0) is constant (as long as η is small enough such that x(T − η) > δ).We end up with The above inequality expresses the fact that 0 is fitter than x(t) in a population with trait x(t).In general, this does not allow to conclude that 0 will invade and become the new dominant trait (i.e., that the jump will occur) because it does not imply that 0 will remain fitter during all the process of invasion.But the particular form of our problem, especially the fact that τ is an odd function, implies F 0 (0) > F 0 (x(t)).
Indeed we have from the definition of Consequently that for all λ ∈ [0, 1] It shows that 0 remains the fittest trait during all the process of invasion, and therefore that 0 will actually invade, i.e that x(t) will actually jump towards 0 at time T + .

Threshold for cycles
In the previous section, we described the possible evolutionary rescue, i.e the possible jumps in the dynamics of x(t) towards x = 0.When a jump occurs, a new cycle begins: it leads to a periodical behavior of x(t), hence the cycling phenomenon.
We recall that a jump corresponds to a rescue of the population concentrated at x(t) by the small population with trait x = 0.It is possible only if x(t) > δ and if 0 is fitter than x(t) during a sufficiently large interval of time (which is the time needed for the small population at x = 0 to regrow).Note that 0 is fitter than x(t) if and only if But if no jump occurs, x(t) formally follows (1), thus x(t) < x and x(t) converges to x when t → +∞ (with x is defined in (1.4.2)).
Statement 3.Under assumptions (1.4.1)-(1.4.1), the evolutionary rescue phenomena occurs if and only if Note that the condition τ 0 > τ cyc is equivalent to x resc < x , which are defined respectively in (1.4.2) and (1.4.4).

Threshold for extinction.
The population is said to be "extinct" at time t if ρ(t) = 0.According to (1.4.1), we define x ext as to solve r(x ext ) = 0, i.e that is, a population concentrated at trait x is extinct iff x ≥ x ext .
The picture is simple in the case of stabilization without cycles, i.e when τ 0 ≤ τ cyc (see (3)).In this case, we recall that x(t) formally follows (1) for all t > 0, thus x(t) < x and x(t) converges to x when t → +∞ (where x is defined in (1.4.2)).Thus, if x ≤ x ext , we have ρ(t) > 0 for all t > 0; on the contrary, if x > x ext , there exists a time t ext > 0 for which ρ(t) = 0 for all t ≥ t ext .It gives a sharp threshold for extinction of the population: indeed, the population eventually gets extinct if and only if x > x ext , which naturally leads us to the following statement.
We point out that, surprisingly enough, τ ext is an increasing function of the death rate d r , meaning that under a higher death rate, the population can survive to a higher HT rate.The interpretation we propose is that if d r is high, the population driven outward x = 0 dies rapidly, thus the population that remained closer to 0 undergoes a milder HT, which makes the overall population more resistant to a high HT rate.
Let us now focus on the case where the cycling phenomenon occurs, i.e when τ 0 > τ cyc .In this case, x(t) will follow (1) and will periodically jump to x = 0. First, note that if x < x ext , x(t) remains below x ext for all t and the population does not get extinct: The most intricate case is when x > x ext , which contains cases of extinction and non-extinction, depending on whether the jump of x(t) towards 0 happens before or after x(t) has passed beyond x ext .In other words, extinction can be avoided if the evolutionary rescue happens before the dominant trait is led to extinction, i.e if x(T − ) ≤ x ext , where T is the time where the jump of x(t) towards 0 occurs.However, we are not able to give a satisfactory formula or estimate on T .
Besides, when the jump of x(t) occurs, it can happen that the trait x = 0 is not fit enough to avoid extinction: in this case the evolutionary rescue does not manage to sustain the population.It corresponds to the case x resc > x ext .We have the following threshold: the evolutionary rescue is able to sustain the population iff r(0) + τ 0 > 0, which is equivalent to If τ ≥ τ sus , the population eventually gets extinct.If τ < τ sus , the population is effectively rescued by the evolutionary rescue, even in the case where it passed through an episode of extinction during the previous cycle: in some cases the population is able to regrow after being extinct, which can be seen on Figure 5c.We think this is an interesting feature that the Hamilton-Jacobi approach is able to grasp.Regarding the stochastic model, an episode of extinction on Hamilton-Jacobi corresponds to an interval of time where the population reaches extremely small values (of order e − 1 ε , with ε the variance of the mutation kernel), and the probability that every individual dies is bigger than the survival of the population.• if τ 0 ≤ τ ext , the population never gets extinct.
• the evolutionary rescue effectively manages to sustain the population if and only if τ 0 < τ sus := b r .

Characteristics of a Hamilton-Jacobi equation
Denoting Since H is convex in the p variable, we have the following representation formula (see Lions (1982)).
where L(t, x, v) is the Lagrangian of the equation, obtained through a Legendre transform (or a convex conjugate) of H. Every γ which is admissible as a minimizer in (1.4.6) is called a characteristic of the Hamilton-Jacobi equation (1.3).Note that every characteristic γ formally satisfies the condition (1.4.6) holds because γ is a critical point of the functional defined in (1.4.6).

Numerical tests
In this section we perform several numerical tests for the presented models considering different values of parameters, replicating different scenarios: stabilization around an optimal value, cycles (occurring through the evolutionary rescue phenomena) and the extinction.We then compare the numerical results obtained for the stochastic and deterministic approaches, using in particular an asymptotic-preserving scheme which allows us to observe the population dynamics on the passage from the integro-differential equation (1.2) to a limit (1.3).Throughout this section we define the birth, death rates and the mutation kernel to those given in (1.4.1)-(1.4.1) respectively, with the parameters fixed throughout all the experiments to b ≡ 1, d r ≡ 1, C ≡ 0.5 respectively (unless otherwise stated).

The scheme
Our aim is to simulate the population dynamics over a fixed interval [0, T ].We begin by simulating an initial population of size N 0 .We assume that the population is normally distributed around the mean trait x 0 mean with a standard deviation σ 0 so that the resulting vector X 0 ∈ R N 0 .We know that in a time step ∆, an individual can die, give birth, or be a subject to HT.Each event happens according to a certain probability that we compute from the rates.More detailed description of the simulations is provided in Algorithm 1.
Note that in our setting it is possible that 1, 2 or 3 events happen within the same time step.Keeping a discretization time step small helps us to keep a biological sense in our simulation: even if the event of horizontal transfer with an "already dead" individual is possible in our setting (if T d ≤ T HT ≤ ∆), this event is extremely rare.
y∈X i h K (x−y,N i−1 ) ; remove individual with trait x and add individual with trait y; end if T d ≤ ∆ then remove the individual with trait x from X i end end return X i end We simulate the population of initial size N 0 = 10000 up to time T = 1000 with ∆ = 0.01, with the parameters being defined at the beginning of the section, and α is a Heaviside function.Even if a Heaviside function is not the most easy to analyze when we pass to the deterministic limit of the system (see Subsections 1.2 and 1.3), we use it for the stochastic simulation, since it is the most straightforward model for HT in biological context, and is much faster to compute than a smooth function.We fix all constants but τ 0 , which regulates the Horizontal Transfer, and study how it affects the dynamics.Then we plot the density of the population at each moment of time (left side of each Figure ): brighter colors on plot mean that there is a big amount of individuals with very similar traits.On the right top and right bottom we plot the normalized population size (ratio between the actual size and the carrying capacity of the system), and the mean trait.
Depending on the parameters we may observe three types of behavior (see Figure 1).First possibility, for small values of τ 0 , is the stabilization (Figure 1a).In this case the population rapidly reaches the equilibrium and concentrates around the optimal trait, which is close to 0.1 (with stochastic fluctuations).Note that in this case, the mean trait is shifted in comparison to the optimal trait without HT (which is x = 0).Second option, for intermediate values of τ 0 , is the cycling behavior (Figure 1b).Since the transfer rate is sufficiently large, the population is driven towards a deleterious trait, which is eventually less fit than the trait x = 0.If the drift is not too strong, the very few individuals which were not affected by HT and remained fit (with x close to 0) manage to regrow and eventually repopulate the environment, which launches the cycle again.
The last possibility, for large values of the horizontal transfer rate τ 0 , is the extinction of the population (Figure 1c).It occurs because too many individuals were affected by deleterious traits of their neighbors, so that they die faster than is needed for replicating the population.To understand better this phenomenon, we have to give a precise definition of what do we actually refer to, when we say "the critical value" of the transfer rate?In stochastic setting the answer is not trivial, and that is where the individual-based model reaches its limit.What we observe experimentally is the following when we change the value of HT rate starting from zero, the cycles in the population dynamics become more clearly visible, the fluctuations of the mean trait and the population size become more ample, until at some point the probability of extinction overweights the probability of survival and, finally, at the value of τ 0 , which we call "critical" we obtain an almost sure extinction.
But since we are working with a point process, giving a strict definition of a "critical value for an extinction" in terms of probability measures seems to be out of reach.Even in the experimental setting this notion is ambiguous: when the value of τ 0 is getting closer to a "critical" (numerically we observe an almost sure extinction at τ 0 = 0.49), in different repetitions of the same experiment we may observe different types of behavior: either cycles, or extinction, which occurs after several cycles.It is illustrated on Figure 2, where the computations, launched with exactly the same set of parameters, give very different results.Furthermore, it is not always clear how to differentiate between the stabilization and cycles, especially when the variance of the mutation kernel is large.To the best of our knowledge, there is no straightforward way to analytically measure the probability of each outcome under given initial conditions, which makes the model difficult to analyse.
This constraint of an individual-based model naturally leads us to studying a limiting system described in Subsection 1.2.1).

Lineages
With the help of the stochastic model we can keep track of the lineage of an individual i which lives at a final observed time T .More precisely, we are interested in a history of a phenotype which leads to a long-term survival of an individual.
We illustrate some numerical experiments on Figure 3.The four simulations are done with the same parameters.In the background, every point with coordinates (t, x) represents an individual with trait x living at time t (as in Figure 1).The solid lines represent the lineages of the individuals that live at final time.Small fluctuations are the results of birth with mutation, while the large upwards jumps correspond to an occurrence of a HT.
First of all, we can see on the plot that all the lineages are gathered into one line up to t = 400.It means that all individuals that live at final time t = 700 emanate from one single ancestor of the initial population.This phenomenon is well known and referred to as coalescence in the literature (see for instance Kingman (1982), or Arenas andPosada (2014, 2010) for a mathematical description of a classical population genetics theory).
Besides, we see that the lineages remain centered around x = 0 during almost all the observed time.It is explained by the fact that every lineage that goes to a high value of x (corresponding to deleterious phenotype) cannot recover (since the mutations are small), and eventually goes extinct.This illustrates that the population manage to sustain because of the very few individuals that were not affected by HT throughout the history.

Numerical scheme for the PDE model
In this subsection, a numerical scheme for (1.2) is presented, and its properties are numerically investigated.For the discretization of (1.2), we consider a bounded space of traits [X min , X max ], discretized with N x points.Denoting N x the number of discretization points of the interval [X min , X max ], we define ∆x = X min − X max N x − 1 , and We consider the time interval [0, T max ], discretized with N t points t n = n∆t, for 0 ≤ n ≤ N t − 1, and where ∆t is defined as The approximations of the solution f of (1.2) at (t n , x i ), and of its density ρ at t n are denoted f n i and ρ n respectively.We recall that the initial condition f 0 is a smooth function of x given in (1.4.1) and the initial density ρ 0 is computed using a left-point quadrature rule for f 0 as follows: The scheme is written with an explicit Euler scheme, in which the integrals are computed with a left-point quadrature rule.For n ≥ 1 and 0 In (2.2), the convolution product [m * (bf )] n i is computed with a left-point quadrature rule, as well of the other integrals.To do so, a grid in the z variable is defined as for the x variable.Let Z min and Z max , and the number N z of discretization points be given.The grid in z is defined as is computed with a linear extrapolation of the (f n i ) 0≤i≤Nx−1 , using the slope at the corresponding end of the X domain.Using the notation f n (x i + εz k ) for the approximation of f (t n , x i + εz k ), we then define

Case ε = 1: comparison with stochastic model
First thing that we are interested in is whether under identical parameters and initial conditions we may reproduce the same behavior as in the stochastic model.Thus, we conduct several experiments, fixing parameter ε to 1 (thus, we do not rescale time, nor mutation rate), leaving all the other parameters fixed to the same values as in the stochastic simulation case.As we may see on Figure 4, simulations in overall correspond to those of the stochastic model.Indeed, when the HT rate τ 0 is small enough the population rapidly stabilizes around its equilibrium state (see Figure 4a), as in the stochastic simulations.Further similarity between two models is that in both cases the optimal trait is shifted a bit above 0.It is caused by the HT phenomenon.
For larger values of τ 0 , where we would expect to have distinguishable cycles, we observe indeed damped oscillations, see Figure 4b.We stress out that for the stochastic model it is not the case, see Figure 1b.The way we understand the damping in the oscillations is that the PDE model and the numerical algorithm that we use are not designed to have a precise grasp on the exponential small values of f , on which the cycling phenomenon relies.This limitation suggests to perform the change of variable (1.3), and to write a numerical scheme which converges uniformly when ε → 0. This is what the next subsection is devoted to.
On Figure 4c, we observe that as τ 0 becomes larger the population gets extinct, and then, surprisingly enough, "reborns" after a period of extinction.This scenario can only be reproduced on density-based models, since in individualbased model any extinction is definitive.On Figure 4d we observe a full extinction of the population without regrowth.We will give further insights on those two cases in the next subsection.

2.3
The scheme for the Hamilton-Jacobi equation 2.3.1 Case ε → 0: description of the numerical scheme As the rescaling parameter ε goes to 0, the model given by (1.3) gets closer to its limiting state (1.3).However, numerical approximation of the (1.2) for ε 1 is not a trivial task.Indeed, for small ε, the solution f ε of (1.2), is expected to concentrate around the dominant trait.To be able to catch its stiffness numerically, one has to refine the grid in x, to ensure enough precision in the computation of f .As a consequence, the computational cost of the numerical simulations increases when ε → 0, and reaching the asymptotic regime with this scheme is not possible.In this part, we present a numerical scheme for (1.2) which enjoys stability properties in the limit ε → 0.
To avoid the increase of computational cost when reaching the asymptotics, and to ensure the scheme approaches the limit Hamilton-Jacobi equation for small ε, a scheme for the solution u ε of (1.3) which enjoys the Asymptotic Preserving (AP) property is proposed here.Such schemes have been introduced in Klar (1998Klar ( , 1999)), Jin (1999), their properties are often summarized by the following diagram: It should be understood as follows: when the parameter ε > 0 is fixed, the scheme S h ε is consistent with the ε-dependent problem P ε .When ε goes to 0, the solution of P ε converges to the solution of the limit problem P 0 .The AP scheme S h ε is stable along the transition to the asymptotic regime.It means that, when ε goes to 0 with fixed discretization parameters h, the scheme becomes a limit scheme S h 0 , which is consistent with the limit problem P 0 .As an AP scheme is required to enjoy stability properties when ε is going to 0, one has to ensure that all the quantities that have to be computed enjoy this property.In the case we are considering, the main concerns are the computation of the integral containing the birth term, the computation of the integral containing the transfer term and the computation of ρ.If all of them are correctly defined, the scheme we propose reads where B n i stands for an approximation of and Here, we used the notations and discretization grids defined in the beginning of Section 2.2, and the dependencies in ε are omitted to simplify the notations.In what follows, we present how T n i , B n i and ρ n+1 can be computed in a way that ensures they are consistent with their definition for fixed ε, that they can be computed with a constant computational cost with respect to ε, and that their asymptotic behavior when ε goes to 0 is meeting the continuous one (1.3).
• Computation of T n i .The direct approximation of (2.3.1) with a quadrature rule is consistent for ε ∼ 1.However, since f is expected to concentrate when ε → 0, it lacks precision in the asymptotic regime.Especially, the convergence of f /ρ to a Dirac is not ensured when the integral is approximated directly.Remarking that (2.3.1) is computed with a left-point quadrature rule in the integrals of the previous expression.It reads (29) For fixed ε, (2.3.1) is consistent with (2.3.1).Since all the arguments of the exponentials are nonpositive, the limit of (2.3.1) for small ε can be read on that expression.Denoting j 0 the index such that and supposing that there exists a unique such j 0 , the limit of (2.3.1) for small ε is τ This is consistent with the last term in the limit Hamilton-Jacobi equation (1.3).
• Computation of B n i .Once again, the numerical approximation of (2.3.1) is done with a quadrature in the integral.Using the notations of Section 2.2, a grid in z is defined.The functions m and b are respectively evaluated at z k and x i +εz k , but the interpolation of u n at x i +εz k has to be done with special care to make the scheme enjoy the expected asymptotic behavior.Using a left-point quadrature rule, (2.3.1) is approximated by , where ∇ ε n,i,k stands for an approximation of In both cases, it is computed with a linear interpolation of the values where ũn i,k is computed as the linear interpolation of (u n i ) 1≤i≤Nx at x i +εz k .If x i + εz k < X min or x i + εz k > X max , the extrapolation is done linearly using the slope at the first or last point of the interval.Since εz k > ∆x, no stability issue is faced in this computation.Still using a linear interpolation, when 0 < εz k ≤ ∆x, it is worth noticing that and when 0 > εz k ≥ −∆x, as a consequence, we define: This definition of B n i is consistent with (2.3.1).Moreover, when ε goes to 0 with fixed numerical parameters, such as Z min and Z max , the expression ∇ ε,large n,i,k is not used at all, and • Computation of ρ n+1 .In (2.3.1),ρ n+1 is considered in an implicit way, to make the limit scheme be consistent with the limit equation (1.3).Since for ε > 0, we define A closed equation on ρ n+1 can be deduced from (2.3.1).Indeed, (2.3.1)yields e u n+1 i and so where to simplify the notations.Eventually, ρ n+1 is the solution of h(y) = 0, where where A n i0 = max i A n i has been taken apart to get an uniform estimate with respect to ε on the remaining sum.It is also a solution of the equivalent equation g(y) = 0, with To find ρ n+1 , a Newton's method is applied on expression (2.3.1) or on (2.3.1).Both expressions are smooth convex functions of ρ, and are equivalent.Hence, the Newton's method converges whatever is used.Nevertheless, it must be chosen with care.(2.3.1) is to be chosen when ρ n+1 is close to 0 (for large values it becomes less accurate), whereas (2.3.1) is more adapted when ρ n+1 is not small, since it is more prone to accumulate numerical errors when ρ n+1 → 0. In the effective implementation of the method, either one formulation or the other is chosen, depending on the values reached during the iterations of the algorithm.Eventually, to ensure the stability of the numerical resolution of (2.3.1) when ε → 0, the inverse of the derivatives of h and g are analytically computed and implemented as Since y > 0, these two expressions are uniformly bounded with respect to ε when ∆t is fixed.As a consequence, the cost of the numerical resolution of (2.3.1)does not increase with ε.
When ε > 0 is fixed, the scheme (2.3.1) is consistent with (1.3), since only quadrature formula and interpolation methods have been used to write it.The way all the terms are computed, as well as the numerical resolution of the nonlinear equation (2.3.1),ensures the stability of the numerical computations in the small ε regime.Hence, when ε → 0 with fixed discretization parameters, the scheme (2.3.1)becomes where j 0 is such that u n j0 = max i u n i , and B n,0 i has been defined in (2.3.1).
We do not give a strict proof of consistency of this scheme with respect to the limiting Hamilton-Jacobi equation (1.3), since it is out of scope of the project.However, we draw the attention to few important points which need to be taken into account while working with the scheme.In particular, the behaviour of the quantity ρ(t) is not well understood in the case of an extinction.The problem is that intuitively ρ(t) must represent the density of the population -so that when it goes to zero, we expect an extinction.However, in a Hamilton-Jacobi case even when the ρ(t) reaches zero, the population can still regrow after some time.This can be explained by the fact that after two limiting procedures (passing first to the infinite system size, and then to the infinite time horizon), the "size" of the population can not be described straightforwardly.Accurate link between the quantities obtained as a result of stochastic and PDE simulation is also a question which requires further investigation when ρ(t) 1.

Case ε → 0: the numerical results
In this subsection we simulate the dynamics of the population by considering a small value of ε and discuss the obtained results in order to compare them with previous simulations.Note that, in order to compare both, the stochastic and the Hamilton-Jacobi behaviours, the first thing to do is to obtain the simulations for the stochastic model also in the case where the HT rate is a smooth function as we do for the Hamilton-Jacobi case.We recall that, in subsection 2.1 simulations for stochastic model are done with a Heaviside function as HT rate since it is a more natural choice for simulation of a jump process.
On Figure 5 we simulate the population dynamics for ε = 0.01.Upon rescaling time (for chosen ε time scale T = 10 corresponds, in fact, to T ε = 1000 in previous simulations) and the variance parameter, we see the same patterns, with few differences.
On Figure 5a, we observe a stabilization of the mean trait, as in Figure 1a.Similarly, on Figure 5b, we observe cycles, but on the contrary to the PDE model oscillations are not damped.Moreover, it is worth pointing out that the duration of a cycle here corresponds to what we observe in the corresponding stochastic plot (on Figure 1b) multiplied by ε = 0.01.On Figure 5c, we also observe a cycling behavior, but the population goes periodically extinct (i.e the population reaches exponentially small value, of order e 1/ε ), and then reborn.On the stochastic model, it corresponds to what is illustrated in Figure 2. It is not surprising that this behavior is difficult to observe on the stochastic model, since very small populations are likely to go extinct.
On Figure 5d, we can see that the population goes completely extinct.The most interesting case to comment is probably the "partial" extinction seen on 5c.Note that despite the fact that ρ remains at 0 for some time, the population regrows.The point is that, as it was already mentioned above, this numerical parameter has no 1:1 correspondence to the population size parameter Nt K used in stochastic model.Also note that similar behaviour of stochastic and HJ model are reproduced under a bit different values of parameters.It is caused by the rescaled time and mutation kernel, so that the rigorous link between two models is still to be developed.
Another interesting thing to comment is that on Figure 5b we may notice that, from the dynamics of the mean trait and the density of the population, it is easy to estimate the periods of the system.Indeed, since the system is deterministic, we just have to compute the distances between local maxima on each curve.For the stochastic system this task is more difficult, especially for a small population, because it includes filtering problem of a noisy signal.To get more accurate results in stochastic model we have to increase the time scale and number of individuals, which is costly from computational point of view.However, if our goal is to study numerically the lineages which lead to the evolutionary rescue of the population, it is still more straightforward to use the individual-based model.
To finish with, let us give some flavor on the computational cost of the simulations for each type.In

2.4
Comparison of the theoretical analysis of the Hamilton-Jacobi equation and the numerical simulations of the stochastic model

Formal computations
In this section, we propose some formal computations on the stochastic model, based on the analysis of the Hamilton-Jacobi equation performed in the previous section.To fix ideas, we assume n = 1 and (1.1)-(1.4.1)-(1.4.1), and we fix all constants but τ 0 , as in the previous section.However, we choose the function α as a Heaviside function (this is what has been used in the simulations), which is not a smooth function, and thus will lead to minor modifications compared to the previous section.We make a strong formal assumption: taking K 1, we assume that the population behaves like a normally distributed random variable all the time, i.e for some standard deviation s(t) and for x(t) defined in (1.3).We expect s(t) to be of the same order as σ, but giving a general estimate for s(t) in function of x(t) seems intricate.The normalized size of the population ρ(t) := where r is defined in (1).We now formally compute the evolutionary singular state x .But as α is a Heaviside function (which formally corresponds to the case when δ → 0 in (1.4.2)), our derivations must be slightly adapted.In particular, τ (x − x(t)) in (1.3) has to be replaced by and accordingly, recalling that the weak derivative of a Heaviside is a Dirac mass at 0, τ (0) in (1.4.2) has to be replaced by where s is an unknown corresponding to the standard deviation of the population at equilibrium concentrated at x = x .Note that it corresponds to (1.4.2) with δ := s π/2.We now try to estimate s .Formally, s should be such that u (x) := is a stationary solution of (1.3).Differentiating twice, and applying at x = x we find 0 = b r σ 2 (u (x )) 2 − 2d r , (with the reasonable assumption τ (0) = 0), which gives Numerically, we find s = 0.12.We end up with the following formula:

Stabilization
We run a numerical test on the stochastic model corresponding to stabilization, for τ 0 = 0.02, and the other parameters as in Figure (1a).In this case, x correspond to the mean trait of the population for large time.From, (2.4.1) we find x = 0.067, and from (2.4.1), we obtain ρ = 1.99, which corresponds to what we can see on Figure (1a).

Threshold for cycles
Since equation (1.4.4) remains unchanged, we obtain the following threshold for cycles (corresponding to (3)): With our choice of parameters, we obtain τ cyc = 0.09.This threshold corresponds to the numerical simulations (however, characterizing precisely whether cycles occurs or not on the numerical simulations is not easy when τ 0 is close to the threshold).

Threshold for extinction
Using (1.4.5), we can also find a threshold for extinction: τ ext := 2πb r d r σ 4 b r 2d r .
For our choice of parameters, we obtain τ ext = 0.30.We now compare this formula with numerical experiments on the individualbased model.They are organized as follows: we fix the birth b r or the death rate d r , and save the first value of τ 0 under which the extinction occurs.Then, we increase the rate and save the next HT rate under which we have an extinction.Resulting curve for the birth rate is saved on Figure 6a (for death rate: Figure 6b).Non-concerned parameters remain fixed as in Subsection 2.1.
The numerical results, in particular, justify at the first glance surprising fact that the extinction threshold depends on the birth and death rate in the same manner.It seems logical to assume that while the higher birth rate contributes to a bigger survival probability even with a relatively big horizontal transfer rate, higher death rate must have an opposite effect.However, in conditions of a very "harsh" environment individuals with non-fit traits die out before they manage to transfer their genetic information to the other individuals.As a consequence, value of the critical τ increases as the value of the birth (or death) rate constant increases.

Conclusions
First achievement of the paper consists in an accurate numerical study conducted on the stochastic model given by a point measure (1.1).To the best of our knowledge, in-depth analysis of the influence of the HT rate on the evolutionary dynamics has not been yet attempted.Along with its accuracy, the stochastic model reveals its limitation: an accurate theoretical description of what actually happens in each observed scenario from a mathematical point of view seems to be out of reach.However, we show that this model can be used for tracing back the lineage of the survived individuals through several generations.
On the next step, in a numerical comparative study between the stochastic (individual based) and the PDE (density) model both models exhibit the same behavior for a given set of parameters, which justifies theoretical results from Billiard et al. (2018Billiard et al. ( , 2015)).Minor differences (in particular, the presence of damping oscillations) can be explained by a choice of a numerical scheme.However, further analysis shows that the classical PDE model defined by (1.2) leads to instabilities if we try to pass to an asymptotic setting under the small mutation assumption.Those instabilities are then resolved by a transformation of an initial model to a Hamilton-Jacobi type equation and using an asymptoticpreserving scheme.Further advantage of this approach is that the resulting equation (1.3) makes an easier subject of a theoretical analysis.
Finally, in a Hamilton-Jacobi setting we manage to numerically replicate the evolutionary rescue of a small population which we observe in the stochastic model.This phenomena is illustrated for stochastic, PDE and HJ simulation on Figure 7. On Figures 7a-7c we trace the moment of the regrowth for different models.Figure 7a show the state of the population at certain moment of time: we see how the individuals are centered around a mean trait.For PDE and HJ model (red and green line respectively) we simply plot the density function, and on the first (blue) plot we approximate a histogram which describes ratio Nt K sorted by traits in stochastic model.Stochastic simulations show the evolutionary rescue in more distinct manner: we see how the very small number of non-mutated individuals rescues the whole population from extinction (transition from 7b to 7c).On the contrary, the transition on the PDE model is dumped, and the regrowth is not clearly visible.It is due to, again, numerical instability of the PDE scheme for small values of the density function.Finally, HJ explicitly shows how the cycle occurs: the regrow of the "fit" individuals we see in stochastic plot is reproduced by a change of the maximum point (see again 7b to 7c).
We highlight again that in order to compare the models on a more applied level, we have to give a formal definition of a quantity represented by ρ in a Hamilton-Jacobian case.In this work we have made few steps toward the theoretical analysis of the limiting equation and an accurate description of each event (evolutionary rescue, extinction, etc) in terms of solutions of a PDE.Even though establishing a rigorous mathematical link between the behavior observed in the individual-based model and the Hamilton-Jacobi equation is out of scope of this project, obtained analytical results already give a flavor of how the analysis of the evolutionary dynamics can be simplified in the future.

Figure 5 :
Figure 5: Behavior of the population dynamics described by a PDE model for ε = 0.01 as the mutation rate τ is changing, (b r = d r = 1, σ = 1).

Figure 6 :
Figure 6: Dependency on the threshold for extinction τ ext with respect to the birth rate b r and death rate d r

Figure 7 :
Figure 7: Comparison of numerical simulations between the different models.τ 0 = 0.4, ε = 0.1, δ = 0.001 and other parameters as in Figure 1.Blue line stands for the stochastic model, red line: for a PDE, green -for a Hamilton-Jacobi PDE

Table 1 :
Table1we give a short overview of the elapsed time for the same values of parameters, but for different schemes.As expected, individual-based model is the most expensive to compute.All the computations were performed in numpy library of Python on MacBook Pro (Intel Core i5 processor, 2,7GHz).Elapsed time for simulation of population dynamics for different models (other parameters are fixed to values used throughout all the other simulations, τ = 0.5).