Invariance properties of bacterial random walks in complex structures

Motile cells often explore natural environments characterized by a high degree of structural complexity. Moreover cell motility is also intrinsically noisy due to spontaneous random reorientation and speed fluctuations. This interplay of internal and external noise sources gives rise to a complex dynamical behavior that can be strongly sensitive to details and hard to model quantitatively. In striking contrast to this general picture we show that the mean residence time of swimming bacteria inside artificial complex microstructures, can be quantitatively predicted by a generalization of a recently discovered invariance property of random walks. We find that variations in geometry and structural disorder have a dramatic effect on the distributions of path length while mean values are strictly constrained by the sole free volume to surface ratio. Biological implications include the possibility of predicting and controlling the colonization of complex natural environments using only geometric informations.

S wimming bacteria must find their way through complex structures that are so common both in their natural environment 1,2 and also in the laboratory [3][4][5] . More recently, microfabrication techniques have been increasingly used to design artificial environments with precise and tunable internal structure [6][7][8] . For example, arrays of scattering obstacles have been used to demonstrate the possibility of rectification and sorting in self-propelled systems [9][10][11] . In these applications it is often found that small details in dynamical behavior can have significant quantitative consequences. For example, the timescale of spontaneous reorientation or the distribution of scattering angles produced by obstacles have a dramatic effect on the rectification efficiency of microstructures [12][13][14] . In striking contrast, a recently rediscovered invariance property of random walks implies that the average path length inside a closed domain of arbitrary shape is only proportional to the volume to surface ratio with a numerical prefactor that solely depends on the spatial dimensions 15,16 . Despite its wide generality, this invariance property has started to find applications only very recently, mainly in the field of light propagation in turbid media 17,18 .
Here we study motile bacteria exploring artificial microstructures with arbitrary geometries and a wide range of obstacle densities. Using the invariance property, we quantitatively predict the mean length of the paths traced by bacteria inside these quasi-2D microstructures. Assuming that the mean swimming speeds are not significantly perturbed by the presence of obstacles, we further predict and experimentally verify the invariance of the mean residence time, a more biologically relevant quantity. As a result, for all obstacle densities, the mean residence time is only determined by the microstructure surface to perimeter ratio and the mean inverse speed.

