Spatial modulation of individual behaviors enables an ordered structure of diverse phenotypes during bacterial group migration

Coordination of diverse individuals often requires sophisticated communications and high-order computational abilities. Microbial populations can exhibit diverse individualistic behaviors, and yet can engage in collective migratory patterns with a spatially sorted arrangement of phenotypes. However, it is unclear how such spatially sorted patterns emerge from diverse individuals without complex computational abilities. Here, by investigating the single-cell trajectories during group migration, we discovered that, despite the constant migrating speed of a group, the drift velocities of individual bacteria decrease from the back to the front. With a Langevin-type modeling framework, we showed that this decreasing profile of drift velocities implies the spatial modulation of individual run-and-tumble random motions, and enables the bacterial population to migrate as a pushed wave front. Theoretical analysis and stochastic simulations further predicted that the pushed wave front can help a diverse population to stay in a tight group, while diverse individuals perform the same type of mean reverting processes around centers orderly aligned by their chemotactic abilities. This mechanism about the emergence of orderly collective migration from diverse individuals is experimentally demonstrated by titration of bacterial chemoreceptor abundance. These results reveal a simple computational principle for emergent ordered behaviors from heterogeneous individuals.


Introduction
Collective group migration, as an important class of coordinated behaviors, is ubiquitous in living systems, such as navigation, foraging, and range expansion Partridge, 1982;Sumpter, 2010). In the presence of individual heterogeneity, the migrating group often exhibits spatially ordered arrangements of phenotypes Parrish and Edelstein-Keshet, 1999;Partridge, 1982;Sumpter, 2010). In animal group migration, individual behavioral abilities (e.g., directional sensitivity) would result in social hierarchy, which further drives the spatial arrangement in a coordinated group (Couzin et al., 2005). At the same time, spatial arrangements can lead to different costs and benefits for the individuals participating in the group migration (Krause, 1994;Parrish and Edelstein-Keshet, 1999;Partridge, 1982). Participating individuals must follow disciplinary rules to organize themselves into coordinated patterns while on the move, which requires complex computational abilities to interact with the group and the environment (Couzin and Krause, 2003;Couzin et al., 2002;Vicsek and Zafeiris, 2012). Therefore, understanding how individuals of different phenotypes determine their location in the group is an essential prerequisite to uncover the organization principles of collective populations.
The chemotactic microbe, Escherichia coli, provides a simple model to address the emergence of collective decision-making among diverse population, as it can exhibit both individualistic behaviors Frankel et al., 2014;Kussell and Leibler, 2005;Waite et al., 2016;Waite et al., 2018) and collective migratory patterns (Adler, 1966a;Fu et al., 2018;Segel, 1971a, Wolfe andBerg, 1989). Individual cells perform run-and-tumble random motions by spontaneously switching the rotating direction of flagella (Berg, 2004;Berg and Brown, 1972). These cells can facilitate the chemotaxis pathway to control the switching frequency to bias their motions toward their favorable direction along the chemoattractant gradient, where the efficiency to climb the gradient is defined as the chemotactic ability ( χ ) (Celani and Vergassola, 2010;Dufour et al., 2014;de Gennes, 2004;Si et al., 2012). In addition, the chemotactic abilities of individual cells exhibit substantial phenotypic heterogeneity even for the clonal bacterial population, which diversifies the chemotactic response to identical signals (Spudich and Koshland, 1976;Waite et al., 2016;Waite et al., 2018). Despite the stochastic solitary behavior and variations in phenotypic ability, the E. coli population can migrate as a coherent group by following a self-generated attractant gradient, via consumption of the whole population (Adler, 1966a;Saragosti et al., 2011;Wolfe and Berg, 1989). The migratory group form a stable pattern of phenotypes sorted by their chemotactic abilities ( Figure 1A), which is believed to maintain phenotypic diversity in the group Waite et al., 2018). Although a previous study showed that behavior modulation helps migrating bacteria to maintain a consistent group (Saragosti et al., 2011), how individuals eLife digest Organisms living in large groups often have to move together in order to navigate, forage for food, and increase their roaming range. Such groups are often made up of distinct individuals that must integrate their different behaviors in order to migrate in the same direction at a similar pace. For instance, for the bacteria Escherichia coli to travel as a condensed group, they must coordinate their response to a set of chemical signals called chemoattractants that tell them where to go.
The chemoattractants surrounding the bacteria are unequally distributed so that there is more of them at the front than the back of the group. During migration, each bacterium moves towards this concentration gradient in a distinct way, spontaneously rotating its direction in a 'run-and-tumble' motion that guides it towards areas where there are high levels of these chemical signals. In addition to this variability, how well individual bacteria are able to swim up the gradient also differs within the population. Bacteria that are better at sensing the chemoattractant gradient are placed at the front of the group, while those that are worst are shifted towards the back. This spatial arrangement is thought to help the bacteria migrate together. But how E. coli organize themselves in to this pattern is unclear, especially as they cannot communicate directly with one another and display such diverse, randomized behaviors.
To help answer this question, Bai, He et al. discovered a general principle that describes how single bacterial cells move within a group. The results showed that E. coli alter their run-and-tumble motion depending on where they reside within the population: individuals at the rear drift faster so they can catch up with the group, while those leading the group drift slower to draw themselves back. This 'reversion behavior' allows the migrating bacteria to travel at a constant speed around a mean position relative to the group.
A cell's drifting speed is determined by how well it moves towards the chemoattractant and its response to the concentration gradient. As a result, the mean position around which the bacterium accelerates or deaccelerates will vary depending on how sensitive it is to the chemoattractant gradient. The E. coli therefore spatially arrange themselves so that the more sensitive bacteria are located at the front of the group where the gradient is shallower; and cells that are less sensitive are located towards the back where the gradient is steeper.
These findings suggest a general principle for how bacteria form ordered patterns whilst migrating as a collective group. This behavior could also apply to other populations of distinct individuals, such as ants following a trail or flocks of birds migrating in between seasons.  with phenotypic variations manage to determine their relative positions in the group remains to be determined.
Here, we analyzed single-cell trajectories of bacterial run-and-tumble motions in the chemotactic migration group (see Materials and methods). We found that the expected drift velocity of individual cells decreased from the back to the front. Such a spatial profile modulates cells to behave as mean reverting processes relative to the entire group, that is, cells effectively tend to revert their direction of runs toward the mean position of the group. Using an Ornstein-Uhlenbeck (OU)-type model, we demonstrated that the mean reversion behavior is a result of a pushed wave, where the driving force decreases from the back to the front of the group. Cells of different phenotypes are imposed to the same type of driving force, of which the strength is coupled with their chemotactic abilities. As a result, the pushed wave front, driven by the spatially structured force, can maintain more diverse individuals in the migratory group. By theoretical analysis and stochastic simulations, we also discovered that the balanced locations of diverse phenotypes are spatially ordered by their chemotaxis abilities. Further simulations and experiments with cells of titrated chemoreceptor abundance demonstrated that this spatial modulation of individual behavior enables the ordering of bacteria with diverse chemotaxis abilities. Therefore, although the high-order computational abilities are not available to simple organisms, the spatial modulation of stochastic behaviors at the individual level reveals novel decisionmaking capabilities at the population level.

