## Abstract

Due to stochastic fluctuations arising from finite population size, known as genetic drift, the ability of a population to explore a rugged fitness landscape depends on its size. In the weak mutation regime, while the mean steady-state fitness increases with population size, we find that the height of the first fitness peak encountered when starting from a random genotype displays various behaviors versus population size, even among small and simple rugged landscapes. We show that the accessibility of the different fitness peaks is key to determining whether this height overall increases or decreases with population size. Furthermore, there is often a finite population size that maximizes the height of the first fitness peak encountered when starting from a random genotype. This holds across various classes of model rugged landscapes with sparse peaks, and in some experimental and experimentally-inspired ones. Thus, early adaptation in rugged fitness landscapes can be more efficient and predictable for relatively small population sizes than in the large-size limit.

## 1 Introduction

Natural selection drives populations towards higher fitness (i.e. reproductive success), but actual fitness landscapes (representing fitness versus genotype [1, 2]) can possess several distinct local maxima or peaks. Such rugged fitness landscapes arise from epistasis, i.e. interactions between genetic variants [3–6], especially from reciprocal sign epistasis [4], where two mutations together yield a benefit while they are deleterious separately, giving rise to a fitness valley [7, 8]. While the high dimension of genotype space makes it challenging to probe fitness landscapes [9, 10], experimental evidence has been accumulating for frequent landscape ruggedness [6–8, 10–15]. This strongly impacts the predictability of evolution [5, 6, 14]. Populations can remain stuck at a local fitness peak, thus preventing further adaptation. Which local peak is reached depends on the starting point, on the mutations that occurred, on their order, and on whether they took over or not. Historical contingency may thus play important roles.

In a constant environment, if mutations are rare, the evolution of a homogeneous population of asexual microorganisms can be viewed as a biased random walk in genotype space, and thus on the associated fitness landscape [16]. Indeed, random mutations can either fix (i.e. take over) or get extinct, depending on how mutant fitness compares to wild-type fitness (natural selection) and on stochastic fluctuations due to finite population size (genetic drift). In the weak mutation regime, mutations are rare enough for their fate to be sealed before a new mutation takes place. Thus, the population almost always has a single genotype, i.e. it is monomorphic. When a mutant fixes, it becomes the new wild type: the population has moved in genotype space – hence the biased random walk in genotype space. If in addition natural selection is strong [16, 17], only beneficial mutations, which increase fitness, can fix. In this regime, the random walk describing the evolution of the population can only go upwards in fitness. Such *adaptive walks* (AWs) [16] have been extensively studied [18]. Strong selection neglects the possibility that deleterious or neutral mutations may fix due to genetic drift, which is appropriate only for very large populations [19]. Conversely, if the strong selection hypothesis is dropped, deleterious mutations may fix [20, 21], and a population’s ability to explore its fitness landscape depends on its size, which determines the amplitude of genetic drift [22]. How does the interplay between genetic drift and natural selection [23] impact adaptation of a finite-size population on rugged fitness landscapes? In particular, is adaptation always more efficient for larger populations?

To address this question, we consider homogeneous populations of constant size *N*, which evolve in the weak mutation regime, either through the Moran model [22, 24], or through the Wright-Fisher model under the diffusion approximation [25, 26]. The steady-state properties of such evolution have been studied, in particular the stationary distribution of states [27, 28] and their dynamical neighborhoods [29]. The mean steady-state fitness monotonically increases with population size (see Supplementary material, Section S1 and Fig. S1), so the long-term outcome of evolution becomes more optimal and predictable when population size increases. A very large finite population will reach the highest fitness maximum of the landscape, but this may take very long, due to the difficulty of crossing fitness valleys for large populations with rare mutations. Here, we investigate the dynamics of adaptation before steady state is reached, and we ask how population size impacts early adaptation.

We focus on early adaptation, by considering the first fitness peak encountered starting from a randomly chosen genotype. We mainly study the fitness of this first encountered peak, and we also discuss the time needed to reach it. Both have been extensively studied for adaptive walks [18]. We find that, in contrast to the steady-state fitness, the fitness of the first encountered peak, averaged over starting genotypes, does not always increase with population size *N*. Thus, adaptation is not always more efficient for larger populations. Furthermore, we observe a wide variety of behaviors of with *N*, even among small and simple rugged landscapes. We show that the accessibility of the different fitness peaks is a key ingredient to determine whether is larger or smaller for large *N* than for *N* = 1. We find that the ensemble mean of over different model landscapes often features a maximum for a finite value of *N*, showing that early adaptation is often most efficient for intermediate *N*. This effect occurs in rugged landscapes with low densities of peaks, is particularly important for large genomes with pairwise epistasis, and matters for larger populations when genomes are large. More generally, such finite-size effects extend to larger populations when many mutations are (almost) neutral. These situations are relevant in practice. Furthermore, our main conclusions hold for multiple experimental and experimentally-motivated landscapes.

## 2 Methods

### 2.1 Model

We consider a homogeneous population comprising a constant number *N* of asexual haploid individuals, e.g. bacteria. We assume that their environment is constant, and we neglect interactions between genotypes (individual types, characterized by the state of all genes) and frequency-dependent selection. Each genotype is mapped to a fitness through a fitness landscape [1, 2], which is static under these hypotheses [6]. We consider various rugged fitness landscapes (see Results).

Evolution is driven by random mutations, corresponding to a genotype change in one organism. The genotype of each organism is described by a sequence of *L* binary variables, taking values 0 or 1, which correspond to nucleotides, amino acids, genes or any other relevant genetic unit. The binary state is a simplification [30], which can represent the most frequent state (0) and any variant (1). Genotype space is then a hypercube with 2^{L} nodes, each of them having *L* neighbors accessible by a single mutation (i.e. a substitution from 0 to 1 or vice-versa at one site). Note that we do not model insertions or deletions. For simplicity, we further assume that all substitutions have the same probability.