Results
Design of artificial complex environments. We use direct laser writing by two-photon polymerization 19,20 to build 3D microchambers consisting of a thick "roof" supported by randomly distributed pillars fabricated on a microscope coverslip. A 1.4μm-thick gap between the coverslip and the roof confines bacteria in a quasi-2D geometry. The entire path traced by the cells inside the microchambers is therefore restricted on the focal plane and can be easily tracked by digital video microscopy (see Supplementary Movie 1). Moreover, the presence of two close surfaces prevents circular swimming caused by hydrodynamic coupling to a single solid wall 21,22 . In all experiments we use a smoothswimming strain of E. coli bacteria expressing a red fluorescent protein. Microstructures are immersed in a low-density cell suspension (~3 × 10 6 cells ml −1 , see Methods) that we track by epifluorescence videomicroscopy. The pillars play the role of obstacles and by varying their number we can tune the degree of internal complexity of the structures. The obstacles are fabricated as randomly distributed and non-overlapping short segments measuring 3.7 μm in length and with a thickness of 0.7 μm (see Supplementary Fig. 1). Obstacles with such an elongated shape significantly deflect colliding bacteria and can be densely packed inside microstructures.
Mean path length invariance in structures with increasing obstacle density. We fabricate a total number of 11 circular structures with a radius R = 31 μm and with a varying number of obstacles N = 7, 15, 25, 36, 46, 55, 64, 76, 86, 109, and 119. When N is small, bacteria traverse the structures with approximately straight trajectories (see Fig. 1a). Since the flux of bacteria through a line element of the boundary is proportional to the cosine of the angle between the cell swimming direction and the local boundary normal, the distribution of path lengths L for straight trajectories is given by the chord-length distribution pðLÞ ¼ L= 2R ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ffi 4R 2 À L 2 p . As shown in Fig. 1b, this distribution increases monotonically diverging at the maximum value L = 2R. The experimental distribution of path lengths, obtained by tracking~1000 bacteria in a structure with N = 7 obstacles, closely follows the theoretical distribution with small deviations due to rotational diffusion of bacteria and to scattering by the few isolated obstacles. When the number of obstacles is increased, bacteria are more likely to be back-scattered by obstacles close to the domain boundary giving rise to an excess of short paths that appears as a growing peak at small path lengths. At the same time, dense obstacles produce multiple deflections that result in trajectories with a total length that can exceed the circle diameter producing a tail in the distribution at L > 2R.
Despite the strong dependence on N of the path length distribution, the invariance theorem can be used to obtain a strikingly simple formula for the mean path length that quantitatively matches observed values for all N. To this aim we now illustrate a derivation of the invariance theorem using an ergodic type argument 15,23 . Let's imagine to observe for a total time T the motion of n non-interacting random walkers moving with constant speed v over a region of space of total area Σ. If reorientation dynamics is isotropic, the walkers will fill the region with a uniform concentration ρ ¼ n=Σ and an everywhere isotropic velocity distribution. The time t spent by each walker inside a generic subregion of area S will be given by: Alternatively we can obtain t as the mean residence time τ multiplied by the number of times each walker is expected to enter the subregion during the observation time T. This number can be obtained by counting the number of bacteria that enter the subregion in a total time T and then divide by n. Since, for an isotropic velocity distribution, the inward flux of walkers is ρv/π over the entire perimeter P of the subregion, we have: Equating (1) and (2) we obtain: When the subregion contains rigid obstacles, the above derivation remains valid as long as their presence does not significantly perturb the homogeneity of the density field in the accessible space and the isotropy of random walks along the domain boundary 24 . This condition is fulfilled for small and convex obstacles producing scattering events lasting for a short interaction time. In this regime, however, the total area S in Eq. 3 must be replaced with the total accessible area S′ ¼ S À Ns where s is the excluded area due to a single obstacle and Ns the total excluded area. Therefore the mean path length ' is expected to decrease linearly with the number of obstacles according to the law: In Fig. 1c we report as solid circles the experimental values of the mean path lengths as a function of the number of obstacles. Experimental data closely match the predicted linear behavior in (Eq. 4) with an intercept fixed at πS/P = πR/2 = 49.3 μm and a value for s = 6.3 μm 2 that is independently estimated by dilating the physical boundary of the obstacle by half the cell width (0.4 μm 25 ) (see Supplementary Fig. 1).
Mean residence time. There are many situations in which the residence time is more relevant then the path length. For example, if adhesion to surfaces is an activated process 26 the probability that a cell will remain stuck inside a structure will be proportional to the total time spent inside it. The population average residence time τ can be related to the mean path length under the reasonable assumption that cell speeds v are uncorrelated to path lengths L so that: with v ¼ 1=hv À1 i. Although speeds can be broadly distributed in a cell population we can again use the invariance property to quantitatively predict mean residence times once the characteristic speed v is known. The measured mean residence time as a function of N is plotted in Fig. 1c showing again a close agreement with the theoretical prediction in Eq. 5 where the parameter v has been independently measured from experimental trajectories.
The effect of size and shape. We have demonstrated that, for a fixed shape, the density of obstacles has a strong effect on the distribution of path lengths while leaving the mean value unchanged as long as the total internal accessible area remains the same.
We will now investigate the effects of shape and size on the path length distributions and again conclude that, although path distributions are very sensitive to the detailed geometry of the domain, mean path lengths and residence times can be accurately predicted using only the surface to perimeter ratio. We fabricate microstructures of circular, squared and triangular shapes all in four different sizes as shown in Fig. 2a. In all structures the obstacle density is fixed to N/S = 0.016 μm −2 . All recorded trajectories are also plotted in Fig. 2a with a color map encoding the scaled path length L/'. In Fig. 2b we plot for each structure the histogram of path lengths normalized by the expected value ' in Eq. 4. As we move from circles to squares and then to triangles we observe that the corresponding histograms are characterized by larger frequencies for both short and long path lengths. The probability of short paths increases as we introduce convex corners and reduce their angle, as evidenced by the blue-violet color of the corners in squared and triangular structures. The presence of longer paths in triangles can be also understood noting that the normalized maximum straight paths for circles, square and triangles are respectively 4/π, 4 ffiffi ffi 2 p /π and 4 ffiffi ffi 3 p /π (see Supplementary Fig. 2). Despite these qualitative and quantitative differences between histograms, mean path lengths are always close to 1 when normalized by the predicted value ' as shown in Fig. 2b. The observed path length distributions can be very well reproduced by a Lorentz gas model where collisions with obstacles are described as instantaneous reorientation events 27 . These events are assumed to occur with a constant probability per unit path length given by ρσ, where σ ¼ 2b/π is the rotational average cross section of line obstacles with length b (see Methods). For perfectly straight trajectories, circles and squares have path length distributions with a vertical asymptote. A strong peak is found at the location of this divergence and is progressively smeared as the linear size of the domain becomes larger than the mean free path λ ¼ ðρσÞ À1 . Upon increasing the size of the region a peak around L ¼ 0 appears due to bacteria that scatter close to the boundary, reorient and exit. The mix of these two types of trajectories gives rise to the observed doublepeak structure. Differently for the triangle no asymptote is present in the P(L) for large λ, therefore only a peak at L ¼ 0 progressively appears. These results show that P(L) depends strongly on the random walk properties (as the mean free path), and on the domain features (shape and size). Differently the  Fig. 3a for all shapes and sizes. We find an excellent agreement with theory using the same value s = 6.3 μm 2 that was used previously to predict the experimental values of ' as a function of the number of obstacles (see Fig. 1c). This value of s has also been used to calculate τ according to Eq. 5 which captures quantitatively well the experimental data as shown in Fig. 3b.