Results
The drift velocity of individual cells during group migration exhibits a spatially structured profile To directly investigate the ordering mechanism in a coherent migration group, we quantified the stochastic behaviors of bacterial run-and-tumble motions relative to the stable migrating group. To achieve this, we employed a microfluidic device that generated a stable propagating band of bacteria, as previously reported Saragosti et al., 2011). Using aspartate (Asp) as the only chemoattractant to drive the migration of E. coli, we tracked a small fraction of fluorescent bacteria (JCY1) as representatives of the non-fluorescent wild-type cells (RP437) (see Materials and methods, Appendix 1-figure 1, Video 1). Because the group velocity VG = ⟨ ∆xi ( t ) /∆t ⟩ was constant over time, VG ∼ 3.0 µm/s (Appendix 1-figure 2), we were able to map the tracks to a moving coordinate With the shifted tracks, we calculated the key statistics of the single-cell behaviors. We first checked that the average instantaneous velocity, V I (z) = ⟨∆x i (z)/∆t⟩ , was constant along the density profile ρ ( z ) ( Figure 1B). This result confirmed that the group migrates coherently. Then, we identified all the run states and tumble states of individual trajectories using a previously described computer assistant program Waite et al., 2016), to ensure that the tracks are separated into successive tumble-and-run events (see Materials and methods). Comparing the sample events initiated from the back (b), middle (m), and front (f) of the migration group, we observed that the runs in the front were longer but distributed more uniformly in terms of the directionality, whereas the runs in the back were shorter but more oriented toward the group migration direction ( Figure 1C, Appendix 1- figure 3A, B).
dashed line), implied that bacteria perform mean reversion motions. The VD ( z ) profile was cut to present the majority of cells (~90%) ( ±1.65σ ). (G) The time evolution of the average position ( z , solid lines) of cells starting from the back, middle, and front of the migration group (color code was defined in B) confirmed the reversion behavior. Shaded area represents the s.e.m. of more than 450 cells (see Materials and methods). Analytically, the OU-type Quantitatively, the statistics of run length (and duration) displayed exponential distributions with the means for the direction of group migration longer than those for the opposite direction ( Figure 1D, Appendix 1- figure 3C). The angular distribution of the run length confirmed the difference in directionality between cells in different spatial locations ( Figure 1E, Appendix 1- figure 3D). We also confirmed that cells in the back showed greater directional persistence toward the migration direction (Appendix 1-figure 4A-C), as (Saragosti et al., 2011) reported previously. All these results suggested that the bacteria in the back run more effectively toward the direction of group migration than those in the front.
To quantify the spatial extent of the drift efficiency, we defined the expected drift velocity V D ≡ ⟨lR·cos θR ⟩ ⟨τR+τT⟩ , by the projection of the average run length along the migration direction over the average duration of runs and tumbles . This quantity reflects the effective run speed of run-and-tumble events that start running on a given location relative to the group. The drift velocity was found to decrease from the back to the front, crossing the group velocity VG in the middle of the group ( Figure 1F). This particular trend of VD ( z ) suggests a mean reverting behavior of bacteria in the group: the cells at the back drift faster than the group ( V D > V G ), enabling the cells to catch up with the group; at the same time, the cells in the front drift slower than the group ( V D < V G ), causing them to slow down and fall back ( Figure 1G). Such mean reverting process also results in sub-diffusion of individuals relative to the group (Appendix 1- figure 3F), for which the mean square displacement (MSD) is constrained over time (Appendix 1- figure 3G). The slope of the spatial extent of VD ( z ) , −r = −0.05 min −1 , quantifies the speed at which individuals revert to its center.
We noted that the spatial profile of the expected drift velocity VD ( z ) was different from the instantaneous velocity VI ( z ) . This is because the instantaneous velocity VI ( z ) defines the average speed of cells in a given time interval dt , which reflects the positional shift of a group of cells at a given position. However, the expected drift velocity VD ( z ) defines the average speed of run-and-tumble events that start tumbling at a given position. Since the run duration is explicitly modulated by the gradient of chemoattractant g z ) and is dependent on the chemotactic ability χ , VD represents the drift velocity driven by the external stimuli (Celani and Vergassola, 2010;de Gennes, 2004;Dufour et al., 2014;Si et al., 2012).

The decreasing drift velocity implies a pushed wave front of group migration
To understand how the spatially structured profile of the drift velocity VD impacts on the group migration, we first adopted a Langevin-type model that describes bacterial motions as an active Brownian particle driven by the expected drift velocity VD and a random force: dx = VDdt + ϵdW (Berg, 2004). In this model, the run-and-tumble random motions are considered as a Gaussian random force ϵdW , while the cell motions are imposed to a deterministic force VD (Rosen, 1973;Rosen, 1974). The strength of Gaussian noise can be estimated by the effective diffusion coefficient ϵ = √ 2D , while the drift velocity is determined by the product of the perceived gradient g ( z ) and the chemotactic ability . Such a stochastic description of bacterial motions has been proven equivalent to the classic Keller-Segel (KS) model that described the population dynamics of bacterial chemotactic group migration Segel, 1971a, Rosen, 1973). In the moving coordinate, z = x − V G t , this Langevin-type model specifies that dz = VD ( z ) dt − VGdt + ϵdW . Thereby, the cell motions relative to the migrating group are modulated by two effective forces: one generated by VD ( z ) , which pushes the cells to catch up with the wave; and another generated by −VG , which drags the cells to fall behind the wave. These two 'forces' constrain the random motions of individuals in an effective potential well U ( z ) (Figure 2A). To estimate the spatial profile of the effective driven force VD ( z ) , we analyzed the KS model with moving ansatz (supplementary text). Assuming the density profile ρ ( z ) directly measured from experiments ( Figure 1B), we can deduce the chemoattractant concentration profile S ( z ) (Appendix 1- figure 4D), as well as the perceived gradient g ( z ) ( Figure 2B). Since the perceived gradient g ( z ) is almost linear in the main part of the wave profile, we approximated it by g ( z ) ≈ g0 + g1z ( Figure 2B, dashed line), which allows us to transform the stochastic model to an OU-type equation: . This suggests that the random motions of bacteria are constrained in a parabolic moving potential well, Behind the balanced position, cells experience a pushed force to catch up the group. Cells would start to fall back once they exceed the balanced position, where the driving force becomes negative. Therefore, the decreasing profile of the driving force enable cells to perform mean reverting behaviors around the balanced position. In addition, the expected rate that cells tend to revert back to the balanced position is defined by the slope of the spatially dependent driving force, r = χ g1 ( Figure 2B).
Given the knowledge of individual behaviors, we studied the spatial distribution of population on the group migration. The OU model (Equation 1) which describes the single-cell stochastic motions has an equivalent form, known as the Fokker-Planck equation (Equation S19) which describes the spatial-temporal dynamics of cell density distribution. This population model provides a traveling wave solution with the mean position around z0 and standard deviation σ = From the solution, we noted that the effective driving force, as well as the drift velocity, has a negative slope ( g 1 < 0 ). The decreasing profile of the drift velocity suggests that the leading front of the group migrates as a pushed wave front (Gandhi et al., 2016;van Saarloos, 2003). As a key feature of the pushed wave, the leading front of the group drops parabolically, which is much faster than that of diffusion front. This further leads to a tight density profile of group migration for a single phenotype population.