Because the population size *N* is finite and there is no frequency-dependent selection, each mutant lineage either fixes (i.e. takes over the population) or gets extinct, excluding coexistence between quasi-stable clades [31]. We focus on the weak mutation regime, defined by *Nμ* ≪ 1 where *μ* denotes mutation probability per site and per generation. Mutations are then rare enough for their fate to be sealed before any new mutation takes place. Thus, the population almost always has a single genotype, i.e. it is monomorphic, excluding phenomena such as clonal interference [31–33]. When a mutant fixes, it becomes the new wild type. In this framework, the evolution of the population by random mutations, natural selection and genetic drift can be viewed as a biased random walk in genotype space [16]. A mutation followed by fixation is one step of this random walk, where the population hops from one node to another in genotype space. To describe the fixation of a mutation in a homogeneous population of size *N* under genetic drift and natural selection, we consider two population genetics models: the Moran model [22, 24] and the Wright-Fisher model under the diffusion approximation [25, 26], yielding two specific walks in genotype space. We use these models within the origin-fixation approach [21], where the mutation fixation rate is written as the mutation origination rate times the fixation probability. Note that we assume that fitness is positive, as it represents division rate, requiring minor modifications for some fitness landscape models (Section 3.2).

#### Moran walk

In the Moran process, at each step, an individual is picked to reproduce with a probability proportional to its fitness, and an individual is picked to die uniformly at random [22, 24]. The fixation probability of the lineage of one mutant individual with genotype *j* and fitness *f*_{j} in a wild-type population with genotype *i* and fitness *f*_{i} reads [22]:
where *s*_{ij} = *f*_{j}*/f*_{i} − 1. In the Moran walk, all mutations (substitutions at each site) are equally likely, and when a mutation arises, it fixes with probability *P*_{ij}. If it does, the population hops from node *i* to node *j* in genotype space. The Moran walk is a discrete Markov chain, where time is in number of mutation events, and it is irreducible, aperiodic and positive recurrent (and thus ergodic). Hence, it possesses a unique stationary distribution towards which it converges for any initial condition [34, 35]. It is also reversible [28, 29]. Note that evolution in the strong selection weak mutation regime (large-*N* limit of the present case) yields absorbing Markov chains, with different properties.

#### Wright-Fisher walk

The Wright-Fisher model assumes non-overlapping generations, where the next generation is drawn by binomial sampling [26]. Under the diffusion approximation valid for large populations (*N* ≫ 1) and mutations of small impact (|*s*_{ij}| ≪ 1) [25, 26], the fixation probability of mutant *j* reads
We use this formula similarly as above to define the Wright-Fisher walk, which is also an irreducible, aperiodic, positive recurrent and reversible discrete Markov chain converging to a unique stationary distribution. Note that we use it for all *N* and fitness values, but that it rigorously holds only under the diffusion approximation, i.e. under assumptions of large population and weak selection. In fact, the complete Wright-Fisher model is irreversible for large selection, although this does not impact the steady-state distribution of populations on fitness landscapes [36]. By contrast, the Moran fixation probability is exact within the Moran process.

### 2.2 Quantifying early adaptation

To investigate early adaptation, and its dependence on population size, we mainly focus on the height *h* of the walk, which is the fitness of the first encountered peak [18]. It depends on the initial node *i*, and also on what happens at each step of the walk. We consider the average of *h* over many walks and over all possible initial nodes, assumed to be equally likely: this quantity globally characterizes early adaptation in the fitness landscape. Starting from a random node is relevant e.g. after an environmental change which made the wild type no longer optimal, and allows to characterize early adaptation over the whole fitness landscape. We also study the impact of restricting the set of starting points to those with high fitness (see also [16]), which is relevant for small to moderate environmental changes. To assess the variability of *h*, we also consider its standard deviation *σ*_{h}. Note that by definition, the height *h* is directly the fitness value of a peak.

In addition to , we study the walk length , and its time , which are respectively the mean number of successful fixations and of mutation events (leading to fixation or not) before the first peak is reached, with similar methods as for (see Supplementary material, Section S2).

#### First step analysis (FSA)

To express , we consider the first hitting times of the different peaks (local fitness maxima) of the landscape [35]. Denoting by *M* the set of all nodes that are local maxima and by *T*_{j} the first hitting time of *j ∈ M*, we introduce the probability *P*_{i} (*T*_{j} = min [*T*_{k}, *k ∈ M*]) that a walk starting from node *i* hits *j* before any other peak. Discriminating over all possibilities for the first step of the walk (FSA) yields
where *G*_{i} is the set of neighbors of *i* (i.e. the *L* genotypes that differ from *i* by only one mutation), while , where *P*_{il} is the fixation probability of the mutation from *i* to *l*, given by Eq. (1) or Eq. (2). Thus, is the probability to hop from *i* to *l* at the first step of the walk. Solving this system of 2^{L}*n*_{M} equations, where *n*_{M} is the number of local maxima in the fitness landscape, yields all the first hitting probabilities. This allows to compute
where *G* is the ensemble of all the nodes of the landscape. Note that if the landscape has only two peaks *j* and *k*, it is sufficient to compute *P*_{i}(*T*_{j} < *T*_{k}) for all *i*, which can be expressed from the fundamental matrix of the irreducible, aperiodic, positive recurrent and reversible Markov chain corresponding to the Moran or Wright-Fisher walk [29, 35]. These first hitting probabilities also allow us to compute the standard deviation *σ*_{h} of *h*.