Discussion
In conclusion, we have shown that bacterial random walks inside complex and crowded microstructures do obey a general invariance property that constraints the mean value of the path length to a simple and predictable value uniquely determined by the surface to perimeter ratio of the structure. More interestingly the mean residence time is also invariant as long as the surface to perimeter ratio remains constant. In a counterintuitive way, a greater number of obstacles does not increase the average residence time, but shortens it by decreasing the total accessible surface. Our results are very general and should remain valid also for any other type of swimming microorganisms or self-propelled colloids provided that the obstacles do not capture the particles for prolonged periods and do not alter the conditions of an isotropic velocity distribution over the domain's boundary, as for example would happen if our obstacles were all aligned. In this direction, an interesting question could be how to generalize our results in the presence of further reorientation mechanisms, such as tumbling in wild type bacteria. The robustness of these results also provides a solid starting point for further generalizations of the invariance formula to include the effects of interactions in dense systems, the presence of flow or chemotaxis. Simulations. We simulate bacterial trajectories as straight runs intercalated by random reorientations (run and tumble dynamics) that mimic collisions with obstacles. Run lengths are exponentially distributed with a mean free path λ ¼ ðρσÞ À1 . The obstacle density ρ is fixed to the experimental value ρ = 0.016 μm −2 . The obstacle cross section σ = 2.9 μm is evaluated as the average cross section of a randomly oriented line with length b = 4.5 μm, i.e. σ ¼ π À1 R dθ bcosðθÞ ¼ 2b/π. Assuming that an elongated particle fully aligns with a line-shaped obstacle, collisions will produce angular deflections δ that are only determined by the obstacle orientation and restricted to the interval [−π/2, π/2]. Weighting each outgoing direction with the cross section of the correspondingly tilted obstacle we obtain the distribution of deflection angles p(δ) = sin |δ| for |δ| ≤ π/2 and zero elsewhere. We also account for a small reduction in δ that could be caused by hydrodynamic interactions, causing particles to curve around the obstacle edges 30 , or by the fact that reorientation during collision takes a finite time 22 , while the obstacle has finite length. The total deflection angle is then set to δ′ ¼ δ À signðδÞ α, where α is set to α = 0.39(≈π/8) to fit the histograms in Fig. 2b.
Reporting summary. Further information on research design is available in the Nature Research Reporting Summary linked to this article.

Data availability
The data that support the plots within this paper and other findings of this study are available from the corresponding authors upon reasonable request.

Code availability
Author contributions