Skip to main content
UKPMC Funders Author Manuscripts logoLink to UKPMC Funders Author Manuscripts
. Author manuscript; available in PMC: 2015 Sep 12.
Published in final edited form as: Nature. 2014 Dec 24;519(7542):233–236. doi: 10.1038/nature14024

Mechanosensory Interactions Drive Collective Behaviour in Drosophila

Pavan Ramdya 1,2,*, Pawel Lichocki 2,3,, Steeve Cruchet 1, Lukas Frisch 4, Winnie Tse 4, Dario Floreano 2, Richard Benton 1,*
PMCID: PMC4359906  EMSID: EMS60835  PMID: 25533959

Abstract

Collective behaviour enhances environmental sensing and decision-making in groups of animals1,2. Experimental and theoretical investigations of schooling fish, flocking birds and human crowds have demonstrated that simple interactions between individuals can explain emergent group dynamics3,4. These findings imply the existence of neural circuits that support distributed behaviours, but the molecular and cellular identities of relevant sensory pathways are unknown. Here we show that Drosophila melanogaster exhibits collective responses to an aversive odour: individual flies weakly avoid the stimulus, but groups show enhanced escape reactions. Using high-resolution behavioural tracking, computational simulations, genetic perturbations, neural silencing and optogenetic activation we demonstrate that this collective odour avoidance arises from cascades of appendage touch interactions between pairs of flies. Inter-fly touch sensing and collective behaviour require the activity of distal leg mechanosensory sensilla neurons and the mechanosensory channel NOMPC5,6. Remarkably, through these inter-fly encounters, wild-type flies can elicit avoidance behaviour in mutant animals that cannot sense the odour – a basic form of communication. Our data highlight the unexpected importance of social context in the sensory responses of a solitary species and open the door to a neural circuit level understanding of collective behaviour in animal groups.


Drosophila melanogaster is classified as a solitary species7 but flies aggregate at high densities (>1 fly/cm2) to feed8 (Extended Data Fig. 1a-b and Supplementary Video 1), providing opportunities for collective interactions. Although groups affect circadian rhythms9 and dispersal10 in Drosophila, how social context influences individual sensory behaviours is unknown. To study this question, we developed an automated behavioural assay to track responses of freely-walking flies to laminar flow of air or an aversive odorant, 5% carbon dioxide (CO2)11,12. Odour was presented to one half of a planar arena for 2 min (Fig. 1a and Extended Data Fig. 1c-d). Avoidance behaviour was quantified as the percentage of time a fly spent in the air zone during the second minute of a trial (Fig. 1b-c). Unexpectedly, isolated flies spent very little time avoiding this odour (Fig. 1d), despite the aversion to CO2 observed in other assays11,12. However, increasing the number of flies was associated with substantial increases in odour avoidance (Fig. 1d and Extended Data Fig. 1e). This effect peaked at 1.13 flies/cm2, a density typical for fly aggregates (Extended Data Fig. 1b) and was only apparent for flies in the odour zone (Fig. 1e and Extended Data Fig. 1f). Time-course analysis revealed that, within only a few seconds after odour onset, a larger proportion of flies in high-density groups had left the odour zone compared to isolated individuals (Fig. 1f; comparing 0.06 against 1.13 flies/cm2, P <0.05 for a Mann-Whitney U-test from 0.6 s onwards). Additionally, the motion of flies after odour onset was coherent at higher densities, with flies moving in the same direction, out of the odour zone; this effect was not observed for flies in the air zone (Extended Data Fig. 1g-h).

Figure 1. Collective odour avoidance in Drosophila.

Figure 1

a, Image of flies (triangles) and their trajectories (dashed lines) during 2 s in a two-choice olfactory assay. 5% CO2 (‘Odour’) flows through the right half while air flows through the left half. Two densities of flies are shown (0.06 & 1.50 flies/cm2). The scale bar is 2.5 mm. b, Schematic of the odour avoidance experiment. Flies in the odour zone at stimulus onset (t = 0) are measured for the time spent in the non-odour zone during the second minute of the experiment (‘Time avoiding odour (%)’). c, Flies (white triangles) with a low (top) or high (bottom) percent time avoiding odour. d-e, The percent time avoiding the odour (mean and s.d.) for five different densities of flies starting in the odour zone (black bars) (d) and four densities of flies starting in the air zone (grey bars). N = 37, 38, 36, 35, and 38 experiments for 0.06, 0.38, 0.75, 1.13, and 1.5 flies/cm2 respectively. (e). In this and all subsequent figures, unless otherwise stated, a single asterisk (*) denotes P <0.05 and a double asterisk (**) denotes P <0.01 for a Bonferroni-corrected paired sample t-test (bar plot comparisons) or a Mann-Whitney U-test (boxplot comparisons). f, The proportion of flies outside of the odour zone over the entire experiment. The mean (solid line) and s.e.m. (transparency) are colour-coded for each density (n is as for panels d-e).

To determine the basis of these global behavioural differences, we examined the locomotion of individual flies. Single animals are typically sedentary but walk more when exposed to CO2 (Extended Data Fig. 2a-b). In groups, however, we discovered that 63% of the time, the first walking response of a fly after odour onset coincided with proximity to a neighbouring fly (an ‘Encounter’: distance to a neighbouring fly < 25% body length; Fig. 2a-c and Supplementary Video 2). These Encounters were more frequent with increasing group density (Fig. 2d). Moreover, walking bouts (velocity >1 mm/s) initiated during an Encounter (‘Encounter Responses’) were significantly longer than those spontaneously initiated in isolation (Fig. 2e). These observations indicated that inter-fly interactions might contribute to the enhanced odour avoidance of groups of flies.

Figure 2. Inter-fly Encounters coincide with odour responses and are required for collective odour avoidance in simulations.

Figure 2

a, Images of two flies (left, white circles) undergoing an Encounter (middle, red circles) that results in an Encounter Response (right, blue circle). b, Velocities and Encounters for two flies exposed to CO2 at the odour onset (grey dashed line). The top panel shows the velocity for each fly. Cyan arrowheads indicate the first walking bout initiated after odour onset (‘Odour walking response’). The bottom panel shows when these flies are (white) or are not (black) undergoing an Encounter during the same time period. c, The likelihood of an Encounter with respect to the time of the odour walking response (blue line) or a randomly chosen time point (grey line). Data is from Fig. 1d: density = 1.13 flies/cm2 and n = 200 flies. d, The frequency of Encounters as a function of group density. Data is from Fig. 1d. e, The duration of walking bouts depending on whether they are initiated in isolation (grey boxes) or during an Encounter (white boxes). Data is from Fig. 1d. f, Simulated flies moved through a virtual arena as a function of three parameters: spontaneous bout probability (‘Bout’), Encounter Response probability (‘Encounter Response’), and turn away probability from the air-odour interface (‘Turn away’). Low (small grey arrows) or high (large black arrows) probabilities were experimentally determined (Extended Data Fig. 2). g, The percent time avoiding the odour (mean and s.d.) for five densities of simulated flies (n = 80 experiments for each condition). h, The sensitivity of simulated odour avoidance to Encounter Response probabilities ranging from 0 (never responding to Encounters, blue) to 1 (always responding, yellow). Each coloured line indicates the mean odour avoidance time. The black line indicates Probability = 0.8, taken from real fly data in Fig. 1 (n = 10,902 experiments for each data point). Black circles indicate the mean fly avoidance times from Fig. 1d.

We examined this possibility initially by computational simulation of the olfactory assay. The dynamics of our simulation were driven by three phenomena observed in behavioural assays (Fig. 2f). First, flies initiate spontaneous bouts of walking more in odour than in air (Extended Data Fig. 2a-b). Second, flies are more likely to turn and retreat after entering the odour zone from the air zone (Extended Data Fig. 2c). Third, close proximity to another fly elicits Encounter Responses in stationary flies (Fig. 2e and Extended Data Fig. 2d). Importantly, these elements could reproduce collective behaviour: higher numbers of simulated flies exhibited greater avoidance (Fig. 2g). While changing the olfactory parameters preserved stronger responses in groups than isolated individuals (Extended Data Fig. 2e-h), diminishing the Encounter Response probability could abolish and even reverse collective behaviour (Fig. 2h). These results suggested that Encounter Responses are a crucial component of Drosophila group dynamics.

To experimentally test the role of inter-fly interactions in collective behaviour, we sought the mechanistic basis of Encounter Responses. Although our olfactory experiments were performed in the dark (Fig. 3a), the presence of light did not diminish Encounter Response frequency (Fig. 3a). Volatile chemicals are known modulators of many social behaviours13,14, but putative anosmic flies (lacking known olfactory co-receptors) did not reduce Encounter Responses (Fig. 3a). By contrast, disruption of the mechanosensory channel NOMPC5,6 significantly diminished Encounter Response frequency (Fig. 3a). These data suggested that mechanosensing is required for Encounter Responses.

Figure 3. Leg mechanosensory sensilla neuron activity is necessary and sufficient for Encounter Responses.

Figure 3