The pushed wave front results ordered pattern of phenotypes
To address whether this pushed wave front still holds in presence of phenotypic diversity, we further examined the above analysis with cells of diverse chemotactic abilities χi imposed to the same moving perceived gradient g ( z ) ( Figure 2B). Given a monotonically decreasing profile of perceived gradient g ( z ) , the driving force that each phenotypic individual experiences exhibits the same spatial dependency with the slopes depend on the intrinsic phenotypic properties of each phenotype ri = χi g1 . This monotonic dependency means that the balanced positions z0 of the diverse phenotypes are orderly arranged. By the stochastic Langevin-type model with phenotypic diversity in chemotactic ability, we first confirmed that each phenotypic population migrates at a constant speed VG , following the moving gradient g ( z ) (see supplementary text). The density profiles of cells with different χi follow the same shape but are spatially orderly aligned ( Figure 2C). Under the same moving gradient g ( z ) , the driving force χig ( z ) is phenotype-dependent, so that the bottom position of the potential well, z0,i = − g0 g1 − VG χi g1 , is also spatially arranged according to χi ( Figure 2D). As predicted by the OU model, the balanced positions z0,i of different phenotypes increase with their chemotactic abilities χi ( Figure 2E, black line), while the standard deviation ( σi ) of the density profiles decreases with χi ( Figure 2E, blue line). We also confirmed the ordered structure of phenotypes by a particle-based model of the Langevin-type dynamics coupled with chemoattractant consumption which is further calculated from the experimentally measured density profile (Appendix 1- figure 4D). This gradient profile was then transformed to a moving gradient g ( + VGt , and applied in the simulations of different active particles following Langevin dynamics. A linear fit of g ( z ) around z = 0 is plotted (dashed blue line) and is applied to the Ornstein-Uhlenbeck (OU)-type model. (C) Particles migrate collectively with a moving gradient, while they are located in ordered locations according to their phenotype χi (green lines). Colors from light to dark represent increasing χ . (D) The effective potential wells generated by the effective force ( χg ( z ) ) are spatially ordered. Circles present the minimum of the potential wells. (E) The peak positions (cross) and the mean positions (circles) increase with χ . These were predicted by the OU-type model (Equation S15) (black line). The width of the density profile is defined by two times the standard deviation of all cells ( 2σ ), which decreases with χ , which was consistent with the prediction of Equation S18 (blue line). (F-H) Group migration of mixed phenotypes under decreasing, invariant, and increasing gradient. Simulations were performed in one dimension (1D) with the chemotaxis ability of the group following a Gaussian distribution with a mean of 0.11 mm 2 min −1 and a variation of 0.02 mm 2 min −1 (Appendix 1- figure 5C). The force field used in the simulation followed the linearized force field, as in Equation 1, while g 1 > 0 in F, g1 = 0 in G, and g 1 < 0 in H. All force fields were set as moving with velocity VG . The dashed line in G represents a group with a single phenotype of χ = 0.11 mm 2 min −1 . Insert plots represent the wave front in the moving coordinate after 10 min of simulation. The width of the moving group, defined by the standard deviation of all particles, converges under decreasing gradient (F) while it diverges in cases of G and H.

Figure 2 continued
(Appendix 1- figure 5). Therefore, under the spatially decreasing driving force, cells with phenotypic diversity perform the same type of mean reverting processes with spatially ordered mean positions. The spatial order of phenotypes does not directly promise a compact group migration with phenotypic diversity. By close examination of the density profile, we found that each phenotypic subpopulation propagates as a pushed wave front. We further calculated the total density profile of the entire migratory group with Gaussian distribution of chemotactic abilities under a decreasing linear gradient. Simulation reveals a pushed wave front for the combination of these subpopulations with different chemotactic abilities ( Figure 2F, insert). In addition, we checked that the width of the entire group maintains in a converged width over long time, suggesting that the pushed wave profile enables the migratory population with diversity to keep in a tight shape ( Figure 2F).
We examined the migration profiles under other forms of perceived gradient g ( z ) : a constant perceived gradient and a spatially increasing perceived gradient. In the first case, individual bacteria of identical phenotype follow the diffusion process relative to the group, where the standard deviation of the population increasing with time by σ = 2 √ Dt ( Figure 2G, dashed line). Each phenotype subpopulation is expected to have a constant drift velocity over space. However, as the drift velocity would vary by the chemotactic ability, each subpopulation migrates in different group speeds, suggesting a compact group migration of diverse population cannot be maintained in a constant perceived gradient ( Figure 2G). In the latter case, when imposed to a spatially increasing driving force (a pulled wave, by definition), individual cells display super-diffusion processes. The density profile easily diverges in this case ( Figure 2H). Therefore, we concluded that the pushed wave front, driven by a decreasing shape of driving force, enables a spatially ordered and compact pattern of phenotypes while on the move.

Spatially ordered individual behaviors predicted by agent-based simulation
Although the simplified OU-type model (Equation1) represents a key aspect of the ordering mechanism of phenotypes, it does not detail the signaling processes of bacterial chemotaxis, such as receptor amplification, adaptation, and motor responses (Sumpter, 2010), and it cannot predict bacterial run-and-tumble behavior. To consolidate the proposed mechanism underlying the emergence of spatial orders from the individual random motions, we further performed agent-based simulations integrated with the chemotactic pathway, multi-flagella competition, and boundary effect in three dimensions (3D) Jiang et al., 2010;Sneddon et al., 2012). In the agentbased model, the attractant dynamics governed by diffusion and bacterial consumption is described by a reaction-diffusion equation (Equation S2) as previous multiscale models (Erban and Othmer, 2005;Xue and Othmer, 2009). We constructed a population with multiple phenotypes defined by different chemotactic abilities χi , where χi was varied by changing the receptor gain N (for details, see supplementary text). Since the receptor gain N only affects the amplification factor by which a cell responds to the gradient, the variation in bacterial motility ϵ is unchanged. As a result, a dense band of migrating cells that follow a self-generated moving chemoattractant gradient via consumption were recaptured as experiments (Appendix 1- figure 6A). The phenotypes were spatially ordered as χ varies (Appendix 1-figure 6B), and the velocity profile of each phenotype decreases from the back to front (Appendix 1-figure 6C) as predicted by the OU-type model.
To better analyze the simulations, we simplified the simulation with a non-consumable attractant profile S ( z ) moving with constant speed VG (Appendix 1- figure 4D). Using this simplified model, we first checked that the mean positions of the density profiles of cells with different receptor gains N , as well as their peaks, were orderly aligned with respect to chemotactic ability χi .
As an important advantage of the agent-based simulations, the model allowed us to analyze single-cell behavior during the ordered group migrations. For each phenotype , the expected drift velocity VD,i ( z ) decreased along the density profile ( Figure 3A). Consistent with the ordered structure of the density profiles, the intersection between VD,i ( z ) and VG exhibited the same order of chemotactic ability χi (Appendix 1-figure 7). As the reversion rate ri = dz showed a positive correlation to χi , cells with lower receptor gain N (resulting in a smaller χ ) experienced a weaker reverting force toward the center ( Figure 3A insert). Thus, the effective moving potential, Ui ( z ) , which constrains the cells around the mean positions sorted by their chemotactic abilities, becomes flat for cells with lower chemotaxis ability χ ( Figure 3B; Long, 2019). As a result, cells of each phenotype perform sub-diffusion, whereby the MSD along the migration coordinate relative to the group was bound at a level negatively correlated to χ ( Figure 3C). The width of the density distribution, as an effect of the reversion force, decreased with the reversion rate, as an approximate linear function. Using this agent-based model, we further obtained similar results for populations of different χi through adaptation time τ , or basal CheY protein level Yp0 , which determined the basic tumble bias TB0 Jiang et al., 2010;Sneddon et al., 2012; Appendix 1figure 8). of simulated bacteria decreased from the back to the front of the migration group, where the chemotactic ability χ ranged from 0.2 to 0.35 mm 2 min -1 , which was consistent with the experimental results shown in Figure 1F. The intersections between the VD curves with the preset group velocity VG (black dashed line) shifted toward the back of the migration group as χ decreased (circles). The different colors of the lines and circles correspond to different chemotactic abilities χ , as shown in the legend. The same color coding also applies to (B-D). (B) The reversion rate ri = |dVD,i ( z ) /dz| increased with chemotactic ability. (C) The effective potential well calculated by Ui Positions of the potential minimum zmin are marked as circles. As illustrated, for a lower chemotaxis ability χ , the potential well is shallower and zmin shifts toward the back of the migration group. (D) The width of the density profile (measured by 2σ , see Figure 1B) decreases with the reversion rate ri as well as the chemotaxis ability χi . The mean square displacement (MSD) of bacteria (insert, solid lines) is bound to 2σ 2 i (insert, dashed lines) (see supplementary text). In panel (A, C), curves were cut to present the majority of cells (90%) ( zmin ± 1.65σi ). More details on the results of this simulation are presented in Appendix 1-figure 7.

