1 Introduction

Within the host body, the virus infects target cells, increases the number of copies using host cell machinery, and is transmitted to the uninfected target cells. The replication error of their genome may produce mutants that are more efficient in some key steps of the viral life cycle. The mutants with a faster rate of proliferation or a weaker suppression by immunity than the original strain (or wild-type virus) would increase in number and replace the wild-type strain within the host. However, because these mutants start from a small number of infected cells (often a single infected cell), they suffer strong stochasticity, driving them to extinction. As a result, a considerable fraction of these advantageous mutants go extinct because of the stochasticity caused by the small number of infected cells. While the number of infected cells is small, stochasticity dominates the dynamics of the mutant strain. Once their number becomes sufficiently large, their deterministic increasing ability dominates stochasticity, and extinction becomes unlikely.

In a previous study (Hayashi et al. (2022)), we calculated the fraction of mutants that can escape stochastic extinction, based on a continuous-time branching process with a time-dependent growth rate. The chance for a mutant strain to be established decreases with the time since the infection of the wild-type strain, and it shows damped oscillation before convergence to the low stationary value. We also calculated the probability of escaping stochastic extinction for a drug-resistant mutant when a patient received an antiviral drug that suppressed the wild-type strain. Combining the rate of mutant production from the wild-type strain and the chance of escaping stochastic extinction, the number of emerging drug-resistant mutations may have two peaks: one soon after the infection of the wild-type strain and the second at the start of antiviral drug administration (Hayashi et al. 2022). However, the previous study did not consider the effect of the immune system, which is activated by the abundant wild-type strain and may partially suppress the proliferation of mutant strains.

In the present paper as a sequel to Hayashi et al. (2022), we study the probability of escape from initial stochastic extinction owing to the small number of infected cells when the mutant and the wild-type strains differ in their ability to stimulate immune responses. We evaluate how the fraction of mutants that survive stochastic extinction changes with the time at which they are produced. To illustrate, we consider the following scenario: before the viral infection, the number of target cells in the host was maintained at equilibrium. At a certain time, the host becomes infected with a viral strain that proliferates rapidly, reducing the number of susceptible target cells and activating the immune system. The proliferation of the virus is suppressed by the shortage of susceptible target cells and by the immune activity, leading to a stationary abundance of infected and target cells. Mutant strains may be produced owing to mistakes in the genomic replication of the original viral strain (or wild-type virus). Some of these are advantageous because they proliferate faster or evade immune surveillance more effectively than the wild-type strain. However, they suffer a high risk of stochastic extinction owing to the small number of infected cells.

We apply the mathematical analysis adopted in Hayashi et al. (2022) to the case with immune reaction of the host. To make the analysis of branching process applicable, we consider the escape (establishment) probability of a mutant virus under the following setting (see Fig. 1 for the scheme of the model): The number of cells infected by the wild-type strain is sufficiently large and their dynamics can be handled by a differential equation, deterministic dynamics. In contrast, a mutant strain starts from a single infected cell and has a high chance of stochastic extinction. Because the number of cells infected by the mutant virus is small, the reduction in susceptible target cells due to infection by the mutant strain can be neglected in the dynamics of target cells. In contrast, the proliferation rate of the mutant critically depends on both the abundance of susceptible target cells and the intensity of the immune reaction.

Fig. 1
figure 1

Schematic of the model. The four variables indicated in circles are the number of target cells \(x\), the number of cells infected by the wild-type strain \(y\), those infected by the mutant strain \(z\), and the number of killer T cells \(w\). We consider the situation in which \(z\) is small and requires consideration of stochasticity in the dynamics of \(z\). In contrast, because three other variables are much larger than unity, we can adopt deterministic dynamics for them. We focus on the time frame in which \(z\) does not affect the dynamics of \(x\), \(y\), and \(w\), rather the dynamics of \(z\) are strongly affected by \(x\) and \(w\), both of which depend on time

Under this setting, the fate of a lineage starting from a single cell infected by a mutant strain is independent of the presence or the prevalence of other mutant strains. The independence between lineages is the key assumption that allows us to adopt branching process calculation (see (Hayashi et al. 2022)). The number of mutant-infected cells follows a continuous-time branching process, where the mean rates of proliferation and mortality change with time following the dynamics of the target cells and immune activity. We derive a differential equation for the escape (establishment) probability of a mutant \(p\left(t\right)\) as a function of the time \(t\) at which the mutant is produced. We obtain an explicit mathematical formula for \(p\left(t\right)\). The escape probability of a mutant \(p\left(t\right)\) exhibits characteristic temporal patterns: it starts at a high value, then decreases with time, and converges to a stationary level after damped oscillation. We examine the parameter dependence of the temporal pattern of escape probability and the number of novel mutant viruses produced in a single patient.

2 Model

Let \(x\), \(y\), and \(w\) be the number of susceptible target cells, number of cells infected by the wild-type virus, and number of immune effector cells (e.g., activated killer T cells), respectively (see Fig. 1). We consider the following dynamics:

$$\frac{dx}{dt}=\lambda -cx-bxy$$
(1a)
$$\frac{dy}{dt}=bxy-hwy-\delta y$$
(1b)
$$\frac{dw}{dt}=ay-dw$$
(1c)