a, The frequency of Encounter Responses measured from experiments in Figure 1 (‘Dark’), illuminated experiments (‘Light’), near-anosmic mutants (IR8a1;IR25a2;GR63a1,ORCO1), auditory/proprioceptive mutants (nanchung36a), nociceptive touch mutants (piezoKO), and gentle touch mutants (nompCf00914). To calculate the Frequency of Encounter Responses, we tested how often each stationary fly undergoing an Encounter moved continuously for the next half-second. N = 10 experiments for each condition (density = 0.75 flies/cm2). Reductions for nanchung and piezo mutants were not statistically significant (Extended Data Table 1). b, Single frames from a high-resolution video of an Encounter between a moving fly and a stationary fly. The schematic on the middle frame shows the percent of all observed Encounter Responses resulting from touch for each leg segment (n = 104 experiments). The Encounter Response walking trajectory elicited by touch is shown in yellow on the right-hand frame. c, Encounter Response trajectories (right) colour-coded by the appendage touched by the neighbouring fly (left). Wings (W, n = 54 experiments), Legs (R1-R3 and L1-L3, n = 21, 18, 19 and 23, 15, 17 experiments, respectively). The scale bar is 1 mm and each trajectory represents up to 0.24 s of walking. d, Touch response trajectories (right) colour-coded by which appendage was touched by a metallic disc (left). Wings (W, n = 20 experiments), Legs (R1-R3 and L1-L3, n = 20, 21, 21 and 18, 21, 20 experiments, respectively). The scale bar is 2.5 mm and each trajectory represents up to 1.5 s of walking. e, The frequency of Encounter Responses elicited by moving flies with (‘oe+’) or without (‘oe−’) cuticular hydrocarbon-secreting oenocytes (n = 11 experiments each). f, A transmitted light image, inverted fluorescence image (fluorescence in black), and summed fluorescence for a Mechanosensory Sensilla driver fly leg expressing GFP. Leg mechanosensory sensilla (‘MS’) are indicated in green. A high-resolution image of the tarsus is shown on the right. Endogenous GFP fluorescence (green) is superimposed upon a transmitted light image (magenta). The scale bars are 100 μm. g, The frequency of Encounter Responses for parental line controls (UAS-Tnt/+;+ or piezo-Gal4/+;cha3-Gal80/+), Mechanosensory Sensilla driver flies expressing an inactive tetanus toxin control (UAS-TntIMP/piezo-Gal4;cha3-Gal80/+), or Mechanosensory Sensilla driver flies expressing tetanus toxin (UAS-Tnt/piezo-Gal4;cha3-Gal80/+). N = 12, 13, 15, and 15 experiments, respectively. h, Blue laser optogenetic stimulation responses of flies expressing ChR2 in mechanosensory sensilla (piezo-Gal4/+; cha3-Gal80/UAS-ChR2(T159C)) in the absence (left) or presence (right) of the essential cofactor all trans-Retinal (n = 12 flies for each condition). Each box indicates the response for a single fly (‘walk’, ‘leg shift’, or ‘none’).

By observing groups of flies at high spatiotemporal resolution, we found that active flies elicited motion in stationary animals through gentle touch of peripheral appendages (legs and wings; Fig. 3b and Supplementary Video 3). Leg touches took place exclusively on distal segments (Fig. 3b, inset) and resulted in spatially-stereotyped walking reactions (Fig. 3c). These reactions were kinematically indistinguishable from Encounter Responses (compare Extended Data Figs. 3c and 3e; two-sample Kolmogorov-Smirnov test, P = 0.07; see Methods). This analysis indicates that appendage touch is the stimulus that elicits Encounter Responses. The precise stereotypy of these locomotor responses, similar to cockroach escape reactions15, implies their dependence upon somatotopic neural circuits linking touch with movement.

As fly appendages also house taste receptors16, we tested whether mechanical stimulation was sufficient to elicit Encounter Responses by tracking stationary flies following touch of appendages with a metallic disc (Supplementary Video 4). We observed a stereotyped relationship between the location of mechanical touch and subsequent walking trajectories (Fig. 3d), whose associated kinematics were indistinguishable from those of Encounter Responses. Thus, mechanical touch alone can elicit Encounter Responses (compare Extended Data Figs. 3c and 3g; two-sample Kolmogorov-Smirnov test, P = 0.3). Consistently, genetically ablation of flies’ oenocytes, to remove cuticular hydrocarbon contact chemosensory signals17, had no effect on the ability of these animals to elicit Encounter Responses in wild-type flies (Fig. 3e). These data imply that Encounter Responses are mediated solely by mechanosensory stimulation.

We next identified mechanosensory neurons required for touch-evoked Encounter Responses by driving tetanus toxin (Tnt) expression with a panel of candidate mechanosensory Gal4 lines (Extended Data Fig. 4a). R55B01-Gal4/UAS-Tnt flies exhibited significantly diminished Encounter Responses compared to a gustatory neuron driver line (Extended Data Table 2), without reduced ability to produce sustained high-velocity walking bouts (Extended Data Fig. 4b). R55B01-Gal4-driven expression of a UAS-CD4:tdGFP reporter was detected in neurons innervating leg and wing neuropils of the thoracic ganglia (Extended Data Fig. 5a). Consistently, GFP fluorescence labelled neurons in several leg mechanosensory structures: the femoral and tibial chordotonal organs, and distal leg mechanosensory sensilla neurons (Extended Data Fig. 5b). Notably, amongst the screened lines only R55B01-Gal4 drove expression in leg mechanosensory sensilla (Extended Data Fig. 4c-d) suggesting that these are the critical neurons for Encounter Responses.

To ascertain the contribution to Encounter Responses of leg mechanosensory sensilla and/or chordotonal structures (which can also sense touch18,19), we identified additional Gal4 driver lines that drove expression in subsets of these neuron classes. By intersecting piezo-Gal4 with cha3-Gal80, a Gal4 suppression line, we could limit leg expression to mechanosensory sensilla neurons (termed ‘Mechanosensory Sensilla driver’ line) (Fig. 3f). Importantly, silencing neurons with this driver significantly diminished Encounter Response frequency (Fig. 3g). By contrast, silencing leg chordotonal organs alone had no effect on Encounter Response frequency (Extended Data Fig. 5a-c).

We tested the sufficiency of leg mechanosensory sensilla neuron activity to elicit Encounter Response-like walking by expressing Channelrhodopsin-2 (ChR2) in each class of leg mechanosensory neurons and recording behavioural responses to blue light pulses. Optogenetic stimulation of flies expressing ChR2 in leg mechanosensory sensilla neurons, but not chordotonal organs, resulted in Encounter Response-like walking (Fig. 3h; Extended Data Fig. 5d, Supplementary Videos 5 & 6), consistent with natural elicitation of Encounter Responses by inter-fly touch of distal leg segments (Fig. 3b, inset).

Our identification of a neuronal basis for Encounter Responses allowed us to test our model’s prediction (Fig. 2h) that inter-fly interactions are required for collective odour avoidance. First, we silenced leg mechanosensory sensilla neurons by expressing Tnt with R55B01-Gal4 or the Mechanosensory Sensilla driver. Second, we studied nompC mutants. Each of these perturbations abolished collective odour avoidance behaviour (Fig. 4a-c), supporting the link between mechanosensation and group behaviour.

Figure 4. Encounter Responses are required for collective odour avoidance.

Figure 4

a-b, The percent time avoiding the odour (mean and s.d.) for R55B01-Gal4 (a) or Mechanosensory Sensilla driver (b) flies expressing an inactive tetanus toxin control, or tetanus toxin. N = 22, 21, 22, and 19 experiments for R55B01-Gal4 and N = 23, 21, 21, and 21 experiments for the Mechanosensory Sensilla driver (genotypes: UAS-TntIMP;R55B01-Gal4, UAS-Tnt;R55B01-Gal4, UAS-TntIMP/piezo-Gal4;cha3-Gal80/+, UAS-Tnt/piezo-Gal4;cha3-Gal80/+). c, The percent time avoiding the odour (mean and s.d.) for heterozygous control, or homozygous nompCf00914 mutant animals. N = 22, 22, 21, and 21, respectively. d-e, The percent time avoiding the odour (mean and s.d.) for individual CO2 anosmic virtual and real flies (GR63a1,IR64aMB05283). Avoidance time is measured from a single ‘CO2 anosmic’ fly per experiment in a simulated model (d, n = 80 experiments each), or in Drosophila (e, n = 35, 37, 40, and 38 experiments) where single mutant flies were tested for CO2 avoidance in the context of wild-type flies.

Touch may enhance odour avoidance by increasing awareness of the stimulus. Alternatively, touch may produce an odour-independent Encounter Response reaction that initiates departure from the odour zone. To distinguish between these possibilities, we asked if odour insensitive flies displayed increased avoidance in the presence of odour sensitive animals. Indeed, both in simulations (Fig. 4d) and in real flies (Fig. 4e), increasing the number of odour sensitive individuals led to greater avoidance behaviour of odour insensitive individuals. Thus, in this context, touch-mediated modulation of odour awareness plays little, if any, role in collective avoidance.