In practice, we solve Eq. (3) numerically using the NumPy function `linalg.solve`. Note however that since the number of equations increases exponentially with *L* and linearly with *n*_{M}, this is not feasible for very large landscapes.

#### Stochastic simulations

We also perform direct stochastic simulations of Moran and Wright-Fisher walks based on Eq. (1) or Eq. (2), using a Monte Carlo procedure. Note that we simulate the embedded version of these Markov chains, where the transition probabilities to all neighbors of the current node are normalized to sum to one, avoiding rejected moves. The only exception is when we study the time *t* of the walks, which requires including mutations that do not fix.

#### Averaging over multiple fitness landscapes

To characterize adaptation in an ensemble of landscapes, we consider the ensemble mean of by sampling multiple landscapes from the ensemble, and taking the average of , either computed by FSA or estimated by simulations.

#### Code availability

## 3 Results

### 3.1 Early adaptation on *LK* fitness landscapes

The *LK* model (originally called *NK* model) describes landscapes with tunable epistasis and ruggedness [37]. In this model, the fitness of genotype reads
where denotes the fitness contribution associated to site *i*, and *ν*_{i} is the set of epistatic partners of *i*, plus *i* itself. Here *L* is genome length, i.e. the number of binary units (genes or nucleotides or amino acids) that characterize genotype, while *K* is the number of epistatic partners of each site *i* – thus, for each *i, ν*_{i} comprises *K*+1 elements. Unless mentioned otherwise, we consider *LK* landscapes where sets of partners are chosen uniformly at random, i.e. in a “random neighborhood” scheme [18], and each fitness contribution is independently drawn from a uniform distribution between 0 and 1. Epistasis increases with *K*. For *K* = 0, all sites contribute additively to fitness. For *K* = 1, each site *i* has one epistatic partner, whose state impacts *f*_{i}. For *K* > 1, there is higher-order epistasis. For *K* = *L* −1, all fitness contributions change when the state of one site changes, yielding a House of Cards landscape [38, 39] where the fitnesses of different genotypes are uncorrelated.

How does finite population size *N* impact the average height of the first peak reached by an adapting population starting from a uniformly chosen genotype? We first tackle this question in *LK* landscapes with *L* = 3 and *K* = 1, which are small and simple rugged landscapes.

#### Average over *LK* landscapes with *L* = 3 and *K* = 1