Equation (1a) indicates the dynamics of susceptible target cells. The first term on the right-hand side indicates the supply of target cells at rate \(\lambda\) and the second term indicates the loss of target cells with a turnover rate of \(c\). Without viral infection, the target cells have a mean longevity of \(1/c\). The third term indicates the rate of infection of the target cells by the virus, which is proportional to the number of infected cells \(y\).

Equation (1b) indicates the dynamics of the number of cells infected by the virus. The first term on the right-hand side is the total rate of infection (transition from susceptible cells to infected cells), which is the same as the third term in Eq. (1a). The second term indicates the removal of infected cells by the action of cytotoxic T lymphocytes (i.e., killer T cells), and the third term indicates the mortality of infected cells by other processes. The instantaneous mortality of the infected cells is \(hw+\delta\), which increases linearly with the number of active killer T cells \(w\).

Equation (1c) gives the dynamics of the number of active killer T cells. They are formed by the activation of naïve killer T cells through the action of antigen-presenting cells, and subsequent proliferation by cell division of a finite number of times. The rate of production of active killer T cells is proportional to the abundance of viral antigens, which increases with the number of infected cells \(y\). The proportionality coefficient is \(a\), as indicated in the first term on the right-hand side. This functional form was called "linear immune response" by Nowak and May (2000) and was adopted in Iwasa et al. (2021). In the following analysis, we adopt this simplest form, although more complex functional forms of immune activation have also been studied (Boer et al. 2001). The second term on the right-hand side is the loss of activated killer T cells owing to mortality at rate \(d\). The mean lifetime of killer T cells is \(1/d\). If we neglect the function of killer T cells (either \(h=0\) or \(w=0\)), the model is the same as that used in our previous study (Hayashi et al. 2022).

Because \(x\), \(y\) and \(w\) are large numbers, we can assume them as the deterministic differential equations given in Eq. (1). Figure 2 illustrates the case with the following scenario: Initially, there was no virus (\(y=0\)). The abundance of the target cells was calculated using Eq. (1a) with \(y=0\), and converged to \(x=\lambda /c\). The wild-type virus then invaded with a very low initial abundance. For simplicity of argument, we set the infection time to \(t=0\). We denoted the initial abundance of the virus as \(y\left(0\right)=\varepsilon\), where \(\varepsilon >0\) was positive but much smaller than \(\lambda /c\). Viral prevalence \(y\) measured in terms of the number of infected cells increased and then decreased because the target cells decreased and killer T cells \(w\) increased in number. Finally, it converged to a positive value \(y\left(\infty \right)\). At equilibrium, the abundance of susceptible target cells \(x\left(\infty \right)\) and the intensity of immune reactions \(w\left(\infty \right)\) were positive.

Fig. 2
figure 2

Time dependent solutions. a Numbers of susceptible target cells \(x\left(t\right)\), infected target cells \(y\left(t\right)\), and killer T cells \(w\left(t\right)\). The horizontal axis represents time \(t\) at which the mutant is produced. b Escape probability of a mutant virus starting from a single infected cell at time \(t\), \(p\left(t\right)\). Two curves are for different \(h^{{\prime } }\): \(h^{{\prime } }\)\(=0\), and \(h^{{\prime } } = 2 \times 10^{ - 5} ( < h)\). Other parameters were: \(a=10\), \(b=2.5\times {10}^{-4}\), \(c=1\), \(d=5\), \(\delta =5\), \(\lambda =5\times {10}^{4}\), \(h=5\times {10}^{-5}\), \(b^{{\prime } } = 3 \times 10^{ - 4}\), and \(\varepsilon =100\)

The mutants are produced from the original (wild-type) strain at a very low rate. Because a newly produced mutant strain starts from a single infected cell, it has a high risk of extinction even if it has a positive mean growth rate. The escape probability of a mutant strain depends on the time \(t\) at which the mutant is produced (\(t>0\)). The mean per capita rate of increase of the mutant infected cells decreases with time because the abundance of target cells \(x\left(t\right)\) declines and the immune reaction \(w\left(t\right)\) increases as the wild-type strain proliferates. Hence, mutants produced earlier have a higher chance of escape than those produced later.

The mutant has an infection rate \(b^{{\prime } }\) and the effectiveness of immune reaction \(h^{{\prime } }\) (i.e. efficiency of cytotoxic T lymphocytes), which may differ from the corresponding rates for the wild-type strain (\(b\) and \(h\), respectively). Because the mutant is produced from the wild-type viral strain, we consider the situation in which the wild-type virus has a positive abundance. This precludes the case of \(\lambda /c\le \delta /b\), for which the wild-type strain cannot be maintained in the host body (Appendix A). Hence, we assume \(\lambda /c>\delta /b\) in the following.

To simplify the mathematical analysis, we assume that the stochasticity caused by the small number of infected cells is important for the mutant strain, but not for the wild-type strain. Even if the initial abundance of the wild-type strain \(y\left(0\right)=\varepsilon\) is much smaller than the abundance of the susceptible target cells, it can be sufficiently larger than 1. The dynamics of \(x\), \(y\), and \(w\) are then described by the deterministic dynamics given by Eq. (1).