Combining systems-level and neurogenetic approaches, we have uncovered a hierarchy of mechanisms that drive collective motion in Drosophila. Active flies elicit spatially stereotyped walking responses in stationary flies through appendage touch interactions, requiring the NOMPC mechanosensory channel and distal leg mechanosensory sensilla neurons. Through Encounter Responses, odour reactions of sensitive flies spark cascades of directed locomotion of less sensitive (or even insensitive) individuals, causing a coherent departure from the odour zone. This behavioural positive feedback and group motion are absent among flies in the non-odour zone since they are less likely to initiate walking and, consequently, have a reduced frequency of Encounters. Additionally, flies retreat when encountering the odour while transiting from the air zone. Together these behavioural phenomena cause flies to escape the odour zone and then remain in the air zone, resulting in higher odour avoidance for groups compared to isolated animals (Extended Data Fig. 6). When distal appendage mechanosensory touch detection is impaired, groups of flies cannot produce Encounter Responses, are less likely leave the odour zone, and instead behave like isolated flies. Encounters are likely to have widespread influence on sensory-evoked actions of individuals in groups. For example, movement of flies towards areas of high elevation20 is also increased in higher density groups (Extended Data Fig. 7).

Behaviour in animal groups arises from the detection and response to intentional and unintentional signals of conspecifics. While neural circuits controlling pairwise interactions, such as courtship, are increasingly well-understood21, we know little about those orchestrating group-level behaviours. The identification of sensory pathways that mediate collective behaviour in Drosophila opens the possibility to understand the neural basis by which an individual’s actions may influence –and be influenced by– group dynamics.

Methods

Drosophila lines

Actin88F-eGFP22 back-crossed 5 generations to w1118 was used as the wild-type line enabling distinction from non-fluorescent mutant flies in Fluorescence Behavioural Imaging experiments (Fig. 3a,e,g and Fig. 4e and Extended Data Fig. 5c).

GR63a1,IR64aMB05283 mutant flies were used as the CO2-anosmic individuals (Fig. 4e).

IR8a1;IR25a2;GR63a1,ORCO1 quadruple mutant flies were used to measure the influence of olfaction on the frequency of Encounter Responses (Fig. 3a).

nanchung36a 23, piezoKO 24, and nompCf00914 5 mutant flies were used to measure the impact of mechanosensing on the frequency of Encounter Responses (Fig. 3a).

P{GMR-Gal4}attP2 transgenic flies25,26 were used to identify neural populations with deficient touch responses (Fig. 3g, and Extended Data Fig. 4,5). Gal4 drivers were selected by pre-screening a large panel (http://flweb.janelia.org/) for those displaying sparse expression in neurons that projected from the legs to the thoracic ganglia and neurons innervating the antennal mechanosensory and motor centre in the brain26. To identify R55B01-Gal4, we compared the frequency of Encounter Responses in animals bearing these transgenes against that of a control driver, R27B07-Gal4, which drives a gustatory pattern of expression in the legs27 and Thoracic Ganglia (Extended Data Fig. 4a, green and data not shown). Brain expression in R55B01-Gal4 was limited to neurons projecting to the Antennal Mechanosensory and Motor Centre, and weaker expression in those innervating the suboesophogeal zone (which receives both gustatory and mechanosensory input from the labellum) and several visual areas (optic lobes and optic tubercle; Extended Data Fig. 5a). These weakly marked neural populations are likely to contribute only minimally to Encounter Responses as labellar touch was never observed and all experiments were performed in the dark. Finally, we also observed fan-shaped body expression in R55B01-Gal4. However, inhibiting the fan-shaped body cannot explain Encounter Response reductions in R55B01-Gal4 since silencing these neurons alone has no effect on Encounter Response frequency (Extended Data Fig. 5c, R65C03-Gal4).

piezo-Gal4;cha3-Gal80 flies were used to target mechanosensory sensilla neurons.

UAS-Tnt and UAS-TntIMP flies were used to measure the effects of neural knockdown on Encounter Responses and collective behaviour (Fig. 3g, and Fig. 4a-b, and Extended Data Fig. 5c).

UAST-ChR2(T159C) flies were generated by cloning ChR2(T159C)28 into pgUASTgattB29,30 and inserting this transgene into attP2 site (Genetic Services, Inc., Cambridge MA, USA). UAS-ChR2 flies were then crossed with Gal4 driver lines for Channelrhodopsin2 stimulation experiments (Fig. 3h, and Extended Data Fig. 5d).

PBac{y[+mDint2] w[+mC]=UAS-CD4:tdGFP}VK00033 flies31 were used to visualise Gal4 driver expression in leg, brain, and thoracic ganglia neurons (Fig. 3f, and Extended Data Figs. 4d-e and 5a-b).

PromE(800)-Gal4 [4M],Tub:Gal80ts flies, UAS-StingerII, UAS-Hid/CyO flies and UAS-StingerII flies were used for oenocyte ablation experiments (Fig. 3e) as described previously32.

Experimental and statistical conditions

Experiment sample sizes were chosen based on preliminary studies. If sample size constraints and proper experimental conditions were met, all experiments were included for subsequent analysis. Experiments for different conditions and genotypes were interleaved to minimise the effects of time-of-day on behavioural results. Due to the automated nature of almost all data acquisition and analysis, the experimenter was not blinded. For data meeting the criteria of normality, bar plots are presented and parametric statistical tests were used. For other data, boxplots and non-parametric statistics were used. Groups with similar variance are compared throughout the study.

Arena design and flow simulation

Arenas were designed using the 3D CAD software, SolidWorks (Dassault Systemes, Waltham, Massachusetts, USA) and CNC machined from polyoxymethylene and acrylic glass. Arena flow patterns were simulated using EasyCFD (www.easycfd.net) incorporating measured physical and flow parameter values (Extended Data Fig. 1d).

Behavioural imaging and tracking

For low-resolution behavioural imaging, we used Fluorescence Behavioural Imaging (FBI)22 acquisition software and hardware. In all cases, we used Ctrax33 for fly tracking and data analysis was performed using custom Matlab scripts (The Mathworks, Natick, Massachusetts, USA).

Behavioural experiments

All experiments were performed on adult female Drosophila raised at 25°C on a 12 h light:12 h dark cycle 2-4 days post-eclosion, with the exception of experiments in Extended Data 1b, which used male flies). Experiments were performed in a temperature-controlled room at 25°C, except for those in Fig. 3c, which were performed at 22°C. In all cases except for aggregation measurements, flies were starved in empty 50 mm Petri dishes for 3-6 h in humidified 25°C incubators. Experiments were performed in either the morning or late afternoon ZT.

Aggregation measurements (Extended Data Fig. 1)

Flies were starved for 24 h at 25°C in humidified tubes with moist Kimwipes™. Ripe banana paste was prepared on the day of experiments and placed into a 12.78 cm2 dish. Experiments were performed in either the morning or late afternoon Zeitgeber time (ZT). Experiments for summary data (Extended Data Fig. 1b) were filmed with a webcam (Microsoft LifeCam Studio, Redmond, USA) for 90 min with images acquired every 10 min. Flies were placed into a clean transparent box (23.5 cm × 25 cm × 37.5 cm) with only red light illumination. To calculate densities, the number of flies on the food source was calculated for each image and averaged from the 30th to 90th minute.

Collective odour avoidance – wild-type, neural knockdown, nompC, and mixed wild-type/anosmic (Fig. 1 and Fig. 4a-c,e)

