C. elegans forage in a patchy environment with an explore-then-exploit strategy.

(A) An example animal’s midbody location (colored to represent time in the experiment) as it forages in an environment bounded by a large (30 mm diameter) arena containing 19 small (∼1.8 mm diameter) bacterial patches (gray). Each patch was made by pipetting ∼0.5 µL of OP50 E. coli diluted to OD600 ∼10 and grown at room temperature for ∼1 hour. (B) Distance between the example animal’s midbody position and the nearest patch edge (positive indicates inside patch) is plotted (black) for every time point. Putative encounters with a bacterial patch are indicated (gray). (C) Patch encounters (colored to represent the duration of the encounter) for 50 individuals foraging in these environments are plotted. (D) The number of total and unique patch encounters for each animal are shown. (E) Duration for each patch encounter was computed and classified as either short (0-2 minutes) or long (2-60 minutes) using a Gaussian mixture model. The distributions of all observed short and long encounters are plotted with duration binned logarithmically. (F) The observed start time of each patch encounter is shown for all short and long duration encounters. Long duration encounters occur significantly later (one-tailed Mann-Whitney U-Test). (G) The probability of residing on patch was computed for all worms across time (black) and compared to the probability of residing on patch if patch locations were semi-randomly permuted (pink). Smoothed median values are plotted with bootstrap-derived 2.5% and 97.5% quantiles shown in shaded regions. Time points where observed probabilities of residing on patch significantly exceed permuted probabilities are indicated by a black line (one-tailed Fisher’s exact test with Benjamini-Hochberg correction). (H) The track of the example animal in (A) is replotted with color used to represent the animal’s instantaneous velocity at each time point. (I) Velocity of the example animal over time is plotted (black) alongside patch encounters (gray) as previously identified in (B). Example encounters – one early, short duration (green) and one late, long duration (blue) – are indicated. (J,K) A 60-second time window surrounding the start of these example encounters is enlarged. (L) Velocity trajectories were aligned to patch entry for every encounter. Mean encounter-aligned (black/gray) and randomly-aligned (pink) trajectories are plotted for each animal (light) and across all animals (dark). (M) Deceleration upon encounter with the patch edge is plotted for every encounter and grouped by duration type. Deceleration was significantly lower for encounter-aligned as compared to randomly-aligned trajectories (pink) for all duration types (one-tailed Mann-Whitney U-Tests with Bonferroni Correction). (N) Mean velocity as a function of the distance from the edge of bacterial patches (computed for 50 μm bins) is shown for every animal (gray) and across all animals (black). (O) Each animal’s mean velocity during time spent on and off (midpoint at least -0.46 mm from patch edge) patch is shown. Velocity on patch was significantly slower than off patch (one-tailed paired-sample t-test). Sample data for one animal (worm #1) are shown in (A-C,H-K). Summary data for all animals (N = 50 worms) and encounters (N = 419 total encounters) are shown in (D-G,L-O). Violin plots in (D,F,M,O) give the KDE and quartiles for each measure. Asterisks denote statistical significance (***p<0.001). See also Figure 1 – supplement 1-5 and Video 1-4.

The timing of the switch from explore-to-exploit is density-dependent.

(A) The relative density (as estimated by fluorescently-labeled OP50-GFP) is shown for small (∼1.8 mm diameter) bacterial patches made by pipetting ∼0.5 µL droplets of OP50 E. coli diluted in LB to a range of optical densities (OD600 = {0, 0.05, 0.1, 0.5, 1, 2, 3, 4, 5, 10} and controlling growth time at room temperature (hours = {1, 12, 48}). For (A-G,L-O), gray-scale color saturation is proportional to the relative density of each condition and corresponds to labels in (A). (B) The mean velocities of animals foraging in environments containing patches matching one of the 12 bacterial densities are plotted as a function of the distance from the edge of bacterial patches (computed for 50 μm bins). (C) Animals’ average on-patch velocity is plotted as a function of the relative density of bacteria. Compared to animals foraging amongst bacteria-free patches containing only LB (relative density 0), animals foraging on bacterial patches with relative density of 0.5 or greater display significantly slower on-patch velocities (one-tailed Mann-Whitney U-Tests with Bonferroni Correction). (D) The midbody location (colored to represent time in the experiment) of example animals foraging in environments containing patches (gray) of relative density 0, 1, 5, 10, and 200 are shown. (E) The total time each animal spent on patch is plotted as a function of the relative density of bacteria. Time on patch increased monotonically with increasing bacterial density (Kendall’s τ correlation, p<0.001) following a sigmoidal trend. (F) Smoothed median values of the probability of worms residing on patch over time for each density condition are plotted. Time points where observed probabilities of residing on patch either match (pink) or significantly exceed (gray) the probability of residing on patch if patch locations were semi-randomly permuted are indicated (one-tailed Fisher’s exact test with Benjamini-Hochberg correction). (G) A KDE of the distribution of encounter durations is plotted for each density condition. (H) For each encounter, the average velocity of the animal during the encounter and the duration of that encounter are plotted on a double-logarithmic plot with color representing the probabilities of clustering classification as search (orange), sample (green), or exploit (blue). Contours showing the first, second, and third standard deviation of the GMM used to classify explore and exploit encounters are shown as shaded ellipses with saturation corresponding to standard deviation. KDEs for distributions of average on-patch velocity and encounter duration are plotted for each encounter type. (I) For each encounter, the minimum on-patch velocity and maximum change in velocity are plotted. Contours showing the separation of sensing and non-sensing encounters as estimated by semi-supervised QDA are indicated. A KDE for the distribution of the maximum change in velocity is plotted for each encounter type. (J) Features used to classify encounters as search, sample, or exploit are summarized. (K) KDEs of the distributions of animals’ velocities are shown for all timepoints during search off and on patch as well as during sample and exploit encounters. (L) Ethograms of patch encounters (colored to represent the probability of classification as search, sample, and exploit) are shown for 443 individuals. (M) The average proportion of each encounter type over time is plotted. (N) Time elapsed and (O) number of encounters occurring prior to the first exploitation event are plotted for every animal (blue). In the event that no exploitation event occurred, the maximum observed time and encounters are plotted (red-orange). Both time and encounter number before exploitation decrease monotonically with increasing patch density (Kendall’s τ correlation, p<0.001) following a sigmoidal trend. Summary data for all animals (N = 443 total worms; N = 20-50 worms per condition) and encounters (N = 6,560 total encounters; N = 46-876 encounters per condition) are shown in (A-C,E-I,K-O). Asterisks denote statistical significance (***p<0.001). See also Figure 2 – supplement 1-7 and Video 5-6.

C. elegans explore first even when only one patch is available.

(A) Relative density of large (∼8.3 mm diameter) and (B) small (∼1.8 mm diameter) bacterial patches was varied by pipetting 20 µL and 0.5 µL, respectively, droplets of OP50 E. coli diluted in LB to a range of optical densities (OD600 = {0, 0.05, 0.1, 0.5, 1, 2, 3, 4, 5, 10} and controlling growth time at room temperature (hours = {1, 48}). (C) Large patches were formed in the center of 30 mm arenas while small patches were formed in the center of 9 mm arenas. (D-E) The midbody location (colored to represent time in the experiment) of example animals foraging in environments containing a single (D) large or (E) small patch (gray) are shown. (F-G) Ethograms of patch encounters (colored to represent the probability of classification as search, sample, and exploit) for (F) 144 individuals (8-15 per condition) foraging on a single large patch and (G) 191 individuals (27-38 per condition) foraging on a single small patch are shown. (H-I) Time elapsed prior to the first exploitation event (blue) for animals foraging on (H) large and (I) small patches is plotted for every animal. When exploitation was not observed, time elapsed in the experiment is plotted (red-orange). Animals in large and small patch environments exploited higher density patches significantly earlier (Kendall’s τ correlation, p < 0.001) following a sigmoidal trend. See also Figure 3 – supplement 1-2.

Exploitation decisions are driven by available sensory information, satiety, and prior experience.

(A) Schematic of the covariates xk used in our logistic regression model to predict the probability of exploiting a patch upon any given encounter p(yk = 1|β · xk). xk includes the relative density of the encountered patch k (ρk), the duration of time spent off food since departing the last exploited patch (τs), the relative density of the patch encountered immediately before encounter k (ρh), and the relative density of the last exploited patch (ρe). (B) To account for uncertainty in our classification of sensation, we produced 100 sets of observations wherein we probabilistically included sensed encounters (νk = 1) estimated from the distribution νk|wk ∼ Bern(p(νk = 1|wk)) where p(νk = 1|wk) is the probability that the patch was sensed as estimated in Figure 2I. To account for uncertainty in our classification of exploitation, we substitute the response variable yk with our estimate of the probability that the patch was exploited p(yk = 1|zk) as estimated in Figure 2H, a procedure analogous to including exploitations (yk = 1) estimated from the distribution yk|zk ∼ Bern(p(yk = 1|zk)). A schematic of these procedures is shown (see Models of exploitation probability). (C) Coefficient values for each covariate in the GLM were estimated across 50000 replicates (500 replicates of hierarchically bootstrapped animals in combination with 100 sets of probabilistically sensed encounters). All coefficients are significantly greater than or less than 0 (two-tailed, one-sample bootstrap hypothesis tests with Bonferroni correction). (D) Using observed p(yk = 1|zk) and estimated p(yk = 1|β · xk) probabilities of exploitation, exploitation events were simulated from a Bernoulli distribution. Distributions of the probability of first exploiting as a function of the number of encounters as estimated by the model with covariates added one-by-one and as observed are shown for animals foraging in single-density, multi-patch environments of relative density 1 or 10. (E) A schematic of multi-density, multi-patch assays where animals foraged in environments containing small (∼1.8 mm diameter) bacterial patches (gray) of varying combinations of OP50 E. coli with relative densities 1, 4, and 7 is shown. (F) The probability of exploitation as estimated with (p(yk = 1|β0 + βkρk + βsτs + βhρh + βeρe)) and without (p(yk = 1|β0 + βkρk + βsτs)) the history-dependent terms and as observed p(yk = 1|zk) is shown for every pairing of current patch density (ρk) combined with the density of recently encountered (ρh) or exploited (ρe) patches. Heat maps for observed values were interpolated between the 9 patch density pairings tested. (G) Exploitation events were simulated from the distribution yk|zk ∼ Bern(p(yk = 1|zk)) and used to calculate the probability of observing exploitation for the first time as a function of the number of encounters for N2, mec-4, and osm-6 animals foraging in single-density, multi-patch environments of relative density 1 or 10. (H) Coefficient values for each covariate were estimated using ridge regression models for each strain across 50000 replicates. A subset of these coefficients significantly varied between wild-type and mutant strains (mean of differences tests with Benjamini-Hochberg correction). Summary data for all animals (N = 443 total worms; N = 20-50 worms per condition) and encounters (μ = 2659.8, σ = 15.9) in the single-density, multi-patch assay are shown in (C,D). Summary data for all animals (N = 198 total worms; N = 20-40 worms per condition) and sensed encounters (μ = 1,724.6, σ = 9.9) in the multi-density, multi-patch assay are shown in (F). Summary data for all wild-type and mutant animals (N = 221 total worms; N = 14-44 worms per condition) and encounters (N = 1,352 total encounters) in a single-density, multi-patch assay are shown in (G,H). Violin plots in (C,H) show the KDE and quartiles for each measure. Asterisks denote statistical significance († punadjusted<0.05; *p<0.05; **p<0.01; ***p<0.001). See also Figure 4 – supplement 1-5.

Assay preparation, arena and patch detection, and behavioral tracking.

(A) Graphic describing the steps to prepare assay plates. Created with BioRender. (B) Example frames from a “contrast video” showing how a piece of dark cardstock passed between the light source and the assay plate enables visualization of dilute bacterial patches. (C) An image of the bacterial patches is generated from the “contrast video”. (D) Masks of the arena (black) and bacterial patches (gray) were constructed using image processing techniques and, when applicable, subsequent manual corrections (see Bacterial patch location detection). Arena masks were used to calculate the image scale in pixels/mm. (E) Example frame from a behavior video containing four adult C. elegans is shown. (F) WormLab was used to identify the midbody location of animals in each frame (see Behavioral tracking). An inset shows detection of one of the four worms. (G) An example animal’s tracked location as it forages in this environment is plotted with color used to represent time (dark blue = 0 mins; dark red = 60 mins).

Defining a patch encounter using high resolution behavioral recordings.

(A) Example frame from a behavior video containing one adult C. elegans is shown. (B) WormLab was used to track the body of the animal in each frame (see Behavioral tracking). (C) An example image showing the center spline of the example animal as well as the location of the bacterial patch (gray) and arena (black). The inset shows the animal’s center spline and bacterial patch superimposed on top of the raw image. (D) Example body postures/orientations (black) of an animal during frames when its head is on the patch edge. The distance (blue lines) between the head (black dot) and midpoint (blue dot) of the animal was calculated. A histogram of this head-to-midpoint distance is plotted, and the median value (blue) is indicated (sample size: 220 animals; 74839 frames). The median head-to-midpoint distance was subsequently used as a threshold for detection of patch encounter and leaving events. For one example animal, the distance between the head (black) or midbody (blue) position and the nearest patch edge (positive = inside patch; negative = outside patch) is plotted for every time point. The edge of the patch (solid black line) and threshold for encounter detection (dashed -.- black line) are indicated. Putative patch encounter (green) and leaving (red) events are shown. (E) Example body postures/orientations of an animal when its head is on the patch. The distance between the midpoint of the animal and the patch edge (blue lines) was calculated. A histogram of this midpoint-to-patch distance is plotted, and the 1st percentile (blue) is indicated (sample size: 220 animals; 1571163 frames). This value is used a threshold for excluding putative encounters where the animal’s midpoint never comes within 0.28768 mm of the patch edge. A 1.5 minute time window of the example animal’s position in (D) is shown. The edge of the patch (solid line), threshold for encounter detection (dashed -.- line), and threshold for encounter exclusion (dashed – line) are indicated. Example putative encounters are shown. The first two sets of enter and exit events were excluded. The third set shown was included. The included encounter is shaded in gray. (F) The standard deviation of the distance between the location of the patch edge and the midpoint of the animal was calculated for every putative on-patch encounter and off-patch event (sample size: 220 animals; 2945 putative on-patch events; 2725 putative off-patch events). A subset of putative off-patch events had low standard deviations matching those of on-patch events. A one-dimensional Gaussian mixture model was fit to the off-patch standard deviation values and a threshold was set where the posterior probability of events falling in the high or low variance cluster was 0.5. A 1.5 minute time window of the example animal’s position in (D) is shown. Examples of two excluded off-patch events and one included event are shown.

Classifying encounters based on duration using a Gaussian mixture model.

(A) As in Figure 1E, duration for each patch encounter (N = 419 events; 50 worms) was computed and classified as either short or long using a Gaussian mixture model (GMM). The distributions of all observed short and long encounters are plotted with duration binned logarithmically. The probability density functions for the two component Gaussians are shown. (B) The posterior probabilities for classification as short or long are sorted for all encounters, highlighting the low posterior variance of the GMM. (C) Given that some patch encounters were not fully observed (i.e., ∼22% of animals were already on patch at the start of the recording and ∼96% of animals were on patch when the recording ended), we identified that ∼14% of observed patch durations were left-censored (i.e., having actual duration ≥ observed duration). Thus, to confirm findings in Figure 1E-F, we re-classified only non-censored observations where both the entry and exit of a patch encounter were observed. As in Figure 1C, patch encounters for 50 individuals foraging in these patchy environments are plotted across time. Encounters that were uncensored (pink) and censored (gray) are indicated. (D) The distribution of the duration of only fully observed (uncensored) encounters (N = 360 events; 50 worms) is plotted. The component Gaussians for a GMM fitting this subset of data are shown. (E) Sorted posterior probabilities for the uncensored model are shown. (F) The observed start time of each uncensored patch encounter is shown for all short and long duration encounters. Long duration encounters occur significantly later (Mann-Whitney U-Test, ***p<0.001). Violin plots show the KDE and quartiles for each duration type. (G) Posterior probabilities for classification in the long duration cluster are shown for the two models. The uncensored data model results in a slight increase in posterior probabilities of long duration classification, but ultimately affected classification of only one of the 419 encounters.

Permuting patches to test for significance of the observed time-dependent increase in patch residence.

(A) Locations of bacterial patches (dark gray) are shown with the threshold for putative encounters (light gray) set at 0.46024 mm as described in Figure 1 – supplement 2 and Patch encounter detection. (B) Patches were permuted via randomized rotation and translation with the restriction that patches could not overlap with other patches nor with the arena. (C,D) Midbody location of the animal over time was overlaid on the original and semi-randomly permuted patches. (E,F) On patch events were subsequently identified. This permutation procedure was repeated for 1000 replicates for every worm tested. Smoothed median values of the probability of worms residing on patch over time was compared for every time point in Figure 1G, 2F and Figure 2 – supplement 5.

Analyzing deceleration upon encounter with a patch.

(A) To quantify the magnitude of slow-down upon encounter with the patch edge, we averaged the velocity trajectories across encounters and found the velocity reached a maximum at 1.5 seconds before (green) and a minimum at 6 seconds after (red) the start of the encounter (gray). (B,C) Subsequently, for every encounter, a line (blue) was fit to the animal’s velocity (black) for that 8 second time window surrounding the start of the encounter. Deceleration was defined as the slope of this line. Examples matching (B) the short duration encounter in Figure 1J and (C) the long duration encounter in Figure 1K are shown.

Obtaining intensity profiles for fluorescent bacterial patches.

(A) Fluorescently labeled OP50-GFP bacterial patches were seeded onto agar plates under conditions matching those in the experimental assay. Small patches (0.5 µL) were pipetted in an isometric grid (6 mm center-to-center spacing) on a 16 × 25 mm rectangular template comparable to the one used in behavioral assays. Large patches (20 or 200 µL) were seeded directly onto agar plates. Brightfield and fluorescence images were acquired for every condition at multiple time points of bacterial growth. The fluorescence intensity profile of these images was obtained. (B) Due to uneven illumination within the field-of-view of our imaging system, matched fluorescence images of an empty agar plate were acquired at each time point. These “background” images were smoothed using a two-dimensional averaging filter to remove noise. (C) Fluorescence images of the bacterial patches were normalized to these background images. (D) Locations of bacterial patches within the template were automatically detected using image processing techniques. Each patch was then radially segmented in bins of equal area. The mean pixel intensity value for each bin was computed and used to create an intensity profile of the patch. (E) The patch border and peak were detected using signal processing techniques. Specifically, the patch border was identified by finding a peak in the curvature κ of the edge profile. Border amplitude was defined as the magnitude of the difference between the patch border and peak. Relative border amplitude was defined as the border amplitude divided by the exposure time. A line was fit to the values of relative border amplitude across numerous time points and experiment days (5 replicates shown as varying color points).

Example fluorescence profiles of bacterial patches under varied growth conditions.

Fluorescently-labeled OP50-GFP bacterial patches were imaged as described in Figure 2 – supplement 1 and Bacterial patch density estimation. Inverted images (darker saturation = more bacteria) are shown here to highlight the range of bacterial densities tested in these experiments. All patches are shown on the same spatial scale and using one of the two linear saturation scales: 1) regular – normalized to show variance in high density patches; 2) augmented (∼22x) – normalized to show variance in low density patches). Each patch shown is labeled with the optical density (OD600) at time of seeding and the amount of time bacteria was grown for at room temperature (i.e., 1, 12, or 48 hours). (A) An example large (200 µL) bacterial patch of the type that animals experienced immediately prior to the assays in this paper. (B) Example small (0.5 µL) bacterial patches of greatest density. (C) Example small (0.5 µL) bacterial patches of lower density. The saturation of each image has been uniformly augmented to ∼22x darker to the extent that the OD600 10 (1H) bacterial patch is the same patch as the one in B. (D) Example small (0.5 µL) bacterial patches of lower density seeded on NGM agar plates lacking peptone. (E) Example medium (20 µL) bacterial patches of greater density. (F) Example medium (20 µL) bacterial patches of lowest density. The OD600 1 (1H) bacterial patch is the same patch as the one shown in E, but ∼22x darker.

Quantifying the relative density of bacterial patches across conditions and time points.

(A) Relative density of OP50-GFP bacterial patches matched to all assay conditions in this paper are shown. Relative density represents the relative border amplitude (as defined in Figure 2 – supplement 1 and Bacterial patch density estimation) normalized to the mean density of patches seeded with 0.5 µL of OD600 = 10 grown for 1 hour on plates with peptone (blue asterisk). In this manner, the bacterial patches experienced by animals in Figure 1 have been set to an average relative density of 10. Violin plots show the KDE and quartiles for each condition. (B) Linear fits for the relative density of bacterial patches in each condition as a function of time are plotted. Saturation of each line corresponds to the relative density as depicted in (A). For each experimental plate, the relative density of bacterial patches was estimated by applying the coefficients from these linear regressions to the total amount of time the bacteria was grown at room temperature.

Example traces of animals foraging in environments with varying bacterial density.

Traces showing the midbody location of 12 example animals as they forage within a 30 mm arena are plotted with color used to represent time (dark blue = 0 mins; dark red = 60 mins). Locations of bacterial patches are indicated in gray. The relative density of bacterial patches in each environment is noted. Animals shown foraging on relative density 0, 1, 5, 10, and 200 are the same as those in Figure 2D.

Time- and density-dependent increase in patch residence.

Probability of residing on patch was computed for all worms across time (black) and compared to the probability of residing on patch for semi-randomly permuted patch locations (pink) as described in Figure 1 – supplement 4. Smoothed median values are plotted with bootstrap-derived 2.5% and 97.5% quantiles shown in shaded regions. Time points where observed probabilities of residing on patch significantly exceed permuted probabilities are indicated by a black line (one-tailed Fisher’s Exact Tests with Benjamini-Hochberg correction, ***p < 0.001). The smoothed median values for observed data are shown in Figure 2F. Data for relative density 10 match those in Figure 1G.

Classifying encounters as exploration or exploitation.

(A) The average velocity of the animal during an encounter and the duration of that encounter are plotted for each encounter as visualized on a double-logarithmic plot. Contours showing the first, second, and third standard deviation of the two-dimensional Gaussian mixture model (GMM) are shown as shaded ellipses with saturation corresponding to standard deviation. Encounters for all data in the paper are individually plotted as in Figure 2H but with color representing the posterior probability of clustering classification as explore (green) or exploit (blue). (B) Posterior variance of the data as defined in Patch encounter classification as exploration or exploitation was calculated for 1000 replicates of GMMs with varied regularization value α. The classifier with minimum posterior variance (i.e., α = 0.025) was used. (C) The posterior probabilities for classification as explore (green) or exploit (blue) are sorted for all encounters, highlighting the low posterior variance of the GMM. (D) Posterior probabilities for only the data in Figure 2 are shown.