Let \(z\) be the number of cells infected with the mutant strain. It is produced by rare mutations at the time of replication of the wild-type strain. We assume that \(z\) starts from 1. The dynamics of \(z\) can be expressed as:

$$\frac{dz}{dt}={b}^{{{\prime }}}xz-{h}^{{{\prime }}}wz-\delta z+[\mathrm{stochastic fluctuation}]$$
(2)

where the last term on the right-hand side indicates stochastic fluctuation with a mean of zero. If the infection rate of the mutant strain is higher than that of the wild-type strain (\(b^{{\prime } } > b\)), the immune suppression on the mutant is weaker than that on the wild-type strain (\(h^{{\prime } } < h\)), or both, \(z\) increases on average over time (otherwise the mutant becomes extinct with probability one). However, the stochasticity caused by the small number of cells results in the extinction of mutant with a considerable probability. Once the abundance of the number of infected cells becomes sufficiently large, the effect of stochasticity is weaker than the deterministic rate of increase, and thereafter the cell number \(z\) continues to increase exponentially.

Because we focus on the situation in which the number of target cells infected by the mutant strain is much smaller than that of cells infected by the wild-type virus, we neglect the effect of the mutant strain on the abundance of susceptible target cells. Hence, Eq. (1a) does not contain a term for \(z\).

3 Escape Probability of a Mutant

We represent the dynamics of the number of infected cells by stochastic process in which \(z\) is an integer (\(z=0, 1, 2, 3,..\).). For simplicity of mathematical analysis, we first consider the viral transmission by cell-to-cell contact, in which an infected cell encounters a susceptible cell and infects it at a rate proportional to \(x\left(t\right)\). The transmission via cell-to-cell contact was proved in the experiment with HIV (Iwami et al. 2015). Alternatively, viruses may proliferate to produce free viral particles that infect susceptible cells, in which a single infected cell ruptures, resulting in a number of newly infected cells with a Poisson distribution. The latter model for viral proliferation will be discussed later.

Equation (2) indicates that \(z\) increases with infection \(b^{{\prime } } x\left( t \right)z\) and decreases with mortality \(\left( {h^{{\prime } } w\left( t \right) + \delta } \right)z\), which are both proportional to \(z\), suggesting that these events occur independently between infected cells. Thus, we can handle the stochastic change in \(z\) by focusing on the events experienced by a single infected cell. Suppose that a cell infected by a viral strain infects many other cells by transmission of the virus. Then, we regard these cells as "descendants" of the wild-type cell in this study. This usage of "lineage terminology" is useful for explaining the model, in which we treat the virus as a focal agent, and cells as their habitat (Hayashi et al. 2022).

We consider a single cell infected by the mutant strain at time \(t\) and ask the provability of the lineage not to extinct within a finite time. This can be calculated by considering \(p\left(t\right)\) as the probability that the lineage starting from the focal cell does not go extinct by time \(T\), and examining the limit when \(T\) is infinitely large. To derive the differential equation for \(p\left(t\right)\), we decompose it according to the alternative events occurring in a short interval from \(t\) to \(t+\Delta t\), which are given as follows.

  1. (i)

    The cell encounters with an uninfected target cell and virus is transmitted (generating two "offspring" cells) with a probability \(b^{^{\prime }}x\left( t \right){\Delta }t\).

  2. (ii)

    The cell dies with a probability \(\left( {h^{{\prime } } w\left( t \right) + \delta } \right){\Delta }t\).

  3. (iii)

    The cell remains unchanged with probability \(1 - b^{{\prime } } x\left( t \right){\Delta }t - \left( {h^{{\prime } } w\left( t \right) + \delta } \right)\)\(\Delta t\)

In these three events, the number of infected cells are (i) two, (ii) zero, and (iii) one, respectively. Then, we have the following equation:

$$p\left( t \right) = b^{{\prime } } \left( {t } \right) x\left( t \right)\Delta t{p}_{2}\left(t+\Delta t\right) +\delta\Delta t\cdot0 + \left(1 - b^{{\prime } } x\left( t \right){\Delta }t - \left( {h^{{\prime } } w\left( t \right) + \delta } \right)\Delta t\right)p\left( t +\Delta t\right) + o\left( {{\Delta }t} \right)$$
(3)

where \({p}_{2}\left(t+\Delta t\right)\) is the probability that the lineage starting from two initial cells at time \(t+\Delta t\) does not go extinct by time \(T\). This explains the first term on the right-hand side of Eq. (3). If the cell dies by \(t+\Delta t\), the probability for the focal lineage to escape by time \(T\) is zero, which explains the second term on the right-hand side of Eq. (3). The third term is the case when the infected cell remains unchanged.

The behavior of the lineages starting from different cells is assumed independent of each other, which is a key premise of branching process. We have \({p}_{2}\left(t\right)=1-{\left(1-p\left(t\right)\right)}^{2}\) because the extinction of descendants starting from two cells is equivalent to the extinction of both lineages starting from one cell. The last term in Eq. (3), \(o\left(\Delta t\right)\), indicates a small quantity of higher order than \(\Delta t\), which satisfies \(o\left(\Delta t\right)/\Delta t\to 0\) when \(\Delta t\to 0\). Hence, as \(\Delta t\to 0\), Eq. (3) becomes the following:

$$-\frac{dp}{dt}=b^{\prime }x\left(t\right)p\left(t\right)\left[1-p\left(t\right)\right]-\left(h^{\prime }w\left(t\right)+\delta \right)p\left(t\right)$$
(4)

For detailed explanation of the derivation of Eq. (4), see Appendix B.

We can calculate \(p\left(t\right)\) by integrating Eq. (4) with respect to \(t\) using the terminal condition \(p\left(T\right)=1\). Because we here ask whether or not a newly produced mutant virus can be established in the target cell population, we consider the behavior at the limit \(T\to \infty\). As explained in Appendix B, Eq. (4) can be solved, as follows:

$$p\left(t\right)=\frac{1}{{\int }_{t}^{\infty }b^{\prime }x\left(s\right)exp\left[-{\int }_{t}^{s}\left(b^{\prime }x\left(t^{\prime }\right)-\left(h^{\prime }w\left(t^{\prime }\right)+\delta \right)\right)dt^{\prime }\right]ds}$$
(5)

We first calculate the target cell abundance and immune activities \(\left\{x\left(t\right)\mathrm{ and} w\left(t\right),\mathrm{ for }t>0\right\}\) using Eq. (1). Next, we obtain the escape probability from Eq. (5).

3.1 Trajectories of Escape Probability \({\varvec{p}}\left({\varvec{t}}\right)\)

The vertical axis indicates \(x\left(t\right)\), \(y\left(t\right)\), and \(w\left(t\right)\) in Fig. 2a, and the escape chance of the mutant \(p\left(t\right)\) in Fig. 2b, which is calculated from Eq. (5). The horizontal axis indicates time \(t\). We also performed direct simulations of the stochastic process. An explanation of this method can be found in our previous paper (Hayashi et al. 2022). These results are consistent with the predictions of the mathematical formula.

The escape probability of a mutant \(p\left(t\right)\) starts from the highest value \(p\left(0\right)\) because the wild-type viral type \(y\left(t\right)\), a competitor for the mutant strain sharing the common resources \(x\left(t\right)\), is initially small. As competitor abundance increases, the probability for the focal mutant to establish decreases. Figure 2b illustrates \(p\left(t\right)\) in two cases that differ in the value of \(h^{{\prime } }\), but in which the two stains have the same rate of infection of the target cells (\(b^{{\prime } } = b\)). When the mutant escapes the immune attack developed by the wild-type strain (\(h^{{\prime } } = 0\)), there is no cross-immunity. The mutant has a positive escape probability because it has an advantage over its competitor in that it is not attacked by immunity. When the mutant suffered an immune attack with an intensity lower than that of the wild-type strain (\(0 < h^{{\prime } } < h\)), cross-immunity exists but is weaker than the immunity to the wild-type type. Therefore, \(p\left( t \right)\) is positive but is smaller than that in the case where \(h^{{\prime } } = 0\).

4 Number of Mutations that Escape Stochastic Extinction

The production rate of novel mutants is proportional to the number of infection events per unit time, \(bx\left(t\right)y\left(t\right)\). Because the fraction of novel mutations that can escape the initial high risk of stochastic extinction is \(p\left(t\right)\), the rate of production of novel mutants that will eventually be established is proportional to their product \(f\left(t\right)=bx\left(t\right)y\left(t\right)p\left(t\right)\), although it needs to be multiplied by the mutation rate. We examine this quantity \(f\left(t\right)\) as an indicator of the emergence rate of novel mutants as a function of time \(t\).

An example is shown in Fig. 3. The top part indicates \(x\left(t\right)\), \(y\left(t\right)\), and \(w\left(t\right)\), the middle part illustrates \(p\left(t\right)\), the escape probability. The horizontal axis represents time \(t\). The bottom part of the figure illustrates \(f\left(t\right)\), an indicator of the production rate of mutations surviving stochastic extinction, which has a sharp peak shortly after the start of infection. Let \({\tau }_{f}\) be the time interval between the start of infection with the wild-type strain and the time when quantity \(f\left(t\right)\) attains its maximum value. The height of the peak is \(f\left({\tau }_{f}\right)\). In Appendix C, we show the sensitivities of \({\tau }_{f}\) and \(f\left({\tau }_{f}\right)\) on the parameters in the model in terms of elasticity.

Fig. 3
figure 3

An indicator for the rate of novel mutant production \(f\left(t\right)\). Horizontal axis is the time at which mutants are produced. We can see that the curve for \(f\left(t\right)\) has a sharp peak near the onset of the infection. We numerically calculated the area under the curve between 0 and \({t}_{1}\), the latter being the time for the first local minimum of function \(f\left(t\right)\). We call the size of the shaded area, \({F}_{M}={\int }_{0}^{{t}_{1}}f\left(t\right)dt\), "potential of novel mutant production in the early phase of infection." Standard set of the parameters were: \(a=10\), \(b=2.5\times {10}^{-4}\), \(c=1\), \(d=5\), \(\delta =5\), \(\lambda =5\times {10}^{4}\), \(h=5\times {10}^{-5}\), \(b^{{\prime } } = 3 \times 10^{ - 4}\), \(h^{{\prime } } = 2 \times 10^{ - 5}\), and \(\varepsilon =100\)