For olfactory stimulation, pre-mixed 5% CO2, or air (Messer Schweiz AG, Lenzburg, Switzerland) was flowed through Mass Flow controllers (PKM SA, www.pkmsa.ch) at a regulated flow rate of 500 mL/min via computer controlled solenoid valves (The Lee Company, Westbrook, CT, USA). A custom-fabricated circuit board and software22 (sQuid, http://lis.epfl.ch/squid/) controlled valves, illumination LEDs (Super Bright LEDs Inc. St. Louis Missouri, USA), and acquisition cameras (Allied Vision Technologies, Stadtroda, Germany). Flies were imaged in the olfactory arena using the following illumination/olfactory stimulation protocol:

  1. Infrared (IR)/blue light; air both sides (10 s)

  2. IR light; 5% CO2/air (2 min)

  3. IR/blue light; air both sides (10 s)

The location of CO2 was varied across experiments to eliminate the effects of other possible environmental asymmetries on behavioural results. Blue light was used in all cases to keep experiments consistent with mixed genotype FBI collective behaviour experiments (Fig. 4e).

Collective negative gravitaxis (Extended Data Fig. 7)

For negative gravitaxis experiments, we tilted the behavioural arena at a 22.5° incline for 2 min. Flies were placed near the lower portion of the arena and were illuminated using red light. The Negative Gravitaxis Index was calculated by averaging their position along the long axis of the arena (with values ranging from 0 (bottom of the arena) to 100 (highest point of the arena)) during the second minute of the experiment.

Encounter Response modality screen (Fig. 3a)

12 flies (‘Wild-type Light’) or mixtures of 6 wild-type and 6 mutant flies (using a GFP reporter and Fluorescence Behavioral Imaging to distinguish genotypes22) were imaged in the olfactory arena using the following illumination/odorant protocol:

  1. Infrared (IR)/blue light; air both sides (10 s)

  2. IR light; air both sides (5 min)

  3. IR/blue light; air both sides (10 s).

Blue light was used in all cases to keep experiments consistent with mixed genotype Encounter Response experiments.

High-resolution inter-fly touch response (Fig. 3b-c and Extended Data Fig. 3d-e)

Four flies were imaged in a small arena (1 cm × 5 cm) backlit with IR light (Super Bright LEDs Inc. St. Louis Missouri, USA). Images were continuously acquired at 125 fps using a high-speed video camera (Fastec Imaging, San Diego, CA, USA). The experimenter captured a video if a stationary fly exhibited touch-elicited walking.

High-resolution mechanical touch response (Fig. 3d and Extended Data Fig. 3f-g)

Individual flies were imaged in a small arena (3 cm × 3 cm) illuminated by a red ring light (FALCON Illumination MV, Offenau, Germany). Images were continuously buffered at 20 fps using a high-resolution video camera (Gloor Instruments, Uster Switzerland). A small magnetic metallic disc (1 mm diameter) was directed to individual leg or wing appendages using a larger permanent magnet. The experimenter captured a video if a stationary fly exhibited touch-elicited walking.

Neural silencing Encounter Response screen (Extended Data Fig. 4a-b)

18 flies expressing Tnt under the control of a specific Gal4 driver were imaged in the group arena using the following illumination protocol:

  1. Infrared (IR)/blue light (10 s)

  2. IR light (2 min)

  3. IR/blue light (30 s)

  4. IR light (2 min)

  5. IR/blue light (10 s).

Neural silencing Encounter Response frequency (Fig. 3g and Extended Data Fig. 5c)

6 flies expressing UAS-Tnt/+,<driver>-Gal4/+, UAS-Tnt/<driver>-Gal4, or UAS-TntIMP/<driver>-Gal4 were imaged in the presence of 6 wild-type flies in the group arena using the following illumination protocol:

  1. Infrared (IR)/blue light; air both sides (10 s)

  2. IR light; air both sides (2 min)

  3. IR/blue light; air both sides (10 s).

Optogenetic stimulation (Fig. 3h and Extended Data Fig. 5d)

Flies bearing UAS-ChR2 (T159C) and the specified Gal4 driver were raised either in food mixed with 2 mM all trans-Retinal (‘ATR’, Sigma-Aldrich, St. Louis USA) or in the 95% ethanol solvent. Individual flies (2-4 days post-eclosion) were imaged in a small arena (3 cm × 3 cm) illuminated by a red ring light (FALCON Illumination MV, Offenau, Germany). Images were continuously buffered at 20 fps using a high-resolution video camera (Gloor Instruments, Uster Switzerland). A red laser (Thorlabs, Newton, USA) was aligned to the fly’s thoracic segment. Stimulation consisted of a short (1 s) pulse of blue laser light (Coherent, Santa Clara, USA). The experimenter video recorded three stimulations per fly at an interval of approximately 2 min. The behaviour of the fly during at least 2/3 of these stimulations was noted.

Behavioural analysis

To determine threshold values for fly motion, Encounters, and Encounter Responses, we measured velocities, accelerations and distances that could conservatively account for a test dataset of manually annotated events. To the best of our knowledge our results should be qualitatively robust to small variations in these values.

Percent of time avoiding odour (Fig. 1d-e, Fig. 2g-h, Fig. 4, and Extended Data Fig. 2e-h)

To calculate odour avoidance, we measured the percent of time that flies spent in the non-odour (air) zone during the experiment’s second minute. This time period was chosen since we observed that flies tend to reduce exploration after one minute – see Fig. 1f). ‘% of time avoiding odour’ = (time spent in the odour zone during the last minute / 1 min) × 100. To report quantitatively equivalent values for different density experiments, we resampled data using bootstrapping. This entailed randomly selecting a subgroup of experiments and, from these, one fly per experiment. We then averaged the odour avoidance for these flies to yield one result. We repeated this process a specified number of iterations to generate a distribution from which to report the mean and s.d. The number of iterations was closely linked to the average number of experiments. For example, in cases where n ~ 40, the number of bootstrapping iterations was 40.

Walking bouts (Fig. 2e and Extended Data Fig. 2b)

We measured activity bouts using a hysteresis threshold on forward velocity (Extended Data Fig. 2b) or velocity magnitude (Fig. 2e) to create a binary time-series. Bouts began when velocity exceeded a high threshold of 1 mm/s. Bouts ended when velocity was below a low threshold of 0.5 mm/s. Short bouts or pauses (<2 frames or 100 ms – Extended Data Fig. 2b; <20 frames or 1 s - Fig. 2e) were removed by merging the fly’s state with neighbouring measurements. Bouts were also terminated when moving flies Encountered obstacles including other flies. This can explain the decreasing Encounter induced bout lengths observed at higher densities (Fig. 2e).

Coherent Motion Index (Extended Data Fig. 1g-h)

To measure the coherence of group motion away or towards the odour zone, we calculated a Coherent Motion Index (CMI). We did this by first identifying walking flies at every time-point. For these flies, we identified the orientation of walking in a binary fashion: within the half-circle pointing towards the odour half of the arena or within the half-circle pointing towards the air half of the arena. The CMI for each time-point is: (# of flies moving towards the air − # of flies moving towards the odour) / total # of moving flies

For a given experimental replicate, we average the CMI for the first ten seconds of odour presentation to capture the initial avoidance response. We report the distribution of this time-averaged CMI value across experimental replicates. For our analysis we examined the CMI for flies starting either in the air zone or the odour zone. Since the number of flies in a replicate can affect possible CMI values, comparisons should be limited to experiments with the same density of flies.

Encounter likelihood / Frequency of Encounters (Fig. 2b-d)

To calculate Encounter likelihood with respect to odour walking responses (Fig. 2b,c), we identified odour reactions as the time at which a stationary fly within the odour zone began moving (velocity magnitude >1 mm/s). As a control, a random time was selected from the entire experiment. We then determined the times at which each fly was undergoing an Encounter (distance to nearest neighbour <25% long-axis body length). Using these two datasets, we performed an event-triggered average of the Encounter time-series for all flies.

Notably, the timing of the peak in Encounter likelihood is not of sufficient resolution to make inferences about causality. This is due to the inability to precisely define a touch encounter in low-resolution video for which the legs are not visible. With Encounters, we instead rely on an estimate based on the overlap between two circles defining the peripheral space of neighbouring flies. Therefore Encounters can continue past the onset of motion since neighbouring flies may not have become distant enough to terminate the Encounter. This is illustrated in Figure 2b in which the Encounters (white blocks) persist past the times of ‘odour walking response’ (blue arrowheads) for both flies shown.

To calculate the frequency of Encounters for different group densities (Fig. 2d), we measured the proportion of time flies spent having Encounters during a given experiment. Notably, Encounters are a function of motion: flies that move are more likely to Encounter other flies.

Encounter Response frequency (Fig. 3a,e,g, Extended Data Fig. 4a, and Extended Data Fig. 5c)

To calculate the Frequency of Encounter Responses, for each stationary fly (velocity magnitude <1 mm/s) undergoing an Encounter (distance to nearest neighbour <25% long-axis body length), we identified motion events (velocity >1 mm/s or angular velocity >2 rad/s or acceleration magnitude >15 mm/s2). If there was continuous motion for the next half-second (mean velocity magnitude >5 mm/s) an Encounter Response occurred, otherwise not. The average frequency across all flies in a given experiment was used to calculate summary data. Notably, the Encounter Response frequency is normalised by the number of Encounters: Frequency of Encounter Responses = Encounters producing walking reaction / (Encounters producing walking reaction + Encounters eliciting no reaction). Therefore this frequency is not a function of motion (e.g. flies with high walking probabilities may generate more Encounters but reactions to these interactions - Encounter Responses - may still be more or less frequent. Similarly, flies that are predominantly stationary may have few Encounters but these too may result in a high or low frequency of Encounter Responses).

Encounter Response trajectories and kinematics (Extended Data Fig. 3b,c)

To calculate Encounter Response trajectories (Extended Data Fig. 3b), for each stationary fly (velocity magnitude <1 mm/s and angular velocity <2 rad/s) undergoing an Encounter (distance to nearest neighbour <25% long-axis body length) near the centre of the arena (distance to wall >2 mm), we identified motion events (angular velocity ≥ 2 mm/s or acceleration magnitude >= 15 mm/s2). The position of the fly was recorded for the remaining frames until it stopped (velocity <1 mm/s) or gained proximity to a new fly (distance to nearest neighbour <25% long-axis body length) or proximity to a wall (distance to wall <2 mm). Resulting response trajectories were pooled across experiments as a function of the octant of the Encounter (Extended Data Fig. 3a; the appropriate octant was identified as the region surrounding the fly subsected by a straight line between the fly’s centre of mass and that of the neighbouring fly). Encounter Response velocities were obtained for each of these trajectories and averaged to produce kinematic data. Boxplots were calculated by averaging over the first 500 ms of kinematic data (Extended Data Fig. 3c).

Touch response trajectories and kinematics (Fig. 3c,d, Extended Data Figs. 3d-g)

Trajectories were taken from raw tracking data of flies responding to touch. Trajectories ended when flies were near another fly or a wall. Each resulting response trajectory was pooled across experiments depending on the location of touch (e.g. leg or wing). Touch response velocities were also obtained for each of these responses and averaged to recover kinematics. Boxplots were calculated by averaging over the first 160 ms (Extended Data Fig. 3e) or 500 ms (Extended Data Fig. 3g) of kinematic data. This discrepancy is due to the difference in frame-rate between the two measurements.

Comparing response kinematics

Our aim was to compare the shape of kinematic data across Encounter responses, interfly touch responses, and mechanical touch responses. However, these data could be quite distinct with regards to spatial and temporal resolution. Therefore, we first concatenated the median value from each of the common seven octants (excluding the front octant in the Encounter response dataset) across each of three velocity measures (forwards, sideways, and angular velocities) yielding a vector with 21 data-points. We then normalised these 21 element vectors to range from 0 to 1. These vectors were then compared using the 2-sample KS test.

Simulations

Simulated flies

To verify our model of collective odour avoidance we used an agent-based simulation driven by probabilistic behaviours (Fig. 2f-h, Extended Data Fig. 2). The artificial flies had a circular body of 2.5 mm diameter and were placed in the arena of size 80 mm × 20 mm for 2400 time-steps (corresponding to 120 s of ‘simulated’ time). The odour was presented on one half of the arena during entire simulation. Simulated flies walked with a constant speed of 0.51 mm/time-step in straight bouts, which were separated by periods of inactivity. At the beginning of each bout or when encountering an obstacle (a wall or another fly) each fly randomly changed its walking direction. The bouts were initiated either i) spontaneously in isolation or ii) during an Encounter.