Fig. 1(a) shows that the ensemble mean of over these landscapes monotonically increases with *N* both for the Moran and for the Wright-Fisher walk. FSA and stochastic simulation results (see Methods) are in very good agreement. Thus, on average over these landscapes, larger population sizes make early adaptation more efficient. This is intuitive because natural selection becomes more and more important compared to genetic drift as *N* increases, biasing the walks toward larger fitness increases. Fig. 1(a) also shows for the various adaptive walks (AWs) [18] defined in the Supplementary material, Section S3, and for the pure random walk. For *N* = 1, the Moran and Wright-Fisher walks reduce to pure random walks, since all mutations are accepted. For *N* → ∞, where the Moran and Wright-Fisher walks become AWs, is close to the value obtained for the natural AW, where the transition probability from *i* to *j* is proportional to *s*_{ij} = *f*_{j}*/f*_{i} − 1 if *s*_{ij} > 0 and vanishes if *s*_{ij} < 0 [17, 40, 41]. Indeed, when *N* → ∞, the Moran (resp. Wright-Fisher) fixation probability in Eq. (1) (resp. Eq. (2)) converges to *s*_{ij}*/* (1 + *s*_{ij}) (resp. 1 − exp(−2*s*_{ij})) if *s*_{ij} > 0 and to 0 otherwise. If in addition 0 < *s*_{ij} ≪ 1 while *Ns*_{ij} ≫ 1, then they converge to *s*_{ij} and 2*s*_{ij} respectively, and both become equivalent to the natural AW. The slight discrepancy between the asymptotic behavior of the Moran and Wright-Fisher walks and the natural AW comes from the fact that not all *s*_{ij} satisfy |*s*_{ij}| ≪ 1 in these landscapes. Convergence to the large-*N* limit occurs when *Ns*_{ij} ≫ 1 for all relevant *s*_{ij}, meaning that landscapes with near-neutral mutations will feature finite-size effects up to larger *N*. Besides, this convergence occurs for slightly larger *N* for the Moran walk than for the Wright-Fisher walk (see Fig. 1(a)). Indeed, if *s*_{ij} > 0, ln(1 + *s*_{ij}) < 2*s*_{ij}, so Eq. (2) converges to its large-*N* limit faster than Eq. (1), while if −0.79 < *s*_{ij} < 0, ln(1 +*s*_{ij}) > 2*s*_{ij}, so Eq. (2) tends to 0 faster than Eq. (1) for large *N* (*s*_{ij} < −0.79 is very rare and yields tiny fixation probabilities). Note that on Fig. 1(a), the range of variation of with *N* is small, but this is landscape-dependent (see Fig. 3).

How does the time needed to reach the first peak depend on *N* in *LK* landscapes with *L* = 3 and *K* = 1? First, the ensemble mean length , defined as the mean number of mutation fixations before the first peak is reached, decreases before saturating as *N* increases, see Fig. S2(a). Indeed, when *N* increases, the walk becomes more and more biased toward increasing fitness. Conversely, the ensemble mean time , defined as the mean number of mutation events (fixing or not) before the first peak is reached, increases with *N*, see Fig. S2(b). Indeed, many mutations are rejected for large *N*. Moreover, at a given *s*_{ij}, fixation probabilities (Eq. (1) and Eq. (2)) decrease as *N* increases. Note that for *Ns*_{ij} ≫1 and *s*_{ij} ≪1, the limit of Eq. (1) is *s*_{ij} while that of Eq. (2) is 2*s*_{ij}, explaining why the large-*N* limit of is about twice larger for the Moran than for the Wright-Fisher walk. Note that, more generally, a factor of 2 differs between the diffusion limits of the fixation probabilities of the Moran and the Wright-Fisher models. It arises from a difference in the variance in offspring number [22]. Finally, since mutations occur proportionally to *N*, the actual time needed by the population to reach the first peak is proportional to , which decreases with *N*, see Fig. S2(c).

#### Diversity among *LK* landscapes with *L* = 3 and *K* = 1

How much does the population-size dependence of depend on the specific landscape considered? To address this question, we focus on landscapes that have more than one peak (46% of *L* = 3, *K* = 1 landscapes), since with a single peak, is always equal to the fitness of that peak. Interestingly, Fig. 1(b) shows that does not always monotonically increase with *N*. In fact, this expected case occurs only for about 40% of the landscapes with more than one peak, see e.g. Fig. 1(c), and can exhibit various behaviors versus *N*. Around 30% of landscapes with more than one peak yield a single maximum of versus *N*, see e.g. Fig. 1(d). For these landscapes, there is a specific finite value of *N* that optimises early adaptation. While some landscapes yield multiple extrema of versus *N*, the absolute amplitude of secondary extrema is generally negligible. Indeed, when versus *N* displays two or more extrema, the mean ratio of the amplitude of the largest extremum to that of other extrema is larger than 20. Here, the amplitude of the *i*-th extremum starting from *N* = 1, observed at *N* = *N*_{i}, is computed as the mean of and *A*_{i+1} (where *N*_{0} = 1 and *N*_{i+1} → ∞ for the last extremum). Fig. 1(b) shows that in 14% of landscapes with more than one peak, the Moran and the Wright-Fisher walks exhibit different behaviors. However, the scale of these differences is negligible. As illustrated by Fig. 1(b), studying the behavior of versus *N* could be useful to characterize and classify fitness landscapes, and potentially complementary to epistasis measures in [10, 42–45].

The mean length and time of the walk also vary across landscapes, but the same overall trends as for the ensemble mean length and time are observed, see Fig. S2(d-i).

#### Impact of the starting set of genotypes

So far, we have considered the average of *h* over all possible initial genotypes, assumed to be equally likely. What is the impact of restricting the set of possible starting points to those with high fitness? This question is relevant to adaptation after small to moderate sudden environmental changes [16], where the wild type is no longer optimal, but still has relatively high fitness. To address it, we choose starting points uniformly among the *n* fittest genotypes. In Fig. S3, we study the same landscapes as in Fig. 1, varying *n* between 1 and 2^{L}. For *n* = 2^{L}, all genotypes can be starting points, as before. The behavior of the ensemble mean versus *N* is similar across the different sets of starting points (Fig. S3(a)). Fig. S3(b) further shows that versus *N* always monotonically increases for the landscape of Fig. 1(c). Finally, in Fig. S3(c), versus *N* displays an intermediate maximum for the landscape of Fig. 1(d), except for *n* = 1 and *n* = 2. In these cases, the possible starting points are either only the absolute peak of the landscape, or itself and one of its neighbors that has a higher fitness than the small peak, so the latter rarely comes into play. This is also why the values of are substantially larger for *n* = 1 and *n* = 2 than in other cases. Overall, these results suggest that our main conclusions are robust to varying the set of starting genotypes.

#### Predicting the overall behavior of

Why do different *L* = 3, *K* = 1 landscapes yield such diverse behaviors of versus *N*? To address this question, let us first focus on the *overall behavior* of versus *N* → ∞, i.e. on whether is larger for *N* (*overall increasing*) or for *N* = 1 (*overall decreasing*). This distinction is robust across the Moran and Wright-Fisher walks, as their overall behavior differs only in 0.4% of the landscapes with more than one peak.

Let us focus on the landscapes with 2 peaks (99.5% of the landscapes with more than one peak) for simplicity. 87% of them yield an overall increasing behavior of versus *N*, as e.g. those featured in Fig. 1(c) and (d). Intuitively, the higher a peak, the more attractive it becomes for large *N* given the larger beneficial mutations leading to it, and an overall increasing behavior is thus expected. However, the opposite might happen if more paths with only beneficial mutations lead to the low peak than to the high peak – the low peak is then said to be *more accessible* than the high peak. Indeed, when *N* → ∞, only beneficial mutations can fix. Therefore, we compare the accessibility of the high peak and of the low peak.

In Fig. 2(a-b), we show the distributions of two measures reflecting this differential accessibility in the 2-peak landscapes with either overall increasing or overall decreasing dependence of on *N*. The first measure (Fig. 2(a)) is the number of accessible paths (APs) [9] leading to the high peak minus the number of those leading to the low peak, where APs are paths comprising only beneficial mutations (note that APs included in other APs are not counted). The second measure (Fig. 2(b)) is the size of the basin of attraction of the high peak minus that of the low peak, where the basin of attraction is the set of nodes from which a greedy AW, where the fittest neighbor is chosen at each step, leads to the peak considered [46, 47]. Fig. 2 shows that landscapes displaying overall increasing behaviors tend to have a high peak more accessible than the low peak, and vice-versa for landscapes displaying overall decreasing behaviors. Quantitatively, 99% of the landscapes where both measures are positive or 0, but not both 0 (representing 75.2% of 2-peak landscapes), yield an overall increasing behavior. Moreover, 91% of the landscapes where both measures are negative or 0, but not both 0 (representing 5.7% of 2-peak landscapes), yield an overall decreasing behavior. Hence, differential accessibility is a good predictor of the overall behavior of versus *N*. Note that combining both measures is substantially more precise than using either of them separately (for instance, landscapes where the AP-based measure is strictly negative yield only 73% of overall decreasing behaviors).

However, for 15.2% of all 2-peak landscapes, both differential accessibility measures are 0, and thus do not predict the overall behavior. In practice, 70% of these tricky landscapes yield an overall increasing behavior. One of those is shown in Fig. 2(c) and in a complementary representation in Fig. S4. It yields the versus *N* curve in Fig. 2(d). Note that another tricky, but rarer case, corresponds to landscapes where accessibility measures have strictly opposite signs (3.9% of 2-peak landscapes).

#### Finite-size effects on and

Predicting the intermediate-*N* behavior, e.g. the maximum in Fig. 2(d), is more difficult than predicting the overall behavior, and our accessibility measures do not suffice for this, nor do various ruggedness and epistasis measures from [10, 42–45]. To understand this, let us consider the landscape in Fig. 2(c). The mean heights starting from each node *i* are displayed in Fig. 2(e), showing that diverse behaviors combine to give that of . Starting from node (011), the only accessible path is to the low peak (010), so decreases when *N* increases, but the quite small differences of fitnesses between (011) and its neighbors mean that relatively large values of *N* are required before this matters. Indeed, the convergence of fixation probabilities to their large-*N* limits occurs when *N* |*s*_{ij}| ≫1 (see Eq. (1) and Eq. (2)). Conversely, starting from (100), the only accessible path is to the high peak (101), so increases with *N*, starting at smaller values of *N* due to the larger fitness differences involved, e.g. between (100) and (110). Such subtle behaviors, which depend on exact fitness values in addition to peak accessibility, yield the maximum in Fig. 2(d).

For landscape B (Fig. 1(d)), which also yields a maximum of at an intermediate value of *N*, Fig. S5 shows that the standard deviation *σ*_{h} of the height *h* reached from a uniformly chosen starting node features a minimum at a similar *N*, while the average over starting nodes *i* of the standard deviation of the height *h*_{i} starting from node *i* monotonically decreases when *N* increases. This corroborates the importance of the diversity of behaviors with starting nodes *i* in the finite-size effects observed. Moreover, the minimum in the standard deviation *σ*_{h} starting from any node means that early adaptation is more predictable for intermediate values of *N*. Note that *σ*_{h} and both decrease with *N* for landscape A, where increases with *N* (Fig. 1(c)), see Fig. S5.

#### Magnitude of the overall variation of

We showed above that for two-peak fitness landscapes with *L* = 3 and *K* = 1, the differential accessibility of the peaks allows to predict the overall behavior of , i.e. the sign of , where denotes the large-*N* limit of . What determines the magnitude of Fig. S6 shows that it strongly correlates with the standard deviation of the peak fitness values. This makes sense, as the range of in a landscape is bounded by the fitness of the lowest peak and that of the highest peak.

#### Impact of *L* and *K*

So far we focused on small *LK* landscapes with *L* = 3 and *K* = 1, which generally have one or two peaks. However, real fitness landscapes generally involve much larger genome lengths *L* (number of binary units, representing genes, nucleotides, or amino acids) and may involve larger numbers of epistatic partners *K* and be more rugged. How do these two parameters impact First, increases linearly with *L* at *K* = 1, because all fitness values increase linearly with *L* in *LK* landscapes (Eq. (5)), see Fig. S7(a). For adaptive walks in *LK* landscapes, such a linear behavior was analytically predicted with block neighborhoods and holds more generally when *L ≫ K* [18]. We also find that for each value of features a maximum for an intermediate *K* at *L* = 20, see Fig. S7(b). A similar observation was made on adaptive walks in [18]. We find that the value of *K* that maximizes depends on *N*, illustrating the importance of epistasis for finite-size effects.

While monotonically increases with *N* for *L* = 3 and *K* = 1 (Fig. 1(a())), a pronounced maximum appears at finite *N* for larger *L*, see Fig. 3(a). To quantify how changes with *N*, we consider the overall variation of between *N* = 1 and the large-*N* limit, as well as the overshoot of the large-*N* limit, , see Fig. 3(a). Their dependence on *K* and *L* is studied in Fig. 3. First, Fig. 3(b) shows that for(*L*)= 20, is maximal for *K* = 5, while Fig. 3(c) shows that the relative overshoot is maximal for *K* = 1, and rapidly decreases for higher *K*. This is interesting, as *K* = 1 corresponds to pairwise interactions, highly relevant in protein sequences [48–50]. Next, we varied *L* systematically for *K* = 1 (see Fig. S8 for examples). A maximum of at finite *N* exists for *L* = 4 and above. The associated value of *N* increases with *L* (see Fig. 3(d)), but it remains modest for the values of *L* considered here. A key reason why finite-size effects matter for larger *N* when *L* increases is that more mutations are then effectively neutral, i.e. satisfy *N*|*s*_{ij}| ≪ 1. This abundance of effectively neutral mutations is relevant in natural situations [51]. Furthermore, Fig. 3(e) shows that increases with *L*, and Fig. 3(f) shows that also increases with *L*, exceeding 0.7 for *L* = 20. Thus, finite-size effects on early adaptation become more and more important as *L* is increased. This hints at important possible effects in real fitness landscapes, since genomes have many units (genes or nucleotides). As shown in Fig. S9, the density of peaks in the landscapes considered here decreases when *L* increases at *K* = 1, consistently with analytical results for large *L* and *K* [52]. Therefore, maxima of versus *N* are associated to rugged landscapes with sparse peaks.

Beyond these ensemble mean behaviors, we analyze how *L* and *K* impact the diversity of behaviors of with *N* in Fig. S10. We find that the proportion of landscapes (with more than one peak) yielding a monotonically increasing with *N* decreases steeply as *L* increases when *K* = 1, while the proportion of those yielding a maximum at intermediate *N* increases. An opposite, but less steep, trend is observed as *K* increases at *L* = 6. Thus, most landscapes yield a maximum of at finite *N* when *L* is large enough and *K* = 1 – the maximum of does not just arise from averaging over many landscapes. Besides, about 10% of landscapes with more than one peak yield an overall decreasing behavior of with *N* (i.e., ) when *K* = 1 for all *L* > 2 considered, while this proportion decreases if *K* increases at *L* = 6.

Finally, the impact of *L* and *K* on is shown in Fig. S7(c-d): increases with *L* for *K* = 1, more strongly if *N* is small, and decreases as *K* increases at *L* = 20. Indeed, a larger *K* at constant *L* entails more numerous peaks and a larger *L* at constant *K* yields smaller peak density (the number of peaks increases less fast with *L* than the number of nodes). In addition, smaller *N* means more wandering in the lan(ds)capes and larger . Note that for adaptive walks in *LK* landscapes, a linear behavior of versus *L* was analytically predicted with block neighborhoods and holds more generally for *L* ≫ *K* [18].

### 3.2 Extension to various model and experimental fitness landscapes

While the *LK* model is convenient as it allows to explicitly tune epistasis and ruggedness, many other models exist, and natural fitness landscapes have been measured [15]. How general are our findings on the population-size dependence of early adaptation across fitness landscapes?

#### Model fitness landscapes

We first consider different landscape models (see Supplementary material, Section S4). In all of them, is overall increasing between *N* = 1 and the large-*N* limit, and either monotonically increases or features a maximum at intermediate *N*. This is consistent with our findings for *LK* landscapes, demonstrating their robustness. Specifically, we find maxima of for the *LKp* model, which includes neutral mutations [53], for the *LK* model with more than two states per site [30], and for the Ising model [44, 54], see Fig. S12(a-c). Conversely, in models with stronger ruggedness (House of Cards landscapes, Rough Mount Fuji landscapes [10, 55] with strong epistatic contributions and Eggbox landscapes [44]), we observe a monotonically increasing , see Fig. S12(d-f). Fig. S13 shows that the density of peaks is generally smaller than 0.1 in the first three landscape ensembles and larger in the last three. This is consistent with our results for *LK* landscapes with *K* = 1 and different *L* (see above and Fig. S9), confirming that maxima of versus *N* are associated to rugged landscapes with sparse peaks. Note that tuning the parameters of the model landscape ensembles considered here can yield various peak densities and behaviors, which we did not explore exhaustively.

#### Experimental and experimentally-motivated landscapes

We study versus *N* in 8 experimental rugged landscapes, see Fig. 4(a) and Fig. S14. In all cases, we observe an overall increasing behavior, most of them generally increasing, and two with a notable maximum at an intermediate size *N*, see Fig. 4(a) and Fig. S14(a). This is consistent with our results for model fitness landscapes, and shows their generality.

Tradeoff-induced landscapes were introduced to model the impact of antibiotic resistance mutations in bacteria, in particular their tendency to increase fitness at high antibiotic concentration but decrease fitness without antibiotic [57, 58], see Supplementary material, Section S4. These landscapes tend to be smooth at low and high antibiotic concentrations, but more rugged at intermediate ones, due to the tradeoff [57]. In a specific tradeoff-induced landscape, we find that versus *N* is flat for the smallest concentrations considered (the landscape has only one peak), becomes monotonically increasing for larger ones, and exhibits a maximum for even larger ones, before becoming flat again at very large concentrations, see Fig. 4(b). In all cases, versus *N* is overall increasing or flat. Besides, the ensemble average over a class of tradeoff-induced landscapes (see Supplementary material, Section S4) yields monotonically increasing behaviours of versus *N* for most concentra(tio)ns, except the very small or large ones where it is flat, see Fig. 4(c). The overall variation is largest (compared to the minimal value of ) for intermediate concentrations. These findings are consistent with our results for model and experimental fitness landscapes, further showing their generality.

## 4 Discussion

We studied early adaptation of finite populations in rugged fitness landscapes in the weak mutation regime, starting from a random genotype. We found that the mean fitness of the first encountered peak depends on population size *N* in a non-trivial way, in contrast to the steady-state fitness which monotonically increases with *N*. We showed that the accessibility of different peaks plays a crucial part in whether is larger in the large-*N* limit or for *N* = 1 in simple two-peaked landscapes. A key reason why may not monotonically increase with *N* is that as *N* increases, Moran and Wright-Fisher walks lose possible paths as the fixation probability of deleterious mutations vanishes, while also becoming more biased toward larger fitness increases. These two conflicting effects of increasing *N* yield a tradeoff. Accordingly, we observed that versus *N* (and even the ensemble mean ) often features a maximum for intermediate *N*, especially in rugged fitness landscapes with small peak densities, where most nodes are relatively far from peaks. In these cases, early adaptation is more efficient, in the sense that higher peaks are found, for intermediate *N* than in the large-*N* limit. Studying the behavior of versus *N* could potentially be useful to characterize and classify landscapes.

Our results hold both for the Moran model, and for the Wright-Fisher model in the diffusion limit. Furthermore, they extend to various model rugged landscapes and to many experimental and experimentally-motivated ones, including several experimental fitness landscapes involved in the evolution of antimicrobial resistance. This shows the robustness of our conclusions and their relevance to biologically relevant situations.

The time it takes to cross a fitness valley [59, 60] and the entropy of trajectories on fitness landscapes [61] depend non-monotonically on *N*. However, both results arise from the possibility of observing double mutants in a wild-type population when *N* increases at fixed mutation rate *μ*. Small populations can also yield faster adaptation that larger ones [62, 63], but this occurs at the onset of clonal interference. By contrast, we remained in the weak mutation regime, highlighting that even then, population size has non-trivial effects on adaptation. Our focus on weak mutation without strong selection (see also [20, 21, 27–29]) complements the study of strong selection with frequent mutation [33], going beyond the strong selection weak mutation regime.

The overshoot we find of the large-*N* limit of is often small. In addition, it occurs for modest values of *N*, meaning that adaptation becomes most efficient for sizes that are quite small compared to the total size of many microbial populations. However, the relative amplitude of the overshoot, and the *N* at which it occurs, both increase with genome size *L* in *LK* landscapes. The large-*L* case is biologically relevant since genomes have many units (genes or nucleotides). Furthermore, in *LK* landscapes, the relative overshoot is largest for *K* = 1, i.e. pairwise epistasis, a case that describes well protein sequence data [48–50]. More generally, finite-size effects in early adaptation are expected for population sizes *N* such that *N*|*s*| is small for a sufficient fraction of mutations in the landscape, where *s* denotes the relative fitness effect of a mutation. Thus, finite-size effects should matter for larger population sizes if neutral and effectively neutral [22] mutations are abundant. This is a biologically relevant situation [51].

Besides, spatial structure and population bottlenecks yield smaller effective population sizes, for which our findings are relevant. Studying the effect of spatial structure on early adaptation in rugged fitness landscapes is an interesting topic for future work. Indeed, complex spatial structures with asymmetric updates or migrations impact the probabilities of fixation of mutations [64–68], which should affect early adaptation. Beyond the weak mutation regime, fitness valley crossing by tunneling can aid adaptation [59, 60], which may especially impact subdivided populations, as first discussed in Wright’s shifting balance theory [1, 69] and shown in a minimal model [70]. Another interesting direction regards the effect of environment-induced modifications of fitness landscapes on adaptation [15, 71].

## Supplementary material

### S1 Mean fitness evolution and steady state

#### S1.1 Master equation and mean fitness evolution

As the Moran and Wright-Fisher walks are Markov chains, one can write a master equation on the probability *P*_{i} that the population is in state *i* (representing its genotype). Let us denote time, expressed in number of mutation events, by a discrete variable *τ*. The master equation reads:
where *G*_{i} is the set of neighbors of *i* (i.e. the *L* genotypes that differ from *i* by only one mutation) and the *P*_{ij}*/L* are the transition probabilities. Indeed, 1*/L* is the probability that the mutation yields the neighbor *j* of *i*, while *P*_{ij} is the fixation probability of this mutation, given by Eq. (1) for the Moran walk or Eq. (2) for the Wright-Fisher walk.