Furthermore, we consider the expected number of novel mutants that escape stochastic extinction per patient. The integral of \(f\left(t\right)=bx\left(t\right)y\left(t\right)p\left(t\right)\) over the peak gives the expected number of mutants produced that did not go extinct within the host. Let \({t}_{1}\) be the time at the local minimum of \(f\left(t\right)\) just after the first peak. \({F}_{M}={\int }_{0}^{{t}_{1}}f\left(t\right)dt\) is the potential for novel mutations that escape the stochastic extinction in the early phase of infection. \({F}_{M}\) is proportional to the expected number of novel escape mutations per patient.

Figure 4 illustrates \({F}_{M}\). The horizontal axis is the magnitude of immune pressure \(h\). Because we fixed the ratio \(h^{{\prime } } /h\), a larger \(h\) results in a larger \(h^{{\prime } }\). \({F}_{M}\) is small under both strong and weak immune pressures. \({F}_{M}\) attains a maximum at an intermediate magnitude of immune pressure.

Fig. 4
figure 4

Potential of novel mutant production in the early phase of infection \({F}_{M}\). The horizontal axis represents the strength of immune reaction \(h\), shown in the logarithmic scale. We fixed the ratio \(h^{{\prime } } /h\) \((=0.4)\), and hence a large \(h\) implies a large \(h^{{\prime } }\). Sensitivity analysis showed that \({F}_{M}={\int }_{0}^{{t}_{1}}f\left(t\right)dt\), the potential of novel mutant production in the initial phase, is small both for extremely small \(h\) and extremely large values of \(h\); however, it achieves its maximum at an intermediate rate. Other parameters are the same as in Fig. 3

5 Parameter Dependence

In the current paper and a twin paper (Hayashi et al. 2022), we showed the importance of stochastic extinction of mutant viral strains when they appear in a body of the host. The main aim of these papers is to search for the general property of the system. Numerical examples are simply to illustrate the possibility of the behavior of the model. Research activity of fitting the model to particular situations should be done separately.

Herein, we report the parameter dependence of the model's behavior known from introducing various approximations. Below, we describe the results briefly and the analyses are explained in Appendixes.

5.1 Target Cell Abundance \({\varvec{x}}\left({\varvec{t}}\right)\)

The target cell abundance \(x\left(t\right)\) starts from \(x\left(0\right)=\lambda /c\) and decreases with time (Figs. 2, 3 and 5). The rate of decline is initially slow but becomes increasingly fast, because the abundance of virus infected cells starts from a small value and increases exponentially with time.

Fig. 5
figure 5

Trajectories of the approximate formulas for small \(t\) (Eq. (D.1) in Appendix D). \(x\left(t\right)\), \(y\left(t\right)\), and \(z\left(t\right)\) were accurate for the time close to the infection of the virus. Parameters were the same as in Fig. 3

To characterize the time until \(x\left(t\right)\) to start declining, we consider \({\tau }_{x}\), defined as the time for \(x\left(t\right)\) to reduce by 20% of the initial level: \(x\left({\tau }_{x}\right)=0.8x\left(0\right)\). We numerically derived \({\tau }_{x}\) for different sets of parameters and performed a sensitivity analysis, as explained in Appendix C.

As described in Appendix D, we derive the approximate formulas assuming that \(t\) is small. We define \(\widehat{x}\left(t\right)=x\left(t\right)-\lambda /c\). Then \(\widehat{x}\left(t\right)\), \(y\left(t\right)\), and \(z\left(t\right)\) are of order \(\varepsilon\) for a small \(t\). We derive the linear dynamics for these three variables by neglecting the terms of the higher order with respect to \(\varepsilon\) and solving them explicitly. All three include a dominant term that grows in proportion to \(\varepsilon \cdot exp\left[\eta t\right]\) where \(\eta =b\lambda /c-\delta\). For example, the abundance of the target cells is given by \({x}_{approx}\left(t\right)=\left(\lambda /c\right)\left[1-\left(\varepsilon b/\left(\eta +c\right)\right) \cdot \right.\left.exp\left[\eta t\right]\right]\). As shown in Fig. 5, we plotted this approximation along with the exact solution using Eq. (1). The approximation was accurate for small \(t\); however, the deviation from the exact solution increased with time. The approximate formula for \(x\left(t\right)\) provides an explicit solution for the time taken for the 20% decline in \(x\left(t\right)\) as follows: \({\tau }_{x}=\frac{1}{\eta }log\left(\frac{0.2\left(\eta +c\right)}{\varepsilon b}\right)\) (see Appendix D). This formula underestimates the exact value of \({\tau }_{x}\) but is useful for determining parameter dependence.

After transient behavior including damped oscillation, \(x\left(t\right)\) converges to a stationary value, which can be calculated as the value at the stable positive equilibrium of Eq. (1). See Appendix A for details.