Experiments with titrated phenotypes confirm ordered behavior modulation
To verify the model predictions on the individual behaviors of different phenotypes, we experimentally measured the trajectories of cells with different chemotactic abilities during the group migration. Specifically, we altered the chemotaxis abilities of cells by titrating the expression level of Tar, which is under the control of a small molecule inducer aTc (Sourjik and Berg, 2004;Zheng et al., 2016) (see , together with the peaks (stars, illustrated in the insert figure), and the average positions (diamond) of the bacterial density profiles, all shifted toward the front of the migration group for strains with higher Tar expression levels, which had higher chemotactic abilities and migrated faster on agar plates (x-axis, see Materials and methods; Appendix 1- figure 9). The related density profiles (PDF) were shown in the insert plot and the color coding of lines/symbols in both panels C and D was the same as that in B. (D) The width of density profiles ( 2σ ) of Tar-titrated bacteria decreased with the reversion rate r . Figure 4A). The variations in the expression of Tar would lead to different receptor gains in response to the Asp gradient (Adler, 1966b;Adler, 1969;Sumpter, 2010), but the tumble bias and growth rate would not change. Using the migration speed of the bacterial range expansion to quantify the chemotaxis ability of the titrated strains, we found that the chemotaxis ability increases with aTc concentration (see Materials and methods and Appendix 1- figure 9).

Materials and methods and
The Tar-titrated cells labeled with yellow fluorescent protein (YFP; strain JCY20) were added to the wild-type population at a ratio of 1 in 400. Within the wild-type population, 1 in 50 cells was labeled with red fluorescent protein (RFP) (strain JCY2). As the Tar-titrated strain constituted a small portion of the pre-mixed population, we considered that the density profile of the population would be invariant to different levels of induction of Tar. The premixed population could generate collective group migration, similar to the wild-type population (Appendix 1-figure 9). The trajectories of the YFP-labeled cells were tracked to represent the behavior of cells with different chemotactic abilities, while the profile of wild-type cells with RFP was also measured to characterize the density distribution of the entire migratory population.
By comparing the statistics of cells with different Tar expression levels, we found that the expected drift velocity VD,i ( z ) followed the same decreasing pattern from back to front ( Figure 4B). More importantly, as the Tar expression level (chemotactic ability) increased, the slope of the decreasing pattern increased, which was consistent with the model prediction shown in Figure 3A. The intersections between VD,i ( z ) and VG , as well as the peak positions and mean positions of each Tar-titrated density profile ( Figure 4C), shifted toward the front as the chemotactic ability increased (as measured by the migration rate on agar plates; Cremer et al., 2019;Liu et al., 2019). The VD cross point was always behind the peak position and the mean position ( Figure 4C), suggesting that cells were leaking behind. Moreover, the width of each Tar-titrated density profile (defined by 2σi ) decreased as the reversion rate ri increased ( Figure 4D), consistent with the model results in Figure 3C. Thus, as the OU-type model predicts, the width of the density profile is controlled by the reversion rate determined by the chemotactic ability χi .

Discussion
In summary, coordinated behaviors with ordered spatial arrangements of phenotypes are abundant in a wide range of biological and human-engineered systems, and are believed to involve elaborate control mechanisms. For animal migrations, it is challenging to characterize simultaneously the computational strategy and behavior at the individual level so as to avoid averaging out phenotypic diversity, and the emergent behavior at the population level (Couzin et al., 2005;Couzin et al., 2002;Vicsek and Zafeiris, 2012). For bacterial chemotactic migration, cells with different phenotypes are spatially aligned based on their chemotactic abilities. This observation was explained as a self-consistent result with the decreasing profile of attractant predicted by KS model .
In this study, we demonstrated that the collective consumption of attractant by bacterial group generates a spatial structure of individual drift velocity along the migrating group profile. Such a spatial profile of drift velocity results a pushed wave front on population level, and maintains diverse phenotypes in a compact migration group. Moreover, this pushed wave front enables spatial modulation of individuals to perform mean reverting random motions around centers sequentially aligned by their chemotactic abilities, thereby giving rise to a spatially ordered pattern. Therefore, we demonstrated that the population order could emerge among diverse individuals that following the same rule of behavioral modulation.
This strategy of self-organization does not require sophisticated communications (Curatolo et al., 2020;Karig et al., 2018;Liu et al., 2011;Payne et al., 2013) nor other hydrodynamic interactions (Chen et al., 2017;Drescher et al., 2011;Zhang et al., 2010) among individuals. Our observation of the decreasing drift velocity can imply the effective perceived gradient that cells experience. We believe that this spatial profile is mainly contributed by the consumption of the chemoattractant. By using a Tar-only strain (UU1624) (Gosink et al., 2006), we demonstrated that the mutant could also generate a stable group migration in our experimental condition similar to the wild-type strain (Appendix 1-figure 9G). This further suggests that the secretion of self-attractants is unlikely a necessary condition of collective group migration Fu et al., 2018;Keller and Segel, 1971a), although there are doubts about the existence of self-attractants in high density (Budrene and Berg, 1995).
The spatially dependent drift velocity provides a structured driving force of a migration group, resulting a pushed wave front. Pushed and pulled waves are determined by the spatial distribution of the spreading velocity of a propagation front (van Saarloos, 2003;Figure 2F-H). The properties of pushed and pulled waves have been discussed in growth-driven range expansion (Birzu et al., 2018;Erm and Phillips, 2020;Gandhi et al., 2016), where the wave type is determined by densitydependent growth rates. A prominent example of pulled wave is known as the Fisher wave (Fisher, 1937), where the population expansion is driven by constant diffusion and logistic growth of individuals. However, in such biological systems, the spatial dependence of front speeds is hardly quantified in experiments. Here, by direct measurement of drift velocity on single-cell level, we identified the chemotactic migration group of bacteria as a pushed wave. This chemotaxis system would provide a unique multi-scale model to study further details of pushed wave.
The spatially decreasing profile of driving force does not only cause an ordered pattern of phenotypes, but also results a pushed wave front that enables a negative feedback control on the propagating speed. This further allows a compact density profile for heterogenous population to migrate at the collective level. The advantageous to keep diversity in the pushed wave front was also reported in the growth-driven range expansion system (Birzu et al., 2018). Our study revealed that, other than spatial regulation of fitness, the direct modulation of individual drift velocity in space could also maintain diversity in range expansion.
Detailed analysis of the spatial structured driving force could also provide the limits of phenotype that is allowed in the group. In the migratory group, the same rule of behavioral modulation applied to cells with different phenotypes, such that the random motions of cells were bound by moving potential wells whose basins were sequentially aligned. However, it is noteworthy that cells could skip the potential wells from the back because the 'driving force' decreased again at the far back of the group (Long, 2019). This results in leakage of cells in the migratory group (Holz and Chen, 1978;Novickcohen and Segel, 1984;Scribner et al., 1974). Phenotypes with weaker chemotactic abilities were located at the back of the group, where the effective potential well was shallower ( Figure 3C), allowing for more chances to skip. Thus, such collective migration selects bacteria with higher chemotactic abilities (Liu et al., 2021;Liu et al., 2019).
The simple computational principle of behavioral modulation to allocate different phenotypes in the collective group is likely not limited to sensing the self-generated signal by consumption of attractant. A prominent example of trail-following migration (Couzin and Krause, 2003;Helbing et al., 1997) and a typical class of collective behavior is represented by a modified Langevin-type model, where individuals tracing the accumulated signal secreted by all participants (Equation S20) can reproduce similar spatial-temporal dynamics of behavioral modulation, as well as ordered arrangements of phenotypes in the migratory group (Appendix 1-figure 10). Thus, this mechanism of matching individual abilities by the signal strength might provide an explanation of how other higher organisms organize ordered structures during group migration.

