Host Controls of Within-Host Disease Dynamics: Insight from an Invertebrate System

Within-host processes (representing the entry, establishment, growth, and development of a parasite inside its host) may play a key role in parasite transmission but remain challenging to observe and quantify. We develop a general model for measuring host defenses and within-host disease dynamics. Our stochastic model breaks the infection process down into the stages of parasite exposure, entry, and establishment and provides associated probabilities for a host’s ability to resist infections with barriers and clear internal infections. We tested our model on Daphnia dentifera and the parasitic fungus Metschnikowia bicuspidata and found that when faced with identical levels of parasite exposure, Daphnia patent (transmitting) infections depended on the strength of internal clearance. Applying a Gillespie algorithm to the model-estimated probabilities allowed us to visualize within-host dynamics, within which signatures of host defense could be clearly observed. We also found that early within-host stages were the most vulnerable to internal clearance, suggesting that hosts have a limited window during which recovery can occur. Our study demonstrates how pairing longitudinal infection data with a simple model can reveal new insight into within-host dynamics and mechanisms of host defense. Our model and methodological approach may be a powerful tool for exploring these properties in understudied host-parasite interactions.


Introduction
Parasites and pathogens reside primarily within their hosts, but attempts to understand the ecology of infectious disease often neglect within-host processes (Hawley and Altizer 2011;Becker et al. 2019;Stewart Merrill and Johnson 2020). The concealed nature of within-host disease dynamics can make them difficult to measure. Moreover, a living host ecosystem introduces unique complexities that are absent from abiotic systems (Rynkiewicz et al. 2015). Despite these challenges, quantifying within-host dynamics has become a central goal for understanding the spread of infectious disease (Ellner et al. 2007;Graham et al. 2007;Day et al. 2011;Gog et al. 2015;Handel and Rohani 2015;Civitello et al. 2018).
Within-host dynamics refer to interactions between host and parasite (occurring on or inside the host) that shape a parasite's ability to transmit to new susceptible hosts (Antolin 2008). The outcomes of these dynamics that are useful for understanding transmission include the following: (i) whether the parasite can invade, establish, and develop within the host (given contact); (ii) the size of the within-host parasite population; and (iii) the duration of the infectious period (Antolin 2008;Gog et al. 2015;VanderWaal and Ezenwa 2016;McCallum et al. 2017; for a more evolutionary framing of within-host dynamics, see Mideo et al. 2008). The first of these outcomes represents a key filter for determining whether a susceptible host can support infection and serve as a source for future transmission (Gog et al. 2015). Hence, one of the primary features that regulates within-host dynamics is host resistance, a collection of defenses that hosts use to prevent the entry, establishment, and growth of a parasitic infection.
Considered to be a strategy, host resistance results in a host fitness gain if a parasite is successfully removed and, consequently, results in a fitness loss for the individual parasite (Restif and Koella 2004;Råberg et al. 2007;de Roode and Lefevre 2012). The defenses that comprise host resistance can be diverse and may yield different withinhost dynamics. For instance, host barriers result in only two possibilities for an attacking parasite: either the parasite infects (enters) the host or it does not. Internal immunological defenses increase this range of possibilities, from full host recovery to a spectrum of parasite growth dynamics that ultimately determine whether the parasite achieves a patent (transmitting) infection, as well as the number of parasite infective stages produced. At the population level, either or both of these defenses can influence transmission (Beldomenico et al. 2008;Beldomenico and Begon 2010;Halliday et al. 2018;Stewart Merrill et al. 2021a). Host resistance is therefore intimately linked with transmission parameters in epidemiological models (Miller et al. 2007;Hawley and Altizer 2011;VanderWaal and Ezenwa 2016).
Fundamentally, incorporating host resistance into transmission models requires one piece of information: How effective is host resistance at reducing patent infections? This question condenses host resistance into one comprehensive trait whose average value determines the rate of patent infection success. But growing recognition of the breadth of intraspecific variation, alongside its ecological consequences, has challenged the use of average trait values when modeling interspecific interactions (Bolnick et al. 2011;Des Roches et al. 2018), including host-parasite interactions (Lloyd-Smith et al. 2005;Gog et al. 2015). Building host variation into parasite transmission models may therefore require a second piece of information: How variable is host resistance? This second question not only addresses variation in initial infection success but also encompasses when and to what extent parasites are regulated during the course of infection. The answers to these two questions are rarely connected empirically. For instance, theoretical models often empirically parameterize host resistance, while its variation and distribution are structured on the basis of a priori assumptions (e.g., normal or negative binomial distributions). Alternatively, while substantial empirical effort has addressed genetic and environmental variation in immunological components of host resistance, the complexity of immune networks has made it challenging to link specific immune traits to patent infection outcomes and transmission (Graham et al. 2011;Downs et al. 2014).
For infectious diseases of both economic and public health concern, we often have a limited understanding of how host resistance (and the immunological defenses that comprise it) regulates disease, and this is particularly true for invertebrates. Six of nine neglected tropical diseasescausing more than 1 billion human infections per yearare transmitted to humans by invertebrates (Hollingsworth et al. 2015), but the immunological defenses of these medically important species remain vastly understudied ( fig. 1; see also Loker et al. 2004;Pila et al. 2016;Azambuja et al. 2017;Sloan and Ligoxygakis 2017). For instance, the basic characterization of hemocytes in mosquito vectors is only a recent endeavor (Hillyer et al. 2003;Wang et al. 2011), despite knowledge of these cellular effectors since the late 1800s (Metschnikoff 1884). While for some in-vertebrates there is increasing understanding of the sophistication of immune mechanisms (e.g., immunological specificity and memory in snails; Adema and Loker 2015;Coustau et al. 2015;Pinaud et al. 2016), few studies have addressed how these mechanisms operate in natural systems, how sensitive they are to environmental change, and how they modulate disease risk and transmission ( fig. 1). Determining the relative importance of immune defenses in the natural world is critical, as invertebrates face novel environmental stressors that can disrupt or decrease levels of immunity. Ultimately, a rudimentary understanding of invertebrate immunity and its variability will hinder attempts to generalize regarding how host resistance contributes to natural disease processes.
Here, we build a stochastic model (Allen 2017) that measures variation in host resistance through its connections to infection outcomes. By capitalizing on the multistage interaction of parasites within hosts, we break down host resistance into two key defenses and examine their variation and importance for patent infections. Because of the stochastic nature of the host-parasite interaction, we use a Gillespie algorithm (Gillespie 1977) to unveil the withinhost dynamics of the system and identify signatures of host defense in these dynamics. A sliding divider approach (developed herein) is then used to determine which internal stages of infection are the most vulnerable to host defense. We apply our model to interactions between the invertebrate host, Daphnia dentifera, and its fungal parasite, Metschnikowia bicuspidata, and find that clonal variation in host resistance is broad and explains variation in both within-host dynamics and patent infection outcomes. Moreover, we find that the parasite's within-host development is most sensitive to internal clearance during its early stages. Our model is readily adaptable for a broad array of hostparasite interactions and, in particular, can be used to quantify host resistance in understudied invertebrate-parasite interactions.

