Introduction

When the cell density of a suspension of swimming bacteria increases, collective motion emerges, characterized by intermittent jets and swirls of groups of cells1,2,3. This behaviour is observed for many microorganisms not only in artificial but also in natural situations, often at an interface, e.g., when bacteria swarm on a moist surface in the lab4,5,6,7,8 or during infection9, or at an air-water interface during formation of pellicle biofilms1,10. Bacterial collective motion has been extensively studied experimentally11,12,13,14 and theoretically15,16,17,18,19,20, and it is known to emerge from the alignment between the self-propelled cells21. Two alignment mechanisms have been proposed, based either on steric interactions between the rod-like bacteria22,23,24 or on the hydrodynamics of the flow they create as they swim15,17, which displays a pusher force dipole flow symmetry3,25,26. However, the relative importance of these two mechanisms has not been clearly established so far27.

Bacterial collective motion contrasts to the behaviour of individual motile cells in dilute suspension, when bacteria swim in relatively straight second-long runs interrupted by short reorientations (tumbles), resulting at long times in a random walk by which they explore their environment28. Bacteria can furthermore navigate in environmental gradients by biasing this motion pattern: they lengthen (resp. shorten) their runs when swimming toward attractive (resp. repulsive) environment28. The biochemical signalling pathway controlling this chemotactic behaviour is well understood in E. coli29,30 and it is one of the best modelled biological signalling systems31. Bacteria monitor—via their chemoreceptors—the changes in environmental conditions and respond to them by modifying a phosphorylation signal transmitted to the flagellar motors to change the tumbling frequency accordingly32,33. In E. coli, attractant substances repress the phosphorylation signal, which results in prolonged runs, repellents having the opposite effect. An adaptation module slowly resets the receptor sensitivity for further stimulations, via a negative feedback loop34,35. This effectively allows the cell to compare its current situation to the recent past while swimming along a given direction30, with a memory time scale of a few seconds36,37. Notably, the rotational Brownian motion of the cell body interferes with this mechanism of sensing by randomly changing the direction of swimming while temporal comparisons are performed28,29.

Although typically seen as a single-cell behaviour, chemotaxis also drives collective behaviours based on chemical interactions, such as autoaggregation38,39, self-concentration in patches40,41 and travelling band formation42,43, where the chemotactic response to self-generated gradients of chemoattractants leads to local cell density increases. However, very little is known about how the high-density physical interactions and the resulting collective motion influence the chemotactic navigation of bacteria44,45: for example, it is unclear whether chemotaxis would be improved by alignments of convective flows with the gradient19,45 or instead compromised by random collisions between cells. This lack of knowledge is in part due to the technical difficulty of measuring the dynamics of cells in a dense suspension20. Over the last few years, new image analysis methods have been developed or adapted to bacterial systems2,46,47,48,49, which exploit intensity fluctuations46 or intensity pattern shifts49 to characterize swimming and chemotaxis in populations of bacteria. These Fourier image analysis methods function at arbitrarily high cell densities, capture the dynamics of all cells without bias, and are at least as fast as the more commonly used particle tracking techniques.

In this paper, we use Fourier image analysis methods to investigate how the collective motion developing with increasing cell density affects the ability of E. coli populations to follow controlled chemical gradients in a microdevice. Our experimental results and computer simulations show that, after increasing up to a maximum at intermediate densities, chemotaxis is strongly reduced as collective motion developed in the sample. Collective reorientations act similarly to an active rotational diffusion interfering with the chemosensing mechanism. Additionally, the characteristics of the collective motion are consistent with hydrodynamic interactions being the primary driver of its emergence, additional steric effects being important but secondary. These results have important implications for collective behaviours of motile bacteria at high density.

Results

Measuring chemotactic motion at variable cell density

To measure both the collective dynamics and the chemotactic response of populations of E. coli cells at varying density, we analyzed bacterial swimming in controlled gradients of a chemical attractant using a microfluidics setup, videomicroscopy and Fourier image analysis. Microfabricated devices made of the oxygen-permeable polymer poly-dimethylsiloxane (PDMS) were used as described previously49 to create quasi-static linear gradients of the non-metabolizable attractant \(\alpha\)-methyl-D,L-aspartic acid (MeAsp) in a straight channel (Fig. 1a). This gradient could be mimicked using the fluorescent dye fluorescein (Fig. 1b), which has a diffusion coefficient similar to the one of MeAsp (\(D\simeq 500\ \mu\)m\({}^{2}\)/s). Three channel heights, \(h=50\), \(30\) and \(8\ \mu\)m, were used to increasingly confine the cell suspensions towards two dimensions. Motility of suspensions of E. coli bacteria, measured in the middle of this gradient, was sustained for several hours at all cell densities (Supplementary Fig. 1a), due to oxygen availability and abounding energy source in the medium. When the density increased, the development of collective motion in the sample, characterized by the existence of collective eddies and jets of swimming cells was observed (Fig. 2a) as expected2,13,20. The shape of the gradient, after the transient phase during which it becomes established, is largely unaffected by the collective motion (Fig. 1c), except at the highest bacterial cell body volume fractions. Consistantly, the Peclet number, which compares diffusion and advective transport of MeAsp in an eddy, remains moderate (\(Pe=h{v}_{{\rm{f}}}/D\le 1\), where \({v}_{{\rm{f}}}\) is the fluid velocity; see Supplementary Note 1), confirming that stirring by the bacteria has little effect on the diffusion of MeAsp50. Furthermore, in the present geometry, at steady state the gradient shape does not depend on the diffusion coefficient. Because the cell density slowly changes with time in the area of measurement due to the chemotactic accumulation, thus differing from the average cell density in the suspension, the cell body volume fraction \({\Phi }_{{\rm{c}}}\) was measured in situ for each experiment (Supplementary Fig. 2 and “Methods”).

Fig. 1
figure 1

Microfluidic device used for chemotaxis assays. a Schematic representation of the device, where two reservoirs with different chemical composition are connected by a channel in which the chemoattractant gradient forms. b Central part of the device, highlighted orange in (a), with gradient profile across the channel quantified using fluorescein. Scale bar is 500 \(\mu\)m. The red box indicates the location at which cellular behaviour is recorded. c Examples of gradients, measured in the \(h=50\ \mu\)m device, for cell suspensions of indicated cell densities. Error bars represent measurement error.

Fig. 2
figure 2

Collective motion in bacterial suspensions. a Typical snapshot of the velocity field measured in a high-density cell suspension (\({\Phi }_{{\rm{c}}}=0.08\), cell length \(L=2\ \upmu\)m, channel height \(h=50\ \upmu\)m). b Flow structure factor \(E(q)\) for increasing cell densities at the indicated values of channel height and cell length. c Amplitude of the peak, corrected for the low-density value, \(\Delta E({q}_{{\rm{str}}})\) as a function of cell density in the different experimental conditions. Each point is the median, and associated error bar the standard error of the mean (SEM) of 8 measurements, binned according to cell density. Inset: \(\pi /{q}_{{\rm{str}}}\) as a function of channel height. Dashed line indicates equality.