Strains
The wild-type strain E. coli (RP437) and its mutants were used in this study, where all plasmids were kindly provided by Dr Chenli Liu. Specifically, the Tar-titratable strain was constructed by recombineering according to previous research (Zheng et al., 2016). Specifically, the DNA cassette of the Ptet-tetR-tar feedback loop was amplified and inserted into the chromosomal attB site by recombineering with the aid of plasmid pSim5. The tar gene at the native locus was seamlessly replaced with the aph gene by using the same recombineering protocol. To color-code the strains, we use plasmids with chloramphenicol-resistant gene carrying yfp under constitutive promoter (for JCY1 strain) and pLambda-driven mRFP1 plasmids maintained by kanamycin (for JCY2). To color-code Tartitratable strain (JCY20), a plasmid carrying yfp chloramphenicol-resistant gene was transformed into constructed Tar-titratable strain. The tar-only strain (UU1624) was modified from RP734 and was kindly provided by Prof. Johan Sandy Parkinson.

Sample preparation
The bacteria from frozen stock were streaked onto the standard Luria-Bertani agar plate with 2 % (w/v) agar and cultured at 37 °C overnight. Three to five separate colonies were picked and inoculated in 2 mL M9 supplemented medium for overnight culture with corresponding antibiotics to maintain plasmids. The overnight culture was diluted by 1:100 into 2 mL M9 supplemented medium the next morning. For Tar titration strains, related aTc were added in this step. When the culture OD600 reaches 0.2-0.25, it was then diluted into pre-warmed 15 mL M9 supplemented medium so that the final OD600 was about 0.05 Zheng et al., 2020;Zheng et al., 2016).
Bacteria were washed with the M9 motility buffer and were re-suspended in fresh M9 motility buffer to concentrate cell density at OD600 about 1.0. Then, the wild-type strain and fluorescent strain were mixed with ratio of 400:1 before loaded in the microfluidic chamber Saragosti et al., 2011). For Tar titration experiments, the wild-type strain (RP437) was mixed with two fluorescent strains (JCY2 and JCY20) by 400:8:1.

Microfabrication
The microfluidic devices were fabricated with the same protocol and the same design as previous research (Bai et al., 2018;Fu et al., 2018), except that the capillary channel was designed longer than that of previous ones. The size of the main channel was 20 mm×0.6 mm× 0.02 mm and only one gate at the end of the channel was kept (Appendix 1- figure 1A).

Band formation
Fluorescent cells were mixed with non-fluorescent cells by 1:400 for cell tracking in the dense band. Sample of mixed cells with density OD600 ≈1.0 was gently loaded into the microfluidic device and then the device was spun for 15 min at 3000 rpm in a 30 °C environmental room so that almost 100,000-150,000 cells were placed to the end of the channel. After spinning, the microfluidic device was placed on an inverted microscope (Nikon Ti-E) equipped with a custom environmental chamber set to 50% humidity and 30 °C.

Imaging
The microscope and its automated stage were controlled by a custom MATLAB script via the μManager interface (Edelstein et al., 2014;Fu et al., 2018). About 30 min after the sample loading, a 4× objective (Nikon CFI Plan Fluor DL4X F, NA 0.13, WD 16.4 mm , PhL) was placed in the wave front for imaging. The fluorescent bacteria, seen as randomly picked samples of the migrating group, were captured continuously with frame rate of 9 fps in 10 min until they leave the view. Typical tracks are longer than 300 s. Time-lapsed images were acquired by a ZYLA 4.2MP Plus CL10 camera (2048 × 2048 arrays of 6.5 µm×6.5 µm pixels) at 9 frames/s (fps) . An LED illuminator (0034R-X-Cite 110LED) and an EYFP block (Chroma 49003; Ex: ET500/X 20, Em: ET535/30 m) compose the lightening system. For the Tar titration experiments, the channel was first scanned with 10 × objective (CFI Plan Fluor DL 10 × A, NA 0.30, WD 15.2 mm, PH-1) enlighten by an LED illuminator (0034R-X-Cite 110LED) through the RFP block (Chroma 49005, Ex: ET545/X 30, Em: ET620/60 m) and EYFP block channels for seven neighbored views around the migration group. These images were further combined to two large pictures of the RFP strains and YFP strains. The channel was scanned twice, respectively before and after the 10 min tracking of fluorescent Tar-titrated cells.

Track extraction and state assignment
The acquired movie was first analyzed with the U-track software package to identify bacteria and to get their trajectories (Jaqaman et al., 2008). Then the tracks were labeled by run state and tumble state by a custom MATLAB package (Waite et al., 2016) using a previously described clustering algorithm .