Background Biology and Data Collection
We studied a host-parasite system with environmental transmission, where infection results from consumption of infective stages. The host, Daphnia dentifera, is a cyclically parthenogenetic zooplankton and the parasite, Metschnikowia bicuspidata, is a common ascomycete fungus. Metschnikowia produces fungal ascospores that are consumed by filter-feeding Daphnia (Metschnikoff 1884;Ebert 2005). Ingested spores attack the host's gut epithelium, and spores that successfully cross the gut and enter the body cavity develop into a series of morphological stages that ultimately produce infective ascospores that are released on host death (Ebert 2005;Stewart Merrill and Cáceres 2018).
We standardized maternal effects of eight Daphnia genotypes by rearing Daphnia for at least three generations under controlled conditions (Lynch and Walsh 1998). Experimental individuals were collected from standardized mothers as neonates. At 8 days of age, experimental Daphnia were isolated and inoculated with 500 spores of Metschnikowia per milliliter. After a 24-h inoculation period, Daphnia were transferred to individual tubes containing spore-free filtered lake water. Exposed Daphnia were then culled at 2, 4, 6, 8, and 10 days after exposure and assessed microscopically to determine the Metschnikowia developmental stage possessed (Stewart Merrill and Cáceres 2018). Staging was destructive, and each day's examination was performed on a new cohort of individuals. Sample sizes varied because of differential reproduction and mortality among genotypes (table S1; tables S1-S5 are available online).
Following Stewart Merrill and Cáceres (2018), infections were classified into seven developmental stages: spore I (Metschnikowia spores had entered the host gut and had punctured the gut epithelium without fully crossing into the Daphnia body cavity), spore II (at least one spore had crossed into the body cavity), hypha (at least one spore had emitted hyphae), sporocyst (fungal sporocysts were detectable), conidium (conidia had been released from sporocysts and were replicating within the body cavity), ascus (asci filled the host body cavity), and uninfected.

The Conceptual Model
The achievement of patent infection is a multistage process, beginning with exposure and culminating with production of infective stages. Several models have broken this process into a multistage narrative. Combes (2001) A B Figure 1: Understudied invertebrate-parasite interactions motivate the development of the host resistance model. The general structure of our model is intended for application to understudied host-parasite interactions for which we lack information on the forms and importance of immune defense. To quantify the extent of knowledge gaps in invertebrate immunity, we conducted a systematic literature survey, asking: What are the large unknowns in the field of invertebrate immunity? And which medically important invertebrates are good candidates for use of our model? We surveyed the literature for studies of susceptibility and immunity of invertebrate vectors/hosts of six neglected tropical diseases (NTDs). The invertebrates included snails (schistosomiasis), mosquitoes (lymphatic filariasis), flies (sleeping sickness, leishmaniasis, and river blindness), and true bugs (Chagas disease). A, Comparison of the cumulative number of publications categorized by type of study: review papers (orange), studies characterizing functional mechanisms of immunity/susceptibility (purple), laboratory studies measuring immunological variability (green), and ecological studies measuring natural variation in immunity/susceptibility (red). Invertebrate immune defense and susceptibility is understudied in five of six invertebrates, and studies documenting natural variation in invertebrate immunity are particularly rare. B, Number of studies (all six NTDs combined) per year, by study type. Research on invertebrate immunity accelerated in the 1980s, with the functional characterization of immune defense representing the dominant form of study. Literature survey methods are provided in appendix F. describes patent infections as the outcome of host-parasite encounter (in the environment) followed by host-parasite compatibility (within the host). Likewise, Bertram et al. (2013) consider these same two transitions from the host's perspective: infection is initiated with exposure (in the environment) and determined by susceptibility (within the host). In generalizing across consumer-resource systems, Lafferty et al. (2015) describe the process as parasites transitioning from questing (in the environment) to attacking (attempting to enter the host) to consuming (within the host). The general narrative of the host-parasite interaction provides a conceptual model for immune defense (LaFonte and Johnson 2013;Hall et al. 2017;Stutz et al. 2019). First, when hosts are exposed to parasites, initial infection (entry) can be blocked with barriers. Barrier resistance prevents attacking parasites from entering the host and includes physical and chemical barriers, such as those present in midguts of dipteran vectors (Michalski et al. 2010). Second, if a parasite successfully establishes, the infection can be eliminated with internal clearance. Internal clearance removes parasites from within the host and comprises internal immunological defenses, such as killing of trematode sporocysts with snail cellular and humoral responses (Pinaud et al. 2016).