To further investigate the effect of cell elongation, which is typically observed for bacteria swarming on a wet hydrogel at high density4, we compared normally-sized E. coli with average length \(L=2\ \mu\)m and cells elongated to an average of \(L=4\ \mu\)m upon treatment with cephalexin, a drug preventing cell division (“Methods” and Supplementary Fig. 2). We observed that the cephalexin treatment strongly increases cell autoaggregation, which is mediated in this E. coli strain by the adhesin Antigen 4338. We then used \(\Delta\)flu strain deleted for the gene encoding this adhesin for all results reported in this study, since, in absence of the cephalexin treatment, flu+ and \(\Delta\)flu cells behave similarly, regarding both their collective motion and chemotaxis (Supplementary Fig. 3), and the elongated \(\Delta\)flu cells show normal motility (Supplementary Fig. 1).

Structure of the collective motion

The collective motion was measured in the gradient using an image velocimetry method derived from Phase Differential Microscopy49 (“Methods”) to quantify the local velocity field \({\bf{v}}({\bf{r}})\), averaged over several neighbouring bacteria (Fig. 2a). The spatial structure of the flow field at varying cell volume fraction \({\Phi }_{{\rm{c}}}\) was characterized by the 2-dimensional power spectral density of the velocity field (“Methods”)20:

$$E(q)=q{\left\langle \frac{\tilde{{\bf{v}}}({\bf{q}},t){\tilde{{\bf{v}}}}^{{\boldsymbol{* }}}({\bf{q}},t)}{{A}_{0}\left\langle {{\bf{v}}}^{2}\right\rangle }\right\rangle }_{t,| {\bf{q}}| =q}\ ,$$
(1)

with \({\tilde{\bf{v}}}\) the spatial Fourier transform of \({\bf{v}}\), \({\bf{q}}\) the wave vector and \({A}_{0}\) the area of the field of view. This quantity \(E(q)\) (Fig. 2b) measures the distribution of kinetic energy over the flow structure sizes \(\pi /q\), hence representing the probability to observe a “vortex” of size \(\pi /q\)20. At \({\Phi }_{{\rm{c}}}\gtrsim 0.01\), this flow structure factor exhibits, at a low wave number \({q}_{\max }\), a maximum \(E({q}_{\max })\), which grows in amplitude as the cell volume fraction increases (Fig. 2b). After an initial decrease, the value of \({q}_{\max }\) reaches a plateau \({q}_{{\rm{str}}}\) at moderate cell volume fraction, corresponding to \(E({q}_{\max })\gtrsim 15\ \mu \)m (Supplementary Fig. 4a). Fully developed collective motion thus takes the form of flow structures (eddies) with a specific size, \(\pi /{q}_{{\rm{str}}}\). An increase in cell density results in an increase of the amount of collective flow of this size – the amplitude of the collective motion, which can be quantified by \(E({q}_{{\rm{str}}})\). Interestingly, \({q}_{{\rm{str}}}\) is apparently determined by the height \(h\) of the channel (Fig. 2c inset and Supplementary Fig. 4a), indicating that the flow structures are constrained by the system size. The observed decrease of \({q}_{\max }\) at low cell volume fraction might be due to a combination of \(E({q}_{\max })\) reaching the noise level, represented by the featureless \(E(q)\) observed at the lowest cell volume fractions (Fig. 2b), and a genuine reduction of the eddy size when \({\Phi }_{{\rm{c}}}\) becomes low.

For simplicity, the amplitude of the collective motion was quantified by \(\Delta E({q}_{{\rm{str}}})\) at all volume fractions (Fig. 2c), i.e., \(E({q}_{{\rm{str}}})\) (Supplementary Fig. 4b, c) corrected for background noise. We observed that \(\Delta E({q}_{{\rm{str}}})\) tends to grow more slowly with volume fraction for more confined suspensions (lower \(h\)). At moderate confinement (\(h=30\) and \(50\ \upmu\)m), \(\Delta E({q}_{{\rm{str}}})\) also grows more slowly for longer cells, whereas for \(h=8\ \mu\)m it is on the contrary a single function of \({\Phi }_{{\rm{c}}}\) for both cell lengths (Fig. 2c). Importantly, when normalized to its value at high \({\Phi }_{{\rm{c}}}\), \(\Delta E({q}_{{\rm{str}}})\) was found to be for all conditions a single function of the flux of bacterial mass integrated over the vortex size \({\Phi }_{{\rm{c}}}{v}_{0}\ \pi /{q}_{{\rm{str}}}\), where \({v}_{0}\) is the population-averaged swimming speed of the cells (Supplementary Fig. 4d). For \({\Phi }_{{\rm{c}}} {\,} \lesssim {\,} 0.01\), \({v}_{0}\) itself is on average constant at a value between \(10\) and \(25\ \upmu\)m/s which depends on cell length and the degree of confinement, and also tends to vary between biological replicates (Supplementary Fig. 1b, c). At \({\Phi }_{{\rm{c}}} {\,} \gtrsim {\,} 0.01\), \({v}_{0}\) progressively increases, by a factor of up to two, as \(\Delta E({q}_{{\rm{str}}})\) grows and the collective motion developped, consistantly with previously reported behaviour2.

Dependence of chemotaxis on cell density

The chemotactic response of the cells to the MeAsp gradient was first quantified using their chemotactic drift velocity \({v}_{{\rm{ch}}}\), i.e., the population-averaged speed of displacement up the gradient, measured as detailed in the “Methods” section following Colin et al.49. The gradient of MeAsp concentration (from 0 to 200 \(\upmu\)M in 2 mm) was chosen to maximize \({v}_{{\rm{ch}}}\) at low cell density49. For all combinations of cell length \(L\) and channel height \(h\), we observed that the chemotactic drift \({v}_{{\rm{ch}}}\) first tends to increase when the cell volume fraction \({\Phi }_{{\rm{c}}}\) increases in the range \(5\ 1{0}^{-4}-0.01\). It then strongly decreases above a cell volume fraction \({\Phi }_{{\rm{c}}}\) that depends on \(L\) and \(h\), corresponding to the one above which collective behaviour is observed (Fig. 3a). Consistantly, the drift decreases as function of \(\Delta E({q}_{{\rm{str}}})\), albeit differently for each \(L\) and \(h\) (Supplementary Fig. 5). Swirling collective motion thus clearly impairs the ability of the cells to perform chemotaxis.

Fig. 3
figure 3

Effect of collective motion on the chemotactic drift. a, Chemotactic drift \({v}_{{\rm{ch}}}\) as a function of cell density for indicated values of cell length (L) and channel height (h). b Chemotactic coefficient \({v}_{{\rm{ch}}}/{v}_{0}^{2}\) as a function of cell density. cd Chemotactic coefficient normalized to its low-density value as a function of cell density (c) or of the amplitude \(\Delta E({q}_{{\rm{str}}})\) of the collective motion (d). Labels throughout the figure are defined in panel (a). Each point represents the median of 8 experiments. Error bars represent the SEM in abscissa and the sum of the SEM and the mean measurement error in ordinate.

Since the chemotactic drift depends both on the cell swimming speed and on their ability to bias their direction of motion towards the gradient—the chemotactic efficiency, we aimed to separate these two contributions by normalizing \({v}_{{\rm{ch}}}\) to the swimming speed \({v}_{0}\). For non-interacting cells in 3D in a chemical gradient, they are expected to be related by51,52,53:

$${v}_{{\rm{ch}}}=G{v}_{0}^{2}\tau \left({\tau }_{{\rm{m}}},{\tau }_{{\rm{T}}},{\tau }_{{\rm{R}}}\right)\nabla f(c)\ ,$$
(2)

where \(G\) is the total gain of the chemotaxis system, \(f(c)\) is the part of the chemoreceptor free energy difference due to the binding of chemical ligand, present at concentration \(c\) and \(\tau\) is the typical time during which the bacterium is able to measure a change of \(f(c)\) in a given direction. The latter depends on the memory time scale \({\tau }_{{\rm{m}}}\) as well as on two reorientation times. The first is due to Brownian rotational diffusion during the runs, \({\tau }_{{\rm{R}}}=1/{D}_{{\rm{r}}}\), with \({D}_{{\rm{r}}}\) the rotational diffusion constant of isolated cells. The other is due to tumbling, \({\tau }_{{\rm{T}}}={\tau }_{0}/(1-\exp (-{D}_{T}{\tau }_{{\rm{t}}}))\), with \({\tau }_{0}\) the steady state tumbling rate and \({D}_{T}{\tau }_{{\rm{t}}}\) the mean squared angular change during tumbles. It is expected from previous studies51,52,54 that (Supplementary Note 2):

$$\tau =\frac{{\tau }_{{\rm{R}}}}{{\tau }_{{\rm{R}}}+{\tau }_{{\rm{T}}}}\,\frac{{\tau }_{{\rm{T}}}}{1+{\tau }_{{\rm{T}}}/{\tau }_{{\rm{R}}}+{\tau }_{{\rm{T}}}/{\tau }_{{\rm{m}}}}\ .$$
(3)

In absence of interactions, according to Eq. 2, the chemotactic coefficient \({v}_{{\rm{ch}}}/{v}_{0}^{2}\) depends only on internal—fixed—parameters of the chemotaxis pathway and on the fixed concentration profile. This quantity was therefore chosen to quantify chemotactic efficiency at all densities, although at high densities cell behaviour might deviate from Eq. 2. We observed that the chemotactic coefficient \({v}_{{\rm{ch}}}/{v}_{0}^{2}\), like the chemotactic drift, tends to increase with volume fraction, peaks at a condition–dependent \({\Phi }_{{\rm{c}}}\) around \(0.01\), before decreasing sharply —by a factor of up to 100—as the collective motion develops (Fig. 3b). We therefore concluded that both the intermediate maximum of \({v}_{{\rm{ch}}}\) and its subsequent reduction by the collective motion arise from cell-density effect on the chemotactic efficiency, and that the moderate increase in swimming speed at high cell density cannot compensate for the much stronger density dependence of the chemotactic coefficient.

Chemotaxis was also found to be affected by cell length and channel height. Even at low cell volume fraction, if cells are longer or in a higher channel, they have a higher chemotactic coefficient \({v}_{{\rm{ch}}}/{v}_{0}^{2}\) (Fig. 3b). Cell elongation is indeed expected to result in increased chemotactic coefficient in steady gradients55, because of the lower Brownian rotational diffusion of longer cells51 and their expected reduced tumbling angle42,56. To directly compare the pure effect of cell density under various \(L\) and \(h\), chemotactic coefficients were normalized to the average value at low volume fractions (\({\Phi }_{{\rm{c}}} {\,} < {\,} 0.0015\)) in each condition (Fig. 3c). Even this normalized chemotactic coefficient is significantly higher for longer cells at \({\Phi }_{{\rm{c}}} {\,} > {\,} 0.01\) under moderate confinement (\(h=50\) and \(30\ \upmu\)m, Fig. 3b). It is however a single function of \({\Phi }_{{\rm{c}}}\), irrespective of cell length, for \(h=8\ \upmu\)m (Fig. 3c).

The behaviour of the chemotactic coefficient is thus reminiscent of the one of \(E({q}_{{\rm{str}}})\). Indeed, the normalized chemotactic coefficient was found to be a single function of the amplitude of the collective motion \(\Delta E({q}_{{\rm{str}}})\), irrespective of the cell length and channel height (Fig. 3d), decreasing exponentially as a function of \(\Delta E({q}_{{\rm{str}}})\) from its low-density value. The amplitude of the collective motion therefore appears to determine the reduction of the ability to follow gradients, irrespective of vortex size \(\pi /{q}_{{\rm{str}}}\), for \({\Phi }_{{\rm{c}}} {\,} \gtrsim {\,} 0.01\), in all conditions.

Collective reorientations impair chemotaxis

As the indirect effect of gradient distortion by the swimming bacteria could be ruled out (Fig. 1), we hypothesized that the observed reduction of chemotaxis at high density is due to the forced reorientations resulting from the physical interactions, which would interfere with the sensing mechanism based on temporal comparisons: As the cell is swimming, it monitors the change in chemoattractant concentration within a few seconds, to decide whether to tumble. If during this time the direction in which the cell swims has changed significantly, the decision becomes less relevant, thus making the biochemically hard-wired bacterial chemotaxis strategy inefficient. In this hypothesis, collective reorientations would then act analogous to an enhancement of rotational diffusion, where the time scale of sensing \(\tau\) would decrease because \({D}_{{\rm{r}}}\) effectively increases52,53,57, reducing the chemotactic coefficient accordingly (Eqs. 2 and 3).

To test whether collective reorientations may indeed reduce chemotactic drift, we performed numerical simulations of a population of self-propelled chemotactic rods of variable aspect ratio \(L\) in a viscous medium, with the cell motion being confined to two dimensions. The cells interact sterically upon contact as well as hydrodynamically (Fig. 4a), being transported and reoriented by the flow generated by the other cells, which were approximated as pusher force dipoles in Hele-Shaw geometry8,58. The strength and reach of the hydrodynamic interaction is channel-height dependent in this approximation because of viscous friction on the walls (Methods and Supplementary Fig. 6). Rods reorient rotationally when tumbling, with the tumbling probability being determined according to the concentration of chemoattractant experienced by the rod, using a model of the chemotaxis system of E. coli59. They also are subject to rotational Brownian motion, with the rotational diffusion coefficient \({D}_{{\rm{r}}}\) being smaller for longer cells55.

Fig. 4
figure 4

Numerical simulations of self-propelled interacting chemotactic rods in 2D. a Schematic representation of the simulated steric interaction between the rods, where interpenetration (\(\delta\)) results in Hertzian-like repulsion (\({F}_{{\rm{el}}}\)) and friction (\({F}_{{\rm{fr}}}\)), and the fluid flow generated by the hydrodynamic force dipole, here for channel height \(h=30\ \upmu\)m. For other heights, see Supplementary Fig. 6. b Snapshot of a simulation output (length \(L=4\ \upmu\)m, \(h=30\ \upmu\)m, \(\Phi =0.244\)), showing collective motion of packs of rods. The green shading represents the gradient. c Flow structure factor \(E(q)\) for indicated conditions, exhibiting a growing maximum at a \({q}_{{\rm{str}}}\) depending only on the channel height \(h\). Darkening shading of a given colour indicates increasing area fraction in the range \(0.002-0.25\). d Maximum subtracted of its low-density value, \(\Delta E({q}_{{\rm{str}}})\), as a function of cell area fraction. (Inset) Typical vortex size \(\pi /{q}_{{\rm{str}}}\) as a function of the channel height. Note the difference in scale compared to Fig. 2c. e Chemotactic coefficient as a function of the cell area fraction. Dotted lines represent its value in absence of interactions. f, Chemotactic coefficient, normalized to its low-density value, as a function of the maximum of the flow structure factor \(\Delta E({q}_{{\rm{str}}})\). g Time autocorrelations of the cells velocity, the colour coding is the same as in (c). h Chemotactic coefficient as a function of the decorrelation time \({\tau }_{{\rm{dec}}}\), defined by \({C}_{v}({\tau }_{{\rm{dec}}})=0.5\), and fit according to Eq. (4). df, h, Conditions are as indicated in panel d and error bars represent SEM on at least 3 runs, totalizing at least 1000 cells.

