## Abstract

In order to target threatening pathogens, the adaptive immune system performs a continuous reorganization of its lymphocyte repertoire. Following an immune challenge, the B cell repertoire can evolve cells of increased specificity for the encountered strain. This process of affinity maturation generates a memory pool whose diversity and size remain difficult to predict. We assume that the immune system follows a strategy that maximizes the long-term immune coverage and minimizes the short-term metabolic costs associated with affinity maturation. This strategy is defined as an optimal decision process on a finite dimensional phenotypic space, where a pre-existing population of naive cells is sequentially challenged with a neutrally evolving strain. We unveil a trade-off between immune protection against future strains and the necessary reorganization of the repertoire. This plasticity of the repertoire drives the emergence of distinct regimes for the size and diversity of the memory pool, depending on the density of naive cells and on the mutation rate of the strain. The model predicts power-law distributions of clonotype sizes observed in data, and rationalizes antigenic imprinting as a strategy to minimize metabolic costs while keeping good immune protection against future strains.

## I. INTRODUCTION

Adaptive immunity relies on populations of lymphocytes expressing diverse antigen-binding receptors on their surface to defend the organism against a wide variety of pathogens. B lymphocytes rely on a two-step process to produce diversity: first a diverse naive pool of cells is generated; upon recognition of a pathogen the process of affinity maturation allows B cells to adapt their B-cell receptor (BCR) to epitopes of the pathogen through somatic hypermutation [1]. This process, which takes place in germinal centers [2], can increase the affinity of naive BCR for the target antigen by up to a thousand fold factor [3]. Through affinity maturation, the immune system generates high-affinity, long-lived plasma cells, providing the organism with humoral immunity to pathogens through the secretion of antibodies—the soluble version of the matured BCR—as well as a pool of memory cells with varying affinity to the antigens [4]. However, the diversity and coverage of the memory pool, as well as the biological constraints that control its generation, have not yet been fully explored.

Analysis of high-throughput BCR sequencing data has revealed long tails in the distribution of clonotype abundances, identifying some very abundant clonotypes as well as many very rare ones [5, 6]. Additionally, many receptors have similar sequences and cluster into phylogenetically related lineages [7–11]. These lineages have been used to locally trace the evolution of antibodies in HIV patients [12, 13] and in influenza vaccinees [14, 15]. Analysis of influenza booster vaccines shows large clonal dominance, with 90% receptor sequences belonging to 10% of clones [16]. Memory B-cell clones are more diverse and less specific to the infecting antigen than antibody-producing plasma cells [17, 18]. This suggests that the immune system is trying to anticipate infections by related pathogens or future escape mutants [19].

Theoretical approaches have attempted to qualitatively describe affinity maturation as a Darwinian coevolutionary process, and studied optimal affinity maturation schemes [20, 21], as well as optimal immunization schedules to stimulate antibodies with large neutralizing capabilities [22–24]. Most of these approaches have been limited to short timescales, often with the goal of understanding the evolution of broadly neutralizing antibodies. Here we propose a mathematical framework to explore the trade-offs that control how the large diversity of memory cells evolves over a lifetime.

Despite long-lasting efforts to describe the co-evolution of pathogens and hosts immune systems [25–29], and recent theoretical work on optimal schemes for using and storing memory in the presence of evolving pathogens [30], few theoretical works have described how the B-cell memory repertoire is modified by successive immunization challenges. Early observations in humans [31] have shown that sequential exposure to antigenically drifted influenza strains was more likely to induce an immune response strongly directed towards the first strain the patients were exposed to [32]. This immune imprinting with viral strains encountered early in life was initially called “original antigenic sin,” as it can limit the efficiency of vaccination [33]. This phenomenon has been observed in a variety of animal models and viral strains [34]. Secondary infections with an antigenically diverged influenza strain can reactivate or “backboost” memory cells specific to the primary infecting strain [35]. This response is characterized by lower binding affinity but can still have in-vivo efficiency thanks of cross-reactive antibodies [36]. There is a long-standing debate about how detrimental “original antigenic sin” is [37, 38]. However, the question of under what circumstances an immune response based on memory re-use is favourable has not been addressed.

We build a theoretical framework of joint virus and repertoire evolution in antigenic space, and investigate how infections by evolving pathogens have shaped, over evolutionary timescales, the B-cell repertoire response and re-organization. Pathogens causing acute infections usually show a seasonal periodicity, while the maturation processes in the B-cell repertoire take place over a few weeks. This observation allows us to consider that affinity maturation happens in a negligible time with respect to the reinfection period. Within this approximation, we investigate the optimal immune maturation strategies using a framework of discrete-time decision process. We show the emergence of three regimes—monoclonal memory response, polyclonal memory response, and naive response—as trade-offs between immune coverage and resource constraint. Additionally, we demonstrate that reactivation of already existing memory clonotypes can lead to self-trapping of the immune repertoire to low reactivity clones, opening the way for “original antigenic sin.”

## II. RESULTS

### A. Affinity maturation strategies for recurring infections

B cells recognize pathogens through the binding of their BCR to parts of the pathogen’s proteins, called antigens. To model this complex protein-protein interaction problem, we assume that both receptors and antigens may be projected into an effective, *d*-dimensional antigenic space (Fig. 1), following the “generalized shape space” idea pioneered by Perelson and Oster [39]. Receptor-antigen pairs at close distance in that space bind well, while those that are far away bind poorly. Specifically, we define a cross-reactivity function 0 ≤ *f* ≤ 1 quantifying the binding affinity between antigen *a* and receptor *x*, which we model by a stretched exponential:

where *r*_{0} is the cross-reactivity radius, and *q* a stretching exponent.

For simplicity, we focus on a single pathogen represented by its immunodominant antigen, so that each viral strain is represented by a single point *a _{t}* in antigenic space (black square), where