5.2 Escape Probability \(p\left(t\right)\)

Next, we consider \(p\left(t\right)\), the probability for a mutant to be established depending on the time \(t\) at which the mutant is produced.

5.2.1 Initial Value \(p\left(0\right)\)

The escape probability is the highest just after the onset of infection by the wild-type strain (\(t=0\)), and it declines with time because the target cells are consumed and the immune reactions become stronger owing to the increase in the wild-type strain. In Fig. 6, the different parts illustrate the changes in curve \(p\left(t\right)\) when one of the nine parameters is modified. In Appendix C, we numerically performed a sensitivity analysis of \(p\left(0\right)\). The results are summarized as follows: \(p\left(0\right)\) increases with \(b^{{\prime } } /b\), \(\lambda\), and \(b\); it decreases with \(c\) and \(\delta\); however, it is independent of \(h^{{\prime } } /h\), \(h\), \(a\), or \(d\).

Fig. 6
figure 6

Parameter dependence of function \(p\left(t\right)\). We set the standard parameter set, and changed parameters one by one by multiplying 1.2, 1.1, 1.0, \(1/1.1=0.9091\), and \(1/1.2=0.8333\), shown as curves in red, orange, gray, blue, and black, respectively. Parameters are the same as in Fig. 3

The lineage starting from a mutant produced at time \(t\) experiences temporal changes in the availability of target cells \(x\left(t\right)\) and in the intensity of the immune system \(w\left(t\right)\). These changes affect the escape probability. If most extinction events of mutant lineages occur within a short time after mutation, we may be able to calculate \(p\left(t\right)\) using \(x\left(t\right)\) and \(w\left(t\right)\) fixed at the values at which the mutant is produced. Under this approximation, the result is given as follows: \({p}_{SCA}\left(t\right)=1-\frac{h^{\prime }w\left(t\right)+\delta }{b^{\prime }x\left(t\right)}\), which we call "slow-change approximation."

In Appendix E, we explained this approximation in detail. Numerical analysis showed that the approximation was exact for the final stationary value \(\overline{p }=p\left(\infty \right)\) and was relatively close for the initial value \(p\left(0\right)\) when \(p\left(0\right)>0.6.\) However, between these two situations, the formula deviates significantly from the exact value. This is plausible because the time change of \(p\left(t\right)\) was zero for the stationary value and was small near \(t=0\) but very fast between them. The parameter dependence shown in Fig. 6 indicates that the dependence of \(p\left(0\right)\) on the nine parameters is consistent with the slow-change approximation. Further details are provided in Appendix E.

5.2.2 Time Required for \(p\left(t\right)\) to Decline by 20%

Let \({\tau }_{p}\) be the time at which \(p\left({\tau }_{p}\right)=0.8p\left(0\right)\) holds. This is the time for \(p\left(t\right)\) to decrease by 20% of the initial level. We performed sensitivity analyses as explained in Appendix C.

5.2.3 Stationary Value \(\overline{p }\)

After the transient behavior, Eq. (1) converges to a stationary state, which is a stable equilibrium. The escape probability for a novel mutant produced at time \(t\) also reaches its stationary value \(\overline{p }=p\left(\infty \right)\).

According to calculation in Appendix A, the stationary value of escape (establishment) non-extinction probability \(\overline{p }\) is affected by parameters as follows (summarized in Fig. 7 in Appendix A): \(\overline{p }\) is determined by the relative rates of infection \(b ^{\prime } /b\) and immune removal \(h ^{\prime } /h\). In addition, \(\overline{p }\) also depends on \(\Omega =hw/\delta\), which is the immune removal relative to the natural mortality of cells infected by the wild-type strain. All other parameters affect \(\overline{p }\) by modifying \(\Omega\), which is the positive solution of the quadratic equation, \(1=\left(\Omega +1\right)\left(\frac{\delta c}{\lambda b}\Omega +\frac{{\delta }^{2}d}{\lambda ah}\right)\). The importance of immunity compared to natural mortality \(\Omega\) increases with the efficiency of the immune reaction to remove infected cells (\(ah/d\delta\)), the rate of infection of susceptible target cells (\(b/c\)), and the rate of supply of target cells (\(\lambda /c\)), as illustrated in Fig. 7 in Appendix A.

Fig. 7
figure 7

Scheme of the dependence of the stationary level of escape probability \(\overline{p }\). It increases with ratio \(b^{{\prime } } /b\) and decreases with ratio \(h^{^{\prime }}/h\). In addition, it also depends on other parameters via \(\Omega\), the importance of mortality by immune killing relative to random mortality. We assumed \(0 < h^{{\prime } } < h\). Other parameters are the same as in Fig. 3. See Appendix A for derivation

In the following two cases, we can obtain simple results:

Case 1. When the immune efficiency is the same between strains.

If \(h ^{\prime } /h=1\) holds, the immune system activated by the wild-type strain operates on the mutants at the same strength (perfect cross-immunity). The stationary probability of escaping stochastic extinction is \(\overline{p }=1-b ^{\prime } /b\) (see Appendix A for the derivation). This is the same as in our previous study (Hayashi et al. 2022), where the dynamics of the immune reaction were neglected. In the current paper, \(p\left(t\right)\) depends on the dynamics of the immune reaction \(w\left(t\right)\); however, the stationary value \(\overline{p }\) is independent of the immune system.