When the cell area fraction increases in the simulations, the rods form increasingly large swirling packs of cells, similarly to previous reports, whether hydrodynamic interactions are present8,14,20,58 (full simulations, Fig. 4b) or not23,24 (steric-only simulations, Supplementary Fig. 7). However, qualitatively better agreement with experiments is achieved when hydrodynamic interactions are taken into account, suggesting that they are the primary contributor to the emergence of the collective motion in this case. Notably, when hydrodynamics is accounted for, the flow structure factor \(E(q)\) peaks at a \({q}_{str}\) which depends only on channel height and not on cell density or cell length, in agreement with experiments (Fig. 4c), although the simulated vortex size is smaller than the experimental one. In contrast, when only steric interactions are simulated, \({q}_{\mathrm{str}}\) clearly depends on cell length (Supplementary Fig. 7d). The dependences of simulated \(E({q}_{{\rm{str}}})\) on channel height, cell length and cell density in the full simulations are similar to the experiments (Fig. 4d). Similarly, the swimming speed \({v}_{0}\) increases in the full simulations, although to a lesser extent than in the experiments, whereas it decreases in the steric-only case (Supplementary Fig. 8), suggesting that this increase is due to hydrodynamic entrainment and further confirming the importance of hydrodynamic interactions in the emergence of the collective motion.

In the full simulations, the chemotactic coefficient \({v}_{{\rm{ch}}}/{v}_{0}^{2}\), plotted as a function of cell body area fraction, decreases at the cell densities where the collective motion develops (Fig. 4e). However, contrary to the experiments, no increase in chemotactic coefficient is observed at intermediate cell area fractions. Nevertheless, \({v}_{{\rm{ch}}}/{v}_{0}^{2}\) does scale with \(E({q}_{{\rm{str}}})\), as in the experiments, although with a sharper decrease (Fig. 4f). In the steric-only simulations, \({v}_{{\rm{ch}}}/{v}_{0}^{2}\) instead peaks as a function of cell area fraction at high densities but it is not a single function of \(E({q}_{{\rm{str}}})\) (Supplementary Fig. 7e).

Finally, we took advantage of having access to all single-cell trajectories in the simulations to gain more insight into the mechanism of chemotactic drift reduction. The time autocorrelation of the individual cell velocity \({{\bf{v}}}_{i}\), \({C}_{v}(t)={\left\langle {{\bf{v}}}_{i}(t+{t}_{0})\cdot {{\bf{v}}}_{i}({t}_{0})\right\rangle }_{i,{t}_{0}}/{\left\langle {{\bf{v}}}_{i}^{2}({t}_{0})\right\rangle }_{i,{t}_{0}}\), shows a faster decorrelation as cell density increases for all values of \(h\) and \(L\), because of the collective reorientations (Fig. 4g). We used the decorrelation time, defined as \({C}_{v}({\tau }_{{\rm{dec}}})=0.5\), as a measure of directional persistence (Supplementary Fig. 9a). In absence of all physical interactions, the decorrelation time depends on the Brownian and tumbling reorientation times as \(1/{\tau }_{{\rm{dec}}}=1/{\tau }_{{\rm{R}}}+1/{\tau }_{{\rm{T}}}\), and combining Eqs. 2 and 3, the chemotactic coefficient can be written as:

$$\langle {v}_{{\rm{ch}}}/{v}_{0}^{2}\rangle =\frac{{\tau }_{{\rm{dec}}}^{2}/{\tau }_{{\rm{T}}}}{1+{\tau }_{{\rm{dec}}}/{\tau }_{{\rm{m}}}}G\nabla f(c)\ .$$
(4)

At higher cell densities, \({\tau }_{{\rm{dec}}}\) also includes collective reorientations, \(1/{\tau }_{{\rm{dec}}}=1/{\tau }_{{\rm{R}}}^{{\rm{eff}}}+1/{\tau }_{{\rm{T}}}\), with \(1/{\tau }_{{\rm{R}}}^{{\rm{eff}}}=1/{\tau }_{{\rm{R}}}+1/{\tau }_{{\rm{C}}}\) an effective rotational diffusion rate including Brownian (\({\tau }_{{\rm{R}}}\)) and collective (\({\tau }_{{\rm{C}}}\)) reorientation times. Despite this additional contribution of collective motion, the dependence of the simulated chemotactic coefficient as a function of \({\tau }_{{\rm{dec}}}\) is found to follow Eq. 4 very well at all densities, with the computed—and not fitted—coefficient values given in Supplementary Table 2, for all conditions in the full simulations (Fig. 4h). The effect of simulated collective motion can therefore be interpreted as an active enhancement of rotational diffusion, which decreases \({\tau }_{{\rm{R}}}^{{\rm{eff}}}\), hence \({\tau }_{{\rm{dec}}}\) and the drift. In contrast, the chemotactic coefficient does not match well the dependence on the reorientation time predicted by Eq. 4 when only steric interactions are taken into account (Supplementary Note 3 and Supplementary Fig. 6h). Notably, the reorientations coming from physical cell-cell interactions do not necessarily respect the detailed balance of cell orientation fluxes, as Brownian rotational diffusion does, which may explain the deviations from Eq. 4 that we observed even when the hydrodynamic interactions are taken into account (Supplementary Note 4 and Supplementary Figs. 9 and 10).

Discussion

Although the principles of bacterial chemotactic sensing are fairly well understood for a single cell29,31, little was known about the effects of physical interactions between cells on chemotaxis, despite their frequent occurrence during self-concentration processes38,39,40,41,42,43 and high-density collective motility4,5,10. While the physical properties of the collective motion, e.g. in a swarming colony, are largely unaffected by activity of the chemotaxis pathway58,60,61, the reverse is not necessarily true. Here, we thus used suspensions of E. coli in a controlled environment as a model system to investigate the effect of collective motion, emerging when cell density increases, on chemotactic sensing.

