Microbes growing in animal host environments face fluctuations that have elements of both randomness and predictability. In the mammalian gut, fluctuations in nutrient levels and other physiological parameters are structured by the host’s behavior, diet, health and microbiota composition. Microbial cells that can anticipate environmental fluctuations by exploiting this structure would likely gain a fitness advantage (by adapting their internal state in advance). We propose that the problem of adaptive growth in structured changing environments, such as the gut, can be viewed as probabilistic inference. We analyze environments that are “meta-changing”: where there are changes in the way the environment fluctuates, governed by a mechanism unobservable to cells. We develop a dynamic Bayesian model of these environments and show that a real-time inference algorithm (particle filtering) for this model can be used as a microbial growth strategy implementable in molecular circuits. The growth strategy suggested by our model outperforms heuristic strategies, and points to a class of algorithms that could support real-time probabilistic inference in natural or synthetic cellular circuits.

Outside the laboratory, microbes are faced with rich and changing environments. To improve their chances of survival, single microbial cells must adapt to fluctuations in nutrients and other environmental conditions. The mammalian gut, home to prokaryotic and eukaryotic microbes (

It remains unclear what the information processing capabilities of microbial populations are in such changing environments. To what extent are cells able to learn from their environment’s history and use this information to predict future changes? How sophisticated are the resulting computations, and in what environments will they lead to increased fitness? Insight into these questions would shed light on the type of environments cells were selected for and may guide the search for molecular mechanisms that implement adaptive computation. This direction could also inform how microbes become pathogenic. The yeast

Progress on these questions requires analysis at multiple levels of abstraction, as outlined by

There has been much work on understanding the molecular and genetic determinants of microbial growth in changing environments (e.g., using experimental evolution

A natural context in which to study the microbial response to changing environments is metabolic adaptation to nutrients. Because of its strong effect on growth, the way cells adapt to nutrients is a highly selectable trait, either genetically in long-term changing environments (as shown by experimental evolution studies

While the control of nutrient and carbon source metabolism has been studied extensively in yeast and other microbes (

Some of the complexity arises from the fact that microbes prefer to consume some nutrients over others, and that distinct nutrients require different and sometimes mutually exclusive pathways to be expressed. Glucose is generally the preferred sugar and its presence inhibits the expression of pathways required to metabolize alternative sugars like galactose (

In addition to molecular complexity of nutrient signaling, there are also memory effects at play in the nutrient response. For example, prior exposure to galactose in yeast alters the rate at which the GAL pathway will be induced upon subsequent galactose exposures (

Taken together, the intricate molecular machinery underlying nutrient signaling, the effects of nutrient memory, and single-cell variability in response to fluctuations suggest that microbes process information about their environment (

(A) Examples of discrete changing environments (time in arbitrary units). Top plot indicates sharp fluctuations in two nutrients. Remaining plots show changes thought to be experienced by microbes when interacting with host gut (unrelated to top nutrient panel), which include changes in temperature (25°C in external environment, 27°C on human skin, 37°C in gut), pH and oxygen levels (see main text). (B) Schematic of interaction between cell and changing environment in our framework. Cells sense dynamic environment over time, make inferences about the future state of the environment and use these predictions to take action (e.g., upregulate genes required to metabolize a nutrient).

To ask how the environment’s history influences microbial decision-making, a number of theoretical and experimental studies have used changing discrete environments (

In early theoretical work on changing environments (

Here, we develop a computational framework for characterizing the statistical structure of changing discrete environments and the adaptive strategies that support optimal growth in these environments. We focus on environments that are characterized by a blend of randomness and order, of the sort one would expect in the gut or other rich microbial ecosystems. We propose that adaptation to changing environments can be framed as inference under uncertainty (

Growth rates for 61 yeast strains were measured as described in

In

A(i)–(vi) Discrete Markov nutrient environments, characterized by two parameters: the transition probability from a glucose state back to glucose state (_{Glu→Glu}) and from galactose state to glucose state (_{Gal→Glu}). Environment assumed to switch from fixed levels of glucose to galactose, visualized as rectangles (collapsing the _{Glu→Glu} and _{Gal→Glu}) that parametrize the environment (see ‘Materials & Methods’ for detailed calculation). From (i) to (ii), increasing galactose growth rate (μ_{Gal}) with fixed glucose growth rate (μ_{Glu}).

To compare the growth rate differences between a glucose-only policy and the posterior predictive policy in two-nutrient Markov environments, we assumed an idealized case where the transition probabilities _{Glu→Glu} and _{Gal→Glu} are known. The “optimal” policy relative to an environment is one that maximizes the expected growth rate. The expected growth rate is dependent on the environment’s transition probabilities, the growth rates afforded by each of the nutrients, as well as the cost of being “mismatched” to the environment (i.e., being tuned to a nutrient that isn’t present in the environment.)

In our Markov nutrient environment, there are two environment states (glucose or galactose) and two possible actions for the cell population, each associated with a different growth rate. Notation for these states and parameters is as follows:

Environment states: the state of the environment at time _{t}, which takes on one of two values, _{1} = _{2} =

Transition probabilities: _{Glu→Glu}, _{Gal→Glu}.

Actions: tuning to glucose (_{1} = _{2} =

Growth rates associated with each action and environment state:

When tuned to glucose in glucose environment: _{11} (identical to growth rate on glucose, μ_{Glu}, from main figures)

When tuned to glucose in galactose environment: _{12}

When tuned to galactose in galactose environment: _{22} (identical to growth rate on galactose, μ_{Gal}, from main figures)

When tuned to galactose in glucose environment: _{21}.

A policy _{t−1}), which is the growth rate given the previous environment state _{t−1}. Let _{1} and _{2} correspond to policies that constitutively tune to glucose or galactose, respectively. The conditional growth rates for these policies are:

For simplicity, we assume that the growth rate is zero when the internal state of the cells is mismatched to the environment, i.e., _{12} = _{21} = 0. The conditional growth rates then simplify to:

To get the expected growth rates, we sum over the possible states of the environment at time

The policy _{1} is optimal when

(A) Dynamic Bayesian model for meta-changing nutrient environments in graphical model notation (_{t}, depends on the nutrient value at time _{t−1}, and on the switch state _{t}. See

Unlike the glucose-only or galactose-only policy, the posterior predictive policy chooses the next action based on the transition probabilities _{Glu→Glu} and _{Gal→Glu}. This policy, denoted _{3}, chooses the most probable nutrient as a function of the environment’s previous state _{t−1}:

We can now write the expected growth rate for the posterior predictive policy by analyzing each of the cases involving the transition probabilities _{Glu→Glu} and _{Gal→Glu}:

The ratio _{Glu→Glu} and _{Gal→Glu} for different values of each nutrient’s growth rate (_{11} and _{22}).

(A) Meta-changing environment with two hidden states: a periodic environment and a constant environment. The hidden state transitions are parameterized by the probability of transitioning from the periodic environment to itself, _{1}, and from the constant to the periodic environment, _{2}. (B) Growth rates obtained by growth using different policies in meta-changing environments (mean growth rates from 20 simulations plotted with bootstrap confidence intervals as shaded regions). Four environments shown, each parameterized by different settings of _{1}, _{2} (where μ_{Glu} is twice μ_{Gal}). Posterior predictive policy generally outperforms other policies. Mean growth rates from 20 simulations plotted with bootstrap confidence intervals (shaded regions).

Here we describe in detail the dynamic Bayesian model used to adapt to meta-changing environments (such as the one shown in _{t}, depends on the value of the switch state _{t} and the previous nutrient _{t−1}. The next switch state _{t+1} is generated conditioned on _{t} based on a separate set of switch state transition probability, then _{t+1} is generated conditioned on _{t+1} so on.

The transition probabilities associated with each switch state, as well as the probabilities of transitioning between switch states, all have to be learned from the environment. We therefore place a prior on these transition probabilities.

The full graphical model including hyperparameters is shown in _{1} is drawn from a probability distribution on the initial switch state values, _{s1}. Since _{s1} is unknown, we place a prior on it using the Dirichlet distribution, i.e.,:

which means _{s1}. For clarity, we will sometimes omit the explicit value assignment for a random variable, and write _{t} = _{s1}) as simply _{1}∣_{s1}). The switch states at later time points are generated as follows: each switch state _{i}, whose _{t−1} and the switch state transition probabilities:

Similarly, each nutrient state can take one value _{0} is drawn from a probability distribution, _{c0}, which is in turn drawn from a Dirichlet prior distribution:

The probability of a nutrient output at time _{t−1} and on the switch state at time

The posterior predictive distribution, _{t+k}∣_{0:t}), is the main quantity of interest (we assume _{t}∣_{0:t}), called the _{t−1}:

Note that the third term is the filtering posterior over the switch state at time _{0} and the initial switch state _{1} (as shown in

The posterior predictive distribution _{t+1}∣_{0:t}) can then be written as a product that uses the filtering posterior, marginalizing out the hidden switch states:

The distributions that the filtering posterior decomposes to depend on parameters that are unobserved, such as the transition probabilities. Since Dirichlet-Multinomial distributions are conjugate (

Similarly, the probability of observing a nutrient given the previous nutrient and the switch state, _{t+1}∣_{t}, _{t+1}), can be computed while integrating out the nutrient transition probabilities

We discuss in detail how to estimate these distributions from observations in the section on particle filtering.

_{s1}, _{c0}, _{c} to be vectors consisting of all ones. The hyperparameter on switch state transitions _{s} was set such that self-transitions get the hyperparameter value 2, i.e., for the _{s} are set to 1. This encodes a weakly “sticky” prior that slightly favors self-transitions for hidden switch states.

We estimate the posterior predictive distribution above in real-time using particle filtering (

In particle filtering, a distribution of hidden state values (in our model, the hidden switch states) is represented using a set of particles. Each particle corresponds to a configuration of the hidden states (configurations are typically assigned from the prior distribution at time

We now turn to the representation of our state space that is encoded in each particle. As discussed above, because of the conjugacy of Dirichlet-Multinomial distributions (^{(i,j)} is the number of times hidden switch state ^{(i,j,k)} is the number of times nutrient _{t},

_{t+1} ∼ _{t+1}∣_{t} = _{t}). By conjugacy, the switch state transition probabilities _{st} can be integrated out, yielding the posterior predictive distribution for a Dirichlet-Multinomial:

which can be sampled from.

_{t+1} is observed, we update the weight _{t+1}, _{t+1}∣_{t}, _{t+1}):

We simulated growth with different policies using a simple model of exponential growth. Cells were assumed to grow exponentially with a growth rate determined by the environment’s nutrient state. The initial population size and the time duration of each environment simulated are as described in figure legends. To determine growth rates empirically, we fitted splines to the log of the population sizes across the time and computed the first derivative. All code for fitness simulations is available in the paper’s

The nutrient transition counter model was drawn in CellDesigner (version 4.4) (

We first asked whether an adaptive strategy, which exploits the probabilistic structure of the environment, would pay off in terms of growth compared with a non-adaptive strategy. We considered a class of _{Glu→Glu}) and the probability of transitioning from galactose to glucose (_{Gal→Glu}), as shown in _{Glu→Gal} and _{Gal→Glu}, since _{Glu→Gal} = 1 − _{Glu→Glu}.) Intuitively, the higher _{Glu→Glu} and the lower _{Gal→Glu}, the more likely we are to encounter glucose in the environment. Different settings of the transition probabilities can produce qualitatively different environments (

In our framework, the behavior of a cell population is determined by a _{Glu→Glu} and _{Gal→Glu}), and a non-adaptive strategy in which cells are constitutively tuned to the preferred nutrient, glucose. The quantity of interest in the posterior predictive policy is the posterior predictive distribution, which is the probability of a nutrient at the next time step given the previously observed nutrients: _{t+1}∣_{0:t}), where _{t+1} denotes the nutrient at time _{0:t} denotes the environment’s nutrient history up until

To compare the fitness difference between these policies, we simulated population growth with each policy using a highly simplified growth model, similar to one used in

Given these growth assumptions, we plotted for each Markov environment the ratio of expected growth rate using the posterior predictive policy to the expected growth rate under the glucose-only policy in

We find that in environments where glucose yields a significantly larger (∼2–4 fold) growth rate than galactose, the posterior predictive policy outperforms the glucose-only policy only in specific regimes of the space of possible Markov environments (red regions in

This idealized calculation shows the importance of the probabilistic structure of the environment in assessing where an adaptive strategy would pay off. This suggests that in order to highlight the advantage of adaptive strategies, specific types of environmental fluctuations will have to be used.

Our analysis of Markov nutrient environments above doesn’t capture several key aspects of adaptive growth in changing environments. First, our environment’s changes had a simple “flat” structure describable by only two parameters, whereas natural environment may be generated by far more complex underlying mechanisms. Second, our comparison of the adaptive and glucose-only strategies assumed that the transition probabilities governing the environment, _{Glu→Glu} and _{Gal→Glu}, are known and can be used by cells. In reality, if this information can be used by cells, it has to be learned from the environment and cannot be assumed as given. Third, such information has to be learned in real-time as cells must respond to the environment while it is changing. We now address each of these aspects in turn.

Changes in complex environments may be governed by dynamic processes that are unobservable to cells. Some environments may oscillate between noisy regimes, where the nutrient switches are less predictable, and stable regimes where the nutrient switches are either rare or more predictable. Such environments can be thought of as “meta-changing” in the sense that there’s a change in the way they fluctuate: the probability of being a specific state of the environment (e.g., where a nutrient is available) changes through time, depending on an unobserved condition, such as whether we’re in a noisy or stable regime. The transition from noisy to stable regimes might itself be governed by another time-varying mechanism. As an intuitive example of meta-changing environments, consider the eating routine of animals like us. During feeding, bursts of nutrients that are otherwise scarce may become available in the gut. The fluctuations in nutrient levels within a feeding period will depend on what and how much is being consumed. The separation between meals is also subject to randomness, but can still be predictable, depending on how consistent we are in our eating schedule. This high-level structure can be exploited by adaptive systems to anticipate future changes and to separate noisy fluctuations in nutrients from signals of feeding periods.

To understand the adaptive strategies that may be used for effective growth in such environments, we developed a dynamic Bayesian model of meta-changing environments. In our model, we assume a fixed number of hidden “switch states” that correspond to regimes in the environment, and these states are used to generate the fluctuations in nutrients (_{t+1}∣_{0:t}), which depends on the nutrient history _{0:t} and on the hidden switch state _{t+1}:

For an inference-based strategy to be biologically plausible, it has to be carried out in real-time since cells respond to the environment while it is changing. To compute the posterior predictive distribution (

The particle filtering algorithm can be understood by analogy to evolution through mutation and selection. Initially, all particles are weighted equally. Before the environment changes, particles are probabilistically assigned to new configuration based on our model of the environment (“mutation” step). When a new state of the environment is observed, the particles are re-weighted by their fit to this observation and probabilistically resampled using the updated weights (“selection” step). This process repeats as the environment continues to change. Particles that represent more probable states of the environment will get “selected” for through time, while the “mutation” and resampling steps ensure that diversity is brought into the particle population. As each particle

Our model makes a number of predictions about the dynamics of adaptation by systems that represent hidden environmental states. In _{t+1}∣_{t}), as it gets updated by real-time inference, is plotted along the environment (

The change in the posterior predictive distribution has a number of characteristic features. Starting with a uniform probability over the nutrients, the posterior predictive distribution slowly changes to “learn” the first periodic regime of the environment (

We next asked how beneficial the adaptive patterns that result from representing hidden environmental states (of the sort shown in _{1} and _{2} in _{1} and _{2}, the posterior predictive policy generally results in faster (in some regimes, nearly two-fold higher) growth rates, which are often less variable, compared with other policies (

While all the policies we have considered so far act at the population-level, bet-hedging has been proposed as an adaptive strategy in fluctuating environments (

In natural nutrient environments, unlike in most laboratory conditions, multiple nutrients that can be metabolized by cells may be available. We next asked how distinct growth strategies would do in such multi-nutrient environments.

We analyzed Markov environments with three nutrients—glucose, galactose and maltose—that many yeast strains can grow on as primary carbon sources (as shown in

(A, B) Three multi-nutrient Markov environments where glucose, galactose and maltose fluctuate. Transition probability matrices shown as heat maps (A) along with the environments they produce starting with glucose as initial state (B). (C) A meta-changing multi-nutrient environment that switches between the second and third Markov environments shown in (B). (D) Growth rates obtained using different policies in meta-changing environment shown in top, shown for four different settings of _{1}, _{2}. Growth rate settings used: μ_{Glu} was twice μ_{Gal} and μ_{Gal} = μ_{Mal}. Mean growth rates from 20 simulations plotted with bootstrap confidence intervals (shaded regions).

For fitness comparisons of growth policies, we considered meta-changing environments that switch between the second and third multi-nutrient environments shown in _{1} and _{2} (_{1} and _{2} (

Our results suggest that cell populations that use a probabilistic inference-based growth strategy can achieve greater fitness, but it’s not clear how such a strategy can be realized in molecular circuits. We next asked whether the particle filtering algorithm can inform the design of molecular circuits that implement the posterior predictive strategy.

In order to implement the posterior predictive strategy, we need a way to encode the inference algorithm’s representation of the environment in molecules. Our particle filtering algorithm uses a minimal representation of (Markovian) environments that a circuit that performs inference in real-time would have to track. This representation consists of the hidden switch state

To build this circuit, we need three types of components: (1) sensors that detect the presence of nutrients, (2) activators that act downstream of the sensors to turn on the relevant metabolic pathway, and (3) “memory molecules” that record each relevant transition (glucose-to-galactose or galactose-to-glucose). Two of these component types, the sensors and the activators, are already part of the basal nutrient signaling pathway. What’s left is to wire these components to the memory molecules so that the circuit can count nutrient transitions.

We constructed such a nutrient transition counter for an environment that has glucose and galactose. The eight-component circuit is shown in

(A) Network of chemical reactions for implementing nutrient transition counter. ∅ denotes null species in degradation reactions. Reaction equations represented by the network are listed in

We simulated the behavior of this circuit in an environment that switches between glucose and galactose (

A key feature of this circuit architecture is that sensors associated with one nutrient (e.g., glucose) get activated by other nutrients (such as galactose). This “crosstalk” between the two arms of the pathway enables the environmental change tracking that is needed for inference. It may be argued that it’s inefficient for organisms to express a sensor for a nutrient that isn’t present, but yeast cells in fact do so: for instance, cells grown in galactose express glucose sensors and transporters, while cells grown in glucose also express galactose transporters and internal galactose sensors. Our circuit design shows that a relatively simple change in wiring among mostly existing components (such as a nutrient sensor and activator), in addition to a memory molecule, is sufficient to make the transition counter. While a true digital counter is unbounded, this molecular counter’s dynamic range and reliability is limited by the degradation rates and dynamic ranges of the molecular components involved (such as the sensors and counting molecules in

Whether such a circuit is likely to be used by an organism will depend on the type of fluctuations in the organism’s environment and on the fitness advantage conferred by tracking metabolites (relative to the cost of tracking). These tradeoffs are currently unknown, but can be studied experimentally by engineering synthetic circuits such as the one we have proposed into cells and analyzing their fitness in various environments. It’s plausible that even if such circuits exist in nature, only a subset of the nutrients cells consume may be tracked in this way.

Our circuit is a proof-of-concept design of the core machinery needed for real-time inference in our probabilistic model, but a full implementation of inference would require integration with the remaining basal glucose/galactose signaling network (as well as careful analysis of the circuit’s robustness and precision).

Fluctuations in complex environments, such as the gut, can be driven by mechanisms that cells cannot sense directly. The main contributions of this work have been to: (1) provide a framework for characterizing the computational (or information-processing) problem that cells face when living in such environments (conceived here as a form of probabilistic inference), (2) suggest particle filtering as one class of algorithms that cells may use to solve inference in real-time, and (3) propose a proof-of-concept design of a circuit that implements part of this algorithm using familiar protein biochemistry. Together, this gives an outline of a three-level analysis, following Marr’s framework (

We found that a growth strategy based on inference, where hidden environmental features are represented, can give cells a fitness advantage. An important future direction would be to test if signatures of adaptation by inference (such as those in

Although we assumed in our fitness simulations that the goal is to maximize population-level fitness, other goals—like minimizing the probability of population extinction (

Another future challenge is to link the continuous features of the environment (which can be clearly sensed by microbes) to more abstract discrete structure like that of meta-changing environments. Elegant work by Sivak and Thomson derived optimal enzyme induction kinetics for the noisy statistics of an environment with continuously varying nutrients (

To represent the structure of meta-changing environments, our model posited a finite number of hidden states that drive nutrient fluctuations. The number of hidden states was fixed in advance, but nonparametric dynamic Bayesian models offer a principled alternative (

While we have focused on glucose-galactose environments, our framework generally applies to environments that change too quickly for mutation and natural selection to take hold. This is distinct from cases where natural selection (e.g., through experimental evolution, as in

We have proposed a design for one critical part of an adaptive inference circuit, which can be supported by a variety of molecular mechanisms. Our circuit design can be implemented using transcriptional, post-transcriptional or epigenetic chromatin-based regulation. The choice of mechanism will determine the timescale and precision of the adaptive response. More work is needed to understand the precision and reliability of the circuit we proposed in the presence of gene expression variability and cell division. A computational account of circuits that can track the state needed for probabilistic inference may also apply to neuronal circuits.

Recent work argued compellingly for developing methods that “compile” abstract computational problems, like probabilistic inference, to molecular descriptions that are physically implementable (

Real-time inference algorithms, such as particle filtering, have the potential to guide the construction of synthetic cellular circuits that adapt to rich changing environments. Since particle filtering algorithms rely on noise, these procedures point to areas where biochemical noise (in gene expression or protein interactions) would not only be tolerated, but would in fact be required for inference to work. These algorithmic features may inform the design of synthetic circuits that implement probabilistic computation out of noisy molecular parts.

Equations with all rate parameters are available in

(A) Mean growth rates (doublings per hour) from two replicate cultures grown with different sugars as primary carbon source. (B) Distribution of the ratio of glucose to galactose growth rate for 61 yeast strains.

All random variables and hyperparameters shown. Model drawn using plate notation. (This model is similar to an Autoregressive HMM.)

(A) Meta-changing environment (same as Figure 5A). (B) Growth rates obtained using different growth policies in meta-changing environment shown in (A). ”Posterior pred. (BH)” indicates a bet-hedging policy where fraction of population tuned to a nutrient is set by the real-time estimate of the posterior predictive probability of the nutrient, ”Random (BH)” indicates a bet-hedging policy where fraction of population tuned to nutrient is set randomly. ”Plastic” policy is a non-bet-hedging policy plotted for reference (same as Figure 5B). Mean growth rates from 20 simulations plotted with bootstrap confidence intervals (shaded regions).

We thank Matt Johnson, Tommi Jaakkola, Bo Hua, Jenny Chen, Nikolai Slavov, Andrew Bolton, Eric Jonas, Lauren Surface, Ariella Azoulay and Josh Tenenbaum for helpful discussions. We thank Jue Wang for sharing growth rate measurements from 61 yeast strains.

The authors declare there are no competing interests.

The following information was supplied regarding data availability:

Code and rawdata: