Spatial distribution of two types of sharp turns.

(left) The spatial distribution of both spontaneous sharp turns and escape turns inside the arena. (Middle) Spontaneous turns, defined as sharp turns that occur during forward crawling, occur at an equal rate. (right) The escape turn rate, defined as sharp turns following a reversal, is sharply increased near the repellent boundary of the arena. Pixels at the edge that have been occupied by a worm with fewer than 5k data points (− 7 min) are not included.

Figure 1—figure supplement 1. Worm collisions minimally impact the trajectory dynamics.

Figure 1—figure supplement 2. Average speed across all worms remains mostly constant.

Ω and δ turns are separated by thresholding the loading of the third Eigenworm Broekmans et al. (2016); Stephens et al. (2008).

(A) The distribution of (top) ventral and (bottom) dorsal maximum Eigenmode loadings across both spontaneous sharp turns and escape turns. The ventral distribution can be approximated as the sum of 2 Gaussians (black). The orange Gaussian is an approximation of the Ω turn distribution, and the blue Gaussian is an approximation of the δ distribution. The A3 value where the lines cross, 18.0 (black dashed line), is henceforth used as the threshold to separate Ω and δ turns. The dorsal distribution only includes Ω turns. (B) The distribution of (top) ventral and (bottom) dorsal reorientation angles towards the direction of the body bend. The distribution of Ω and δ turns after thresholding the maximum A3 amplitude in orange and blue respectively.

Variability in turn frequency, but not D-V bias or Ω-δ bias, substantially affects exploratory propensity.

(A) Schematic illustration and population-average statistics of the three random variables that govern spontaneous sharp turns: (left) the turn frequency, ζ; (center) the dorsal turn probability P(D), a measure of D-V bias in sharp turn orientation; (right) the δ-turn probability P(δ|V), a measure of Ω-δ bias for ventral turns. The most common turn type is an Ω-turn in the ventral direction. (B-D) Distribution across the population of the three random variables ζ (B), P (D) (C), and P (δ | V) (D) indicate substantial variability across individuals. Blue bars represent statistics for individual measured trajectories, and orange bars are from Monte Carlo simulations assuming all individuals are sampled from a population with identical parameters for the corresponding random variable (see Methods). (E-G) Relationship between the trajectory persistence length P, a measure of exploratory propensity, and the three random variables ζ (F), P (D) (G), and P (δ | V) (H). P demonstrates a substantial negative correlation with the sharp turn rate ζ (−0.59 ± 0.12, 95% CI; p ≤ 7.7 · 10−11), but its correlation with D-V bias and Ω-δ bias was, respectively, insignificant (−0. 13 ±0.25, 95% CI; p ≤ 2. 1 · 10−1) and marginally significant (−0.20 ± 0. 14, 95% CI, p ≤ 4.2 · 10−2). Indicated p-values were computed using a t-test assuming a two-tailed probability.

Figure 3—figure supplement 1. Interval distribution of spontaneous turns.

Figure 3—figure supplement 2. Variability across worms compared to random resampling.

Figure 3—figure supplement 3. Variance attributed to individual experience and batch effects.

Figure 3—figure supplement 4. Mean-squared displacement of individual worms and population average.

Gradual turning behaviour during exploration demonstrates both short-time fluctuations and long-time biases.

(A) Representative trajectory segments (10, 000 frames = 14.5 min) for 3 individual worms, demonstrating strong (blue), intermediate (green) and weak (red) gradual-turn bias and correspondingly different trajectory curvature. In addition to the ‘loopiness’ caused by the long-timescale bias, diffusive orientation fluctuations induce wiggles in the shape of trajectories. Scale bar 10 mm. (B) Gradual-turn bias can cause trajectories to accumulate many net rotations during the course of the experiment, resulting in a slope. A positive value means that the worm has rotated more in the ventral direction than in the dorsal direction. Inset: angular changes on short time scales from undulatory fluctuations, result in an effective angular diffusion DΨ. (C) The average mean-square angular displacement (MSAD) and (inset) the local exponent (i.e. log-log slope) of the unwrapped average body angle across worms of our data set (blue) and a previously published data set from ref. Stephens et al. (2010) (green; see Methods) show near ballistic behaviour on long time-scales. A slope of 1 indicates diffusive angular dynamics, and a slope of 2 corresponds to ballistic angular dynamics. The dip in the slope of the blue curve of the MSAD at ≈ 2 s can be attributed to angular oscillations due to the body wave (and is not observed in the green curve, due to differences in the sampling rate and the manner in which angular dynamics were extracted; see Methods). (D) Probability density histogram of the angular diffusion coefficient DΨ, extracted from each of 100 individual trajectories. (E) Probability density histogram of the local gradual-turn bias K, defined as the average trajectory curvature within 15 min windows, extracted from all such non-overlapping windows in all 100 trajectories. The sign of κ was set to be positive in the ventral (V) direction and negative in the dorsal (D) direction. The average rotational drift for each worm shows no dorso-ventral population mean. (F) Slow fluctuations gradual-turn bias decorrelate on a timescale comparable to the duration of the measurement, and can be fit by a single-exponential decay with a time constant of82 ± 17 min. Because the time scale of the fluctuations is similar to the length of the measurement, the mean cannot be established of individual measurements, and the global mean value of 0 is used. (G) The angular diffusivity DΨ is negatively correlated with the persistence length P, with a correlation coefficient −0.57 ± 0. 13 (95% CI) (p < 2.9 · 10−10). (H) The root-mean-square gradual-turn bias κRMS is strongly negatively correlated with the persistence length P, with a correlation of −0.72 ± 0. 11, (95% CI) (p < 1.3 · 10−17). Indicated p-values were computed using a two-tailed t-test.