Isolated bouts (Extended Data Fig. 2a-b)

To estimate the propensities of flies to initiate walking in isolation, we performed 45 additional single fly experiments (density = 0.06) in which the animal walked in the dark for 2 min. It was exposed to air throughout the entire arena in the first minute and odour during the second minute. For each fly i (i = 1,2, … 45), we integrated the differences between its consecutive positions during the first minute of the experiment (air) and separately during the second minute of the experiment (odour) at 20 Hz. The minimum of these 45 × 2 values (i.e., 29.9 mm) was treated as noise and subtracted from all 90 values. Consequently, we obtained the total distance travelled in air and in odour by each of the 45 flies (i.e., DAiri and DOdouri for i = 1, 2, … 45). To estimate bout durations, we rescaled these 90 values such that their mean was equal to the mean duration of Isolated bouts observed in the six flies experiments (density = 0.38). Overall, we obtained 45 values of prototypical Isolated bout lengths initiated spontaneously in air and 45 values of prototypical Isolated bout lengths initiated in odour (i.e., LAiri = 0.29DAiri and LOdouri = 0.29DOdouri for i = 1, 2, … 45). Of note, the estimated bout lengths varied between animals, and between air and odour for a single animal.

We used the 45 values of LAiri and the 45 values of LOdouri to bootstrap the behaviour of simulated flies. A simulated fly performed a self-induced bout of length LAirs if initiated in air, and of length LOdours if initiated in odour, where s denoted which prototypical behaviour the simulated fly used. The value of was set at time-step 1 for each simulated fly independently and uniformly at random to an integer value between 1 and 45. Thus, the values of s varied between the flies but it was possible for some flies to have the same s value. The values of s were kept constant for each simulated fly during all 2400 time-steps. Consequently, each simulated fly had a fixed propensity to move spontaneously. Moreover, within the same group, simulated flies usually differed between themselves in their propensity to move spontaneously.

Between bouts, a simulated fly following the prototypical behaviour s remained inactive for (LMax − LAirs)/v time-steps when resting in air and for (LMax − LOdours)/v time-steps when resting in odour, where LMax is the maximal value of all 90 values of L (i.e., LMax = 214 mm) and v is the walking speed. We estimated the walking speed v as the maximum of (DAiri + DOdouri) over all i =1,2, … 45 divided by 120 s, which resulted in v = 10.2 mm/s = 0.51 mm/time-step.

Crossing the air-odour interface (Extended Data Fig. 2c)

A simulated fly changed its direction of motion by 180 degrees when crossing from air to odour with probability P(turn away from odour) = 0.4, and when crossing from odour to air with probability P(turn away from air) = 0.2. The values of P(turn away from odour) and P(turn away from air) were estimated from 40 single fly (density = 0.06) experiments taken from Fig. 1d in which animals walked freely in the dark for 2 min with odour exposure on one half of the arena. We calculated the time flies spent in the odour after crossing from air, and vice versa. We classified a crossing from one half of the arena to another as a ‘turn around’ if the time spent in the new half was ≤ 3 s. Overall, we observed 76 crossings from air to odour out of which 31 were classified as a ‘turn around’, and 72 crossings from odour to air out of which 16 were classified as a ‘turn around’.

Encounter-induced bouts (Extended Data Fig. 2d)

In the simulation, at each time step t and for each walking fly we detected if the fly encountered an obstacle. To this end, we checked whether in time-step t+1 the fly’s body would overlap with a wall or with other flies’ bodies (assuming the fly would walk for 0.51 mm in the same direction it was heading). In such cases, the walking fly did not move in time-step t, but randomly changed its direction, and resumed the walk in time-step t+1.

Moreover, if the walking fly encountered an inactive fly, it caused the encountered fly to initiate a bout with probability P(Encounter Response) = 0.8 (from Fig. 3a). The length of this Encounter Response bout was equal to E(LAiru) and to E(LOdouru ) when initiated in air and in odour, respectively. The value u is a random integer between 1 and 45, and E is a mapping from the lengths of Isolated bouts to the lengths of Encounter Response bouts. Note that in contrast to the lengths of Isolated bouts (i.e., LAirs and LAirs) where the value s was fixed for each fly at the beginning of a simulation, here u was a random variable redrawn independently for each Encounter Response. Consequently, simulated flies did not vary in their propensity to move due to Encounters.

We did not explicitly encode directionality in the Encounter Response angle. However, we observed that since virtual flies cannot occupy the same space, stationary flies would move on average away from the location of touch, an implicitly directional response.

We estimated E using the data from the six fly experiments (density = 0.38) in which animals walked freely in green light illumination for 5 min without odour exposure. We observed 1314 Isolated bouts and 618 Encounter-induced bouts. For all 1932 bouts we calculated their lengths by integrating with temporal resolution of 20 Hz the differences between the consecutive positions of a given fly. Next, for both types of bouts, we calculated the 0th, 1st, 2nd, … 100th percentiles of their lengths, created a scatter plot and calculated a double linear mapping from the lengths of Isolated bouts to the lengths of Encounter Response bouts, which fit the data best (i.e. E(x) = 4.71x + 0.75 when × <20 and E(x) = 1.04x + 70.69 otherwise).

Experiments and sensitivity analyses (Fig. 2h and Extended Data Fig. 2e-h)

Overall, there were six experiments, each corresponding to a different sensitivity analysis. In each experiment there were eleven conditions, each corresponding to a different value of the investigated simulation’s parameter.

In the first experiment we varied the propensity to move due to Encounters by setting P(Encounter Response) between 0 and 1 with a step size of 0.1 (Fig. 2h). In the second experiment we varied the propensity to move in air (Extended Data Fig. 2e). To this end, we used L’Airs = aAirLAirs in place of LAirs value, and we set the damping coefficient aAir from 0 to 1 with a step size of 0.1. In the third experiment we varied the propensity to move in odour (Extended Data Fig. 2f). To this end, we used L’Odours = aOdourLOdours in place of LOdours value, and we set the damping coefficient aOdour from 0 to 1 with a step size of 0.1. In the fourth experiment we varied the probability to turn back when crossing the interface from odour to air by setting P(turn away from air) between 0 and 1 with a step size of 0.1 (Extended Data Fig. 2g). In the fifth experiment we varied the probability to turn back when crossing the interface from air to odour by setting P(turn away from odour) between 0 and 1 with a step size of 0.1 (Extended Data Fig. 2h).

Odour avoidance

For each pair of 6 treatments and 11 conditions, we ran simulations with 9 different group sizes, i.e., we used groups composed of n = 1, 3, 6, 9, 12, 15, 18, 21, and 24 simulated flies. Overall, there were 6 × 11 × 9 lines of experiments. Each experimental line was replicated 22,000 times using a Mersenne Twister pseudo-random numbers generator34 with a seed set to 1, 2, … 22,000, respectively. The initial positions, initial directions and the prototypical behaviours of simulated flies were identical between corresponding replicates across different experimental lines.

The odour avoidance of a simulated fly was calculated as the proportion of time-steps the fly spent in air during time-steps 1200 to 2400 corresponding to the second minute of the experiment. To compare simulations’ outcomes between treatments, conditions and group sizes, we averaged in each experimental line the odour avoidance of the first simulated fly across all replicates in which the fly was initially placed in odour (there were 10,902 such replicates out of all 22,000 replicates). Note that we chose to compare experimental lines based on the first simulated fly because it was the only fly used in all experimental lines. For example, the second and the third simulated flies were present in all experimental lines with groups composed of 3 or more flies, but were not present when the group was composed on just one fly.

For more details see the simulation’s implementation in Java available on-line at: http://documents.epfl.ch/users/r/ra/ramdya/www/ramdya/collective_sim.html.

Anatomical imaging

Brain / thoracic ganglia staining and imaging (Extended Data Fig. 5a)

Immunofluorescence on whole mount brains and thoracic ganglia was performed as described previously29. The primary antibodies were mouse monoclonal nc82 (1:10 dilution; Developmental Studies Hybridoma Bank), rabbit anti-GFP (1:200, Invitrogen A-6455). The secondary antibodies were Alexa Fluor 488- and Cy3- conjugated goat anti-rabbit or anti- mouse IgG respectively (Molecular Probes and Jackson ImmunoResearch) diluted 1:250. Microscopy was performed using an LSM 510 laser scanning confocal microscope (Zeiss).

Leg neuron imaging (Fig. 3f and Extended Data Figs. 4c-d and 5b)