Model Structure
We constructed a stochastic model (Black and McKane 2012;Allen 2017) to estimate host defenses from infection outcomes. Our model is a discrete state, continuous time Markov model (Norris 1997;Hurtado and Kirosingh 2019) with parameters estimated using maximum likelihood with a least squares distance function (Kalbfleisch et al. 1983). The model's finite state space consists of four states: exposed (E), infected (I), uninfected (U), and dead (D). These four states allow for the estimation of the rates and probabilities of infection (E to I), barrier resistance (E to U), internal clearance (I to U), and mortality (any transition to D; fig. 2A, 2B). The model is designed for application to longitudinal aggregate data, in which the number of individuals occupying each state is observed at intervals evenly spaced through time, with separate cohorts of individuals observed at each time point.
We allow hosts to transition forward in the infection process and assume no reverse transitions. Reversals to the exposed state are not possible because the exposure period was restricted to 24 h, after which individuals were transferred to spore-free water. Furthermore, hosts were maintained in isolation, precluding between-host transmission. However, we emphasize that the uninfected state is not necessarily an immune state; hosts that recover can become exposed again if they are reintroduced to the parasite (dashed line in fig. 2B).
We allow hosts to transition from exposed to uninfected, which reflects barrier resistance, and from infected to uninfected, which reflects internal clearance ( fig. 2B). While hosts may reduce feeding to minimize parasite exposure (Strauss et al. 2019), we confirmed that the administered spore dose was sufficiently high to result in exposure for all individuals. We examined a subset of hosts (N p 62) 24 h after inoculation and determined that all individuals had spores attacking their gut epithelia. Finally, we assumed constant mortality for all states on the basis of prior analyses and knowledge of the system. While Metschnikowia must kill its host in order to release ascospores, parasiteinduced mortality occurs in time periods later than those studied in the current experiment (the ascus stage results in eventual host death, and asci take at least 10 days, on average, to develop; Rapti and Cáceres 2016).