Track analysis
The group velocity VG was calculated by averaging the frame-to-frame velocity ( dt ≈ 0.11s ) over all tracks and all time. The cell number for the first frame over a spatial bin of ∆x = 60 µm and a channel section a=12,000 µm 2 were calculated to get the density profile ρ ( . The peak position of the first frame ( xpeak ( t = 0 ) ) was then determined by the maximum of ρ ( ) was transformed to moving coordinate position zi by the group velocity VG and origin of the axis on the density peak by zi = xi . Given the relative position of each cell, we recalculated the density profile in moving coordinate ρ a·dx . The width of the density profile was defined by two times the standard deviation of relative posi- The spatial distribution of the instantaneous velocities ⟨ V I ( z )⟩ was calculated by averaging the velocity in spatial bin of ∆z = 240 µm .
A tumble-run event is the minimal element of bacterial behavior. The typical spatial scale of a tumble-run event is about 20 μm, which is much smaller than the spatial bin size chosen in this study (240 µm). The spatial distributions of run time were calculated by averaging the related values of all the events with tumbling position ( zT ) located in each spatial bin ( z ). As the displacement of tumble is small, the tumbling position is approximately the starting position of runs. For each tumble-run event, we have the vector linking starting position and end position of the run. The running angle θR is then defined by the angle between run direction and the group migration direction. One can easily deduce all the other quantities with the formulations in Table 1.
Instantaneous velocity Perceived gradient Growth rate and migration rate measurement Growth rates of Tar-titrated strains were calculated from exponential fitting ( R 2 > 0.99 ) over measured curves of cell density (OD600) with respect to time. A 250 mL flask with 20 mL M9 supplement medium were used. All measurements were performed in a vibrator of rotation rate of 150 rpm at 30 °C. OD600 was measured by a spectrophotometer reader every 25 min. Each strain has been measured for at least three times. The semi-solid agar plate was illuminated from bottom by a circular white LED array with a light box as described previously (Liu et al., 2011;Liu et al., 2019;Wolfe and Berg, 1989) and was imaged at each 2 hr by a camera located on the top. As bacteria swimming in the plate forms 'Adler ring', we used the first maximal cell density from the edge to define the moving edge of bacterial chemotaxis. The migration rate was then calculated from a linear fit over the data of edge positions in respect to time ( R 2 > 0.99 ).

Models and simulations
Details of the theoretical models and numerical simulations were presented in the appendix notes. In which, the Langevin equation was deduced and solved numerically with a particle-based simulation; the approximated OU-type equation and its traveling wave solution were deduced; an agent-based simulation of bacterial with chemotaxis pathway was performed following previous works Jiang et al., 2010;Sneddon et al., 2012).

Additional files
Supplementary files • Transparent reporting form

Data availability
All data generated or analysed during this study are included in the manuscript and supporting files.

Appendix 1 Theory and numerical simulations Summary
In this note, we first deduced the Langevin-type equation from the classic KS model that describes bacteria group migration in a capillary. The Langevin-type equation describes the dynamics of single-cell particle motion as active particles (Section 1). Together with the chemoattractant consumption equation, we investigated the Langevin-type equation through particle-based simulations for a group of particles of single phenotype or multi-phenotypes (Section 2). Then, we transformed the equations into moving coordinate, so that the stable density profiles as well as the chemoattractant profiles were observed (Section 3). In this moving coordinate, the chemoattractant consumption can be decoupled from particle dynamics, which allows us to simulate particle motions over a non-consumable field of chemoattractant on the move (Section 4). Furthermore, the Langevin dynamics describes that the particle motion was simplified to an OUtype process, of which the particle dynamics can be solved analytically (Section 5). To gain more insights of the chemotactic response, we described an agent-based model which integrated the bacterial chemotaxis pathway in Section 6. And specifically, we deduced the chemotactic ability χ from the pathway parameters (Section 7). The agent-based simulations were performed under a moving gradient, from which ordered structures of phenotypes were recaptured (Section 8). The model was further extended to system with signal secretion and shows similar results (Section 9).

The Langevin equation with chemoattractant consumption
The bacterial chemotactic migration in a capillary was first modeled by Segel in 1971 (Keller andSegel, 1971a). In this model, the bacterial cell division was neglected as the nutrition in the capillary was poor. In 1D, the dynamics of cell density ρ ( x, t ) is a combination of diffusion and chemotaxis: where D and χ respectively represent the diffusion coefficient and chemotactic ability of bacteria, and g ( x, t ) represents the perceived gradient of chemoattractant. The dynamics of the chemoattractant S ( x, t ) follows a reaction-diffusion-type equation with a diffusion coefficient Ds and consumption with a constant rate k : with Kon, Koff were dissociation constants for active and inactive conformation of the receptor, respectively.
Following Rosen, 1973, one can deduce the Fokker-Planck equation associated to the KS model that describes the probability P = P ( x, y; t ) to observe of a cell which initiates from position y at position x and time t . The related equation writes: is equivalent to the Langevin dynamics as: where xi represents the position of the i-th bacteria and g ( xi, t ) is the perceived gradient of each bacteria at time t . dW is a Wiener process that describes a random walk with noise level ϵ = √ 2D . As previously proofed, the expected drift velocity equals the production of chemotactic ability χ and the perceived gradient g , VD = χg (Waite et al., 2016). So that, the Langevin-type Equation S5 can be reformed to: The initial condition of the chemoattractant was S ( x, 0 ) = S0 = 200 µM . In the stochastic model, the density profile ρ ( x, t ) was calculated by the sum of cell number and time t over volume a · ∆x , where a is the capillary section area and dx is the spatial bin size:

Particle-based simulation with consumption
The Langevin-type model in the absolute coordinate x (Equation S5) was simulated with a customized code using MATLAB. In each case, 100,000 particles were simulated in a 1D space where x ∈ [ 0, 20 ] mm . The absorption boundaries were applied for x = 0 mm and x = 20 mm , so that particles stay at the boundary until they leave them actively ( x ( x > 0 mm ) = 0 and x ( x > 20 mm ) = 20 mm ). Initially all particles were placed at x = 0 mm and their positions were calculated according to Equation S7 at each time step of ∆t = 0.05s for 60 min. The random noise follows a Gaussian distribution generated by MATLAB function 'randn.m' with amplitude multiplied by √ 2ϵ √ ∆t . Unlike the particles that change their position continuously, the spatial profile of cell density ρ ( x, t ) was first calculated on a space mesh of grid ∆x = 10 µm , and then linearly interpolated to a finer mesh of grid ∆x = 0.1 µm . The chemoattractant S ( x, t ) and perceived gradient g ( x, t ) were deduced accordingly. At each time point, following Equation S7, cells located on grid [ x, x + ∆x ] were summed and were divided over a∆x to get the density profile. In order to avoid fast consumption near S = 0 , a saturation effect of consumption rate was added to Equation S3 using where Ks = 0.1 µM , of which the value was small and does not affect the linear relation in most range of S > Ks .
Then the chemoattractant profile S ( x, t ) was calculated from ρ ( x, t ) according to Equation S8, using a fourth-order Runge-Kutta method from an initial condition of S ( . Having the discrete g ( x, t ) over grid of ∆x = 0.1 µm , the perceived gradient of each particle g ( xi ) was assigned by detecting the particle position over the spatial mesh grid.
Following the above instructions, density profile and peak positions with bacteria of χ = 0.11 mm 2 min −1 and D = χ/22 were plotted in Appendix 1-figure 5A. The group migration reached steady state after 20 min simulation. The peak velocity was then defined by linear fitting of peak positions for t ∈ [ 20, 60 ] min , which was found to be Vp = 3.03 µm/s . To simulate a bacterial group of multiple phenotypes, we constructed 100,000 cells with their chemotactic ability χ follows a Gaussian distribution with the average chemotactic ability ⟨χ⟩ = 0.11 mm 2 min −1 and s.d. of 0.03 mm 2 min -1 (Appendix 1-figure 5B) while the diffusion coefficient D was fixed to ⟨χ⟩ /22 for all cells. The consumption rate of each bacterium was also set constant of 4.6 · 10 −9 µM/cell/s . The group of multi-phenotypes migrates slower than single phenotype with peak velocity Vp = 2.90 µm/s (Appendix 1-figure 5A). The bacterial positions after 20 min simulation were further transformed to the moving coordinate zi = xi − Vpt . They were subgrouped according to their chemotactic ability χ to six subgroups. And the corresponding average density profiles of each subgroups were plotted in Appendix 1- figure 5D with colors defined in Appendix 1- figure 5C. The density profile of subgroups was found ordered according to their average chemotactic ability χ . The time-shifted profiles, S ( z ) and g z ) , were shown in Appendix 1-figure 5E,F.
The simulations of bacteria with consumption confirmed that coherent group migration and ordered spatial structures can emerge from a system of active particles modulated by gradient of consumable chemoattractant.
Given a stable density profile measured experimentally, we can integrate Equation S10 to get a stable profile of chemoattractant S ( z ) . As the chemoattractant was unconsumed at z = ∞ and it is completely consumed as the wave passes z = −∞ , the boundary condition of S ( z ) can be written as S ( ∞ ) = S0 and S ( −∞ ) = 0 . We get: dz is the accumulated number of cells up to position z . We then used the experimentally measured cell density profile together with the group speed VG to calculate the moving attractant profile S ( z ) (Appendix 1-figure 5A). The perceived gradient g ( z ) in the moving coordinate was then calculated by: In a stable migration group, the g ( z ) deceases from back to front over the density profile. Suppose the gradient does not steepen toward the back, then cells with lower chemotactic abilities will fall behind and see shallower gradient, drifting even slower and causing the wave to spread out. Since the gradient is formed by local consumption, the front of the wave will have less cells and become shallower, while the back of the wave will accumulate more cells and become steeper. This will automatically readjust the gradient steepness until the back becomes steep enough to allow cells will lower chemotactic abilities to catch up, stabilizing the gradient and the traveling wave.

Particle-based model with preset moving gradient
The chemoattractant profile S ( z ) can be deduced by an experimentally measured stable density profile ρ ( z ) in the moving coordinate. With the experimental mesh grid ∆x = 240 µm , we plot the average S ( z ) over three biological replicates in Appendix 1- figure 4D (circles). In order to apply this profile into the particle-based simulation, we first expanded the space range of S ( z ) Next, we used a cubic spline data interpolation to construct a profile of S ( z ) with much finer spatial mesh grid ∆x = 0.001 µm (Appendix 1-figure 4D, line). Therefore, a g ( z ) profile on finer meshes was calculated accordingly (Figure 2A). The g ( z ) profile was then translated to an absolute coordinate by g ( + VGt , with VG = 3.0 µm/s . Using the preset moving gradient g ( x, t ) , we can simulate the particle motions without calculation of ρ ( x, t ) and S ( x, t ) . We used the same method as described in Section 2 to simulate particle motions, and at each time point t , we assigned g ( xi ) by indexing bacterial position on g ( x, t ) , with spatial precision of ∆x = 0.001 µm . For bacteria of four different χ ranging from 0.15 to 0.3 mm 2 min -1 , we simulated 10,000 particles for each phenotype with the same noise level ϵ = 15 mm · min −0.5 . During simulation of 60 min, bacteria of all phenotypes move as a group with peak positions linearly increasing with time. The fitted slope of all peaks equals the preset velocity of the moving gradient VG . In the moving coordinate z , the density profiles of all phenotypes were ordered (Figure 2A), and they were clearly ordered by χ . The peak positions and mean positions of the density profile increase with χ ( Figure 2C), while the width (defined by σ ) decreases with χ ( Figure 2D).

The type model
The perceived gradient g ( z ) deduced from experimental data shows linear decreasing trend in the major range of density profile −0.4 mm < z < 0.4 mm . It can be then linearly fitted by g ( z ) ≈ g1z + g0 with g1 ≈ −2.1 mm −2 and g0 ≈ 1.2 mm −1 . Subscribe this linear approximation in Equation S7, we get: Now, we compare Equation S10 to the standard OU model given by dx = −λxdt + ϵdW . Equation S9 can be taken as an OU-type process with −χg1 as the reversion rate λ and the mean position deviated from origin to z0 : where the mean position z0 is the steady-state position of its ensemble average ⟨z⟩ : The original OU model describes an active particle motion under a linear force field around x = 0 . Since Equation S10 can be taken as a generalized OU model, we can thus consider our bacteria in the migration group as an active particle under an effective force field of χg1z ) . Integrating this force field over z , we get an effective potential well U ( z ) : The U0 is an integral constant controlled by boundary condition, which was set by U ( ∞ ) = 0 in this article. The effective potential well U dz from the particle-based simulation and Equation S17 are compared in Figure 2B.
Using a variable substitution of /g 1 , and applying the general solution of the dt ′ (Cherstvy et al., 2018), we get the . The standard distribution σ of the density distribution is the limit of MSD: The trend of both mean positions ( Figure 2C) and width ( Figure 2D) was successfully predicted by analytical solutions of the OU-type model Equation S15 and Equation S18.
Moreover, the OU-type model Equation S14 has an equivalent Fokker-Planck equation that describes the probability density function of particles on z , P ( z, t ) : At t → ∞ , the probability density function reaches the steady stat P ( z ) , where the density dz 2 . Solving this equation with boundary conditions of P ( z = ±∞ ) = 0 and ∂P ( z=±∞ ) ∂z = 0 , we get the steady stat density profile with C0 is the integral constant that allows ´∞ −∞ P ( z ) dz = 1 . The exponent of this density profile is position-dependent that drops in parabolic form as z → ∞ . Compare to the front of Fisher wave, where the exponent of the density profile decreases linearly with z ( P ( z ) = e −Cz ), we know that the density profile of a chemotaxis migration wave is more compact than a Fisher wave.