Legs were removed from female adults 2 days post-eclosion and mounted in VectaShield under a coverslip. Cuticle was imaged with a 543 nm laser while CD4:tdGFP was imaged using a 488 nm laser. Microscopy was performed using an LSM 510 laser scanning confocal microscope (Zeiss). We reoriented leg images using a custom script to identify and crop the femur, tibia, and tarsal segments. Using these sub-images, we then quantified fluorescence values (excluding autofluorescence from the cuticle and surface debris) orthogonal to the long axis of each leg segment to produce a profile of leg mechanosensory structures. Chordotonal organs and mechanosensory sensilla neurons were distinguished by morphology: sensilla neurons had small somata with dendrites projecting to the base of leg sensilla (Extended Data Fig. 4d).

Extended Data

Extended Data Figure 1. Drosophila aggregate and move coherently at high densities.

Extended Data Figure 1

a, Images at the start (left) and end (right) of a ~3 h video recording with 100 flies (50 male and 50 female) moving within a large container containing a banana paste dish (left) and an agarose dish (right). b, Fly densities on the banana paste dish for each gender or mixture of genders averaged from the 30th through 60th minute of a 90 min experiment (n = 4 experiments for each genotype). c, The arena for simultaneous odour stimulation and behaviour tracking of Drosophila groups. d, Laminar flow and odour localisation validation using simulated fluid dynamics. High velocity vectors (yellow/red) are present at the odour entry and exit ports while lower uniform velocity vectors (green/blue) are located within the arena. e, A histogram showing the percent of time avoiding the odour for all flies in all experiments and for each density (colour-coded). Data is from Fig. 1d. f, The percent time avoiding the odour (mean and s.d.) for five different densities of the subset of flies starting in the odour zone that have at some point entered the air zone (n = 37, 38, 36, 35, and 38 experiments for 0.06, 0.38, 0.75, 1.13, and 1.5 flies/cm2 respectively). In contrast to Fig. 1d, the lack of density dependence suggests that flies that leave the odour zone tend not to return. g, The formula for a Coherent Motion Index that captures the degree of motion in the same direction (top) and an example of coherent motion away from the odour zone by 9 out of 11 flies total (bottom, cyan). h, The Coherent Motion Index for flies in the air (white boxes) or in the odour (grey boxes) zones during the ten seconds following odour onset. Data is from Fig. 1d. Shown are the results across all tested densities (0.06-1.5 flies/cm2) for flies that began the experiment in the odour (grey boxes) or the air zone (white boxes). N = 31-38 experiments. A single asterisk (*) denotes P <0.05 and a double asterisk (**) denotes P <0.01 for a Bonferroni Sign Test comparing medians to 0.

Extended Data Figure 2. Model parameter determination and the sensitivity of simulated collective behaviour to parameter variation.

Extended Data Figure 2

a-b, Individual freely walking flies were presented with 5% CO2 (‘odour’) or air across the entire arena for 1 min. Mean (solid line) and s.e.m. (translucent shading) walking velocity magnitude (a) and forward bout probability (b) before, during, and after an odour impulse (black, n = 45 flies) or an air impulse control (blue, n = 43 flies). Bouts began when velocity exceeded a high threshold of 1 mm/s. Bouts ended when velocity dipped below a low threshold of 0.5 mm/s. Short bouts or pauses (<2 frames or 100 ms) were removed by merging the fly’s current behavioural state with neighbouring measurements. Grey indicates the period of odour presentation. c, Probability for Drosophila to turn back when crossing the interface from odour to air and vice versa after a given period of time. Data is from Fig. 1d (density = 0.06). d, Scatter plots of Drosophila bout lengths during isolation versus Encounter Response bout lengths (red dots) and the double-linear function fitting the data (blue line). N = 16 experiments at density = 0.38 flies/cm2. The graph on the right is a zoom-in of that on the left (dashed box). e-h, Sensitivity of simulated collective behaviour to P(boutair) ranging from Probability = 0 (blue, never initiating spontaneous walking in air) to Probability = 1 (yellow, always initiating spontaneous walking in air) (e), P(boutodour) ranging from Probability = 0 (blue, never initiating spontaneous walking in odour) to Probability = 1 (yellow, always initiating spontaneous walking in odour) (f), P(turn around from air) ranging from Probability = 0 (never turning around from the air zone, blue) to Probability = 1 (always turning around from the air zone, yellow) (g), P(turn away from odour) ranging from Probability = 0 (never turning around from the odour zone, blue) to Probability = 1 (always turning around from the odour zone, yellow) (h). In all panels, each coloured line indicates the mean percent time avoiding the odour across densities, the black line indicates the simulation result for parameter values taken from real fly data, n = 10,902 for all data-points, and superimposed are the mean values for real flies (black circles).

Extended Data Figure 3. Encounter Response kinematics for interfly or metallic disc touches.

Extended Data Figure 3

a, Schematic of octant colour-coding. Each Encounter Response trajectory is assigned to the perimeter octant subsected by a line drawn to the nearest neighbouring fly during an Encounter. A head octant (red) is included here but these responses likely represent front leg touches. b, The mean (solid lines) and standard error (translucent areas) for Encounter Response trajectories (right) colour-coded by the relative location of the neighbouring fly as in panel a. The scale bar is 1 mm. c, Boxplot of mean forward (top), sideways (middle), and angular (bottom) velocities for the first 0.5 s of Encounter Responses (n = 112-244 Encounters with duration >0.5 s) in the olfactory avoidance experiment from Fig. 1d (density = 0.75 flies/cm2). Velocities are colour-coded by octant. d, Schematic of touch-point colour-coding for high-resolution inter-fly touch response experiments. Each walking trajectory is colour-coded by the appendage touched by a neighbouring fly. Data is from Fig. 3c. e, Boxplot of mean forward (top), sideways (middle), and angular (bottom) velocities for the first 0.16 s of touch responses. Velocities are colour-coded by touch-point. f, Schematic of touch-point colour-coding for mechanical touch response experiments. Each touch response trajectory is assigned to the appendage touched by a metallic disc. Data is from Fig. 3d. g, Boxplot of mean forward (top), sideways (middle), and angular (bottom) velocities for the first 0.5 s of touch responses. Velocities are colour-coded by touch-point.

Extended Data Figure 4. A behavioural screen for neurons mediating Encounter Responses and their leg expression patterns.

Extended Data Figure 4

a, Frequency of Encounter Responses for each Gal4 driver expressing UAS-Tnt. Driver lines are sorted by median frequency of Encounter Responses. A single asterisk (*) indicates P <0.05 for a Bonferroni-corrected Mann-Whitney U-test comparing a given line against a gustatory neuron expression line, R27B07-Gal4 (green). Density = 1.13 flies/cm2 and n = 10 experiments for each line. The selected line, R55B01-Gal4, drives expression in distal leg mechanosensory neurons (cyan). b, The fraction of flies in each experiment exhibiting walking velocities that meet the criteria for Encounter Responses (mean velocity magnitude greater than 5 mm/s for more than 0.5 s) at any time during the experiment. Lines are sorted and colour-coded as in panel a. c, The identity and leg expression patterns of Gal4 drivers tested in the screen. Black boxes denote the presence of a given cell class. A cyan outline indicates distal leg mechanosensory neuron expression. A red outline indicates thoracic ganglion expression in lines with significant reductions in Encounter Response frequency. The expression pattern is also shown for piezo-Gal4, which was used in subsequent experiments to refine identification of the leg mechanosensory neuron class required for Encounter Responses. d, Tarsal segments for w;UAS-tdCD4:GFP;R55B01-Gal4 (left) and w;UAS-tdCD4:GFP;piezo-Gal4 (right) flies. Each tarsal segment is labelled from proximal to distal (T1-T5). Endogenous GFP fluorescence (green) is superimposed upon a transmitted light image (magenta). The scale bars are 30 μm. Below is a high-resolution image of a mechanosensory sensilla neuron on the tarsus of a w;UAS-tdCD4:GFP;R55B01-Gal4 fly. Endogenous GFP fluorescence (green) is superimposed on cuticular autofluorescence (magenta). The axon, cell body, and dendrite of this neuron are labelled. The scale bar is 10 μm.

Extended Data Figure 5. Leg mechanosensory sensilla neurons but not chordotonal organs are necessary and sufficient for Encounter Responses.

Extended Data Figure 5