*t*= 1, 2

*, …*is a discrete time counting the number of re-infections. It is difficult to estimate the rate of re-infections or exposures to the same pathogen. It can be fairly high in humans, where individuals are exposed to the most common viruses from less than once to several times a year [40]. The numbers of lifetime exposures would then range from a few to a few hundreds.

The B cell repertoire, on the other hand, is represented by a collection of antigenic coordinates corresponding to each receptor clonotype. We distinguish memory cells (dark blue circles in Fig. 1A), denoted by *P _{t}*, which have emerged in response to the presence of the virus, and a dense background of naive cells

*N*(light blue circles) which together provide a uniform but weakly protective coverage of any viral strain (subsumed into the parameter

*ϕ*defined later).

The viral strain evolves randomly in antigenic space, sequentially challenging the existing immune repertoire. This assumption is justified by the fact that for acute infections with a drifting viral strain, such as influenza, the immune pressure exerted on the strain does not happen in hosts but rather at the population level [25]. Viral evolution is not neutral, but it is unpredictable from the point of view of individual immune systems. Specifically, we assume that, upon reinfection, the virus is represented by a new strain, which has moved from the previous antigenic position *a _{t}* to the new one

*a*

_{t+1}according to a Gaussian distribution with typical jump size

*σ*, called “divergence”: where ⟨

_{v}*η*⟩ = 0 and ⟨

_{t}*η*·

_{t}*η*⟩ =

_{t′}*δ*.

_{tt′}To model how the immune repertoire is re-organized in response to a new infection *a _{t}*, we postulate that its strategy has been adapted over evolutionary timescales to maximize the speed of immune response to subsequent challenges, given the resource constraints imposed by affinity maturation [41]. This strategy is assumed to be stochastic and characterized by the law according to which the BCR repertoire evolves from

*P*

_{t−1}to

*P*as a result of affinity maturation: (Fig. 1C).

_{t}We consider the following rules inspired by known mechanisms available to the immune system [2]. Upon infection by *a _{t}*,

*m*new receptors are matured to target the virus, with

_{t}*m*distributed according to a Poisson law of mean . Each new receptor is roughly located around

_{t}*a*in antigenic space with some imprecision

_{t}*σ*:

*x*=

_{j}*a*+

_{t}*σξ*,

_{j}*j*= 1, … ,

*m*, with

_{t}*ξ*normally distributed with ⟨

_{j}*ξ*⟩ = 0 and = 1. These new positions are added to the ones from the previous repertoire

_{j}*P*

_{t−1}.

In addition, each clonotype *x* ∈ P_{t−1} from the previous repertoire may be reactivated and be subsequently duplicated through cell divisions [19], with probability *μf*(*x, a _{t}*), proportional to the cross-reactivity given by (1), where 0 ≤

*μ*≤ 1 is a proliferation parameter. These previously existing cells and their offspring may then die before the next infection. We denote by

*γ*their survival probability, so that the average lifetime of each cell is (1 −

*γ*)

^{−1}. We denote by

*c*the size of clonotype

_{x,t}*x*at time

*t*. By convention we set

*c*= 1 for newly matured clonotyes.

_{x,t}This strategy is characterized by two parameters that can be tuned by evolution: the mean number and diversity *σ* of newly matured clonotypes. The proliferation and death parameters *μ* and *γ* are assumed to be constrained and fixed. To assess the performance of a given strategy, we define an overall loss at each time step:
where *ϕ* > 0 is a maximal cost corresponding to using naive cells, and *α* > 0 and *κ* > 0 are model parameters.

The first term of (3) corresponds to the infection cost *I _{t}*, which is a decreasing function of the coverage of the virus by the memory repertoire,

*C*(

*a*) = , with a power

_{t}*α*governing how sharp that dependence is. Intuitively, the lower the coverage, the longer it will take for memory cells to mount an efficient immune response and clear the virus, incurring larger harm on the organism [41, 42]. When memory coverage is too low, the naive repertoire takes over, incurring a maximal cost fixed to

*ϕ*. In the Supplementary Text we show how this naive cut-off may be derived in a model where the immune system can choose to activate either its memory or its naive compartment in response to a new infection, when naive clonotypes are very numerous but offer weak protection. In that interpretation,

*ϕ*scales like the inverse density of naive cells, so that we will refer to

*ϕ*

^{−1}as “naive density.” In Fig. 1B we plot an example of the infection cost along a cross-section of the antigenic space.

The second term in the right-hand side of (3) corresponds to a plasticity cost encoding the resources necessary to implement affinity maturation. It is assumed to be proportional to the number of new clonotypes *m _{t}*, with cost factor

*κ*.

We assume that, over evolutionary timescales, the immune system has minimized the average cumulative cost over a large number of infections *T* :

This optimization yields the optimal parameters of the strategy. In the case described above, we obtain the optimal mean number of added receptors and their optimal diversity *σ**:

In the next section we discuss the results of that optimization with various choices of parameters.

### B. Phase diagram of optimal affinity maturation strategies

We obtain optimal strategies , *σ** by minimizing the simulated long-term cost (Eq. 4) in a 2-dimensional antigenic space (see Methods for details of the simulation, optimization procedures, and phase determination). By varying two key parameters, the cost *ϕ* associated to the use of the naive repertoire, and the virus divergence *σ _{v}*, we see a phase diagram emerge with three distinct phases: the naive, monoclonal response, and polyclonal response phases (Fig. 2A). In Figs. 2B-C we show examples of the stochastic evolution of memory repertoires with optimal rules in the two phases (monoclonal and polyclonal responses). Figs. 2D-F show the behaviour of the optimal parameters, as well as the fraction of infections for which the naive repertoire is used (when the maximal infection cost

*ϕ*is paid). The general shape and behaviour of this phase diagram depends only weakly on the parameter choices (see SI Fig. S1).