Agent-based simulation with chemotaxis pathway
In order to simulate more details of bacterial group migration in a capillary, we use a previously established chemotactic pathway integrated agent-based simulation. This model integrated bacterial chemotactic signaling pathway to determine the switch rate of motors, the conformation changes of flagella, as well as the competition of multiple flagella.
We first simulated 80,000 cells evenly distributed in four phenotypes of different receptor gain N with consumption of chemoattractant. The cells were simulated as described in a previous paper (Saragosti et al., 2011), while the chemoattractant field S was calculated at each time step ( ∆t = 0.01 s ) according to Equation S8. In a 3D channel of 0.2 mm×0.01 mm× 10 mm, space was discretized to grid of 2.5 µm×2.5 µm× 2.5 µm . The evolution of the attractant during each time step was calculated by the sum of the consumption of every cell in the neighbor grids weighted by their effective diffusion distance. The consumption rate was fitted for reasonable migration speed. Detailed methods were described in a previous paper (Xue and Othmer, 2009). The perceived attractant of each cell was then linearly interpolated from the closest grids of the attractant field.
Simulation starts by setting all cells in one end of the channel ( x = 0 ), randomized in y and z directions and setting uniform chemoattractant concentration S 0 = 200 µM within the channel. Flip boundary condition was used for all three directions. After 20 min simulation, the bacterial population from stable migration groups (Appendix 1- figure 6A) tracks with cellular runtumble stat was recorded from 30 to 32 min with time step of 0.1 s. Using the group velocity VG of this period as the speed of moving coordinate z = x − VGt , density distribution of subgroups of different receptor gain N was plotted to show spatial ordering of subgroups (Appendix 1- figure  6B). The tracks were analyzed with exactly the same method as the experimental tracks (see Materials and methods). The expected drift velocity VD ( z ) of all subgroups decreases from back to front and was also spatially ordered (Appendix 1-figure 6C).
The particle-based simulations (Section 4) have already shown that the chemoattractant consumption can be decoupled from bacterial motions. To simplify the analysis, we used the same non-consumable moving gradient g ( x, t ) described in Figure 2A. Using the preset gradient, we simulated 100,000 bacteria of four evenly distribution phenotypes of different receptor gain N or adaptation time τ or basal CheY-p level Yp0 . The simulation was performed in 3D with reflection boundary on x = 0 mm & x = 20 mm and with free boundaries in the other two directions ( y, z ). Initially all cells were placed on x = 2 mm, y = z = 0 mm . In each time point with step ∆t = 0.01s , the internal states of every bacterium were updated according to their perceived gradient indexed by g ( xi ) with spatial precision ∆x = 0.001 µm . And then the bacterial moving stat (run or tumble) was updated accordingly, which results in movement to the next time point. Most parameters used in the simulation follow previous paper (Saragosti et al., 2011), while the changed parameters were the upper limit of chemoattractant sensing Kon = 1000 µM ; the lower limit of chemoattractant sensing Koff = 1 µM (Si et al., 2012); the diffusion coefficient of chemoattractant Ds = 1000 µm 2 /s ; the run speed of bacteria v 0 = 30 µm/s (Keller and Segel, 1971b); the adaptation time τM = 1s (Waite et al., 2016); the motor number was set 5 as in Sneddon et al., 2012; while the basic CheY-P level Yp0 = 2.77 µM , which corresponds to TB0 ≈ 0.27 . After 40 min of simulation, bacterial tracks were recorded with 10 fps for 20 min.

Estimation of χ from chemotaxis pathway
In order to compare the agent-based simulation results to the analytical OU-type model, we need to estimate the chemotactic ability χ from the parameters of chemotaxis pathway. Considering an simple case where perceived gradient of chemoattractant g is a fixed value, the averaged drift velocity of a group of bacteria VD can be estimated by the parameters of bacterial chemotaxis pathway In this equation, τR0 is the run time in homogenous environment, τ ′ R0 = dτR0/df with f is the free energy of the receptor, τM is the adaptation time, d is the dimension (e.g. d is 3 in this case), TB0 is the tumble bias in homogenous environment, and N is the receptor gain.
On the other hand, given the expression of VD , comparing the two expressions of expected drift velocity in fixed gradient, we can deduce: Using the expression Equation S20, we can deduce the required receptor gain N from χ , which is the case shown in the main text in Figure 3.

Agent-based simulation for different parameters
To investigate the bacterial behavior in moving gradient, we have simulated bacteria with χ ranging from 0.15 to 0.30 corresponding to receptor gain N ranging from 14.5 to 25.4. Related results were shown in Figure 3 and discussed in the main text.
Receptor gain is not the only parameter that affects the chemotactic ability. We have also varied the adaptation time τM and basal CheY-p level Yp0 to investigate the effect of these parameters on bacterial behaviors with a moving chemoattractant profile of larger slope of perceived gradient, g 1 = −2.5 mm −2 . For both cases, the density profile ρ ( z ) spatially ordered according to the variant parameter, and the expected velocities for call parameters Vd ( z ) decrease from back to front. These results show that bacteria perform mean reversion flow for all these parameters and were spatially ordered according to phenotypes.
For the case of basic CheY-p level Yp0 ranging from 2.70 µM to 2.85 µM, the basic tumble bias TB0 varies from 0.07-0.19, and the chemotactic ability χ decreases with Yp0 from 0.16 to 0.25 mm 2 min -1 . The mean positions of subgroups increase with χ so that it decreases with Yp0 . Unlike the receptor gain N , the basic tumble bias also increases the diffusion coefficient D . Analogized to the OU-type model, varying Yp0 changes the reversion rate χg and the noise level ϵ = √ 2D at the same time. Thus, the reversion rate decreases with Yp0 and the width of the density profile σ increases with the reversion rate r (Appendix 1- figure 8A-D).
For the case of adaptation time τM ranging from 1 to 10 s, mean positions and width of the density profile show non-monotonic dependence on τM . This phenomenon shows that adaptation time has a trade-off effect on bacterial chemotaxis. As Frankel et al., 2014 have discussed, the increasing adaptation time enforces chemotactic ability, while it weakens the sensitivity of bacteria to the chemoattractant gradient changes. Such dual effect was also reflected on the reversion rate defined by the slope of VD (Appendix 1-figure 8E-H).

Modified Langevin-type model for accumulated signals
As discussed in the main text, the reversion flow of individuals in the migrating group relies on a decreasing driving force from back to front. In the case of bacterial chemotaxis, such decreasing force comes from the gradient of perceived signal of chemoattractant, which is consumed by all the agents. Such mechanism can be generalized to the systems of trail-following migration (e.g. ants), where the signal is secreted by agents instead of being consumed. In this case, the signal concentration Ss ( x, t ) decreases from back to front, because more agents have passed the back than front, thus have secreted more signal on the back. Such dynamics can be modeled by similar Langevin equations and signal accumulations as discussed in Section 1: where γ = 3 * 10 −13 µM · s −1 · cell −1 is the secretion rate of the signal Ss and β = 0.001 s −1 is the decay rate of it. Other terms and parameters are identical to equations in Section 1.
Then, we solve Equation S21 numerically by applying 10 6 particles with normally distributed response ability χi of mean value of 1 and s.d. of 0.3 (Appendix 1-figure 10C). Results show that a coherent migrating group is formed spontaneously with constant migration speed ∼6.7 µm/s (Appendix 1-figure 10B). In the moving coordinate, the 'effective global force' Ss ( z ) decreases from the back to front as predicted. The particles with different response ability χi are ordered arranged (Appendix 1-figure 10D), while particles with larger χ locate more in the front. The microfluidic chip used in this study is consisted of a long channel (20 mm×0.6 mm×0.02 mm) and a large chamber (3 mm× 3 mm). Prepared bacteria are first loaded in the chip through inlets with M9 motility buffer (see Materials and methods). Next, the chip is spun at 3000 rpm for 15 min so that the bacteria are concentrated to one end of the channel. Bacteria consume aspartate (Asp) as the single chemoattractant to form a moving gradient that attracts the group migration. Finally, the bacterial