We observed that the size of bacterial flow structures in fully developed collective motion is set by the smallest system size, the channel height, independently of cell length and volume fraction, and that an increasing amount of the kinetic energy of the system gets poured into this flow structure as the cell density increases. This property strongly suggests that hydrodynamics plays the primary role in the emergence of the collective motion, since, in the Hele-Shaw geometry of our system, the channel height sets the reach of the hydrodynamic interaction8, fundamentally because of viscous friction on its top and bottom walls. Previous works also predicted that the largest possible flow structure—set by system size—dominates in hydrodynamics-based collective motion15,62. Also consistent with previous simulations of such motion63 is the observed reduction of the total kinetic energy at fixed \({\Phi }_{{\rm{c}}}\) but under increased confinement. Interestingly, similar flow properties are observed for the hydrodynamics-based collective flows during sedimentation of dense suspensions of passive particles64,65. Consistantly, our numerical simulations show that considering hydrodynamic interactions is key to reproduce the main experimental features, including the dependence of the vortex size on channel height, and its independence of cell length. Although the simulated vortex size is smaller than in the experiments, such shifts were previously observed on other quantities for this type of model58. Notably, besides the channel height, hydrodynamic interactions also set another characteristic length in our system, the hydrodynamic dipole length. This might explain the apparent saturation of the vortex size at about \(20\ \upmu\)m in the experiments, when the channel height approaches the estimated dipole length (\(\sim {\!}6\ \upmu\)m).

Physical interactions between cells at high densities result in a strong reduction and ultimately in the abolishment of the specific ability of E. coli to track chemical gradients, and thus of the chemotactic drift, despite the moderate increase in swimming speed due to collective entrainment. The collective motion is the driver of this decrease, with its amplitude \(E({q}_{{\rm{str}}})\) being the sole determinant of reduced chemotactic efficiency. Collective motion acts directly on the mechanism of gradient-sensing since the gradient itself is little affected. Our analysis based on agent-based simulations suggests that this reduction is induced by an increased reorientation rate of cell bodies due to the collective motion, whether it emerges from steric or hydrodynamic interactions, which in this sense acted similarly to an active rotational diffusion. Importantly, we conclude that Eq. 2 derived for non-interacting swimmers can describe the chemotactic drift well at all densities, provided that the time scale of rotational diffusion is set to account not only for Brownian but also for interaction-induced reorientations. A similar reduction of chemotaxis by forced cell reorientations could be expected in other contexts, such as cells swimming in circles near surfaces66 or during migration through a porous medium where cells collide with obstacles67,68.

In contrast to the inhibition at high densities, the chemotactic drift is enhanced between low and intermediate densities. Although the nature of this increase remains to be elucidated, it is unlikely to result from self-attraction38,39 or other chemical effects, as its extent depends on the degree of confinement and on cell length. In the simulations, a similar enhancement is observed when only steric interactions are considered—but not with the full model including hydrodynamic interactions, although it is not clear whether the nature of the transient enhancement in those simulations is the same as in the experiments. This discrepancy, along with the other quantitative differences between experiments and simulations, could potentially be explained by a number of factors our hydrodynamic simulations do not account for, such as collisions with the top and bottom channel walls and other physical effects neglected by two-dimensional confinement, flagellar entanglements and fluid flows affecting the flagellar bundles stability69, as well as the point force approximation.

The observed regulation of chemotactic behaviour through physical interactions among motile cells has several important consequences for bacterial high-density behaviours. First, it provides a physical mechanism that might regulate chemotactic accumulation of bacteria near sources of chemoattractants (e.g., nutrients), because gradually increasing cell density70 would initially promote and subsequently limit the process. Indeed, this effect could explain why the density of cells entering a capillary filled with chemoattractant saturates as a function of the cell density in the suspension71. The density for which the chemotactic drift is maximal, \({\Phi }_{{\rm{c}}}\simeq 0.01\), which should play a cut-off role, is indeed the typical maximal cell density reached within travelling chemotactic bands which form through a self-generated gradient42,43. Thus, the hitherto neglected effects of physical interactions should be taken into account when describling these phenomena, in conditions for which the density gets high. Second, the observed strong reduction in chemotactic drift at cell densities typical of swarming (\({\Phi }_{{\rm{c}}} \sim 0.30\))5 suggests that, without specific counteracting mechanisms, chemotactic navigation of bacteria swimming within a swarm is nearly impossible, consistent with recent indications that the swarm expansion rate is set by the cell growth rate rather than motility8. Interestingly, we observed that cell elongation, one of the major hallmarks of swarming bacteria4, indeed improved chemotaxis at high \({\Phi }_{{\rm{c}}}\) under moderate confinement. However, it appeared to have little effect under stronger confinement expected in the swarm. Bacterial swarming was already known to be unaffected by the lack of functional chemotactic sensing60,61. Although more prominent steric interactions within a swarming colony7,8 might potentially improve tracking of gradients at high density, as could other differences in swimming behaviour72,73, or additional cohesive interactions44 caused by cell differentiation in a swarm, our results suggest that the emergence of swirling collective motion fundamentally undermines the chemotactic behaviour.

Methods

Strains and cell culture

Escherichia coli strain W3110 (RpoS+), flu+ or \(\Delta\)flu38, were grown at 34 \({}^{\circ }\)C in Tryptone Broth (TB) from a 100-fold dilution of overnight culture to an optical density at 600 nm OD\({}_{600}=0.7\). Where applicable, the culture was supplemented with 0.01 \(\%\) cephalexin at one division time (\(1\) h) before harvesting the cells. Cells were washed thrice and resuspended in motility buffer (\(10\) mM KPO\({}_{4}\), \(0.1\) mM EDTA, \(67\) mM NaCl, pH \(7.0\)) supplemented with \(55\) mM glucose as energy source, cooled to 4 \({}^{\circ }\)C for 20 min to reduce metabolic activity and then concentrated by centrifugation (\(1.5\ 1{0}^{3}\) g, \(7\) min) to a final cell density of \({\Phi }_{{\rm{c}}} \sim 0.20\) (OD\({}_{600} \sim 100\)). Series of dilutions were then performed in motility buffer, so that the amount of glucose per cell remains constant for all cell densities (\(\sim {\!}0.5\) mM/OD\({}_{600}\)).

Microfabrication

Molds were fabricated using standard photolithography and microfabrication techniques. The SU8 photoresist (MicrochemTM) was spincoated on a silicon wafer for 90 s, covered with a positive mask of the device, produced using AutoCAD and printed by JD Photo Data (UK), and exposed to UV light, baked and developed according to manufacturer instructions. SU8 grade and spincoat speeds are indicated in Supplementary Table 1. Poly-di-methylsiloxane (PDMS), in a 1:10 crosslinker to base ratio, was poured on the cast, degazed, baked overnight at 70 °C, peeled off, cut to shape and covalently bound on isopropanol-rinsed microscopy glass slides after oxygen plasma treatment. PDMS to glass covalent bounds were allowed to form for 15 minutes at room temperature and the devices were then filled with sterile DI water for short term storage (few hours), in order to retain their hydrophilic properties.

Chemotaxis assay

The assay was described in detail previously49. In the microfluidic device (Fig. 1a), the two reservoirs were filled with cell suspensions of the same volume fraction supplemented with either no or 200 \(\upmu\)M \(\alpha\)-methyl-D,L-aspartic acid (MeAsp), and then sealed to avoid residual flows. The MeAsp gradient formed in the 2 mm long, 1 mm wide, channel connecting them. Bacterial motion in the middle of the channel was recorded thrice, at one hour interval, at mid-height, in phase contrast microscopy at \(10{\!}\times\) magnification, using a Mikrotron 4CXP camera (\(1\) px \(=1.4\ \upmu\)m, field of view \({A}_{0}=512\times 512\) px\({}^{2}\), \(1\) ms exposure) running at 100 frames/s (fps).