Solving numerically Eq. (6) allows us to compute the mean fitness *F*(*τ*), see Fig. S1:
where *G* is the set of all nodes and *f*_{i} is the fitness of node *i*.

#### S1.2 Mean steady-state fitness increases with population size

At steady state, the mean fitness in a given fitness landscape, corresponding to the large-*τ* limit of Eq. (7), is given by
where *G* is the set of all nodes and *f*_{i} is the fitness of *i*, as above, while *π*_{i} is the stationary probability that the population is in state *i*. Indeed, because the Markov chain corresponding to the Moran or Wright-Fisher walk is irreducible, aperiodic and positive recurrent, it possesses a unique stationary distribution *π*_{i} towards which it converges for any initial condition [34, 35], and we can write lim_{τ→∞} *P*_{i}(*τ*) = *π*_{i}.

For the Moran process, [28], and thus Eq. (8) gives:
where we introduced the sequence (*g*_{N})_{N∈ℕ *} defined by
for all positive integer *N*.

To determine how *F* varies with population size *N*, let us index *F* by *N* and study the sign of
Because fitness values are positive, *g*_{N} is also positive for all positive *N*, and the sign of *F*_{N+1} − *F*_{N} is the same as that of its numerator . Let us thus focus on this quantity:
If *i* = *j, f*_{i} − *f*_{j} = 0. For the remaining terms with *i* ≠ *j*, we can separate the case where *i* < *j* and the one where *j* > *i*, yielding
Combining Eq. (11) and Eq. (13), we have shown that for all positive integers *N, F*_{N+1} − *F*_{N} ≥ 0, which entails that the mean steady-state fitness *F* increases with *N*.