We identified five lines expressing Gal4 in different subsets of mechanosensory neurons (R55B01-Gal4, piezo-Gal4, piezo-Gal4:cha3-Gal80, R86D09-Gal4, and R46H11-Gal4) and one line expressing Gal4 in the fan-shaped body (R65C03-Gal4) as a control for fan-shaped body expression in R55B01-Gal4. a, Brain and thoracic ganglion expression for Gal4 lines driving UAS-CD4:tdGFP. Immunostaining is shown for the neuropil marker nc82 (magenta) and CD4:tdGFP (green). Sensory neuron projections from the wings (‘W’) and legs (R1-R3 and L1-L3) are labelled for R55B01-Gal4. Importantly, neurons expressing GFP in the brains of R55B01-Gal4 and piezo-Gal4, cha3-Gal80 flies are different, implying that they are not responsible for the production of Encounter Responses. The scale bars are 40 μm. b, Transmitted light images, inverted GFP fluorescence images (GFP indicated in black), and summed fluorescence of Gal4 driver legs expressing CD4:tdGFP. Autofluorescent cuticle and pretarsus debris are indicated in black. GFP expression is shown in green. When present, the femoral chordotonal organ (‘fChO’), tibial chordotonal organ (‘tChO’) and mechanosensory sensilla neurons (‘MS’) are labelled. The scale bar is 100 μm. c, The frequency of Encounter Responses for a parental control (‘Gal4’), Gal4 line neurons expressing an inactive tetanus toxin control (‘Gal4 & ‘Inactive Tnt’), or Gal4 line neurons expressing tetanus toxin (‘Gal4’ & ‘Tnt’). N = 10-15 experiments for each condition. d, Blue laser pulse stimulation responses of Gal4 line flies expressing UAS-ChR2 in the absence (left) or presence (right) of the essential cofactor all trans-Retinal (n = 6-12 flies for each condition). Each box indicates the response for a single fly (‘walk’, ‘groom’, ‘leg shift’, ‘none’, or ‘jump’).

Extended Data Figure 6. Schematic of collective odour avoidance in Drosophila.

Extended Data Figure 6

a, A group of flies experiences odour flow on the right half of the arena. The direction of odour or air flow is indicated by red and black arrows, respectively. Odour increases the probability of spontaneous walking (black fly). b, Walking increases the probability of encountering a stationary fly, producing an Encounter Response. c, Walking flies cause additional Encounters and a cascade of Encounter Responses in the odour zone. d, Walking flies pass into the non-odour zone through interactions with the arena walls and possibly by sensing the direction of odour flow. e, The influx of walking flies to the air zone results in additional Encounter Responses. f, The propensity to turn around at the air-odour interface (perhaps compounded by the effects of unknown aggregation pheromones) causes flies to remain in the air zone, resulting in higher odour avoidance.

Extended Data Figure 7. Collective negative gravitaxis in Drosophila.

Extended Data Figure 7

a, A schematic of the negative gravitaxis experiment. Flies are placed at the lowest point of a behavioural arena tilted at 22.5°. The flies’ positions are normalised to the long-axis of the arena ranging from 0 (arena bottom, lowest elevation) to 100 (arena top, highest elevation). b, Image of flies (black triangles) and their trajectories during 1 s (black dotted lines) in the negative gravitaxis experiment. Shown are representative images of an experiment with one fly (density = 0.06 flies/cm2) and an experiment with 18 flies (density = 1.13 flies/cm2). Negative Gravitaxis Index value positions of 0 (lowest elevation in the arena) and 100 (highest elevation in the arena) are shown (white-dashed lines). c, To obtain a Negative Gravitaxis Index for a given fly, its position was averaged during the second minute of the experiment. Shown are the mean and s.d. of Negative Gravitaxis Indices for wild-type animals at densities of either 0.06 or 1.13 flies/cm2 (n = 28 and 30 experiments respectively). d, Images of two flies (left, black triangles in black dashed box) undergoing an Encounter (middle, red dashed box) that results in an Encounter Response (right, blue dashed box) during a negative gravitaxis experiment.

Extended Data Table 1. P values for data in main figures.

The uncorrected P values for each main figure panel and its associated comparison are indicated. The number of comparisons used for post-hoc Bonferroni correction for multiple comparisons are also shown.

Figure Comparison P value
(uncorrected)
Number of
Comparisons
Figure Comparison P value
(uncorrected)
Number of
Comparisons


1d 6 vs. 1 fly 3.37 × 10−6 4 3h Tnt vs. Gal4>Tnt 1.28 × 10−4 3
12 vs. 1 fly 4.20 × 10−13 Gal4 vs. Gal4>Tnt 2.74 × 10−4
18 vs. 1 fly 4.96 × 10−21 Inactive Tnt vs. Gal4>Tnt 1.10 × 10−3
24 vs. 1 fly 6.77 × 10 18
4a Inactive Tnt, 18 vs. 1 fly 2.99 × 10−6 1
2d 12 vs. 6 flies 1.67 × 10−11 1 Tnt, 18 vs. 1 fly 5.54 × 10−1 1
18 vs. 12 flies 3.91 × 10−11 1
24 vs. 18 flies 4.50 × 10−11 1 4b Inactive Tnt, 18 vs. 1 fly 3.90 × 10−8 1
Tnt, 18 vs. 1 fly 3.75 × 10−2 1
2e 6 flies, Enc. vs. Iso. 3.18 × 10−4 1
12 flies, Enc vs. Iso. 3.78 × 10−6 1 4c nompC+/−, 18 vs. 1 fly 1.12 × 10−5 1
18 flies, Enc vs. Iso. 1.30 × 10−3 1 nompC−/−, 18 vs. 1 fly 1.62 × 10−1 1
2g 6 vs. 1 fly 3.69 × 10−8 4 4d 3 vs. 1 fly 3.98 × 10−2 3
12 vs. 1 fly 1.87 × 10−17 6 vs. 1 fly 2.98 × 10−9
18 vs. 1 fly 4.99 × 10−19 12 vs. 1 fly 3.12 × 10−25
24 vs. 1 fly 2.27 × 10−16
4e 3 vs. 1 fly 8.87 × 10−18 3
3a Light vs. Dark 1.73 × 10−2 5 6 vs. 1 fly 1.76 × 10−18
Anosmic vs. Dark 4.27 × 10−1 12 vs. 1 fly 3.60 × 10−38
nanchung vs. Dark 1.73 × 10−2
piezo vs. Dark 1.13 × 10−2
nompC vs. Dark 1.00 × 10−3
3f oe+ vs. oe 5.55 × 10−1 1

Extended Data Table 2. P values for data in Extended Data figures.

The uncorrected P values for each Extended Data figure panel and its associated comparison are shown. The number of comparisons used for post-hoc Bonferroni correction for multiple comparisons are also shown.

Figure Comparison P value
(uncorrected)
Number of
Comparisons
Figure Comparison P value
(uncorrected)
Number of
Comparisons


1h Air vs. Odour, 6 flies 8.90 × 10−1 1 5c R55B01-Gal4 2
Air vs. Odour, 12 flies 2.90 × 10−3 1 Gal4 vs.Gal4>Tnt 1.10 × 10−3
Air vs. Odour, 18 flies 2.16 × 10−4 1 Gal4>lnactive vs. Gal4>Tnt 1.70 × 10−3
Air vs. Odour, 24 flies 1.40 × 10−3 1
piezo-Gal4 2
4a R65A11 vs. R27B07 5.01 × 10−4 19 Gal4 vs.Gal4>Tnt 1.24 × 10−4
R14F12 vs. R27B07 2.18 × 10−4 Gal4>lnactive vs. Gal4>Tnt 1.50 × 10−4
R20C06 vs. R27B07 8.15 × 10−5
R55B01 vs. R27B07 2.50 × 10−3 piezo-Gal4, cha3-Gal80 2
R13E04 vs. R27B07 5.10 × 10−3 Gal4 vs.Gal4>Tnt 2.74 × 10−4
R93A02 vs. R27B07 5.69 × 10−2 Gal4>lnactive vs. Gal4>Tnt 1.10 × 10−3
R39D08 vs. R27B07 2.50 × 10−3 R86D09-Gal4 2
R95A11 vs. R27B07 1.26 × 10−2 Gal4 vs.Gal4>Tnt 2.07 × 10−1
R41A08 vs. R27B07 7.94 × 10−2 Gal4>lnactive vs. Gal4>Tnt 6.94 × 10−1
R46H11 vs. R27B07 1.78 × 10−2 R46H11-Gal4 2
R59C08 vs. R27B07 1.81 × 10−2 Gal4 vs.Gal4>Tnt 6.89 × 10−1
R46D02 vs. R27B07 4.02 × 10−2 Gal4>lnactive vs. Gal4>Tnt 3.51 × 10−2
R86D09 vs. R27B07 3.25 × 10−1
R22A04 vs. R27B07 2.37 × 10−1 R65C03-Gal4 2
R39A11 vt R27B07 4.18 × 10−2 Gal4 vs.Gal4>Tnt 7.94 × 10−2
R27E02 vs. R27B07 2.37 × 10−1 Gal4>lnactive vs. Gal4>Tnt 2.62 × 10−2
R93D11 vs. R27B07 2.18 × 10−1
R86G01 vs. R27B07 3.72 × 10−1 6c 18 vs. 1 fly 3.63 × 10−11 1
R74B10 vs. R27B07 8.44 × 10−1

Supplementary Material

Supplementary Movie 1
Download video file (2.8MB, mov)
Supplementary Movie 2
Download video file (2.6MB, mov)
Supplementary Movie 3
Download video file (1.9MB, mov)
Supplementary Movie 4
Download video file (296.9KB, mov)
Supplementary Movie 5
Download video file (921.6KB, mov)
Supplementary Movie 6
Download video file (501KB, mov)
Supplementary Video Legends

Acknowledgments