Gradient calibration

For gradient calibration experiments, the suspensions—at various cell densities—in the second reservoir were supplemented with 100 \(\upmu\)M fluorescein as well as attractant. The gradient was measured in wide-field fluorescence microscopy (excitation filter 470/40, emission 525/50) at \(10{\!}\times\) magnification. Images were recorded using an Andor Zyla 4.2 sCMOS camera in the middle of the channel and in the attractant reservoir, the former being divided by the latter to correct for inhomogeneous illumination.

Motility measurements by Fourier image analysis

Cell motility was quantified by analysing the movies with three different algorithms. The first is differential dynamic microscopy (DDM), a now well established technique46,47, computing differential image correlation functions (DICF), which were fitted to extract the average swimming speed of the population of cells \({v}_{0}\) and the fraction of swimming cells \(\alpha\), as well as the local cell density (see below). The shortcomings due to the breakdown of two assumptions of Wilson et al.46—even distributions of swimming directions and round cell images—were accounted for via calibrations (see below). Second, phase differential microscopy (\(\Phi\)DM)49 determined the population-averaged drift velocity of the population of cells \({v}_{d}={\langle {v}_{x}(i,t)\rangle }_{i,t}\), with positive \(x\) being the up-gradient direction, \(i\) cell index and \(t\) frame number. The chemotactic velocity, corrected for the fraction of non swimming cells, is then \({v}_{{\rm{ch}}}={v}_{d}/\alpha\). Lastly, maps of the local velocity field were obtained by using a local \(\Phi\)DM algorithm described in detail below. This image velocimetry technique estimated the velocity of a group of few cells located within a region \(5\ \upmu\)m in diameter around a position \({\bf{r}}=(x,y)\). The local velocity field \({\bf{v}}({\bf{r}},t)\) was thus calculated for each time point \(t\), and its spatial Fourier transform, \(\tilde{{\bf{v}}}({\bf{q}},t)=\int \int d{\bf{r}}\ {\bf{v}}({\bf{r}},t)\exp \left(-i{\bf{q}}.{\bf{r}}\right)\), then led to the flow structure factor via Eq. 1.

Local image velocimetry algorithm

The image analysis algorithm is as follows, with parameter values as chosen for our analysis: In a movie of \(T=1{0}^{4}\) frames of size \({A}_{0}={L}_{0}\times {L}_{0}\) pixels (\({L}_{0}=512\)), the local velocities are computed at points situated on a square lattice spaced by a distance \(da=4\) px, starting from a distance \(a/2\) from the edges of the frame (\(a=32\) px). For this, submovies of size \(a\times a\) are considered, each centred on one of the points (represented by the index \(k\) in the following) . The spatial discrete Fourier transform of the blurred time frame \(t\) in the submovie \(k\) is computed as:

$${I}_{k}^{bl}({\bf{q}},t)=\int \int {\rm{d}}r{I}_{k}({\bf{r}},t)\exp \left(-{{\bf{r}}}^{2}/{l}^{2}\right)\exp \left(-i{\bf{q}}{\bf{r}}\right)\ ,$$
(5)

where \(r=0\) in the centre of the submovie and \(l=3\) px is a filtering range. The size of the group of cells, for which the instantaneous velocity is computed, can thus be tuned independently of the Fourier transform parameters. Changes in pixel intensities at a distance farther than \(l\) will not contribute to the evaluation of the velocity at the point considered.

In the fashion of \(\Phi\)DM49, the phase \(\delta {\phi }_{k}({\bf{q}},t)\) of the complex correlator \({I}_{k}^{bl}({\bf{q}},t+1){I}_{k}^{bl}{({\bf{q}},t)}^{* }\) is computed and summed to get \({\phi }_{k}({\bf{q}},t)={\sum }_{t^{\prime} =0}^{t-1}\delta {\phi }_{k}({\bf{q}},t^{\prime} )\). This phase is fitted as a function of \({\bf{q}}\) to get the cummulated displacement \({{\bf{r}}}_{k}(t)\), \({\phi }_{k}({\bf{q}},t)={\bf{q}}\cdot {{\bf{r}}}_{k}(t)\)49. The local instantaneous velocity \({{\bf{v}}}_{k}(t)\) is then computed by fitting:

$${{\bf{r}}}_{k}(t^{\prime} )={{\bf{r}}}_{k}(t)+{{\bf{v}}}_{k}(t)(t^{\prime} -t)$$
(6)

on a range of \(\tau =20\) frames centred on \(t\). Note that this method for measuring local displacements is equivalent to particle image velocimetry (PIV), since the phase of the correlation in Fourier space corresponds to the peak of the image cross-correlation in real space used in PIV to measure such displacement.

In situ measurement and calibration of cell body volume fraction

Chemotaxis microfluidic chips without a chemoattractant gradient were filled with suspensions of defined cell concentration, measured by OD\({}_{600}\). The DCIF \(g(q,\tau )={\langle | I({\bf{q}},t+\tau )-I({\bf{q}},t){| }^{2}\rangle }_{t,| {\bf{q}}| =q}\) were computed from DDM and fitted according to

$$g(q,\tau )={a}_{0}(q)+{a}_{1}(q)(1-f(q,\tau ))\ ,$$
(7)

where \(f(q,\tau )\) is the intermediate scattering function yielding the cells average swimming speed and fraction of swimmers46,47. The amplitude \({a}_{1}\simeq g(q,+\infty )=2{\langle | I({\bf{q}},t){| }^{2}\rangle }_{t,| {\bf{q}}| =q}\) is expected to scale as \({a}_{1}(q) \sim f({N}_{{\rm{part}}}){\langle I\rangle }^{2}F(q)S(q)\), where \({N}_{{\rm{part}}}\) is the number of bacteria in the field of view, \(S(q)\) is the structure factor of the bacterial fluid and \(F(q)\) is a form factor describing the shape of the bacteria. As can be seen in Supplementary Fig. 2a, \({a}_{1}(q)/{\langle I\rangle }^{2}\) has a single maximum for each \({{\rm{OD}}}_{600}\). This maximum was found to obey the equation \({a}_{1}^{\max }/{\langle I\rangle }^{2}=1.25\ m\ {{\rm{OD}}}_{600}/(1+m\ {{\rm{OD}}}_{600})\) (Supplementary Fig. 2b), where \(m\) is a constant depending on the length of the bacteria and the height of the channel, for channel heights \(h=50\ \upmu\)m and \(h=30\ \upmu\)m. In the channel height \(h=8\ \upmu\)m, the data were more scattered due to the difficulty of obtaining a truly homogeneous suspension even in absence of gradient, and the equation \({a}_{1}^{\max }/{\langle I\rangle }^{2}={d}_{0}\ m\ {{\rm{OD}}}_{600}/(1+m\ {{\rm{OD}}}_{600})\), with \({d}_{0}\) also depending on cell length, was found to better fit the data (Supplementary Fig. 2c). In all experiments, we then used \({a}_{1}^{\max }/{\langle I\rangle }^{2}\) obtained from the DDM measurement to evaluate the local \({{\rm{OD}}}_{600}\) via the appropriate equation.