When the naive repertoire is sufficiently protective (small *ϕ*), or when the virus mutates too much between infections (large *σ _{v}*), the optimal strategy is to produce no memory cells at all ( = 0), and rely entirely on the naive repertoire, always paying a fixed cost

*L*= =

_{t}*ϕ*(naive phase).

When the virus divergence *σ _{v}* is small relative to the cross-reactivity range

*r*

_{0}, it is beneficial to create memory clonotypes , but with no diversity,

*σ** = 0 (monoclonal response). In this case, all newly created clonotypes are invested into a single antigenic position

*a*that perfectly recognizes the virus. This strategy is optimal because subsequent infections, typically caused by similar viral strains of the virus, are well recognized by these memory clonotypes.

_{t}For larger but still moderate virus divergences *σ _{v}*, this perfectly adapted memory is not sufficient to protect from mutated strains: the optimal strategy is rather to generate a polyclonal memory response, with ,

*σ** > 0. In this strategy, the immune system hedges its bet against future infections by creating a large diversity of clonotypes that cover the vicinity of the encountered strain. The advantage of this policy is to antic-ipate future antigenic mutations of the virus; its draw-back is that memories are less efficient against the current infection. This diversified pool of cells with moderate affinity is in agreement with recent experimental observations [2, 19, 43, 44]. The diversity of the memory pool is supported by a large number of clonotypes (Fig. 2D). As the virus divergence

*σ*is increased, the optimal strategy is to scatter memory cells further away from the encountered strain (increasing

_{v}*σ**, Fig. 2E). However, when

*σ*it is too large, both drop to zero as the naive repertoire takes over (Fig. 2F). Increasing the naive density

_{v}*ϕ*

^{−1}also favors the naive phase. When there is no proliferation on average, i.e. Γ ≡

*γ*(1 +

*μ*) < 1, there even exists a threshold above which the naive strategy is always best (SI Fig. S1, and see Supplementary Text for estimates of that threshold).

In summary, the model predicts the two expected regimes of naive and memory use depending on the parameters that set the costs of infections and memory formation. But in addition, it shows a third phase of polyclonal response, where affinity maturation acts as an anticipation mechanism whose role is to generate a large diversity of cells able to respond to future challenges. The prediction of a less focused and thus weaker memory pool observed experimentally is thus rationalized as a result of a bet-hedging strategy.

### C. Analytical results in a solvable model

To gain insight into the transitions observed in the phase diagram of Fig. 2, we can make a series of simplifications and approximations about the model that allow for analytical progress. We assume a step function for the cross-reactivity function *f* (*x, a*) = 1 for *x a r*_{0}, and 0 otherwise, corresponding the limit *q* =. Likewise, we assume a uniform distribution of viral antigenic mutations *a*_{t+1} = *a _{t}* +

*σ*′

_{v}

*η*′

_{t+1}, where

*η′*

_{t}is a random point of the

*d*-dimensional unit ball, with (so that the variance is the same as in the Gaussian case), and similarly for memory diversification, with new clonotypes drawn from a uniform distribution is a ball of radius . The infection cost is approximated by an all-or-nothing function, with

*I*= 0 if there is any coverage

_{t}*C*(

*a*) > 0, and

_{t}*I*=

_{t}*ϕ*if

*C*(

*a*) = 0. We further assume

_{t}*γ*= 0: all clonotypes are discarded at each time step, so that memory may only be used once.

In this simplified version of the model, the phase diagram and optimal parameters can be computed analytically. One can show (see Supplementary Text) that the transition from monoclonal to polyclonal response occurs exactly when the radius of the ball within which viral mutations occur reaches the cross-reactivity radius *r*_{0}:

Below this transition (*σ′ _{v}* <

*r*

_{0}), the optimal strategy is to have no diversity at all and perfectly target the recognized antigen

*a*,

_{t}*σ*′* = 0, as any memory cell at

*a*will recognize the next infection. In this case the optimal mean number of memories results in a trade off between the cost of new memories with the risk of not developing any memory at all by minimizing . The transition from the monoclonal response to naive phases is then given by

_{t}*ϕ*=

*κ*, where = 0.

The polyclonal-to-naive transition may also be understood analytically. In the polyclonal response phase, the optimal strategy is, in either of the limits *σ*′_{v} ≫ *r*_{0} or (see Supplementary Text):

In particular this result becomes exact at the transition from polyclonal to naive, where = 0. The transition is thus given by:

The polyclonal response is outcompeted by the naive one when the density of naive cell (*ϕ*^{−1}) becomes larger than the probability density of new strains falling within the cross-reactivity radius , rescaled by the memory cost coefficient *κ*^{−1}.

Fig. 3 shows the resulting phase diagram, as well as the optimal diversity *σ*′* and predicted costs for a fixed *ϕ* and *d* = 1. These predictions reproduce the main features of the full model, in particular the scaling of the immune diversity *σ* with *σ _{v}* (Fig. 2D vs. Fig. 3B) and the general shape of the optimal memory size (Fig. 2E vs. Fig. 3C), which first increases as the virus becomes more divergent, to later drop to zero as memory becomes too costly to maintain and the system falls into the naive phase.

### D. Population dynamics of optimized immune systems

We now return to the full model to study the population dynamics of the memory repertoire. When the virus drifts slowly in antigenic space (small *σ _{v}*), the same clonotypes get reactivated multiple times, causing their proliferation, provided that Γ =

*γ*(1 +

*μ*) > 0. This reactivation continues until the virus leaves the cross-reactivity range of the original clonotype, at which point the memory clone decays and eventually goes extinct (Fig. 4A). Typical clonotype size trajectories from the model are shown in Fig. 4B. They show large variations in both their maximal size and lifetime. The distribution of clonotype abundances, obtained from a large number of simulations, is indeed very broad, with a power-law tail (Fig. 4C). The lifetime of clonotypes, defined as the time from emergence to extinction, is distributed according to an exponential distribution (Fig. 4D). The exponents governing the tails of these distributions,