We thank Lucie Sprecher, Joe Weber, Aurore Gaille, Annick Canapini, and Içvara Barbier for help in aggregation density measurements, Ana Silbering for generating anosmic Drosophila lines, Frédéric Schütz for advice on statistics, Jane Yi for image analysis software, Joel Levine, Ardem Patapoutian, Matthias Landgraf, Martin Göpfert and the Bloomington Drosophila Stock Center for Drosophila strains, Thomas Oertner for plasmids, and the Developmental Studies Hybridoma Bank for antibodies. We thank Darron Cullen, Laurent Keller, Joel Levine, Matthieu Louis, Suliana Manley, Sophie Martin, Jonathan Schneider and members of the Benton and Floreano laboratories for discussions. PR was supported by a Human Frontier Science Program Long-term Fellowship. PL was supported by the Swiss National Science Foundation (200021_127143). DF acknowledges support from the Swiss National Science Foundation (CR32I3_141063/1) and the FP7-FET European Project INSIGHT (308943). RB acknowledges support from European Research Council Starting Independent Researcher and Consolidator Grants (205202 and 615094).

Footnotes

Competing financial interests: The authors declare no competing financial interests.

Reprints and permissions information is available at www.nature.com/reprints.

References

  • 1.Berdahl A, Torney CJ, Ioannou CC, Faria JJ, Couzin ID. Emergent Sensing of Complex Environments by Mobile Animal Groups. Science. 2013;339:574–576. doi: 10.1126/science.1225883. [DOI] [PubMed] [Google Scholar]
  • 2.Ward AJ, Herbert-Read JE, Sumpter DJT, Krause J. Fast and accurate decisions through collective vigilance in fish shoals. Proc Natl Acad Sci USA. 2011;108:2312–2315. doi: 10.1073/pnas.1007102108. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 3.Couzin ID. Collective cognition in animal groups. Trends Cogn Sci. 2009;13:36–43. doi: 10.1016/j.tics.2008.10.002. [DOI] [PubMed] [Google Scholar]
  • 4.Sumpter DJT, Buhl J, Biro D, Couzin ID. Information transfer in moving animal groups. Theory Biosci. 2008;127:177–186. doi: 10.1007/s12064-008-0040-1. [DOI] [PubMed] [Google Scholar]
  • 5.Walker R, Willingham A, Zuker C. A Drosophila mechanosensory transduction channel. Science. 2000;287:2229. doi: 10.1126/science.287.5461.2229. [DOI] [PubMed] [Google Scholar]
  • 6.Yan Z, et al. Drosophila NOMPC is a mechanotransduction channel subunit for gentle-touch sensation. Nature. 2012;493:221–225. doi: 10.1038/nature11685. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 7.Gullan PJ, Cranston PS. The Insects. John Wiley & Sons; 2010. [Google Scholar]
  • 8.Schneider J, Atallah J, Levine JD. Advances in Genetics. Vol. 77. Elsevier; 2012. pp. 59–78. [DOI] [PubMed] [Google Scholar]
  • 9.Levine JD. Resetting the Circadian Clock by Social Experience in Drosophila melanogaster. Science. 2002;298:2010–2012. doi: 10.1126/science.1076008. [DOI] [PubMed] [Google Scholar]
  • 10.Wang L, Anderson DJ. Identification of an aggression-promoting pheromone and its receptor neurons in Drosophila. Nature. 2009;463:227–231. doi: 10.1038/nature08678. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 11.Suh GSB, et al. A single population of olfactory sensory neurons mediates an innate avoidance behaviour in Drosophila. Nature. 2004;431:854–859. doi: 10.1038/nature02980. [DOI] [PubMed] [Google Scholar]
  • 12.Ai M, et al. Acid sensing by the Drosophila olfactory system. Nature. 2010;468:691–695. doi: 10.1038/nature09537. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 13.Billeter J-C, Levine JD. Who is he and what is he to you? Recognition in Drosophila melanogaster. Curr Opin Neurobiol. 2013;23:17–23. doi: 10.1016/j.conb.2012.08.009. [DOI] [PubMed] [Google Scholar]
  • 14.Schneider J, Dickinson MH, Levine JD. Social structures depend on innate determinants and chemosensory processing in Drosophila. Proc Natl Acad Sci USA. 2012;109:17174–17179. doi: 10.1073/pnas.1121252109. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 15.Schaefer PL, Kondagunta GV, Ritzmann RE. Motion analysis of escape movements evoked by tactile stimulation in the cockroach Periplaneta americana. The Journal of Experimental Biology. 1994;190:287–294. doi: 10.1242/jeb.190.1.287. [DOI] [PubMed] [Google Scholar]
  • 16.Stocker RF. Taste perception: Drosophila - a model of good taste. Curr Biol. 2004;14:R560–1. doi: 10.1016/j.cub.2004.07.011. [DOI] [PubMed] [Google Scholar]
  • 17.Billeter J-C, Atallah J, Krupp JJ, Millar JG, Levine JD. Specialized cells tag sexual and species identity in Drosophila melanogaster. Nature. 2009;461:987–991. doi: 10.1038/nature08495. [DOI] [PubMed] [Google Scholar]
  • 18.Holtje M. Rapid mechano-sensory pathways code leg impact and elicit very rapid reflexes in insects. Journal of Experimental Biology. 2003;206:2715–2724. doi: 10.1242/jeb.00492. [DOI] [PubMed] [Google Scholar]
  • 19.Kamikouchi A, Wiek R, Effertz T, Göpfert MC, Fiala A. Transcuticular optical imaging of stimulus-evoked neural activities in the Drosophila peripheral nervous system. Nature Protocols. 2010;5:1229–1235. doi: 10.1038/nprot.2010.85. [DOI] [PubMed] [Google Scholar]
  • 20.Hirsch J, Erlenmeyer-Kimling L. Sign of Taxis as a Property of the Genotype. Science. 1961;134:835–836. doi: 10.1126/science.134.3482.835. [DOI] [PubMed] [Google Scholar]
  • 21.Manoli DS, Fan P, Fraser EJ, Shah NM. Neural control of sexually dimorphic behaviors. Curr Opin Neurobiol. 2013;23:330–338. doi: 10.1016/j.conb.2013.04.005. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 22.Ramdya P, Schaffter T, Floreano D, Benton R. Fluorescence Behavioral Imaging (FBI) Tracks Identity in Heterogeneous Groups of Drosophila. PLoS ONE. 2012;7:e48381. doi: 10.1371/journal.pone.0048381. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 23.Kim J, et al. A TRPV family ion channel required for hearing in Drosophila. Nature. 2003;424:81–84. doi: 10.1038/nature01733. [DOI] [PubMed] [Google Scholar]
  • 24.Kim SE, Coste B, Chadha A, Cook B, Patapoutian A. The role of Drosophila Piezo in mechanical nociception. Nature. 2012;483:209–212. doi: 10.1038/nature10801. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 25.Brand A, Perrimon N. Targeted gene expression as a means of altering cell fates and generating dominant phenotypes. Development. 1993;118:401–415. doi: 10.1242/dev.118.2.401. [DOI] [PubMed] [Google Scholar]
  • 26.Jenett A, et al. A GAL4-Driver Line Resource for Drosophila Neurobiology. Cell Reports. 2012;2:991–1001. doi: 10.1016/j.celrep.2012.09.011. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 27.Ling F, Dahanukar A, Weiss LA, Kwon JY, Carlson JR. The Molecular and Cellular Basis of Taste Coding in the Legs of Drosophila. The Journal of Neuroscience. 2014:7148–7164. doi: 10.1523/JNEUROSCI.0649-14.2014. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 28.Berndt A, et al. High-efficiency channelrhodopsins for fast neuronal stimulation at low light levels. Proceedings of the National Academy of Sciences of the United States of America. 2011;108:7595. doi: 10.1073/pnas.1017210108. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 29.Silbering AF, et al. Complementary function and integrated wiring of the evolutionarily distinct Drosophila olfactory subsystems. J Neurosci. 2011;31:13357–13375. doi: 10.1523/JNEUROSCI.2360-11.2011. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 30.Bischof J, Maeda RK, Hediger M, Karch F, Basler K. An optimized transgenesis system for Drosophila using germ-line-specific C31 integrases. Proc Natl Acad Sci USA. 2007;104:3312–3317. doi: 10.1073/pnas.0611511104. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 31.Han C, Jan LY, Jan YN. Enhancer-driven membrane markers for analysis of nonautonomous mechanisms reveal neuron–glia interactions in Drosophila. Proc Natl Acad Sci USA. 2011;108:9673–9678. doi: 10.1073/pnas.1106386108. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 32.Billeter J-C, Atallah J, Krupp JJ, Millar JG, Levine JD. Specialized cells tag sexual and species identity in Drosophila melanogaster. Nature. 2009;461:987–991. doi: 10.1038/nature08495. [DOI] [PubMed] [Google Scholar]
  • 33.Branson K, Robie AA, Bender J, Perona P, Dickinson MH. High-throughput ethomics in large groups of Drosophila. Nature Methods. 2009;6:451–457. doi: 10.1038/nmeth.1328. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 34.Luke S. The ECJ Owner’s Manual: A user manual for the ECJ Evolutionary Computation Library. San Francisco, California: 2010. [Google Scholar]

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Supplementary Materials

Supplementary Movie 1
Download video file (2.8MB, mov)
Supplementary Movie 2
Download video file (2.6MB, mov)
Supplementary Movie 3
Download video file (1.9MB, mov)
Supplementary Movie 4
Download video file (296.9KB, mov)
Supplementary Movie 5
Download video file (921.6KB, mov)
Supplementary Movie 6
Download video file (501KB, mov)
Supplementary Video Legends

RESOURCES