Figure 4—figure supplement 1. Reorientations are nearly decorrelated after a single body wave.

A simple turning model explains the data and reveals an optimality principle for exploration under biasing constraints

(A) Exploratory propensity, characterized by the trajectory persistence length P, decreases monotonically with increasing turning bias κ, regardless of the rate of random reorientations ε. (B) By contrast, P can either increase or decrease with ε, depending on the value of κ. (C) The measured persistence length Pdata agrees well with predictions of the model Pmodel based on the turning parameters κRMS and ε measured in each worm. The analytical model assumes a constant | κ | = κRMS. (D) The magnitude of the gradual-turn bias κRMS and the effective random-reorientation rate ε is of the same order. Each trajectory is displayed as a white point. The red point is the population average, computed from all trajectories. The orange point indicates the population average for the case that sharp turns are ignored (equivalent to the limit α → 0 in our model), so that ε is defined by rotational diffusion alone (i.e. εDΨ). Error bars represent 95% confidence intervals. The analytical expression for the persistence length is P = ε/(κ2 + ε2)/2, where κ is a constant angular drift (thus |κ| = κRMS) and ε = αζ/s + DΨ is the effective reorientation rate with the angular diffusion coefficient DΨ, the speed s, the sharp turn frequency ζ, and a factor α accounting for the non-uniform distribution of sharp turn angles.

Figure 5—figure supplement 1. The analytic solution of the model closely follows simulations.

Figure 5—figure supplement 2. Evidence for the existence of small reorientation events.

Escape-turn statistics reveal discrete, rather than continuous, control of exit angles to overcome biasing constraints.

(A) We characterise worm orientation during escape turns by the angle θin of the body orientation vector (pointing from tail to head) relative to the repellent gradient (approximated as the vector pointing from the worm centroid to the nearest point on the repellent boundary), where θin = 0° means the worm points directly up the gradient and 0° < θin < 180° and −180° < θin < 0° correspond to the nearest repellent boundary being on the ventral and dorsal sides, respectively. (B) The average reorientation angle 〈|Δθ1〉 of escape turns close to the boundary demonstrates negligible dependence on θin for dorsal Ω-(green), ventral Ω-(orange) and ventral δ-turns (blue), respectively. The dashed line denotes the values for spontaneous turns. (C) Like for spontaneous turns, the worm makes a decision between dorsal and ventral turns, and if turning ventrally between omega and delta turns. The decision tree shows the average probabilities for spontaneous turns (P(D) = 0.24 ± 0.01, P(δ|V) = 0. 18 ± 0. 1) and escape responses close to the boundary (P(D) = 0. 16 ± 0.01, P(δ|V) = 0.40 ± 0.02). Escape-like turns far away from the boundary display intermediate values for P (D) = 0.21 ± 0.03 and P (δ|V) = 0.30 ± 0.03. (D) The D-V bias of escape turns is modulated such that the dorsal turn probability P (D) is suppressed when the repellent is encountered on the dorsal side (−90° < θin < 0°). Dashed line: average P (D) for spontaneous turns during exploration. (E) The Ω-δ bias of ventral escape turns is also modulated, with the δ-turn probability P (δ|V) being increased when the repellent is encountered on the ventral side (0° < θin < 90°). Dashed line: average P (δ|V) for spontaneous turns during exploration. (F) After the turn, the worm leaves at an angle θout (red arrow), which is defined in the environmental reference frame, analogously to θin with θout = 0 if the worm is heading directly towards the boundary. In the anatomical reference frame of the moving worm, the escape turn results in an exit angle either on the ventral side (via a ventral Ω-turn) or on the dorsal side (via a dorsal Ω- or a ventral δ-turns) of its body. Successful escape in the anatomical reference frame is defined by turns that result in exiting the turn on the opposite side of the body as the repellent encounter (gold arrows). (G) The environmental escape probability quantifies how likely the worm is moving moving away from the repellent boundary after the turn (i.e. | θout| > 90°), which depends on the incoming angle θ in. The distribution is asymmetric and higher if the cue is encountered on the dorsal side of the body. (H) The escape probability in the anatomical reference frame quantifies whether the worm escapes on the dorsal or ventral side of its incoming body, respectively: = (1 − P(D))(1 − P(δ|V)) if θin ≤ 0° and = P(D) + (1 − P (D)) P(δ|V) if θin ≥ 0°. It is modulated depending on the incoming orientation θin. The black dotted curve denotes a fit of ±A sin(θin) + 0.5. In all panels, shaded regions correspond to 95% confidence intervals.