Model Application
We collapsed the Metschnikowia developmental stages into our simplified, discrete state space ( fig. 2A). By collapsing the seven fungal stages into four states, our model retains a general structure that can be applied to a diverse array of host-parasite interactions (Stewart Merrill and Johnson 2020; for examples of how other host-parasite interactions can be similarly collapsed, see fig. F3; figs. F1-F3 are available online). The exposed state (E) consists of Daphnia that consumed fungal spores, so all hosts were considered exposed during the 24-h inoculation period. The infected state (I) consists of Daphnia with established infections, or those in which a spore had entered the body cavity and progressed to any of the within-host developmental stages (spore II, hypha, sporocyst, conidium, or ascus). The uninfected state (U) represents hosts with no symptoms of infection, hosts whose infections were successfully blocked by the gut epithelium (spore I), and hosts whose infections had not advanced beyond the spore II stage by day 8 (spores present 8 days after exposure were determined to be inactive). The state when Daphnia are dead (D) is an absorbing state.
From these longitudinal state data, maximum likelihood (Kalbfleisch et al. 1983) was used to estimate state-to-state instantaneous transition rates, which produced the matrix Q (app. A; apps. A-G are available online). Specifically, we consider a continuous time Markov process with state space fE, I, U, Dg p f1, 2, 3, 4g. Our Markov process can be fully specified by a 4 # 4 transition probability matrix P(s, t). Element p ij (s, t) of this matrix denotes the probability that a host in state i at time s transitions into state j at time t, where i, j p 1, 2, 3, 4 and 0 ≤ s ≤ t. Equivalently, A B C D Figure 2: How host resistance regulates patent infection. A, Raw empirical data representing the progression of hosts across infection states through time. Four hundred Daphnia individuals were exposed to Metschnikowia fungal spores on day 0, and on days 2, 4, 6, 8, and 10, Daphnia were culled and observed to determine the parasite developmental stage they possessed (N=day p 80). Developmental stages were then collapsed into four discrete infection states: exposed (E, green), infected (I, orange), uninfected (U, purple), and dead (D, red). The longitudinal infection state data show signatures of host recovery at initial exposure and through time. B, Our model is a discrete state, continuous time Markov model used to estimate two separate forms of host resistance from longitudinal infection state data. Barrier resistance is quantified as the probability of transitioning from exposed to uninfected (E to U). Internal clearance is quantified as the probability of transitioning from infected to uninfected (I to U). Death is an absorbing state from which hosts cannot transition. Following barrier resistance or internal clearance, uninfected hosts can become exposed again (gray dashed line), although our experimental structure eliminated the possibility of secondary exposure. Standardized probabilities of internal clearance (C) explain variation in patent infections in Daphnia, but probabilities of barrier resistance (D) do not. Prevalence data were collected empirically by calculating the proportion of live hosts that had patent infections 10 days after parasite exposure. Barrier resistance and internal clearance probabilities were estimated from 500 simulations with maximum likelihood estimation of the Markov model, followed by standardization to a mortality-free system (app. B).
In C and D, each point represents a unique genotype or population (four genotypes with low sample sizes were apportioned into low susceptibility [N p 2 genotypes] and medium susceptibility [N p 2 genotypes] populations; see "Methods"). Shading represents the standard error of the fit regression.
one may use the transition rates q ij (t) from state i into state j, which are defined as q ij (t) p lim Dt→0 p ij (t, t 1 Dt)=Dt.
We note that the rates q ij are such that each row of the transition matrix sums to zero, since q ii (t) p 2 P j(i q ii (t). The relationship between P and Q for time-homogeneous processes-namely, those for which q ij (t) p q ij -is given by the forward Kolmogorov equation dP=dt p PQ. Our matrix Q takes the following form: In the matrix Q, individuals transition from row states into column states. The infection rate (exposed to infected) is represented by b, the barrier resistance rate (exposed to uninfected) is represented by r, the mortality rate (all transitions to dead) is represented by d, and the internal clearance rate (infected to uninfected) is represented by c.

Model Parameter Estimation
Matrices Q, for each population of Daphnia, were estimated as follows. First, a set of initial transition rates (initial guesses) were randomly selected from a range of values spanning 0 to 5. The distribution over states at time instances t l were then evaluated, and their square distance from the experimental data was calculated. As the number of estimated parameters increases, arriving at a local minimum becomes more likely. We used simulated annealing to increase the probability of arriving at the global minimum. Specifically, we used the Matlab (MathWorks, 1994(MathWorks, -2018 command simulannealbnd to find the minimum of the distance function. A resulting matrix Q was exponentiated (which amounts to solving the forward Kolmogorov equation to obtain P(t) p P(0)e Qt ; Kalbfleisch et al. 1983;Norris 1997) to arrive at the probability matrix, or matrix P, which describes the probabilities of all state-to-state transitions, as previously explained. In the matrix P, each row sums to 1 and all elements are nonnegative. Death is the only absorbing state (state from which individuals do not transition). Our matrix P takes the following form: In this matrix, the elements of biological importance for our study appear in the first and second rows, where P E,U (probability of transitioning from exposed to uninfected) represents the probability of barrier resistance and P I,U (probability of transitioning from infected to uninfected) represents the probability of internal clearance.

Simulations to Quantify Average Probabilities
We ran the model on different groupings of Daphnia to quantify average probabilities of barrier resistance and internal clearance. To relate these probabilities to variation in susceptibility, the genotype should be the unit of replication. However, of the eight genotypes studied, four had low sample sizes (N examined per observation less than 10), so we aggregated these four genotypes' raw longitudinal state data into low-susceptibility (genotype N p 2) and medium-susceptibility (genotype N p 2) "populations" (table S1). We then ran the model for each genotype/population individually to quantify probabilities. In addition, to assess the generic infection process (particularly for our sliding divider approach, outlined in "Analyses"), we also aggregated the raw longitudinal state data of all genotypes and ran the model on this more complete "common population." We ran 500 simulations of the model for each genotype/population and for the common population, with maximum likelihood fits to calculate transition probabilities, assess convergence, quantify error, and determine each model's sensitivity to initial conditions. To facilitate comparisons among genotypes, we standardized barrier resistance and internal clearance probabilities by scaling them to a mortality-free system (app. B). Because our model is a continuous time Markov process, a time period must be selected for estimating a particular probability. The times over which we estimated probabilities are provided, along with rationale, in appendix B.

Mean Field Model
We also present a mean field description of our Markov model. A mean field model averages over a large number of hosts and describes their mean transitions between states. We use a system of linear ordinary differential equations (ODEs), which are analyzed to confirm parameter identifiability (Eisenberg et al. 2013; app. C). As with the Markov model, the rates in the mean field ODE include r (barrier resistance rate), b (infection rate), c (internal clearance rate), and d (death rate). This, for instance, implies that a host being in state E may stay there for an average (and, by assumption, exponentially distributed) amount of time before transitioning into state U at rate r (for a thorough derivation, see Hurtado and Kirosingh 2019). The ODE system describing the transitions reads as follows: Since this is a linear system, it can be solved explicitly. The solution is D(t) p 10(1 2 e 2dt ):

Simulating Within-Host Dynamics
We used Gillespie simulations to describe the within-host dynamics of the host-parasite interaction. The Gillespie simulation is a stochastic simulation that considers a group of individuals starting in a specific state (state E in our case) and tracks the individuals as they move to the other states, such that the proportion of the population occupying a given state can be explored through time. Using matrix Q rates, we ran a standard Gillespie algorithm (Gillespie 1977) to generate 1,000 sample paths. In all runs of the algorithm, the initial conditions matched those of the experiment: 10 individuals were placed in the exposed state, with the infected, uninfected, and dead states having zero individuals each. We ran each Gillespie simulation until the dead class was saturated and/or before time reached 10 days. We saved all transition times and all populations at those times. We then averaged the populations in each epidemiological state and collected information on the aggregate dynamics (further details are provided in app. D).

Experimental Validation
For many internal parasites, detecting infection stages is destructive to the host, and our model and longitudinal approach is structured to allow for host destruction. However, Daphnia have the useful attribute of being transparent, so we used their transparency to ground-truth the model-estimated probabilities of barrier resistance and internal clearance. In a separate experiment, we exposed 33 Daphnia individuals from the same eight genotypes to Metschnikowia following the previously described inoculation methods but at a lower spore dose (200 spores/mL). Following exposure, Daphnia individuals were examined twice throughout the infection process: once at variable time points between days 2 and 8 after inoculation, and once at day 10, when patent infections (the conidia and as- Field-collected Daphnia were sampled from six lakes in central Indiana and exposed to 200 spores/mL within 24 h of collection following our standard inoculation methods. Their infections were staged 1-2 days following experimental inoculation, and individuals were reexamined at day 10 after inoculation to determine whether they possessed patent infections (conidia or ascus). Using the complete set of individuals from the experimental data (N p 33) and the complete set of field-collected Daphnia (N p 554), we calculated each group's percentage of exposed Daphnia that recovered via barrier resistance and the percentage of infected Daphnia that cleared within-host developmental stages to arrive at empirical probabilities of both phenomena. By comparing these empirical laboratory and empirical field probabilities to the model-estimated probabilities, we could see how well the model reflected the true biology of the system.

Analyses
The Markov model was applied in two ways to address our three primary aims. We first applied the model to each genotype's (or population's) longitudinal data to generate genotype-specific probabilities of barrier resistance and internal clearance. With these values, we assessed how host resistance regulates patent infections and simulated each genotype's within-host dynamics. We then applied the Markov model to multiple configurations of the common population's longitudinal data (using a sliding divider approach, developed below) to evaluate how internal clearance declines in the later stages of infection.
How Host Resistance Regulates Patent Infection. We first asked whether barrier resistance or internal clearance better explained variation in patent infection prevalence and used linear regressions and an information theoretic approach to partition susceptibility into its underlying mechanisms. With two mechanisms of recovery, there are four possibilities: (i) barrier resistance, but not internal clearance, explains variation in patent infections; (ii) internal clearance, but not barrier resistance, explains variation in patent infections; (iii) both barrier resistance and internal clearance explain variation in patent infections; or (iv) neither barrier resistance nor internal clearance explain variation in patent infections. We tested for relationships between patent infection prevalence (empirical data; proportion of individuals with patent infections at day 10) and standardized probabilities of barrier resistance or internal clearance (model output), with Daphnia genotype (or population; see "Methods") as the unit of replication. We also ran a null intercept-only model. For each of these three models, we calculated and compared Akaike information criterion (AIC) values. The lowest AIC value represents the most likely model given the data, and a deviation between models of 12 AIC values represents substantially better fit (Burnham and Anderson 2002).

Within-Host Dynamics and Signatures of Host Resistance.
Next, we examined whether barrier resistance and internal clearance could be observed in the within-host dynamics; that is, do the within-host dynamics show signatures of host defense? Barrier resistance should constrain the proportion of the population that initially becomes infected, and internal clearance should result in growth of the uninfected class through time. To evaluate these hypotheses, we tested for associations among the two defenses and the Gillespie output. First, we tested for a relationship between the probability of barrier resistance (model output) and the peak value for patent infection prevalence (Gillespie output). Then we tested for a relationship between the probability of internal clearance (model output) and growth of the uninfected class from peak prevalence to 10 days after exposure (Gillespie output). We assessed relationships with linear regressions and an analytical solution (app. D). The Daphnia genotype (or population) was the unit of replication in the regressions.  (Hall et al. 2007;Bertram et al. 2013;Rapti et al. 2019). An important consideration, then, is whether internal clearance probabilities are sensitive to what is considered an infection. Addressing this question allowed us to gauge which within-host stages are most vulnerable to internal clearance. One means of testing stagespecific clearance is to build a more complex model that incorporates all of the developmental stages. However, such complexity (a 9#9 matrix in our case) can lead to issues with parameter identifiability (Eisenberg et al. 2013). Rather than add within-host states to our model, we used a sliding divider approach (developed below) to infuse our results with within-host complexity while retaining the simple four-state model structure.

Sliding Divider Approach
In the sliding divider approach, we "slid" the distinction between the exposed (E) and infected (I) states through the within-host developmental progression and applied our Markov model to quantify internal clearance probabilities. Importantly, this approach does not require restructuring the Markov model or its mathematical formulation. Rather, we simply changed how hosts were classified as either E or I in our longitudinal input data.
We provide a step-by-step guide to the process in appendix E. In brief, if one assumes that the early within-host stages of infection progression can make up the E state and that later stages can comprise the I state, we can slide the point at which we draw the distinction between the two states to generate multiple configurations of the input data, with each successive configuration containing fewer (and later) stages in the I state. By applying the model to each configuration and then quantifying the probability of internal clearance for a given configuration, one can investigate how internal clearance decays as parasite developmental stages are sequentially removed from the infected state. This approach yields three separate probabilities for internal clearance in this system: (1) in our standard configuration, the infected state contains all within-host stages of the parasite, and the infected to uninfected transition therefore reflects internal clearance of all within-host stages; (2) by sliding the divider between E and I to one stage later, stage spore II becomes reclassified as E, and application of the model to this second configuration will provide a probability of internal clearance for hypha and later stages; and (3) in one final slide of the E-I divider, we reclassify hypha infections as stage E, and then application of the model to this third configuration provides a probability of internal clearance referring only to clearance of sporocyst. We do not consider internal clearance of conidium and ascus infections because Daphnia never recover from these patent stages of infection (Ebert 2005;Stewart Merrill et al. 2019). This approach allowed us to examine how the probability of internal clearance changes as it is restricted to later stages of parasite development. We applied the Markov model to these three configurations for the common population of Daphnia (containing all individuals from all genotypes) and calculated the analogs of these probabilities with our empirical laboratory data and empirical field data (percentage of hosts that recovered from each internal infection; see "Experimental Validation") to determine how well the model results approximated actual stage-specific clearance.

How Host Resistance Regulates Patent Infection
We found that patent infection prevalence in a Daphnia host-fungal parasite system was strongly associated with clonal variation in internal clearance probabilities ( fig. 2C). In our comparison of AIC values among a model for barrier resistance, a model for internal clearance, and a null model, the internal clearance model performed best (AIC p 210:653), substantially outperforming both the barrier resistance model (AIC p 1:509) and the null model (AIC p 2:363). The barrier resistance model did not outperform the null by 12 AIC values. Our analyses therefore support the idea that internal clearance, but not barrier resistance ( fig. 2D), best explains variation in patent infection outcomes. In addition, barrier resistance and internal clearance were not strongly positively or negatively correlated (r p 0:526, P p :284).
Experimental tests confirmed each defense as important for regulating patent infection. The model-estimated probabilities of barrier resistance and internal clearance for the complete Daphnia population (all individuals, all genotypes) were 17.0% and 24.3%, respectively. The analogous empirical probabilities (obtained through tracking individual Daphnia hosts) were 27.3% (laboratory reared; for raw data, see fig. F1) and 11.9% (field collected; published in Stewart  for barrier resistance (percentage of tracked hosts that moved from exposed to uninfected) and 25.0% (laboratory reared) and 19.5% (field collected) for internal clearance (percentage of tracked hosts that moved from infected to uninfected). The modelestimated probabilities lie between those from both sets of empirical data, suggesting that our estimates are biologically reasonable.

Within-Host Dynamics and Signatures of Host Resistance
We applied a Gillespie algorithm to the Markov model output to evaluate the movement of hosts through the infection process ( fig. 3). Within-host dynamics estimated with the Gillespie algorithm well approximated the empirical longitudinal data ( fig. 2A) and demonstrated that infections peak early after exposure, decline as hosts clear infections, and stabilize when infected hosts achieve patent infections that cannot be cleared ( fig. 3A). Visualizing the within-host dynamics provided key information A B

Clearance Decay as a Function of Infection Progression
Our sliding divider approach revealed that internal clearance occurs predominantly during the early stages of infection (spore II and hypha). For the common population of Daphnia (all genotypes and all individuals combined), the probability of internal clearance decayed from 24.3% to 18.0% to only 2.8% when spore II and hypha were sequentially removed from the infected state and reclassified as exposed ( fig. 4, "Model results"). The model estimates of clearance decay were similar to those empirically observed in laboratory-reared and field-collected Daphnia ( fig. 4, "Empirical lab results" and "Empirical field results"), highlighting the generality of clearance decay across the three studied populations. While accounting for all seven fungal stages in a Daphnia-specific model (a data-hungry endeavor) would have provided explicit probabilities of host resistance for each fungal stage, such complexity should not change our qualitative result that internal clearance best explains variation in susceptibility (because the internal clearance probability for each independent within-host fungal stage is nested within the overall probability of internal clearance). Our sliding divider approach is therefore a dataefficient means of capturing stage-specific internal clearance from a more general model. Data underlying all results and figures have been deposited in the Dryad Digital Repository (https://doi.org/10.5061/dryad.73n5tb2ws; Stewart Merrill et al. 2021b).

Discussion
We constructed a discrete state, continuous time Markov model to estimate two forms of host resistance-barrier resistance and internal clearance-from longitudinal infection state data in Daphnia. By collapsing a fungal parasite's complex within-host life cycle into a finite set of states (which broadly encapsulate the general infection process across taxa) and then applying our model to separate host genotypes, we learned that internal clearance is a strong determinant of Daphnia susceptibility to patent infection. Our model provided a new depiction of the within-host dynamics of this interaction, within which signatures of barrier resistance and internal clearance can be directly observed. Moreover, we found that the earliest within-host stages of infection are the most vulnerable to internal clearance, such that hosts have a limited window of time during which recovery may occur. We align our discussion under two themes. We first focus on the general model, exploring the model framework, the advantages of our methodological approach, and how the model can be applied to understudied hostparasite interactions. Then we take a more detailed look at the biology of Daphnia and Metschnikowia, examining what our model and approach can tell us about stagespecific clearance and mechanisms of host defense.

The General Model
Exploring within-host processes entails breaking infection down into a series of intervals (Hall et al. 2017). While the largest interval in a host-parasite interaction represents a host's instantaneous transition from susceptible to patent (transmitting) infection, the smallest intervals involve the complex interplay between host, parasite, and immune response. Models that nest complex within-host processes within between-host transmission have become increasingly informative over the past two decades. Many early nested models were considered "inessential"-that is, they refined our understanding without altering our explicit predictions (Mideo et al. 2008). But more recently, nested models have demonstrated that the outcomes of within-host dynamics can scale up to impart broad consequences on between-host epidemiology (Park et al. 2013;Hite and Cressler 2018;Hall 2019). These models add to the idea that instantaneous transitions from uninfected to infected can neglect important biological information (McCallum et al. 2017). Unfortunately, many of the values used in nested models (such as parasite strain abundances and different forms of immunological effectors and their expression over time) can be challenging to measure and parameterize, and they are hence collected from model systems for which we have a strong mechanistic understanding of within-host processes. Consequently, nested models may not be readily adaptable to understudied host-parasite systems. Simple models that distill within-host processes into a limited set of variables may be a powerful compromise between the oversimplicity of instantaneous transmission and the overcomplexity of hostparasite immune interactions (Gog et al. 2015). For instance, through tracking infection age and pathogen growth, a function-valued trait approach can be used to estimate variation in disease life-history traits, like virulence and transmission Mideo et al. 2011;Hall and Mideo 2018). Similarly, our modeling approach uses the course of host-parasite interactions to infer mechanisms of host defense. By breaking the infection process down at an intermediate scale-with intervals for parasite exposure, entry, and establishment-our model provides a simple quantification for the within-host controls of disease.
The forms of defense we measured have application to both our theory and our understanding of host-parasite interactions. On the side of theory, host resistance has been classically described by two parameters: the transmission coefficient, b, which describes the rate of infection (and declines with increasing host resistance), and the coefficient g, which describes the rate of recovery (and increases with increasing host resistance; Anderson and May 1981). Both of these coefficients can be estimated phenomenologically, although b remains particularly challenging to parameterize and is often back-calculated from prevalence data (McCallum et al. 2017). Our model-estimated infection rates consider the multistage infection process and, by tracking individuals as they move through states, provide Figure 4: Clearance decay as a function of infection progression. We developed and implemented a sliding divider approach-in which we slid the distinction between exposed (E) and infected (I) through the infection stages-to examine how internal clearance decays as early infection stages are sequentially removed from the infected class (see top diagram and guide in app. E). When the infected state contains all within-host stages-our standard data configuration where spore II (SpII), hypha (H), and sporocyst (SC) can be cleared by the host-the probability of internal clearance (probability of transitioning from I to U) falls between 0.20 and 0.25 for the three considered populations. Sliding the divider once (reclassifying SpII as exposed and thus relegating clearance to only H 1 SC) decreases the probability of internal clearance to between 0.10 and 0.18. Sliding the divider a second time (reclassifying H as exposed and relegating clearance to only SC) further decreases the probability of internal clearance to between 0 and 0.05. We do not consider clearance of the conidium (C) or ascus (A) stages because all prior evidence supports that Daphnia cannot recover from those stages. The probabilities estimated with the model on the common population (solid line; all genotypes, all individuals) well approximate empirical observations (dashed lines) of these phenomena, calculated for both laboratory-reared ("Empirical lab results") and field-collected ("Empirical field results") Daphnia (see "Experimental Validation"). direct estimates of the recipient portion of b. Likewise, our model-estimated internal clearance rates provide empirically derived estimates of g by tracking transitions from the infected state back to the uninfected state. These rates likely exceed traditional estimates of g because they incorporate the immediate recovery from early infections that often go undetected. Ultimately, these biologically informed values can enhance models of host-parasite interactions. The parameterized rates can be used to deterministically model infection dynamics over multiple generations, and the model-estimated probabilities can be incorporated into stochastic, long-term simulations of the host-parasite interaction. In either case, such values can be used to assess the importance of host defense for influencing long-term hostparasite dynamics and how variation in defense influences the dynamics.
For many vector-and invertebrate-transmitted diseases, we know little about how the invertebrate's immune system regulates infection and mediates human risk. Accordingly, epidemiological models often exclude parameters for invertebrate recovery, making the implicit assumption that infection rates are driven by exposure. Our results, however, demonstrate that invertebrate infections can be strongly regulated by factors beyond parasite exposure. Faced with identical experimental inocula, Daphnia experienced dramatic variation in infection outcomes. This variation arose from each genotype's host resistance, with probabilities of barrier resistance ranging from 5% to 40% and probabilities of internal clearance ranging from 0% to 50%. Whether parasite success is determined by host exposure or resistance is a simple distinction, with two important ramifications. First, when host resistance determines parasite success, the host can play a regulatory role for the parasite population, removing parasite infection stages and thereby decreasing risk to other susceptible hosts . Indeed, this phenomenon has formed the basis for broad theory on disease dilution (Keesing et al. 2006) and can be directly observed in our simulations of within-host dynamics. Second, when host defenses represent the rate-limiting step for parasite populations, our predictions for transmission are more firmly grounded in the organismal biology of hosts. Considering how host immune traits fluctuate over environmental gradients can then add to our predictions of disease (Becker et al. 2019).
Daphnia represent only one of many invertebrates for which the basis and extent of host resistance has been a black box (indeed, this remains the case for many vertebrates as well; Stewart Merrill and Johnson 2020). While some key invertebrate immune defenses-such as the melanizing prophenoloxidase response, antimicrobial peptides, and cellular action-have been well investigated (particularly in model systems, like Drosophila; Lemaitre and Hoffman 2007), we have only scratched the surface of invertebrate immunological complexity (Loker et al. 2004;Adema et al. 2012;Sloan and Ligoxygakis 2017;Huang and Ren 2020). We see our model and methodological approach as a logistically simple and cost-effective means to begin filling knowledge gaps, particularly in understudied invertebrate-parasite interactions. Implementing a longitudinal design and calculating transition probabilities will reveal whether and at what stage of infection parasites are resisted, as well as how much variation exists in host defense (for an example of within-host stages of medically important invertebrates, see fig. F3). Capturing these probabilities can then allow researchers to hone in on the molecular or physiological mechanisms underlying a particular transition and can guide the search for immunological markers. In addition to exploring clonal/genotypic variation (as in the current study), the model can be applied to interactions spanning a broad variety of factors or treatments, such as different host species, host ages, temperature treatments, or resource availability treatments. With creative modifications to the study design and model structure, our approach can also be implemented in the field to understand natural variation in invertebrate defense. For example, deploying sentinel hosts over a discrete exposure period and then housing them in the laboratory for the remainder of the longitudinal study can provide both natural exposure probabilities and probabilities of host defense. The ability to quantify these values may be a powerful tool for exploring how invertebrate immunity constrains the distribution and spread of parasites.

The Specific Interaction
We found dramatic variation in Daphnia susceptibility, arising from two distinct forms of host resistance. The first, barrier resistance, is the generic outcome of any defense that prevents parasite entry. For instance, in a behavioral form of barrier resistance (sensu de Roode and Lefevre 2012), ants use prophylactic treatments with tree resin (which has antimicrobial properties) to prevent infection of colony members by entomopathogens (Chapuisat et al. 2007;Brütsch and Chapuisat 2014). A more classic immunological form of barrier resistance is the use of physical barriers within the mosquito midgut (the peritrophic membrane and midgut epithelium) to prevent malaria ookinetes (motile infective stages) from traversing the midgut and entering the body cavity (Saraiva et al. 2016). These physical forms of barrier resistance, together with additional chemical barriers, can winnow down malaria ookinete numbers from thousands consumed to fewer than 10 successfully crossing the barrier (Alavi et al. 2003). Indeed, barrier resistance may be commonly employed by midgut attributes when parasites infect by feeding. This is the case for Daphnia and Metschnikowia: attacking fungal spores must breach the gut to infect the Daphnia body cavity, and prior research has established that the size and penetrability of gut epithelial cells contributes to recovery via barrier resistance . The second form of host resistance, which well explained variation in Daphnia patent infections, is internal clearance, which kills and removes any parasites that infect the host. In invertebrate systems, internal clearance has long been attributed to inducible defenses such as phagocytosis and encapsulation, many of which are affected by hemocytes (Vazquez et al. 2009). Indeed, hemocytes that attack establishing fungal spores have been linked with Daphnia recovery (Stewart . Cellular and humoral defenses are generally rapidly upregulated following infection (Hillyer et al. 2003), and we found that the probability of internal clearance declines as Daphnia hosts advanced to later stages of infection. If internal clearance is relegated to an early window following infection, then the speed with which a host mounts an immune response may be as important for clearing parasites as the magnitude of the response.
Our results build on the theory of multistage defense in a similar host-parasite system, Daphnia magna and its bacterial pathogen, Pasteuria ramosa. Like Metschnikowia, Pasteuria must be ingested to infect its host and, following initial infection, the bacterium possesses a complex withinhost developmental trajectory (Ebert et al. 2016) and can be internally cleared by the host (Izhar et al. 2020). Breaking down the Pasteuria infection process has provided considerable insight into the genetic architecture and evolutionary constraints of Daphnia defense, as well as how sequential infection processes shape parasite virulence (Ebert et al. 2016;Hall et al. 2017;Hall et al. 2019). Our conceptual model is similarly designed to capture mechanism through population processes but achieves a separate goal. While work on Pasteuria often takes an evolutionary approach, asking how selection shapes infection, our study takes a more ecological approach, addressing how the infection process might shape effective transmission. Despite differences in our questions and methodological approaches (a quantitative trait locus approach in Hall et al. [2017] and a stochastic Markov model in our own), the similarity of our conceptual models and systems provides a rich common ground for understanding generality in the multistage infection process and for linking evolutionary causes with ecological consequences.
An important consideration moving forward is how host resistance varies as a function of dose (Ebert et al. 2000;Gog et al. 2015). When infection occurs as a multistage process, the mechanisms of host resistance may alternate in their importance for infection. For instance, at low levels of exposure barrier resistance may drive infection prevalence, while at higher levels of exposure internal clearance may be the dominant driver. Internal clearance should also become less effective as the density of established infections achieves a threshold value above which immune defenses become overwhelmed. These lines of thinking reveal a potential connection between barrier resistance and internal clearance: strong investment in barrier resistance should make internal clearance more effective, by limiting the number of internal infections a host must clear (however, we found no evidence for an association between barrier resistance and internal clearance in Daphnia). Future assessments of defense as a function of dose may inform our predictions regarding which defenses dominate under different exposure regimes. In addition, forging connections between dose and defense will facilitate modeling long-term host-parasite interactions, where parasite abundance changes dynamically within a system.

Acknowledgments
Thanks to James O'Dwyer, whose theoretical ecology course led to early versions of this article. Loren Merrill provided generous feedback across all stages that substantially improved this study, and multiple undergraduates at the University of Illinois contributed to data collection. T.E.S.M. is a Simons Fellow of the Life Sciences Research Foundation. This material is based on work supported by the National Science Foundation under grants DGE-1144245 (awarded to T.E.S.M.), DGE-1069157 (awarded to Andrew Suarez), NSF-1354407 (awarded to C.E.C.), 1815764 (awarded to Z.R.), and NSF-1701515 (awarded to T.E.S.M. and C.E.C.). Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.

Statement of Authorship
T.E.S.M. designed the experiment with assistance from C.E.C. and codeveloped the model alongside Z.R., who wrote the model code, mathematical formulations, and analytical proofs. T.E.S.M. conducted the literature survey, collected the empirical data, ran the models, analyzed the model output, and produced the first draft of the manuscript. C.E.C. and Z.R. provided revisions to the manuscript.

Data and Code Availability
Data and code used in this article are available in Dryad (https://doi.org/10.5061/dryad.73n5tb2ws; see the Dryad data set for a link to the Matlab code in Zenodo [https:// doi.org/10.5281/zenodo.4633539]).