The correspondance between optical density and cell body volume fraction was determined by counting cells in suspensions of known OD\({}_{600}\) flowing at 17.5 \(\upmu\)L/min in a flow cytometer (BD Fortessa), which led to a size-dependent correspondance between cell number density (\({n}_{{\rm{c}}}\)) and OD\({}_{600}\). The average length \(L\) of the cells was evaluated by segmenting and fitting as ellipses phase contrast microscopy images of the cells (magnification \(\times 40\), NA \(0.95\)) using ImageJ (Rasband, W.S., ImageJ, U. S. National Institutes of Health, Bethesda, Maryland, USA, http://imagej.nih.gov/ij/, 1997–2016.). The cell body volume fraction was then \({\Phi }_{{\rm{c}}}=\pi {r}^{2}L{n}_{{\rm{c}}}\), where \(r=0.5\ \upmu\)m is the radius of an E. coli cell. The volume fraction was found to be proportional to optical density for both cell sizes, \({\Phi }_{{\rm{c}}}=(1.78\pm 0.03)\ 1{0}^{-3}\ {{\rm{OD}}}_{600}\) (Supplementary Fig. 2d), yielding the local \({\Phi }_{{\rm{c}}}\) for all experiments.

Calibrations of the swimming speed measurement

Confinement effect compensation

Classical fits of the intermediate scattering function46 assume that the cells are swimming in 3D with equal probability in all directions. Biased swimming directions in the plane of the field of view were also shown to not affect the measurement as long as the swimming speed of the cells is the same in all directions49 (in other words, if chemotaxis, but not chemokinesis, biases swimming). If the distribution of swimming directions is however biased in the direction perpendicular to the field of view (z), the measured velocity will be systematically biased. This was notably the case when the suspension gets confined towards two dimensions, in the \(h=30\) and \(8\ \upmu\)m channels. Analytical predictions exist for the DICF both for the 3D and 2D cases, but intermediate situations are more complex; The 3D analytical expression was thus used to extract the velocity and corrected as follows.

Since cells are partially confined in the z direction, we expect that the swimming speed \({v}_{0}\) measured using the formula, valid for cells swimming isotropically in three dimensions46:

$$f(q,\tau )={e}^{-D{q}^{2}\tau }\left(1-\alpha +\alpha \left(\frac{Z+1}{Zq{v}_{0}\tau }\right)\frac{\sin \left({Z}^{-1}{\tan }^{-1}\lambda \right)}{{\left(1+{\lambda }^{2}\right)}^{Z/2}}\right)\ ,$$
(8)

with \({\sigma }_{v}={v}_{0}/\sqrt{Z+1}\) and \(\lambda =q{v}_{0}\tau /(Z+1)\), will be systematically biased compared to the real velocity. To evaluate this bias, the following experiment was conducted. The PDMS chips with 50 and 30 \(\upmu\)m height were bound by plasma treatment facing each other and to a glass slide (Supplementary Fig. 11a). Cell suspensions at OD\({}_{600}\simeq 1\) were flown in the chamber—without a gradient created—and let to equilibrate for one hour. The motion of the bacteria was recorded successively in the two channels of different heights and the effective swimming speed \({v}_{0}\) was extracted using Eqs. 7 and 8 for both channels. The ratio \({v}_{0}(30)/{v}_{0}(50)\) was found to be \(1.075\pm 0.01\) (SD − \(N=10\) repeats). The ratio being higher than \(1\) was expected since confinement makes the horizontal runs more probable and therefore increases the apparent 3D velocity. The same game played on the \(h=8\ \upmu\)m channel lead to a ratio \({v}_{0}(8)/{v}_{0}(50)=1.14\pm 0.02\) (SD − \(N=5\) repeats). All effective velocities obtained by 3D fitting in both devices of lower heights were divided by the corresponding factor to deduce the real swimming speed.

Effect of cell length

The formula 7 is valid only in the case of bacteria with isotropic shapes or for which the orientation of the anisotropic shape is uncorrelated with the direction of motion. This is a good approximation in the case of \(2\ \upmu\)m long cells observed in phase contrast at \(10\times\) magnification, but not anymore for \(4\ \upmu\)m long cells in these conditions. For anisotropic objects like rods, Eq. 7 becomes, in the non interacting case:

$$g(q,\tau )={a}_{0}(q)+\langle {I}^{2}\rangle S(q){\int }_{0}^{2\pi }\langle F(q,\theta )f(q,\theta ,v\tau )\rangle {\rm{d}}\theta$$
(9)

were \(\theta\) measures the orientation of the rods. Only when \(q\) becomes smaller than \(1/a\), \(a\) being the largest size of the objects, does \(F(q,\theta )\to 1\), and \(g(q,\tau )\) can be fitted as in Wilson et al.46 (Eqs. 8 and 7) irrespective of the shape of the particles. The outcome \({v}_{0}(q)\) of the fit of the DICF is plotted for randomly chosen experiments with non-treated and elongated cells in Supplementary Fig. 11b. For elongated cells, above \(q=0.9\) px\({}^{-1}\), the fitted \({v}_{0}\) decreased because of the anisotropy. We therefore used the values of \({v}_{0}\) in the range \(q=0.4-0.9\) px\({}^{-1}\) to evaluate the swimming speed in the case of elongated cells, whereas \(q=0.4-2.0\) px\({}^{-1}\) was used for the normal cells.

Simulations

We performed agent-based simulations of the rod-like—length L, width e—chemotactic particles in two dimensions in a \(256\times 256\ \upmu\)m\({}^{2}\) box with periodic boundary conditions. The particles are self-propelled in an overdamped fluid at constant propulsion force and interacted by exerting forces and torques on each other in the form of a Hertzian repulsion \({{\bf{F}}}_{ij}^{{\rm{el}}}\), a friction \({{\bf{F}}}_{ij}^{{\rm{fr}}}\) and far-field hydrodynamic interactions, which we accounted for following Jeckel et al.8. We write \({{\bf{F}}}_{ij}^{{\rm{tot}}}={{\bf{F}}}_{ij}^{{\rm{el}}}+{{\bf{F}}}_{ij}^{{\rm{fr}}}\) the sum of the elastic repulsion and friction generated upon contact by particle \(j\) on \(i\):

$${{\bf{F}}}_{ij}^{{\rm{el}}}={K}_{{\rm{el}}}\ {\delta }_{i,j}^{3/2}\ {{\bf{u}}}_{ij}\ ,$$
(10)
$${{\bf{F}}}_{ij}^{{\rm{fr}}}=-{K}_{{\rm{fr}}}({{\bf{v}}}_{i}-{{\bf{v}}}_{j})\cdot {{\bf{v}}}_{ij}\ \ {{\bf{v}}}_{ij}\ ,$$
(11)

with \({{\bf{u}}}_{ij}\) and \({{\bf{v}}}_{ij}\) the normalized orthogonal vectors defined in the inset of Fig. 4a, \({\delta }_{i,j}\) the inter-penetration depth between particle \(i\) and \(j\). The free running velocity of particle \(i\) is \({{\bf{v}}}_{i}={v}_{i}{{\bf{n}}}_{i}\), with a norm \({v}_{i}\) chosen randomly in a Gaussian distribution of mean \({v}_{0}\) and variance \(d{v}_{0}\) and direction \({{\bf{n}}}_{i}=(\cos ({\theta }_{i}),\sin ({\theta }_{i}))\). Note that \({{\bf{F}}}^{{\rm{fr}}}\), which was not included in previous studies22,23,24, could be interpreted as effectively resulting from short-range cell-cell interactions including viscous shear in the thin liquid film between two cells, complex flagellar entanglement, and solid friction. The particles can be in two states, either running (\({\Theta }_{i}=1\)) or tumbling (\({\Theta }_{i}=0\)). During tumbles, self-propulsion is switched off and a random torque made the particle turn, with an average magnitude chosen to match literature reported turning angle distributions74. The equations of motion for their position \({{\bf{r}}}_{i}\) and orientation \({\theta }_{i}\) are therefore:

$$\frac{{\mathrm{d}}{{\bf{r}}}_{i}}{\mathrm{d}t}={\Theta }_{i}\ {v}_{i}{{\bf{n}}}_{i}+{\Sigma }_{j}\frac{{{\bf{w}}}_{j}({{\bf{r}}}_{i})+{{\bf{w}}}_{j}({{\bf{r}}}_{i}-{L}_{{\rm{dip}}}{{\bf{n}}}_{i})}{2}+({\gamma }_{\perp }^{-1}{\bf{I}}+({\gamma }_{\parallel }^{-1}-{\gamma }_{\perp }^{-1}){{\bf{n}}}_{i}{{\bf{n}}}_{i}){\Sigma }_{j}{{\bf{F}}}_{ij}^{{\rm{tot}}}$$
(12)
$$\frac{{\mathrm{d}}{\theta }_{i}}{\mathrm{d}t}= {\,}\sqrt{{D}_{{\rm{r}}}}{\eta }_{{\rm{r}}}(t)+\sqrt{{D}_{{\rm{T}}}}{\eta }_{{\rm{T}}}(t)\ (1-{\Theta }_{i})\\ +{\,} {{\bf{n}}}_{i}\wedge {\Sigma }_{j}\left(\frac{{{\bf{w}}}_{j}({{\bf{r}}}_{i})-{{\bf{w}}}_{j}({{\bf{r}}}_{i}-{L}_{{\rm{dip}}}{{\bf{n}}}_{i})}{{L}_{{\rm{dip}}}}+{\gamma }_{r}^{-1}{l}_{i,j}{{\bf{F}}}_{ij}^{{\rm{tot}}}\right)\ .$$
(13)

The translational friction coefficients read \({\gamma }_{\parallel }=2\pi \eta L/\mathrm{ln}(L/e)\) and \({\gamma }_{\perp }=2{\gamma }_{\parallel }\), and \({\gamma }_{r}={\gamma }_{\parallel }{L}^{2}/6\) is the rotational friction coefficient. The distance between the centre of mass of the particle and the contact point with particle \(j\) is \({l}_{i,j}\). Rotational Brownian motion is modelled using the rotational diffusion coefficient \({D}_{{\rm{r}}}\) and the normal Gaussian noise \({\eta }_{{\rm{r}}}(t)\), and reorientation during tumbles using corresponding \({D}_{{\rm{T}}}\) and \({\eta }_{{\rm{T}}}(t)\).

When hydrodynamic interactions are included, \({{\bf{w}}}_{j}({\bf{r}})\) is the flow generated by particle \(j\) at point \({\bf{r}}\). The particles thus react to external flows as a dumbell. As a source of flow, they are modelled as a dipole of point forces of pusher symmetry (Fig. 4a). The point of application of the resistive force coincides with the centre of the rod, the one of the propulsive force being situated \({L}_{{\rm{dip}}}=L/2+{L}_{{\rm{flag}}}/2\) behind the latter in the direction of the rod. Following Jeckel et al.8, we used a quasi-2D approximation to compute the flow generated by the 2D point force \({\bf{F}}={\gamma }_{\parallel }{v}_{j}{{\bf{n}}}_{j}\). The fluid velocity \({\bf{u}}\) is assumed to take a Poiseuille profile in the z-direction, its average (x,y)-component \({\bf{U}}=1/h{\int }_{0}^{h}{\bf{u}}(x,y,z)\mathrm{d}z\) thus obeying an effective 2D Hele-Shaw equation:

$${\boldsymbol{\nabla }}\, {\boldsymbol{\cdot}}\ {\bf{U}}=0$$
(14)
$${\boldsymbol{\nabla }}P-\eta ({\nabla }^{2}{\bf{U}}-\kappa {\bf{U}})=\frac{{\bf{F}}}{h}{\delta }^{(2)}({\bf{r}})$$
(15)

where \(P\) is the pressure, \(\nabla =({\partial }_{x},{\partial }_{y})\) and \(\kappa =12/{h}^{2}\), the origin being taken at the point of application of \({\bf{F}}\). This equation was solved in Jeckel et al.8:

$${\bf{U}}={\bf{G}}\cdot {\bf{F}}$$
(16)

with the symmetric matrix:

$${\bf{G}}=\frac{1}{\pi \eta h\ \kappa | r{| }^{2}}\left[{c}_{1}(\sqrt{\kappa }| r| ){\bf{I}}+{c}_{2}(\sqrt{\kappa }| r| )\hat{{\bf{r}}}\hat{{\bf{r}}}\right]$$
(17)

where \(\hat{{\bf{r}}}={\bf{r}}/| r|\) and the factors:

$${c}_{1}(z)={z}^{2}\left[{K}_{0}(z)+{K}_{2}(z)\right]/2-1$$
(18)
$${c}_{2}(z)=2-{z}^{2}{K}_{2}(z)$$
(19)

where \({K}_{n}\) are modified Bessel functions of the second kind. The flow generated by particle \(j\) at a position \({\bf{r}}\) from the centre of the rod is then:

$${{\bf{w}}}_{j}({\bf{r}})={\bf{U}}({{\bf{F}}}_{j},{\bf{r}})+{\bf{U}}(-{{\bf{F}}}_{j},{\bf{r}}+{L}_{{\rm{dip}}}{{\bf{n}}}_{j})$$
(20)

which we compute as such in the algorithm, because the dipole approximation do not model short-range flows accurately enough for our simulations. Note that the range of the interaction is set by the height of the channel via \(\kappa\). Interestingly, the term \(\eta \kappa {\bf{U}}\) which introduces this scaling in Eq. 15 comes from a term of friction on the wall (\(-\eta ({\partial }_{z}{\bf{u}}(h)-{\partial }_{z}{\bf{u}}(0))\)) which appears when averaging the 3D Stockes equation over the channel height. The fluid flow is plotted for the three channel heights we used in Supplementary Fig. 6a. When the height increases, the flow field goes from circular flow patterns to a pattern qualitatively more akin to 3D dipoles (although quantitatively different).

Finally, the state of each particle (\({\Theta }_{i}\)) was determined by an internal chemotaxis system evolving according to the ligand concentration experienced by the cells, first formulated in Vladimirov et al.59, with the only difference that the instantaneous tumble probability was set directly using the concentration of phosphorylated CheY (CheY-P), disregarding the existence of multiple flagellar motors. This model is detailed in Supplementary Note 2.

The set of equations 1013, 1620 and Supplementary Eqs. 18, which governs the position and orientation of the rods, was solved by Euler integration. Parameter values59,75 are given in Supplementary Table S2.