### S2 Mean length and time of a walk

We define the time *t* of a walk as the total number of mutations (that fix or not) that occur before the first fitness peak is reached. Similarly, the length ℓ of a walk is defined as the number of successful fixations that occur before the first fitness peak is reached.

In a given landscape, the mean time (resp. length ) of a walk starting from a uniformly chosen node can be expressed as the average over all starting nodes of the mean time (resp. length ) to reach the set *M* of all peaks starting from node *i*:
where *G* is the ensemble of all the nodes of the landscape.

To compute , we use the transition probabilities *P*_{il}*/L* to hop from *i* to *l* upon a given mutation event, where 1*/L* is the probability that the mutation yields the neighbor *l* of *i*, while *P*_{il} is the fixation probability of this mutation, given by Eq. (1) for the Moran walk or Eq. (2) for the Wright-Fisher walk. Discriminating over all possibilities upon the first mutation, including cases where it does not fix in addition to cases where it fixes, yields
where *G*_{i} is the set of neighbors of *i* (i.e. the *L* genotypes that differ from *i* by only one mutation).

The exact same approach can be employed to compute , but considering the normalized transition probabilities satisfying for all *i*, instead of the raw transition probabilities *P*_{il}*/L*. The Markov chain associated to these normalized transition probabilities is referred to as the embedded version of the initial Markov chain. Then, we have
Solving the system of 2^{L} equations in Eq. (15) (resp. Eq. (16)) yields (resp. ) for all *i*, which then allows us to compute (resp.) using Eq. (14).