Classifying encounters as sensing or non-sensing.

(A) Minimum velocity (min. velocity on patch), maximum change in velocity (max. Δ velocity), and deceleration (Δ velocity) were calculated as described in Patch encounter classification as sensing or non-sensing. (B) Maximum change in velocity for every density condition is shown. Violin plots show the KDE and quartiles for each condition. (C) Deceleration upon encounter and minimum on-patch velocity during the encounter are plotted for each encounter. A three-dimensional parabolic boundary between sensing and non-sensing clusters was fit using semi-supervised QDA and a subset of labeled data (blue circles = sensing, dark orange circles = non-sensing). Regions identified by the classifier as non-sensing or sensing are indicated by colored contours (orange = non-sensing, green = sensing). Encounters for all data in the paper are individually plotted as in Figure 2I but with color representing the conditional probability of clustering classification as non-sensing (orange) or sensing (green). (D) Maximum change in velocity and minimum on-patch velocity during the encounter are plotted for each encounter in the paper as in (C). (E) Minimum velocity on patch, maximum change in velocity, and deceleration are shown for every encounter in the paper. See Video 5 for three-dimensional rotation of this plot. (F) The probabilities for classification as sense (green) or non-sense (orange) are sorted for all encounters. (G) Probabilities for only the data in Figure 2 are shown. (H) For a subset of encounters that were censored (i.e., recording did not observe animals entering the patch), probabilities of sensing were estimated using the semi-supervised QDA approach as well as via marginalization over the conditional probabilities using only the observed minimum velocity on patch. Marginalized probabilities were used for these values as described in Patch encounter classification as sensing or non-sensing.

