Flexible neural control of transition points within the egg-laying behavioral sequence in Drosophila

Innate behaviors are frequently comprised of ordered sequences of component actions that progress to satisfy essential drives. Progression is governed by specialized sensory cues that induce transitions between components within the appropriate context. Here we have characterized the structure of the egg-laying behavioral sequence in Drosophila and found significant variability in the transitions between component actions that affords the organism an adaptive flexibility. We identified distinct classes of interoceptive and exteroceptive sensory neurons that control the timing and direction of transitions between the terminal components of the sequence. We also identified a pair of motor neurons that enact the final transition to egg expulsion. These results provide a logic for the organization of innate behavior in which sensory information processed at critical junctures allows for flexible adjustments in component actions to satisfy drives across varied internal and external environments.

. Single females were filmed in parallel within a laser-cut acrylic assembly containing four chambers (10 mm x 18 mm x 16 mm). Substrate comprised of 1% agarose and 5% acetic acid (vol/vol) was poured into each chamber and allowed to set for 30 minutes before females were introduced by gentle aspiration. The assembly was placed atop a red led panel light (Advance Illumination) for illumination, and adjacent to a mirror positioned at a 45°angle, allowing for the flies to be simultaneously filmed from the top and side perspective. Video recording was performed using a USB3 camera (FL3-U3-13Y3M-C, Point Grey) attached to a ×6 macro zoom lens (Edmund Optics #68-667) at 2 Hz (262 x 445 x 390 pixels per chamber) via FlyCapture software (Point Grey). b, Average speed of flies over a 180-s window surrounding completed egg expulsion (egg out). t = 0, egg out. The speed surrounding egg expulsion was determined by comparing the distance between the fly's 3-dimensional center-of-mass across successive frames (500 ms).

Supplementary Fig. 2 | High-resolution egg-laying behavioral assay.
Representative video snapshots of an individual chamber from egg-laying behavioral assay at three time points. Scale bar, 1 mm.

Supplementary Fig. 3 | Manual and automated analysis of egg-laying behavior.
i, Video snapshots displaying relevant key-points used to determine features for unsupervised behavioral classification analysis (in Extended Data Fig. 2; Methods). Cyan circle, proboscis tip; red circle, dorsal arch of the stripe on abdominal segment A5; pink circle, region of interest used to determine ovipositor pixel intensity in vii; white circle, T3 (metathoracic) leg joint; green lines, used to determine abdominal bend angle in v, with the upper green line connecting the ocellus to the posterior tip of the thoracic scutellum and the lower green line connecting the ventral-most edge of the stripes on abdominal segments A2 and A6. Red arrows and vertical dashed lines, corresponding time point for each video snapshot in the plots below. ii, Manual annotations. iii, Velocity (black, 'vel'; 1/20× pixels per s) and proboscis movement (blue, 'pe'; pixels per s). iv, Movement of leg joint from each leg (magenta, 'T1'; brown, 'T2'; gray, 'T3'; pixels per s). v, Z-score normalized abdominal bend angle (>0 is downward bending, 'ba'). vi, Egg emergence (DeepLabCut prediction confidence, 'Pegg'). vii, Pixel intensity in a circular region of interest surrounding the ovipositor (1/1,000× intensity; pink circle in i). viii, Magnitude of continuous Morlet wavelet transform of ovipositor intensity trace in vii. The ovipositor intensity trace displays oscillations that slow in frequency as the egg incrementally emerges and is completely expelled. ix, Log magnitude of continuous Morlet wavelet transform of the position of the stripe on abdominal segment A5 (red circle in i; same data are displayed in Supplementary Video 2).  Table 7). b, Average normalized depth of penetration of eggs released on a 1% agarose substrate (n = 39, 18, 15 flies per group). c, Fraction of virgin females that copulated within one hour. NS, p>0.05, two-sided Fisher's exact test (n = 40, 56, 32 flies per group). For the assessment of virgin receptivity and egg-laying after a single mating, experiments were performed similarly as described before (Feng et al., Neuron 83, 135-148 (2014)). Receptivity was scored over a one-hour period. For egg-laying, females were transferred to small chambers (9.5 mm x 8 mm x 10 mm) containing cornmeal-agar-molasses food after the one-hour mating period and again 24 h later. Eggs were counted at 24-h and 48-h post-mating, and combined. d, Number of eggs released in 48 h following a single mating event (n = 31, 31, 28 flies per group). Number of eggs released on a 1% agarose substrate in 2 h with and without constant green-light photo-inhibition (530 nm, 6 μw/mm 2 intensity; n = 18, 14,12,11,15,11,15,14,15, 11 flies per group). **p<0.01, NS, p>.05, two-sided Wilcoxon rank sum test (Supplementary Table 7). burrow Scored during "bend" whereupon the ovipositor is pressed against the substrate or chamber wall, and rhythmic contractions ensue. Depending on the viewing angle and background, these rhythmic contractions were observed to include rhythmic intensity changes of the ovipositor, rhythmic opening and closing of the vaginal plates, rhythmic progression of the egg out of the ovipositor, and/or rhythmic swaying anteriorly and posteriorly of all appendages.
Burrow offset was scored as the termination of rhythmic contractions and lifting or sliding of the ovipositor, or upon completed egg expulsion ("egg out", see below).
"egg out" If the egg was completely expelled during "burrow" (see above), scored as the first frame observed where the egg occupied its final resting place. If the egg was spontaneously expelled without "burrow" (a "spontaneously dropped" egg), scored as the first frame where the egg is observed to be fully emerged from the ovipositor.
detach Scored during "bend", immediately after "egg out", for as long as the fly maintained a bent abdominal posture, following the criteria established for "bend" offset (see above).
groom Scored during all varieties of inter-appendage contact involving the legs. Onset was the time of leg lifting off the substrate or chamber wall, and offset was the time at which all legs were in contact with the substrate or chamber wall.

Supplementary Methods
Unsupervised behavioral classification analysis. DeepLabCut (Mathis et al., Nat Neurosci 21, 1281-1289(2018) was used to track the following 18 key-points: two points on the head (the ocellus and proboscis tip), the posterior tip of the scutellum on the thorax, both wing tips, the joint between the femur and tibia on all six legs, the dorsal arch of the stripe on abdominal segment A5, the ventral-most edge of the stripes on abdominal segments A2 and A6 (per side; 4 points total), the tip of the ovipositor, and the egg, when visibly emerging from the ovipositor.
Given the challenges of resolving a consistent pose estimate from a fixed viewing perspective within a 3-dimensional environment (Günel et al., eLife 8, e48571 (2019)), this analysis was restricted to subsets of the data where the fly displayed an approximately lateral perspective relative to the camera for greater than 4 s (the first and last 2 s were discarded) (Supplementary Fig. 3 and Supplementary Video 2). This was determined as those frames meeting the following criteria: the dorsal and ventral abdominal stripes, as well as the scutellum tip, were all visible, and the distance between the scutellum tip and the wing tips was greater than 70% of the maximum. By this criterion, 7.5 million suitable frames (~105 hours) were identified from 184 wild-type flies. Note that synchronous recordings from multiple cameras would be required to resolve a consistent, orientation-invariant pose-estimation model to implement the unsupervised behavioral classification analysis pipeline used here over contiguous video segments within 3-dimensional chambers.
Abdominal bend angle ('ba') was normalized to correct for angular changes that result from small deviations in perspective. Different perspectives were identified and grouped according to the angle formed between a line connecting the ocellus and scutellum and the chamber surface. Within each group, the mean and standard deviation of bend angles was used to determine the z-score.
Diverse frames were selected from each fly (Berman et al., J. R. Soc. Interface. 11, 20140672 (2014)), amounting to a total of 192,068 frames, which were then embedded into a two-dimensional representation using t-SNE (distance metric, standardized Euclidean distance; perplexity, 750). A subset of frames where the fly was not moving and exhibited a neutral posture were designated as "stationary" frames and were precluded from this analysis. This mapping was then convolved with a Gaussian (sigma = 1.1) and a watershed transform was performed to delineate 53 regions within the embedded space (Extended Data   Fig. 2b). "Stationary" frames were assigned to cluster #0 in Extended Data Fig. 2e,f.
For the projection of egg-laying behavioral sequences onto the t-SNE embedding (Extended Data Fig.   2c-f), an automated analysis was used to identify 731 egg-laying events from 74 flies (a cohort of 52 flies were filmed in chambers that were 50% longer along the lateral-viewing axis of the substrate). This analysis identified peaks in the DLC egg-emergence prediction, derived a spatial mask from the deposited egg surrounding a given peak, and finally determined the egg-laying event as the time at which this mask was >95% occupied by the egg. The cluster identity of individual frames from the ± 60 s of these egg-laying events was determined as the mode cluster identity of the 100 k-nearest neighboring frames in the original t-SNE embedding. To identify clusters with enriched expression surrounding egg laying, the total fraction of frames assigned a given cluster within this 120 second window was compared to its fraction within the original t-SNE embedding (Extended Data Fig. 2f, top). For plotting the time course of expression (Extended Data Fig. 2c), the fraction of frames assigned to a given cluster relative to the total number of analyzed frames was calculated independently at each time point. The statistical significance of mappings between human labels and t-SNE clusters, and vice versa, was determined by comparison to a "chance" mapping distribution obtained by randomly shuffling the annotation data relative to the cluster identities for 10,000 permutations (Extended Data Fig. 2e,f).
Correspondence between the manual labels and unsupervised classifier was high, further validating the behavioral composition and sequential organization of egg-laying behavior described in Figure 1. 14 of the 53 t-SNE behavioral clusters were expressed significantly above chance and formed a temporal sequence in the 40 s surrounding egg deposition (Extended Data Fig. 2a- (2021)). Though reliable, mapping was not one-to-one: individual human labels typically mapped onto a small subset of t-SNE clusters and vice versa. This is an indication that finer scale behavioral sub-components were identified in the unsupervised behavioral classification analysis, and is a function of the Gaussian filter used to smooth the original t-SNE embedding. For example, t-SNE clusters associated with oscillating ovipositor pixel intensity ("w1ovi", "w2ovi") or egg emergence ("Pegg") were both reliably labeled as "burrow" (cluster #20 and #29, respectively), whereas clusters associated with various combinations of hind-leg movement ('T3') and high angular velocity of the abdomen ('velba') were reliably labeled as "groom" (clusters #4, #5, #6, #15, #18; Extended Data Fig.   2d). Note that "PE" reliably maps to t-SNE cluster #17 in Extended Data Fig. 2f, but that cluster #17 maps more reliably to "background" in Extended Data Fig. 2e. This apparent discrepancy is an artifact of the manual labeling criterion used for "PE" where only a single frame was labeled at the onset of a given proboscis extension event.