### S3 Adaptive walk models

Adaptive walks (AWs) are walks in genotype space where deleterious mutations cannot fix. Hence, the population only goes uphill in fitness until it reaches a peak, which is an absorbing state [16]. Here, we present a reminder of some AW models, see also [18]. These AWs are used as references in Fig. 1 to compare with the Moran walk and the Wright-Fisher walk.

#### Natural AW

At each step, the transition probability from the current wild-type genotype *i* to a neighboring genotype *j* is 0 if the fitness of *j* is smaller than the fitness of *i* (*f*_{j} < *f*_{i}). Conversely, if *f*_{j} > *f*_{i}, it reads
where *B*_{i} is the set of neighbors of *i* that have a larger fitness than *i* [17, 40, 41]. Note that there are known analytical results on the natural AW under specific hypotheses, see e.g. [41, 72].

#### Random AW

At each step, the next genotype is chosen uniformly at random among the fitter neighbors of the current wild-type genotype [73].

#### Greedy AW

At each step, the next genotype is the fittest among the fitter neighbors of the current wild-type genotype [38].

### S4 Fitness landscape models considered

Apart from the *LK* model described and used thoroughly in Section 3.1, we consider several other models in Section 3.2, esp. in Fig. S12. Here, we briefly present each of them.

*LKp* landscapes