Case 2. When the rate of infection of target cells is the same between strains.

By setting \(b ^{\prime } /b=1\), we have \(\overline{p }=\left(1-\frac{h ^{\prime } }{h}\right)\frac{\Omega }{\Omega +1}\), where \(\frac{\Omega }{\Omega +1}\) indicates the fraction of mortality of infected cells killed by immune reactions, instead of natural mortality. The probability of escaping extinction is possible when the cross-immunity is weaker than perfect (i.e. \(0<h ^{\prime } <h\)).

Figure 6 indicates that \(\overline{p }\) increases with \(b ^{\prime } /b\) and decreases with \(h ^{\prime } /h\). It also increases with \(\lambda\), \(a\), \(b\), and \(h\) but decreases with \(c\), \(d\), and \(\delta\). These results are consistent with the parameter dependence of \(\overline{p }\) (see Appendix C).

6 Discussion

Pathogens threaten the lives of many organisms including human beings. Vertebrates have developed acquired immunity that prevents infection by the same pathogen twice. However, pathogens evolve by mutation to escape from the hosts’ immune responses. RNA viruses have a high mutation rate and exhibit rapid evolutionary adaptation, causing medical problems such as drug resistance and escape from immune surveillance ((Goulder et al. 1997; Althaus and Bonhoeffer 2005)). Hence, evaluating the emergence rate of mutants within a host is essential for disease control and medical treatment.

Grenfell et al. (2004) proposed “phylodynamics,” a methodology that predicts the epidemic dynamics of RNA viruses by considering viral evolution. In phylodynamics, the frequency and periodicity of pandemics were analyzed using epidemic models incorporating both the dynamics of host immunity and pathogen immune evasion. RNA viruses differ greatly in their epidemic dynamics and evolutionary patterns. These differences can be explained by the differences in the evolutionary potential of viruses to evade host immunity by mutation (antigenic drift) (Koelle et al. 2006; Lewis et al. 2008; Volz et al. 2013; Suchard et al. 2018; Saad-Roy et al. 2021). For example, measles with strong cross-immunity exhibits a highly synchronized and periodic infection. On the other hand, influenza A virus has immunity of intermediate strength, showing recurrent emergence of antigenically-different strains every year and an elongated molecular phylogeny of the virus (Grenfell et al. 2004).

The role of immune escape by mutant strains is also important in the within-host dynamics as well as in epidemiological dynamics. The immune system activated by the wild-type strain may remove cells infected by the mutant strain if they are similar in antigen type (cross-immunity). Many models have been studied to analyzed virus evolution under the influence of immune system (Nowak and May 2000). Most of these models of viral evolution within a host were deterministic. However, because of the stochasticity caused by the small initial number of cells, a large fraction of novel mutations go extinct even if they have a positive mean growth rate in the corresponding deterministic dynamics. This extinction may have a strong influence to the dynamics and evolution of the virus. For example, Sasaki and Haraguchi (Sasaki and Haraguchi 2000) highlighted that the loss of novel mutant viruses with a positive growth rate results in a prolonged existence of antigen drift within a host, rather than an explosion in the diversity of strains (Sasaki and Haraguchi 2000; Haraguchi and Sasaki 1997; Sasaki et al. 2012).

6.1 Expected Number of Mutants that Escape Immune Surveillance

In our previous paper (Hayashi et al. 2022), we studied the temporal pattern of the probability of escape of a novel mutant virus within a target cell population of a host. However, we did not consider the effects of the host immune system. As a sequel, in the current paper, we studied the probability of establishing novel mutations when they experience cross-immunity that is weaker than the one attacking the wild-type strain. We again formalized the model as a continuous-time branching process when the growth rate and mortality of infected cells are given as functions of time. Unlike in Hayashi et al. (2022), we need to consider the time dependence of mortality caused by the immune system.

The rate of production of novel mutants that survive stochastic extinction is proportional to \(f\left(t\right)=bx\left(t\right)y\left(t\right) \cdot p\left(t\right)\), the product of the number of infection events per unit time and the fraction of mutants that can escape the stochastic extinction risk. The potential emergence rate of novel mutants escaping extinction \(f\left(t\right)\) had a sharp peak soon after infection with the wild-type virus (Fig. 3).

We observed that \({F}_{M}\), potential of novel mutations per patient produced during the initial phase of host infection, increased with cell-to-cell contact infection rate and decreased with susceptibility to cross-immunity, both being relative to the values of the wild-type strain (\(b ^{\prime } /b\) and \(h ^{\prime } /h\), respectively). If we fix these ratios, the expected number of novel mutations per patient attains its maximum in the case of immune activity of intermediate strength (see Fig. 4).