Figure 6—figure supplement 1. Escape turns are triggered at the boundary.

Figure 6—figure supplement 2. Comparison of escape response and spontaneous turn across individuals.

Worm collisions minimally impact the trajectory dynamics.

(A) The sharp turn frequency is not affected by the collusion events as the total number of sharp turns (summed up over all worms and all times) is approximately the same before and after a collision (t = 0 marks the midpoint between firstand last contact with another worm during a collision). The dip at t = 0 is from the duration of the collision. (B) A collision event has no long-term effects on the speed. Shaded regions show the 95% confidence interval, bootstrapped for collisions.

The average speed across all worms has a small increase during the first 20 min, but remains constant for the remaining duration of the measurement.

The interval distribution of spontaneous turns for (blue) all worms and (black) individuals.

The observed variability across worms is significantly larger compared to random resampling using population averaged statistics.

(A) The standard deviation of (red) the population average turn frequency and (blue) the standard deviation of resampled statistics using the interval distribution (Figure 3–Figure Supplement 1). (B)The standard deviation of the measured dorsal turn probability, weighted by the total number of spontaneous turns, is significantly larger compared from random sampling using a coin-flip model using the population average statistics. (C) The standard deviation of the measured delta turn probability, weighted by the total number of ventral turns, is significantly larger compared from random sampling using a coin-flip model using the population average statistics.

The portion of the variance in the measurements that can be attributed to individual experience (blue) and batch effects (orange).

The remaining part is attributed to the stochastic nature of the process. Individual experience is estimated by sampling either the interval distribution in the case of turn frequency or sampling from a binominal distribution in the case of dorsal-δ-turns, where the probabilities are sampled from pooled data from the same batch. This way, batch effects and stochastic effects are included, while individual effects are removed. The relative change in variance is referred to as the individual contribution. The sampling process is repeated to estimate the uncertainty. To estimate the effect of batches, first the mean of each batch is subtracted and subsequently total variance is estimated (reducing the degrees of freedom by the number of batches). This is compared against the total variance without subtracting batches. 95% confidence intervals are obtained by bootstrapping for batches. The fraction for variance not accounted for can be attributed to variability as a result of the stochastic processes.

The mean-squared displacement of the individual worms (black) and their population average (blue) as function of the trajectory length is ballistic for short lengthscales, then becomes diffusive proportional to the persistence length, and finally saturates due to the confinement of the arena.

Reorientations are nearly decorrelated after a single body wave.

To eliminate the effect of the body wave oscillations, the orientation Ψ was evaluated every body wave at the same body posture, computed from the phase of the first 2 Eigenworms Stephens etal. (2008). ΔΨ is the difference of Ψ after exactly 1 body wave. The distribution flattens at a value slightly greater than 1, due to the rotational bias. Interval distributions show the 95% confidence interval of the mean across all worms.

The analytic solution of the model closely follows simulations.

Simulations are performed with constant speed (s = 0.15 mms−1) and 2 · 106 data points at 2Hz, using the orientational dynamics described in equation (1) and (2). A large space of motility parameters has been simulated that includes that of the measurements. κ and ζ/s have been varied from 0mm−1 to 1 mm−1 in steps of 0.2mm−1. DΨ has been varied from 0.1 mm−1 to 0.9 mm−1 in steps of 0.2 mm−1. Sharp turn are modelled as a complete randomization of the reorientation. The persistence length extracted from the simulated trajectories is practically identical (correlation of 99.8%) to that computed from the model (equation (3)).

The reorientation distribution is well fitted by 2 Gaussians, which may indicate the existence of small reorientations.

The orientation has been evaluated after subsequent body waves during runs at similar body postures (evaluated from the first 2 Eigenworms Stephens et al. (2008)), to ignore the effect of the oscillatory motion. (A) The reorientation angle ΔΨ is well fitted as the sum of 2 Gaussians (orange curve), with a standard deviation of 13.5° ± 0.1° and 28.3° ± 0.4° with mean values of 4.3° ± 0.9° and −2.8° ± 0.3°, respectively (yellow curves). Fits are performed with the lmfit package in python using the Levenberg-Marquardt method. (B) Four exemplary (left) time series and (right) centroid trajectories of potential shallow turns with a reorientation angle > 45°. To compute the curvature rate, the average body angle of the worm is evaluated at equally spaced distances of 20 µm and the derivative is computed using a Savitzky–Golay filter (3rd order with a window size 300 µm).

Escape turns are triggered when the worm approaches the boundary and reorient the worm away from the boundary. The average distance from the boundary is averaged across escape turns.

Worm variability in (A) dorsal and (B) δ preference during the escape response and spontaneous turns is not significantly correlated.