The *LKp* model [53] is a variant of the *LK* model in Eq. (5) where the fitness contribution *f*_{i} of a given combination of states has a probability *p* to be equal to 0 instead of being drawn from a uniform distribution between 0 and 1. It coincides with the *LK* model for *p* = 0, and becomes a completely flat landscape if *p* = 1. Hence, the larger *p* and the smaller *K*, the more likely a mutation is to be neutral. Because fitnesses equal to 0 are problematic in the Moran walk, we consider a variant of the *LKp* landscape, where there is a probability *p* that a fitness contribution is equal to *q* > 0 (instead of 0). Note that the presence of neutral mutations implies possible fitness plateaus in these landscapes, and we consider them as peaks, meaning that the walk is stopped once the first plateau is reached.

*LK* landscapes with alphabet size *A* > 2

Here, *A* is the number of possible states of each genetic unit, which is 2 in the usual *LK* model. Thus, this model is a variant of the *LK* model in Eq. (5) where each node has *AL* neighbors instead of *L* [30]. Note that genotype space is not a hypercube in this case. Apart from this, everything is the same as in the *LK* model considered elsewhere in this paper, in particular fitness contributions are drawn from a uniform distribution between 0 and 1.

#### Ising landscapes

In this model, fitness is written as (minus) the Hamiltonian of a one-dimensional Ising spin chain where each site only interacts with its closest neighbors along the chain [44, 54]:
where *B* is a positive constant that we add to avoid negative fitness values, while the *J*_{i,i+1} are drawn from a Gaussian of fixed mean and standard deviation, and for all *i, s*_{i} = 2*σ*_{i} − 1 so that *s*_{i} ∈ {−1, 1}.

#### House of Cards landscapes

The House of Cards model is a benchmark for high ruggedness [38], and its name was introduced in [39]. It is the simplest rugged fitness landscape model, because all fitness values are independent and identically distributed. Here, to generate House of Cards landscapes (Fig. S12(d)), we draw fitnesses from a uniform distribution between 0 and 1. Note that *LK* landscapes with *K* = *L* − 1 are House of Cards landscapes. This corresponds to all sites interacting together, and it yields a completely uncorrelated fitness landscape.

#### Eggbox landscapes

In an eggbox landscape [44], half of the genotypes are local maxima. The high fitnesses are drawn from a Gaussian of mean *f*_{0} + *μ*_{E}*/*2 while the low fitnesses are drawn from a Gaussian of mean *f*_{0} −*μ*_{E}*/*2. Both Gaussian distributions have the same standard deviation, chosen small compared to *μ*_{E} to ensure that all non-maxima are surrounded by maxima and vice-versa.

#### Rough Mount Fuji landscapes

In the Rough Mount Fuji model [10, 55], fitnesses have an additive part and an epistatic one:
where is the fitness of a reference genotype , while *C* is the additive fitness effect of any mutation [10] (note that in the original model of [55], mutations can have different additive effects), and denotes the Hamming distance between and . Finally, corresponds to the epistatic contribution to fitness, and is drawn for each from a Gaussian of fixed mean and standard deviation.

#### Tradeoff-induced landscapes

This landscape family aims to model the impact of antibiotic resistance mutations in bacteria, in particular the fact that mutations that increase the fitness of bacteria at high antibiotic concentration often decrease their fitness in the absence of antibiotic [57, 58]. Fitnesses are given by:
where *c* is the antibiotic concentration and we take *a* = 2 (this exponent is typically 2 or 4 in [57, 58]), while and . For the wild type , and . The single mutant at site *i* from the wild type is described by its fitness *r*_{i} < 1 at *c* = 0 and its resistance value *m*_{i} > 1, and the effects of different mutations (i.e. the *r*_{i} and *m*_{i}) are assumed to be multiplicative, yielding and . The parameters *r*_{i}, *m*_{i} of single mutations are independently drawn from a joint probability density *P*(*r*_{i}, *m*_{i}) given by Eq. (8) of [57], namely:

## S5 Supplementary figures

## S6 Supplementary tables

## Acknowledgments

The authors thank Alia Abbara for helpful discussions about Markov chains and Claudia Bank for providing useful data from [14]. This project has received funding from the European Research Council (ERC) under the European Union’s Horizon 2020 research and innovation programme (grant agreement No. 851173, to A.-F. B.).

## Footnotes

Revised version

## References

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