This result reminds us of how the rate of adaptation of RNA virus at the population level depends on host immunity. By studying epidemic dynamics incorporating immune reactions and viral evolution, Grenfell et al. (2004) observed that the evolutionary adaptation of RNA viruses to escape immunity occurs at the highest speed when the immune pressure is of intermediate strength. This is because very strong immune reactions quickly suppress the wild-type virus, making the number of mutations small, but very weak immune reaction does not favor mutants escaping immunity. Many subsequent theoretical studies incorporating the evolution of escape from immune surveillance have confirmed the usefulness of the phylodynamics concept (Koelle et al. 2006; Lewis et al. 2008; Volz et al. 2013; Suchard et al. 2018; Saad-Roy et al. 2021). Although it was proposed for epidemiological dynamics, a similar conclusion can be drawn for the viral dynamics within a single patient, as shown in the current study (Fig. 4).

6.2 Viral Transmission Through Free Viral Particles

Many viruses proliferate within the host body by producing free viral particles that infect susceptible target cells, instead of cell-to-cell contact transmission. We examined the probability of escape of a mutant virus proliferating through free viral particles in the presence of immune responses activated by the wild-type strain by the following stochastic model similar to that in Hayashi et al. (2022): the proliferation event of an infected cell occurs at rate \(r\) (i.e., an infected cell makes contact with an uninfected target cell and made the latter infected). At each event, the number of cells newly infected by viral particles produced from the infected cell follows a Poisson distribution with mean \(\beta x\), proportional to the number of susceptible target cells. Simultaneously, the wild-type infected cell ruptures. The dynamics of \(x\), \(y\), and \(w\), given by Eq. (1) hold if \(b\) is replaced by \(r\beta\) and \(\delta\) is replaced by \(\delta +r\) (see Appendix F for details). Hence, a positive stable equilibrium exists if \(\lambda /c>\left(1/\beta \right)\left(1+\delta /r\right)\) holds (otherwise, no virus exists in the stable equilibrium). After a transient phase, \(x\left(t\right)\) and \(w\left(t\right)\) converge to the stationary levels. These are calculated by the dynamics given in Eq. (1).

The stochastic process of the abundance of a mutant strain is described by a branching process with time-dependent rates. We again considered \(p\left(t\right)\), the escape probability of a mutant strain produced at time \(t\). In Appendix F, we derived a differential equation for \(p\left(t\right)\) and solve it numerically. We obtained \(p\left(t\right)\) using a numerical integral with a sufficiently large \(T\). The behavior of the model was similar to that of cell-to-cell contact transmission (see Appendix F).

6.3 Stochastic Extinction of Advantageous Mutations

Stochastic extinction due to the small number of individuals plays an important role in many different fields of biology and medicine. For example, in evolutionary genetics theory, many advantageous mutations go extinct owing to stochasticity because they start from a small number. The fraction of novel mutants that can escape the extinction was first estimated by branching processes (Haldane 1927; Fisher 1930), which were extended to cover various aspects (Barton 1995; Johnson and Barton 2002; Oliveira and Campos 2004; Haccou et al. 2005; Peischl and Kirkpatrick 2012). A different line of mathematical formalism was based on diffusion processes, which handled the fixation of slightly deleterious mutations as well as the loss of advantageous mutations (Kimura 1957, 1962; Ohta 1972). In infectious diseases dynamics, branching process formalism provides tools for designing disease control strategies (Nishiura et al. 2012, 2017; Nakajo and Nishiura 2021). The stochastic extinction of small number of mutant cells is important in the study of the initiation and progression of cancer. The probability of cancer escaping drug or immune surveillance has been analyzed using stochastic processes (Iwasa et al. 2003, 2004, 2006; Michor et al. 2006; Foo et al. 2014).

The stochasticity plays important roles in many different aspects of viral dynamics and evolution within a host, which can be important themes of future theoretical studies. When a patient receives an antiviral drug treatment that suppresses the proliferation of the wild-type viral strain, the virus may mutate to a different antigen type that is resistant to the drug. Theoretical studies have been conducted on the emergence of drug-resistant mutations (Bonhoeffer and Nowak 1997; Ribeiro and Bonhoeffer 2000; Alexander and Bonhoeffer 2012). However, many of them were based on deterministic models. In our previous study (Hayashi et al. 2022), we discussed the temporal pattern of the escape (establishment) probability of a novel mutant in a patient who receives an antiviral drug. After drug administration starts, the wild-type strain stops proliferating and declines in abundance, and the target cell abundance recovers. Hence, the drug-resistant mutant enjoys an improved chance of escape. Because the mutant needs to be produced from the wild-type stain by mutation, the rate of production of drug-resistant mutants exhibits characteristic temporal patterns, with a sharp peak just before the drug administration (Hayashi et al. 2022). This scenario can be extended to cases in which the mutant enjoys the benefit of escaping immune suppression, in addition to drug resistance. This could be a topic for future theoretical study.

The cumulative viral load is defined as the time integral of the mutant virus abundance within a host. It has been used as an indicator of virulence in several studies (Iwasa et al. 2021; Marconi et al. 2011; Sempa et al. 2016, 2019; Kim et al. 2021; Iwanami et al. 2021). Iwasa et al. (2021) evaluated how the cumulative viral load depends on different processes. However, the analysis was performed based on deterministic dynamics. The effects of the stochastic extinction of the virus on the cumulative viral load in a patient could also be an important theme for future theoretical study.