*β*and

*γ*, depend on the model parameters, in particular the divergence

*σ*.

_{v}We can understand the emergence of these distributions using a simple scaling argument. After a memory clonotype has been created at *a*_{0} at time 0, its size follows the approximate dynamics:
where *r*_{t} = ||*a*_{t} − *a*_{0}||, the distance of the virus to the original strain, follows a random walk:

In (10) we have neglected demographic noise arising from the stochastic nature of duplications and deletions. As the virus drifts away and *r _{t}* increases, the net growth factor

*γ*(1 +

*μf*) decreases, and eventually becomes lower than 1, for

The time it takes for this condition to be fulfilled, *t**, is approximately given by the diffusion law, ⟨*t**⟩ ~ (*r**/*σ*_{v})^{2}, assuming *σ*_{v} ≪ *r**. In a very coarse approximation, the clonotype grows with rate Γ = *γ*(1 + *μ*) until *t**, reaching peak abundance , and decays with rate *γ* for *t > t**.

The tail of the distribution is dominated by rare events when the virus mutates less than expected between infections, leading to larger episodes of growth. One can show (see Supplementary Text) that the distribution of these exceptionally long *t** has an exponential tail:

This translates into a power-law tail for the peak clonotype abundance,

The same scaling holds for the distribution of all abundances, since the peak determines the rest of the trajectory.

Within the same simplified picture, the lifetime *t _{l}* of a clonotype is the sum of the time it takes to reach the peak,

*t**, and the decay time until extinction, which is approximately ln(

*n**)

*/*ln(1

*/γ*):

Thus, *t _{l}* is proportional to

*t**, and therefore also exponentially distributed:

This simple scaling argument predicts the exponents *β* and *λ* fairly well: Figs. 4E-F confirm the validity of the scaling relations (14)-(16) against direct evaluation from simulations, for *d* = 2 and *q* = 2. These scalings still hold for different parameter choices (see SI Fig. S2).

These scaling relations are valid up to a geometry-dependent prefactor, which is governed by dimensionality and the shape of the cross-reactivity kernel. In the Supplementary Text, we calculate this prefactor in the special case of an all-or-nothing cross-reactivity function, *q* = ∞. Generally, *β* increases with *d*, as shown in the insets of Figs. 4E-F for *q* = 2. In higher dimensions, there are more routes to escape the cross-reactivity range, and thus a faster decaying tail of large clonotypes. This effect cannot be explained by having more dimensions in which to mutate, since the antigenic variance is distributed across each dimension, according to . Rather, it results from the absence of antigenic back-mutations: in high dimensions, each mutation drifts away from the original strain with a low probability of return, making it easier for the virus to escape, and rarer for memory clonotypes to be recalled upon infections by mutant strains.

### E. Comparison to experimental clone-size distributions

The power-law behaviour of the clone-size distribution predicted from the model (Fig. 4E) is in qualitative agreement with existing data. Power laws have been widely observed in immune repertoires: from early studies of repertoire sequencing data of BCR in zebrafish [5, 46], to the distribution of clonal family sizes of human IgG BCR [14, 47], as well as in T-cell receptor repertoires [6]. However, these power laws have not yet been reported in the clonotype abundance distribution of human BCR.

To fill this gap, we used publicly available IgG repertoire data of 9 human donors from a recent ultra-deep repertoire profiling study of immunoglobulin heavy-chains (IGH) [45]. The data was downloaded from Sequence Read Archive and processed as in [47]. Repertoires were obtained from the sequencing of IGH mRNA molecules to which unique molecular identifiers (UMI) were appended. For each IGH nucleotide clonotype found in the dataset, we counted the number of distinct UMI attached to it, as a proxy for the overall abundance of that clonotype in the expressed repertoire. The distributions of these abundances are shown for all 9 donors in Fig. 5A. In agreement with the theory, they display a clear power-law decay *p*(*n*) ∼ *n*^{−1−β}, with *β* = 1.2-2.4.

Since the experimental distribution is derived from small subsamples of the blood repertoire, the absolute abundances cannot be directly compared to those of the model. In particular, subsampling means that the experimental distribution focuses on the very largest clonotypes. Thus, comparisons between model and data should be restricted to the tail behavior of the distribution, namely on its power-law exponent *β*.

We used this comparison to predict from the exponent *β* the virus divergence between infections. To do so, we fit a linear relationship to the inset of Fig. 4E, and invert it for various values of the dimension *d* to obtain *σ _{v}/r**. We fixed Γ = 1.4, which corresponds to a 40% boost of memory B cells upon secondary infection, inferred from a 4-fold boost following 4 sequential immunizations reported in mice [19]. The result is robust to the choice of donor, but decreases substantially with dimension, because higher dimensions mean faster escape, and thus a lower divergence for a given measured exponent (Fig. 5B). The inferred divergence

*σ*is always lower than, but of the same order as, the effective cross-reactivity range

_{v}*r**, suggesting that the operating point of the immune system falls in the transition region between the monoclonal and polyclonal response phases (Fig. 2A).

### F. Inhibition of affinity maturation and antigenic imprinting

So far we have assumed that the immune system always activates germinal centers to implement affinity maturation, regardless of the level of protection from existing memory. However it may be optimal for the system to refrain from creating new memory cells to save costs, when the memory repertoire already responds efficiently to the current challenge. Such an approach allows the immune system to be greedy: if the early memory response induced by existing cells is fast enough, it can inhibit the maturation of the repertoire.

We introduce this inhibition of affinity maturation in our model through a cost threshold 0 ≤ *ξ* ≤ *ϕ* below which the formation of new clonotypes is suppressed. When *L _{t}* <

*ξ*, the memory repertoire recognizes the viral challenge with sufficient efficacy to offer protection, and the immune system decides to rely on existing clonotypes rather than to create new ones, saving the plasticity cost

*κm*. However, existing clonotypes are expanded, or “backboosted,” proportionally to their affinity to the new infection as before. The threshold

*ξ*is left as an optimization parameter, in addition to

*σ*and . In the special case

*ξ*= 0, we recover the original model where affinity maturation always occurs.

We find that there exists an optimal threshold *ξ** > 0 in both the polyclonal and monoclonal response phases. The frequency of affinity maturation events mostly depends on *σ _{v}* (Fig. 6A). While this threshold remains approximately constant, the frequency of affinity maturation events increases as

*σ*increases. At small

_{v}*σ*, the optimal strategy is to extensively backboost existing memory cells; for large

_{v}*σ*, the growing unpredictability of the next viral move makes it more likely to have re-course to affinity maturation. In other words, when the virus is stable (low

_{v}*σ*), the immune system is more likely to capitalize on existing clonotypes, and not implement affinity maturation, because savings made on the plasticity cost outweigh the higher infection cost. As the virus drifts away with time, this infection cost also increases, until it reaches the point where affinity maturation becomes worthwile again.

_{v}Typical trajectories of the infection cost show the typical dynamics induced by backboosting, with long episodes where existing memory remains sufficient to keep the cost below *ξ* (Fig. 6B), interrupted by infections that fall too far away from existing memory, triggering a new episode of affinity maturation and concomitant drop in the infection cost. This effect is known as “antigenic imprinting,” and is linked to the notion of “original antigenic sin,” whereby the history of past infections determines the process of memory formation, usually by suppressing it. This imprinting leads to the couterintuitive prediction that a better experienced immune system is less likely to form efficient memory upon new infections.

We call the time between affinity maturation events *t _{ξ}*. Its mean ⟨

*t*⟩ is equal to the inverse of the frequency of maturation events, and thus decreases with

_{ξ}*σ*. Its distribution, shown Fig. 6C, has an exponential tail with exponent

_{v}*λ*. Affinity maturation should happen when the distance of the virus to the original strain,

_{ξ}*r*, has become too large,

_{t}The exponential tail of the distribution of *t _{ξ}* is dominated by episodes where the viral strain drifted less than expected. In that case, the originally matured clonotype grows to a large size, offering protection for a long time, even after it has stopped growing, when

*t*>

*t**. Using the approximate behaviour of the clonotype size during this decay (Fig. 4A), this gives the condition:

Past the critical radius *r**, clonotype sizes start shrinking (*t* ln(1*/γ*) term), and the virus also drifts further away ( term). Both effects contribute to crossing the threshold. Since we focus on the tail of the distribution, we may replace *t** by , and *r*^{2} by , where *b* is the scaling factor determining the decay exponent of the first passage time at a given radius. Doing so yields the following prediction for the decay rate:

Fig. 6D verifies the validity of this scaling, confirming the prediction of rare long episodes of re-infections without affinity maturation.

## III. DISCUSSION

Adaptive immunity coordinates multiple components and cell types across entire organisms over many space and time scales. Because it is difficult to empirically characterize the immune system at the system scale, normative theories have been useful to generate hypotheses and fill the gap between observations at the molecular, cellular, and organismal scales [48, 49]. Such approaches include clonal selection theory [50], or early arguments about the optimal size and organization of immune repertoires [39, 51, 52], and of affinity maturation [21, 53]. While these theories do not rely on describing particular mechanisms of immune function, they may still offer quantitative insights and help predict new mechanisms or global rules of operation.

Previous work developed models of repertoire organization as a constrained optimization problem where the expected future harm of infection, or an *ad hoc* utility function, is minimized [30, 41, 42, 54]. In Ref. [42], it was assumed clonotypes specific to all antigens are present at all times in the repertoire; the mechanism of immune memory then merely consists of expanding specific clonotypes at the expense of others. This assumption describes T-cell repertoires well, where there are naive cells with good affinity to essentially any antigen [55]. For B cells the situation is more complex because of affinity maturation. In addition, re-organizing the repertoire through mutation and selection has a cost, and is subject to metabolic and physical constraints.

Our work addresses these challenges by proposing a framework of discrete-time decision process to describe the optimal remodeling of the B-cell repertoire following immunization, through a combination of affinity maturation and backboosting. While similar to [30], our approach retains the minimal amount of mechanistic details and focuses on questions of repertoire remodeling, dynamics, and structure.

We investigated strategies that maximize long-term protection against subsequent challenges and minimize short-term resource costs due to the affinity maturation polyclonal, with diversity of the memory scaling with the viral divergence, leading to a weakly reactive memory pool to the infecting viral strain. This optimal memory response remains better than the naive response, as long as the next challenge may be anticipated within the cost constraints of affinity maturation.

We expect these distinct phases to co-exist in the same immune system, as there exists a wide range of pathogen divergences, depending on their evolutionary speed and typical frequency of recurrence. For fast recurring or slowly evolving pathogens, the monoclonal response ensures a very specific and targeted memory. This role could be played by long-lived plasma cells. These cells are selected through the last rounds of affinity maturation, meaning that they are very specific to the infecting strain [56]. Yet, despite not being called memory cells, they survive for long times in the bone marrow, providing long-term immunity. For slow recurring or fast evolving pathogens, the polyclonal response provides a diverse memory to preempt possible antigenic drift of the pathogen. The function could be fulfilled by memory B cells, which are released earlier in the affinity maturation process, implying that they are less specific to the infecting strain, but collectively can cover more immune escape mutations. As a sidenote, there is an ongoing debate as to whether affinity maturation starts from memory or naive B cells during sequential challenges [57, 58]. Our model does not commit to either scenario since we assume that the main benefit of memory is on the infection cost, rather than its re-use in subsequent rounds of affinity maturation.

We extended our model to account for the inhibition of maturation processes in the presence of a strongly reactive memory pool. We unveiled a trade-off between the exploitation of existing reactive memory cells through the inhibition of the affinity maturation processes, and the anticipation of future challenges through the generation of new memory clonotypes. We observed that the optimal immune repertoire evolution is frequently stalled for small expected viral divergence, with a strong inhibition of affinity maturation for subsequent challenges. Such an observation can be interpreted as the phenomenon of antigenic imprinting widely described in sequential immunization assays [35], or “original antigenic sin” [34]. This effect implies that having been exposed to previous strains of the virus is detrimental to mounting the best possible immune response. This counter-intuitive strategy is rationalized within our optimization framework: lack of affinity maturation happens only when previous memories are protective enough (relative to the extra cost processes. Using this model, we observed that optimal of creating new specificities), and does not happen strategies may be organized into three main phases as the pathogen divergence and naive coverage are varied. For an expected divergence lower than the cross-reactivity range, we found that the optimal response is monoclonal, with a specificity perfectly matching the one of the infecting strain. As the strain divergence increases, we observed that the optimal formation of memory becomes at all in naive individuals.

While we considered a single antigenic site, our results generalize to multiple immune targets. We expect such generalization to create competition and trade-offs between different antigens, and perhaps different regimes describing whether the immune system tries to target multiple antigens or instead focuses on a single one (immunodominance). For instance, while our interpretation of the original antigenic sin involves a single epitope, a similar concept exists for multiple epitopes [32]. When during sequential challenges only one of multiple epitopes changes at a time, it may be optimal for the immune system to rely on its protections against the invariant epitopes. Only after all epitopes have escaped immunity does affinity maturation get re-activated concomitantly to a spike of infection harm, similar to our result for a single antigen.

We only considered a single pathogenic species at a time, with the assumption that pathogens are antigenically independent, so that the costs relative to different pathogens are additive. Possible generalizations could include secondary infections, as well as antigenically related pathogens showing patterns of cross-immunity (such as cowpox and smallpox, or different groups of influenza), which could help us shed light on complex immune interactions between diseases and serotypes, such as negative interference between different serotypes of the Dengue fever leading to hemorrhagic fever, or of the human Bocavirus affecting different body sites or [34].

## IV. MATERIALS AND METHODS

The average cumulative cost in Eq. 4 is approximated by a Monte-Carlo method. To ensure the simulated repertoire reaches stationarity, we start from a naive repertoire and discard an arbitrary number of initial viral encounters. Because the process is ergodic, simulating a viral-immune trajectory over a long time horizon is equivalent to simulating *M* independent trajectories of smaller length *T*. To ensure the independence of our random realizations across our *M* parallel streams we use the random number generators method *split* provided in Tina’s RNG library [59]. The cumulative cost function is convex for the range of parameters tested. To optimize under positivity constraints for the objec-tive variables *σ*, and *ξ*, we use Py-BOBYQA [60], a coordinate descent algorithm supporting noisy objective functions.

The polyclonal to monoclonal (red curve) and memory to naive (blue curve) boundaries of the phase diagrams in Fig. 3A and Fig. S2 are obtained by respectively solving in the monoclonal phase and in the naive phase. Both these derivatives can be approximated by finite differences with arbitrary tolerances on *σ* and . We fix the tolerance on *σ* to 0.2 and the tolerance on to 0.01. To obtain the root of these difference functions, we use a bisection algorithm. In order to further decrease the noise level, we compute the difference functions across pairs of simulations, each pair using an independent sequence of pathogens *a*_{t} of length *L* = 400. The number of independent pairs of simulations used for each value of *σ*_{υ} and *ϕ* is *M* ~ 10^{5}.

## Supplementary information

## Acknowledgements

The study was supported by the European Research Council COG 724208 and ANR-19-CE45-0018 “RESPREP” from the Agence Nationale de la Recherche and DFG grant CRC 1310 \Predictability in Evolution". The authors thank Natanael Spisak for pre-processing the raw data from [45], and for useful discussions and suggestions.

## Appendix A: Mean-field naive coverage

Here we show how the infection cost function defined in the main text, may be derived as the mean-field limit of a repertoire with memory and naive compartments.

In addition to the evolving memory repertoire *P*_{t} already described in the main text, we define a naive repertoire made of random receptors , distributed uniformly with density *ρ*. Viruses may be recognized by either the memory or naive clonotypes. The naive coverage is defined as:
and the memory coverage as before:
(In this convention, each naive clonotype has size one in arbitrary units.)

Depending on the values of these coverages, the system will choose to use either the naive repertoire, or an existing memory. In this decision, we factor in the fact that using the naive repertoire is more costly, which we account for using a prefactor *β* < 1. The cost is then defined as:

We can simplify this expression in the limit where naive clonotypes are very numerous, but each offer weak coverage. In the limit of high density of naive cells, *ρ* → ∞, the coverage self-averages to its mean value:
with
where we have done the change of variable *x* = *a*_{t} + *yr*_{0}, and where *S*_{d} = 2*π*^{d/2}/Γ(*d*/2) is the surface area of the unit sphere.

Taking the *ρ* → ∞ and *β* → 0 limits, while keeping *βρ* finite, corresponds to a dense naive repertoire but where each naive cell weakly covers the antigenic space. In this limit we recover the model of the main text
with .

## Appendix B: Transition from monoclonal to naive phase at *σ*_{υ} = 0

Here we derive an expression for the phase boundary between the monoclonal and polyclonal phases in the limit *σ*_{υ} = 0, where the virus does not move.

In the special case where *μ* = 0, clonotypes cannot multiply. At each time step, a number *m*_{n} of new clonotypes at created at *a*_{n} = const, distributed according to a Poisson law of mean . This number is added to existing clonotypes, of which a random fraction *γ* survives. If the previous number of clonotypes, *M*_{n}, is Poisson distributed with mean , the number of surviving ones *M*′_{n} is also Poisson distributed with mean (since subsampling a Poisson-distributed number still gives a Poisson law). Then, the new number of clonotypes, *M*_{n+1} = *M*′_{n} + *m*_{n}, is also Poisson distributed, with the recurrence relation:

At steady state, we have

Since all clonotypes are at *x* = *a*_{n}, the coverage is *C*(*a*_{n}) = *M*, so that the expected cost reads:

To find the transition from monoclonal to naive, = 0, we need to find the value of *ϕ* for which changes sign at : if this derivative is positive, it is better to have (since the function is convex); if it is negative, there is benefit to be gained by increasing . The condition:
gives the transition point

For *μ* > 0, we redefine *M*_{n} as the sum of all clonotype sizes, which is equal to the coverage, The recurrence relation is replaced by:

For *γ*(1 + *μ*) > 1, this number explodes, so that *M* is infinite, reducing the infection cost to 0 regardless of . The transition point is then

For *γ*(1 + *μ*) < 1, reaches a steady state value,

Although *M*_{n} is not strictly distributed according to a Poisson law, it is still a good approximation, so that we can repeat the same argument as with *μ* = 0,

## Appendix C: Solutions to the simplified model of section “Analytical results in a solvable model”

Here we derive a general expression for the simplified model defined in the second *Results* subsection of the main text in integral form. Then we derive analytically the boundaries of the phase diagram, as well as an approximate solution in the polyclonal phase. Finally we give exact analytical expressions for the 1-dimensional case.

The simplified model is defined by the following cost:
where *I*_{t} = *ϕ* if *C*(*a*_{n}) = 0, and *I*_{t} = 0 if *C*(*a*_{n}). In addition, all memories die after their first use, which is realized by *γ* = 0.

## 1. General formulation

Define *P*_{hit}(*σ*′, *r*_{0}, *r*) as the probability that a random memory will recognize the next infection at distance *r*, i.e. the probability that a random point in the ball of radius *σ*′ and a point at distance *r* from its center are at distance ≤ *r*_{0}. The probability that none of *m* clonotypes recognize the virus, where *m* is drawn from a Poisson distribution of mean , reads:

The best strategy maximizes this probability, averaged over the location of the next infection, over *σ′*:
where is the ball of radius *σ′*_{υ}, *V*_{d} = *π*^{d/2}/Γ(*d*/2 + 1) is the volume of a unit ball, and *S*_{d} = 2*π*^{d/2}/Γ(*d*/2) the area of the unit sphere.

Then the expected overall cost reads:

## 2. Exact location of the phase transitions, and approximate solution in the polyclonal phase

The location of the optimal *σ′* may be rigorously bounded from above and below. If *σ*′ < *σ*′_{υ} − *r*_{0}, then only part of the future positions of the virus are covered, so increasing *σ*′ can bring no harm. Likewise, for *σ*′ > *σ*′_{υ} + *r*_{0}, memory covers parts of the antigenic space that have no chance of harboring the next virus, so that decreasing *σ*′ is also always advantageous. Thus, the optimum *σ*′* must satisfy:

As already argued in the main text, when *σ*′_{υ} < *r*_{0}, there is clearly no benefit to having *σ*′ > 0, so the optimum is reached at *σ*′ = 0. (C5) further shows that if *σ*′_{υ} > *r*_{0}, then *σ*′* > 0, so that a polyclonal phase is optimal. As a consequence, the transition from the monoclonal to polyclonal phases happens exactly at

In the monoclonal phase, memory always recognizes the next virus. The only risk of paying *ϕ* is when no memory is created, which happens with probability , so that the cost reads:

The optimal cancels at the monoclonal-to-naive transition:

In the polyclonal phase, we could not find a general analytical solution, but there are two limits in which the solution may be calculated. The first limit is when *σ*_{υ} ≫ *r*_{0}. In that case, (C5) implies *σ*′* ≈ *σ*′_{υ}, and
which doesn’t depend on *r*. Then, minimizing
with respect to yields:

The second limit in which things simplify is for small . Then the exponential in (C3) may be expanded at first order, yielding:
where ⟨ ·⟩* _{r}* is the mean of over the ball of radius

*σ*′

_{υ}. Minimizing with respect toi

*σ*′ is equivalent to maximizing ⟨

*P*

_{hit}(

*σ*′,

*r*

_{0},

*r*)⟩

_{r}, which is the probability that a random point in the ball of radius

*σ*′ and a random point in the ball of radius

*σ*′

_{υ}are separated by less than

*r*

_{0}. This probability is maximized for any

*σ*′ ≤

*σ*

_{υ}−

*r*

_{0}, where it is equal to (

*r*

_{0}/

*σ*′

_{υ})

^{d}. Increasing

*σ*′ beyond

*σ*

_{υ}−

*r*

_{0}can only lower the probability of recognition. Thus:

This gives us the condition for the transition from polyclonal to naive, where . This happens when

This condition gives us an exact expression for the location of the transition.

## 3. Exact solution in dimension 1

For *d* = 1, the cost in (C4) may be calculated analytically, by using exact expressions of *P*_{hit}(*σ*′*, r*_{0}*, r*). When *σ*′_{υ} ≤ *r*_{0}, the optimal *σ*′ is zero as explained in the main text. When *σ*′_{υ} > *r*_{0}, we distinguish two cases: *r*_{0} < *σ*′_{υ} ≤ 2*r*_{0}, and *σ*′_{υ} > 2*r*_{0}.

*Case r*_{0}<*σ*′_{υ}≤ 2*r*_{0}. Since we know that the optimal*σ*′ is between*σ*′_{υ}–*r*_{0}and*σ*′_{υ}+*r*_{0}, we focus on that range. Then there are two subcases for*σ*’.If

*σ*′_{υ}−*r*_{0}<*σ*′ ≤*r*_{0}, there are two contributions to the integral of over the position of the virus*r*. Either*r*≤*r*_{0}−*σ*′, then all memories recognize the virus,*P*_{hit}= 1; or*r*_{0}–*σ*′ <*r*<*σ*′_{υ}<*r*_{0}+*σ*′, in which case the recognition probability is given by the normalized intersection of two balls at distance*r*of radii*σ*′ and*r*_{0},Thus we obtain doing the integral over

*r*in (C3):If

*r*_{0}<*σ*′ ≤*σ*′_{υ}+*r*_{0}, there are also two contributions. Either*r*≤*σ*′ –*r*_{0}, in which case there is no boundary effect, and the recognition probability is just*P*_{hit}=*r*_{0}/*σ*′_{υ}; or*σ*′ –*r*_{0}<*r*≤*σ*′_{υ}≤*σ*′ +*r*_{0}, in which case we have again (C15).Performing the integration in (C3) we obtain:

Numerical analysis shows that (C16) admits a minimum as a function of

*σ*′ in its interval of validity,*σ*′_{υ}–*r*_{0}<*σ*′* ≤*r*_{0}, while (C17) is always increasing.*Case σ*′_{υ}> 2*r*_{0}. In this case, there is only a single subcase in the range of interest*σ*′_{υ}−*r*_{0}and*σ*′_{υ}+*r*_{0}. This case is the same as the previous one considered, and the result is given by the same formula (C17). However, for*σ*′_{υ}> 2*r*_{0}, this expression now admits a minimum*σ*′_{υ}−*r*_{0}<*σ*′* ≤*σ*′* +*r*_{0}.We recover that in both cases (a and b), in the limit , this minimum is reached at

*σ*′_{υ}−*r*_{0}.

## Appendix D: Population dynamics in sequential immunization

## 1. Clonotype growth and decay as a first-passage problem

We now want to study clonotype proliferation induced by a recall response. We focus on the limit of small mutation rates *σ*_{υ} ≪ *r*_{0}. Within this regime, the system is in the monoclonal phase with *σ** = 0. We can therefore focus on the case of a single clonotype at position *x* = 0 on the phenotypic space, and ask how successive challenges will modify its size. (Different initial conditions will only change the prefactor in front of the exponential modes in the distribution of first passage times, so the large time behavior of this probability distribution will be the same as discussed below.)

The clonotype has an initial size *n* = 1, and the virus drifts away from *x* = 0 with viral divergence *σ*_{υ}. In the general model, cells have probability *γ* to survive from one challenge to the other. Proliferation is taken to be proportional to the cross reactivity radius, . The population dynamics is thus given by the approximate recursion:
where we have neglected birth-death noise. We can further simplify this equation to , where is defined as the radius at which the net fold-change factor crosses 1, i.e. when birth is exactly compensated by death. This means that, as long as the virus is within distance *r**, the clonotype grows with fold-change factor ~Γ. As soon as it reaches *r**, and neglecting possible returns below *r** (which happen with probability 1 for *d* ≤ 2, but with a frequency that does not affect the overall decay), it will decay with fold-change factor ~*γ*. The problem is thus reduced to determining the first-passage time of the viral antigenic location at radius *r**.

We use a continuous approximation corresponding to a slowly evolving strain, *σ*_{υ} ≪ *r*_{0}:
where *W* is a Wiener process. The radius is given by *r*(*t*) = |*a*(*t*)|.

## 2. First passage time in *d* = 1

The distribution of first passage time, *p*(*t*), can be computed solving diffusion with a box of size 2*r** in *d* = 1 [61]:

The dominant term (*n* = 0) at long times gives an exponential decay:

## 3. First passage in higher dimensions

We define *f* (*r, t*) as the probability density that the virus has not yet reached *r** at time *t*, and is at radius *r*.

This probability density is solution to the diffusion equation with spherical symmetry and absorbing boundary conditions in arbitrary dimension *d* > 1:

Assuming separation of variables, *f* (*r, t*) = *T* (*t*)*R*(*r*), we have:
where *λ* is to be determined later. This implies solution to:
where *C* is a constant. The radial part *R*(*r*) is

For *d* = 1 this equation reduces to a harmonic equation and we recover the above solution in 1D. Using the change of variable *R*(*r*) = *r*^{1−d/2}*g*(*r*) we derive the following equation:

Changing the variable , the function is solution to the Bessel differential equation of order *d*/2−1. It can therefore be written as a superposition of a Bessel function of the first kind and a Bessel function of the second kind, both of order *d/*2 − 1. The Bessel function of the second kind having a singularity at *x* = 0, our solution is only given by the Bessel function of the first kind . The radial function *R* now reads:

The absorbing boundary condition at *r = r** gives us the condition , which has an infinite number of solutions *j*_{0,d/2−1}, … , *j*_{n,d/2−1}, … , so that *λ* can take values

The general solution to (D5) is given as a linear combination of all possible modes, with coefficients *C*_{n} determined from boundary conditions and the Dirac delta initial condition, *f* (*r*, 0) = *δ*(*r*):

The distribution of first passage times asymptotically follows the largest mode of this series, *n* = 0, so that:

For instance for *d* = 2, 3, 4 we have *j*_{0,0} ≈ 2.40483, *j*_{0,1/2} = *π*, *j*_{0,1} ≈ 3.83171.

## 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].↵