Example traces of animals foraging in environments with one large bacterial patch.

Example traces showing the midbody location of 11 animals as they forage within a 30 mm arena are plotted with color used to represent time (dark blue = 0 mins; dark red = 60 mins). Location of bacterial patches are indicated in gray. The relative density of bacterial patches in each environment is noted. The animal shown foraging on relative density 10 is the same as that in Figure 3D.

Example traces of animals foraging in environments with one small bacterial patch.

Example traces showing the midbody location of 6 animals as they forage within a 9 mm arena are plotted with color used to represent time (dark blue = 0 mins; dark red = 60 mins). Location of bacterial patches are indicated in gray. The relative density of bacterial patches in each environment is noted. The animal shown foraging on relative density 10 is the same as that in Figure 2E.

Model selection for nested GLMs.

(A) Values of log-likehood, Aikake Information Criterion (AIC), and Bayesian Information Criterion (BIC) were computed for 50,000 replicates of the linear regression model described in Models of exploitation probability. Each of these metrics is plotted here across 100 replicates of “encounter samples” (i.e., we removed encounters where the animal likely did not sense the encounter νk = 0 as estimated from the distribution νk|wk ∼ Bern(p(νk = 1|wk))) and 500 replicates of hierarchically bootstrapped “worm samples” (i.e., we resampled animals with replacement and included all encounters of the resampled animals). Values for each metric at each replicate are colored to match their respective color bar. Metrics were computed for the addition of each covariate to the model. Lower AIC and BIC values for the full model ((i.e., β · xk = β0 + βkρk + βsτs + βhρh + βeρe), represent better model performance even with penalization for increasing the number of parameters. (B) Coefficients β* for the null distribution (i.e., observations of the response variable p(yk = 1|zk) shuffled relative to the covariates xk) are plotted. Only β0 was significantly greater than or less than 0 (two-tailed, one-sample bootstrap hypothesis tests with Bonferroni correction). Violin plots show the KDE and quartiles for each covariate across the 50,000 replicates. Asterisks denote statistical significance (*p<0.05; **p<0.01; ***p<0.001). These β* represent the null distribution for the β in Figure 4C.

Probability of first exploitation as a function of the number of encounters.

Histograms of the probability of first exploiting as a function of the number of encounters as estimated by the models and as observed are shown for animals foraging in single-density, multi-patch environments of all 12 density conditions. Exploitation events were simulated from a Bernoulli distribution with probability estimated by the model yk |xk∼ Bern(p(yk = 1|β · xk)) where covariates were added one at time as well as from the observed probabilities estimated by the Gaussian mixture model classification yk|zk ∼ Bern(p(yk = 1|zk)) in Figure 2H. Histograms for relative density 1 and 10 are the same as those in Figure 4D.

Exploitation decision of food-deprived animals is well-predicted by the model.

(A) Schematic of experiments used to test satiety’s influence on the decision to exploit. As in all experiments, animals were acclimated to high density (relative density ∼200) patches for ∼24 hours. Well-fed animals were then removed from these acclimation plates, cleaned of bacteria, and then immediately transferred to the assay plate with relative density 5. Food-deprived animals moved about a bacteria-free arena for 3 hours prior to the assay. Examples of animal behavior while foraging in acclimation-like, bacteria-free, and single-density, multi-patch environments of relative density 5 are shown. (B) Patch encounters for 28 food-deprived and 28 well-fed individuals are plotted across time. Each encounter is colored to match its probability of classification as search (orange), sample (green), and exploit (blue). (C) Coefficient values were re-estimated across 50000 replicates as in Figure 4C for a model with the satiety term removed (i.e., p(yk = 1|β0 + βkρk + βhρh + βeρe)). All coefficients are significantly greater than or less than 0 (two-tailed, one-sample bootstrap hypothesis tests with Bonferroni correction; ***p<0.001). Violin plots show the KDE and quartiles for each measure. (D) Histograms of the probability of first exploiting as a function of the number of encounters are shown for food-deprived and well-fed animals. Model predictions of exploitation events were simulated from a Bernoulli distribution yk|xk ∼ Bern(p(yk = 1|β · xk)) where the coefficient values β corresponded to those previously estimated for our linear regression model with (Figure 4C) and without (Figure 4 – supplement 3C) the satiety term using the data set shown in Figure 2 (i.e., the 443 well-fed animals foraging in one of 12 density conditions). Observed exploitations were simulated from a Bernoulli distribution using the probability of exploitation estimated by our GMM classifier yk|zk ∼ Bern(p(yk = 1|zk)) in Figure 2H. Summary data for all animals (N = 56 total worms; N = 28 worms per condition) and encounters (N = 277 total encounters; N = 42-235 encounters per condition) are shown in (B,D).

Example traces and classified behavior of animals foraging in environments with multiple patch densities.

(A) Example traces showing the midbody location of 7 animals as they forage within a 30 mm arena are plotted with color used to represent time (dark blue = 0 mins; dark red = 60 mins). Locations of bacterial patches are indicated in gray with saturation indicating the relative density. Environments contained combinations of patches with relative density 1, 4, and 7 as noted. (B) Patch encounters for 200 individuals (20-40 per condition) are plotted across time. Each encounter is colored to match its relative density. (C) Patch encounters are colored to match their probability of classification as search (orange), sample (green), and exploit (blue). (D) Coefficient values were re-estimated across 50000 replicates as in Figure 4C for a model with the history-dependent terms removed (i.e., p(yk = 1|β0 + βkρk + βsτs)). All coefficients are significantly greater than or less than 0 (two-tailed, one-sample bootstrap hypothesis tests with Bonferroni correction; **p<0.01; ***p<0.001). Violin plots show the KDE and quartiles for each measure. Summary data for all animals (N = 198 total worms; N = 20-40 worms per condition) and encounters (N = 3,493 total encounters; N = 282-795 encounters per condition) are shown in (B,C).

Example traces and classified behavior of animals with chemosensory or mechanosensory deficiencies.

(A) Example traces showing the midbody location of 9 animals as they forage within a 30 mm arena are plotted with color used to represent time (dark blue = 0 mins; dark red = 60 mins Location of bacterial patches are indicated in gray. The relative density of bacterial patches in each environment is noted. 3 strains of C. elegans were tested (grey = N2, pink = mec-4, orange = osm-6) across 3 conditions of relative density (1, 5, and 10). (B) Patch encounters for 76 individuals (16-44 per density condition) of each strain are plotted across time. Each encounter is colored to match its probability of classification as search (orange), sample (green), and exploit (blue). (C) Histograms of the probability of first exploiting as a function of the number of encounters are shown for each strain and density condition. Observed exploitations were simulated from a Bernoulli distribution using the posterior probability of exploitation defined by our GMM classifier yk|zkBern(p(yk = 1|zk)) in Figure 2H. Histograms of each strain for relative density conditions 1 and 10 are the same as those in Figure 4G. (D) Coefficients β* for the null distribution (i.e., observations of the response variable p(yk = 1|zk) were shuffled relative to the covariates xk) are plotted. Violin plots show the KDE and quartiles for each covariate across the 50,000 replicates. These β* represent the null distribution for the β in Figure 4H. (E) The ridge regression parameter λ was optimized for each strain to maximize the mean log-likelihood of the model. Summary data for all animals (N = 221 total worms; N = 14-44 worms per condition) and encounters (N = 1,352 total encounters; N = 27-193 encounters per condition) are shown in (B,C).