Abstract
Natural goal-directed behaviors often involve complex sequences of many stimulus-triggered components. Understanding how brain circuits organize such behaviors requires mapping the interactions between an animal, its environment, and its nervous system. Here, we use continuous brain-wide neuronal imaging to study the full performance of mating by the C. elegans male. We show that as each mating unfolds in its own sequence of component behaviors, the brain operates similarly between instances of each component, but distinctly between different components. When the full sensory and behavioral context is taken into account, unique roles emerge for each neuron. Functional correlations between neurons are not fixed, but change with behavioral dynamics. From the contribution of individual neurons to circuits, our study shows how diverse brain-wide dynamics emerge from the integration of sensory perception and motor actions within their natural context.
Introduction
Natural behaviors involve strong interactions between animals and their surroundings. When an animal is isolated from its natural context, brain dynamics do not display their full range of mechanisms (1, 2). For example, recent brain-wide imaging studies in immobilized C. elegans and other animals have un-covered strong activity correlations among large populations of neurons (3, 4). However, circuit activity becomes more complex when animals are allowed to move and display a larger variety of behaviors. Studies in freely-moving mice have uncovered changes in the functional correlations between brain areas when the animal is engaged in different behaviors (5). Freely-moving C. elegans hermaphrodites exhibit less correlated brain activity than immobilized worms (6). In the mouse, increasing task complexity and the richness of the sensory environment have been shown to progressively decorrelate neurons and brain regions (7). Task-dependent functional reorganization of neuronal circuits has been observed in several invertebrate, vertebrate, and artificial systems (1, 8–11). Here, we use the mating behavior of the male C. elegans to ask how the full richness of a natural behavior is embedded in brain structure and function.
Mating behavior is highly interactive and involves variable sequences of recurrent behavioral components or motifs that carry the animal towards its goal. The male C. elegans uses a dedicated circuit in his tail – a posterior brain with over 100 sensory neurons, interneurons, and motoneurons – to drive the many motifs of mating (12–14) (Fig. 1A, B). He searches for a hermaphrodite by detecting pheromones. When he contacts a hermaphrodite, he presses the ventral sensilla of his tail against her body. He then starts scanning along her body to locate the vulva. During scanning, he frequently changes his movement direction, executes sharp turns when moving around the anterior and posterior ends of her body, and slows at the vulva. Upon vulva location, he will attempt to insert his mating organs (spicules). Successful spicule insertion triggers sperm transfer. Copulation is followed by a prolonged rest (15–18). All of these behavioral motifs can only occur in the context of freely-moving males interacting with a hermaphrodite.
We recorded the activity of nearly every neuron in the posterior brain of freely-moving male C. elegans from beginning to end of mating. Brain-wide imaging revealed functional relationships among all neurons for every step of mating behavior. When brain-wide dynamics are considered in the context of an entire natural behavior, nearly every neuron exhibits a unique activity pattern. Each of the many different behavioral motifs during mating has a specific and consistent circuit representation. As the behavioral sequence unfolds, functional correlations between neurons in the brain are not fixed, but depend on context and change with the dynamic interactions between the animal, the nervous system, and the environment. For one wiring diagram to support many correlation patterns, the relationship between the connectome and activity cannot be one-to-one. By combining functional imaging, behavioral analysis, and single-neuron manipulations, we identify circuit-level mechanisms for several computations that are ethnologically relevant for mating. We show how brain-wide dynamics are shaped by the flow of sensory inputs and motor actions across the full performance of a natural behavior.
Results
Brain-wide imaging throughout mating
To record the activity of the male’s entire posterior brain, we used a spinning-disc confocal microscope customized for multi-color, multi-neuronal imaging (19). We used strains with pan-neuronal expression of both nuclear-localized calcium indicator (GCaMP6s) and red fluorescent protein (mNeptune) imaged at 10 volumes per second with single-cell resolution (Fig. 1C, Movie S1). Neuronal activity in each male was continuously imaged through every step of mating: initial search, contact, scanning, vulva detection, copulation, and rest.
For comprehensive analysis, we selected datasets of continuous 5-10 min recordings from seven animals that showed the broadest range of behavioral dynamics (Table S1). Most neurons in the mating circuit were recorded in multiple datasets. Each neuron was identified by its relative position, morphology, and expression of cell-specific fluorescent markers (Table S2). The seven selected datasets contained the activities of 76 identifiable neurons spanning ∼75% of the circuit (Fig. S1A). Nearly all pairs of left-right symmetric neurons were highly correlated (Fig. S2). Grouping left-right pairs as one neuron type, we recorded 57 neuron types (Fig. S1B). We also acquired additional datasets focused on specific neuron types or behavioral motifs.
We extracted behavioral features concurrent with circuit activity from video analysis of the movements and interactions of the male and hermaphrodite. We quantified a set of continuous features – velocity, sliding relative to the hermaphrodite, tail curvature, spicule position, and position of the tail along the hermaphrodite body – as well as discrete behavioral events and motifs (Fig. 1D–F).
The collective activity of individual neurons predicts behavior across animals
Does brain-wide activity map to behavioral dynamics in the same way from animal to animal? If so, it should be possible to build a computational model that predicts one animal’s behavior based on the brain-wide activity of other animals. Because we could identify the same neurons in every dataset, we were able to build models that account for the individual contributions of each neuron, and test whether neuron-level models built using one group of animals could predict the behavior of other animals.
We built brain-to-behavior models for mating using sparse linear regression with short-term memory applied to the concatenated activity of 46 neurons that we recorded in nearly every experiment and a set of continuous behavioral features (Fig. 2A, B). In each iteration, we used six of our seven comprehensive datasets for concatenation and model training. We evaluated the resulting model in each iteration by its accuracy in predicting behavioral dynamics from brain-wide activity for the dataset that was left out (Fig. 2A–C). We assessed prediction accuracy across seven iterations. Sparse linear regression models accurately predicted most behavioral features, including tail velocity (mean R2 = 0.37), curvature (mean R2 = 0.32), sliding velocity (mean R2 = 0.27), distance of the tail to the hermaphrodite head or tail (mean R2 = 0.29) and the vulva (mean R2 = 0.31), and position of the spicules (mean R2 = 0.16) (Fig. 2D). Thus, these behavioral features are represented in the collective activity of individual neurons in a consistent manner across animals.
How distributed is the representation of behavioral features across neurons? Sparse linear regression ranks neurons by their relative contribution to each behavioral feature (Fig. 2D). In all cases, we found that excluding one top-ranking neuron from the datasets before training had only a small effect on prediction accuracy (Fig. 2D). Moreover, models trained using the activities of single top-ranking neurons performed worse than models trained using all neurons for most behavioral features (Fig. 2D). Thus, most behavioral dynamics during mating have distributed representations in the brain-wide activity.
The brain partitions into functional communities for each behavioral motif
To better understand how neurons interact with one another during behavior (Fig. 3A), we computed neuron-neuron and neuron-behavior correlations for all pairs of neuronal activities and continuous behavioral features. We assembled a consensus correlation matrix that incorporated data from all experiments, and grouped neurons with similar activities using hierarchical clustering (Fig. 3B). Certain clusters were associated with distinct behavioral motifs such as scanning or vulva detection. These clusters indicated a group of principal neurons for each motif. We found that many neurons were strongly correlated with other neurons in more than one cluster, indicating that single neurons often participate in multiple behavioral motifs.
To identify circuits for different motifs, we used link clustering, a community detection algorithm where each node in a network can belong to multiple communities (20, 21). Link clustering applied to the consensus matrix partitioned the mating circuit into overlapping communities for searching, scanning, turning, vulva detection, excretory pore detection, and copulation (Fig. 3C). Many neurons belonged to more than one community, most often between temporally adjacent motifs like scanning, vulva detection, and copulation.
Unique activity patterns for each neuron
We compared the contributions of neurons to different behavioral motifs by aligning their activities to the onset of discrete events such as hermaphrodite contact and turning. Many neurons were consistently activated or inhibited by a different combination of behavioral events (Fig. 3D). When considered relative to the full set of behavioral events used for alignment, 80% of neurons exhibited unique activity patterns.
When we compared the activities of each group of neurons triggered by each behavioral event, we often observed diverse temporal dynamics (Fig. 3E–J). In many cases, we observed highly consistent sequences of peak activities among neurons from the start of a behavioral event, suggesting different and step-wise functional contributions for each neuron. Considering the activity of each neuron relative to all steps of mating behavior and at high temporal resolution, virtually every neuron in the mating circuit emerges as functionally unique.
Functional correlations between neurons are specific to behavioral context
Not only do different and partly overlapping combinations of neurons contribute to different behavioral events, but the correlations exhibited by overlapping neurons can be different for different events. For example, the HOA and HOB hook sensory neurons have long been viewed as contributing similarly to detecting and stopping at the vulva. We confirmed that both HOA and HOB are co-active during vulva detection, but we discovered that HOA activity increases and HOB activity decreases during copulation (Fig. 3D, G, I). Thus, motif-specific correlations diversify brain-wide activity during mating.
To compare circuit-wide functional correlations across motifs, we partitioned each dataset into four states: searching, scanning, copulation, and post-copulatory rest. We calculated a separate correlation matrix for each state for each dataset (Fig. S3, Fig. S4). Neuron-neuron correlations as well as neuron-behavior correlations were more similar when we compared the same states exhibited by different animals than when we compared different states exhibited by the same animal. When arranged using multidimensional scaling, the correlation matrices were more strongly grouped by behavioral state than by animal (Fig. 3K).
Synaptic interactions between functionally-connected neurons and functional communities
The wiring diagram of the male tail has been reconstructed by serial-section electron microscopy (13, 14). If this wiring diagram of chemical and electrical synapses supports the full diversity of brain-wide activity patterns across mating, functional connectivity will not be fully predicted by synaptic connectivity, or vice-versa. We estimated the functional connectivity between individual neurons using the correlation between their activity traces throughout mating (Fig. 3B). Activity correlations across all pairs varied from negative to strongly positive with a mean of 0.12 ± 0.22. Among pairs of neurons with positive correlations above the mean (> 0.12), 19% are connected by synapses. This probability is marginally higher than the 15% probability that two randomly sampled neurons are connected by synapses (Fig. 4A).
Among neuron pairs with stronger positive functional correlations (> 0.3, > 0.5, and > 0.7), larger fractions were connected by synapses (25%, 38%, and 68%, respectively). When we considered more strongly correlated pairs, we observed larger fractions of connections with only electrical synapses or with both chemical and electrical synapses. In contrast, the fraction of connections with only chemical synapses did not change. For neurons connected by synapses, we also quantified the dependence of functional connectivity on the number of electrical or chemical synapses. Functional connectivity was positively correlated with the number of electrical synapses (Pearson correlation r = 0.35, p = 0.001, partial correlation r = 0.34, p = 0.0007), and less positively correlated with the number of chemical synapses (Pearson correlation r = 0.17, p < 0.0013, partial correlation r = 0.12, p = 0.021) (Fig. 4B, C, Table S4). Thus, functional connectivity between individual neurons is prevalent among neurons without synaptic connectivity. Among synaptically connected neurons, functional connectivity is better predicted by the number of shared electrical synapses than chemical synapses.
Functional correlations partition the mating circuit into overlapping communities for different behavioral motifs (Fig. 3C, Fig. 4D). How does synaptic connectivity contribute to signaling within and between the circuits for different steps of mating behavior? For each pair of functional communities, we calculated the density of synaptic connections within each community (in-group connectivitiy) and between the two communities (out-group connectivitiy). An interaction between two communities is called assortative when in-group connectivity for each community is stronger than the out-group connectivity between them (22). For electrical synapses, 61% of all pairwise interactions between functional communities were assortative. For chemical synapses, 40% of all pairwise interactions were assortative (Fig. 4E). Assortative interactions were rare when we randomly shuffled synaptic connectivity (18% ± 17). In contrast, disassortative interactions, when out-group connectivity between communities is stronger than each in-group connectivity, were prevalent when connectivity was randomly shuffled (51%). Disassortative pairwise interactions between functional communities were rare for both electrical (0%) and chemical synapses (12%) (Fig. 4E). In summary, both electrical and chemical connectivity play substantial roles in internal signaling within functional communities. Chemical synapses play the larger role in signaling between functional communities, perhaps coordinating the display of different behavioral motifs.
Circuit-level implementation of behavioral motifs
The mechanisms that diversify brain-wide activity patterns and confer unique functional properties to each neuron are driven by stimulus, feedback, and motor patterns that only occur in the context of natural behavior. Here, we explore several of these mechanisms by dissecting circuits during distinct motifs of mating.
Scanning
The largest functional community within the mating circuit is associated with scanning along the hermaphrodite to locate the vulva. During scanning, the male recognizes the hermaphrodite, distinguishes different locations of her body, and uses feedback to keep track of his own movements.
Sensorimotor initiation of backward movement
Scanning begins with the initiation of backward movement when the tail makes ventral contact with a hermaphrodite. Earlier studies identified neurons required to initiate scanning including ray sensory neurons (Fig. 1B) and the PVY interneuron that receives synapses from the rays (15, 23, 24). Our brain-wide imaging revealed many more neurons for scanning involving 30% of the mating circuit from sensory neurons (R1AL, R2A, R4A, R6A, R9B, PCA) to interneurons (PVY, PDB, EF1-EF3, CP9) to motoneurons (AS10, AS11, VA10-VA12, DA7) (Fig. 3E, S1).
We found that many neurons are functionally correlated during scanning in an unfolding sequence of neuronal activity that triggers backward movement and suppresses forward movement upon hermaphrodite recognition. The first neurons to be activated when the male contacts a hermaphrodite are the R2A and R6A sensory neurons (Fig. 3E). The EF1-3 GABAergic interneurons, postsynaptic to R2A and R6A, become active shortly after contact. The activities of R2A, R6A, and EF1-3 are strongly correlated with each other and with backward scanning (Fig. 3B). The PVY interneuron also becomes active after contact, and is only active during backward movement (Fig. 3D, S1).
EF1-3 make GABAergic (presumably inhibitory) synapses to the AVB premotor interneuron in the head that drives forward locomotion (25). PVY makes excitatory synapses to the AVA premotor interneuron in the head, which is itself pre-synaptic to the A-type motoneurons that drive backward locomotion (23, 26, 27) and AS motoneurons. Indeed, the A-type motoneurons in the tail (VA10-VA12, DA7) and the AS10 and AS11 motoneurons become active with backward scanning. In this manner, hermaphrodite recognition triggers a switch from forward movement during search to backward movement during scanning through a synaptically-connected chain of neurons.
Sensory feedback during backward and forward sliding
The PCA postcloacal sensilla neuron is active during scanning. Close examination of its neuron-behavior correlations revealed a role in sensory feedback rather than in hermaphrodite recognition: PCA activity is strongly associated with the relative sliding between the male and hermaphrodite (t(4) = 3.53, p < 0.025), and is specifically active during backward sliding (Fig. 3D, S1).
Unlike other postcloacal sensilla neurons, PCA expresses the TRP-4 mechanosensory receptor and has striated rootlets like A-type sensory ray neurons (12, 28). PCA may detect backward sliding using mechanosensation. Unlike the ray sensory neurons, the synaptic outputs of PCA are to neurons for behavioral motifs other than scanning. Multiple synaptic targets of PCA are involved in vulva detection. PCA is correlated with other neurons involved in scanning, but its functional role is to monitor backward sliding to provide feedback to neurons in other motifs.
Scanning involves long backward movements that are interrupted by short forward movements. At the onset of forward movements, A-type motor neurons that drive backward movement are inactivated and B-type motor neurons that drive forward movement are activated (Fig. 3D, S1). Forward movements are often initiated when the male overshoots the vulva or the ends of the hermaphrodite (see below). Forward movement during scanning appears to be a form of sensory-triggered course correction.
The mating circuit monitors relative forward sliding between the male and hermaphrodite by mechanosensory feedback using the PHC sensory neuron, the sensory counterpart of PCA. Like PCA, PHC has striated rootlets for mechanosensation (12, 29, 30). Whereas PCA is correlated with backward sliding relative to the hermaphrodite, PHC is correlated with forward sliding relative to the hermaphrodite (Fig. 3D, S1).
In the male, one of the main synaptic targets of PHC is the PVY interneuron which drives backward movement through AVA. PHC is anticorrelated with PVY (Fig. 3B, S1). Thus, a feedback signal from PHC that detects forward sliding may be used to sustain forward sliding by inhibiting PVY. PHC also makes synapses to neurons involved in vulva detection. Thus, both PCA and PHC provide feedback about sliding to modulate other behavioral motifs.
Context-dependent posture control
The tail exhibits rhythmic undulatory movement when not in contact with a hermaphrodite. During mating, the tail stops rhythmic movement and assumes different prolonged postures with motif-specific purposes. Different locations on the hermaphrodite evoke the different sensorimotor transformations needed to assume these postures. These circuits control posture in different ways by context-dependent orchestration of the activity of overlapping sets of motoneurons and muscle cells (see below).
Ventral bending during turning
When the tail reaches either end of the hermaphrodite, the male must turn around her body with a sharp prolonged ventral bending of the tail to maintain contact and continue scanning (Fig. 5A). When turning is successful, the male continues scanning on her other side. When unsuccessful – for example, when the male overshoots before turning – the tail loses contact and the male switches to forward swimming, presumably trying to reestablish contact in a form of course correction.
Several neurons become active specifically during turns including the R4A sensory neuron, the PVV interneuron, the DX1, DX2, and DX3 inter/motoneurons, and the DD6 motoneuron (Fig. 3B, C, F, Fig. 5B, C). Some neurons, like PVV, are active during both successful and unsuccessful turns, suggesting roles in turn initiation. Other neurons, like R4A and DD6, are only active after successful turns, suggesting roles in turn completion (S1).
PVV ablation severely disrupted turning behavior. Without PVV, males were usually unable to turn successfully at the ends of the hermaphrodite and often lost contact (t(16.43) = 14.44, p < 0.001) (Fig. 5D). PVV receives inputs from ray sensory neurons and has direct synaptic output to the ventral cord motoneurons and ventral body wall muscles (13, 14). PVV operates as a trigger for turning behavior by collecting sensory cues associated with the tapering ends of the hermaphrodite and directly signaling to neurons and muscles for ventral bending (Fig. 5B).
The R4A sensory neuron and DD6 motoneuron reach their peak activity when the male reaches the other side of the hermaphrodite. R4A directly innervates PVV and ventral body wall muscles. DD6 is a GABAergic motoneuron that relaxes dorsal body wall muscles. Thus, R4A and DD6 may prolong the ventral bending that allows the male to reach the other side of the hermaphrodite.
Dorsal bending near the vulva
The tail often makes a sharp dorsal bend when it reaches the vulva, presumably to help transition to copulation (31) (Fig. 5A). A subset of neurons are associated with dorsal bending, including sensory neurons involved in vulva detection, the PDB inter/motor neuron, and the AS11 and DA7 motoneurons (Fig. 2D, Fig. 3B).
PDB receives inputs from many different neurons including CP7-9, HOA, EF1-3, and ray neurons, and is thus sensitive to different context-dependent signals for regulating tail posture. PDB-ablated males showed no difference from normal males in dorsal bending during searching and resting (Fig. 5E). However, PDB-ablated males showed less dorsal bending during scanning and vulva detection (t(13.94) = 2.18, p = 0.046 and t(13.98) = 4.14, p = 0.001) (Fig. 5E). PDB may directly evoke dorsal bending through its synaptic innervation of dorsal body wall muscles, as well as by activating AS11 (which synapses onto dorsal muscles) and VD13 (which relaxes ventral muscles) (27) (Fig. 5B). Thus, PDB is poised to change the functional correlations between motoneurons when driving dorsal bending in a context-dependent manner.
The AS11 motoneuron is positively correlated with backward scanning, consistent with its receiving 30% of its synaptic input from the AVA premotor interneuron. AS11 is thus positively correlated with A-type motoneurons for backward movement including VA11 which activates ventral muscles (Fig. 3B, D, Fig. 5B, F). Although both AS11 and VA11 are correlated with backward movement, they have contrasting relationships to tail curvature. AS11 is positively correlated with dorsal bending whereas VA11 is negatively correlated with dorsal bending (r = 0.12 ± 0.15 and r = −0.13 ± 0.15). In PDB-ablated males, AS11 and VA11 became more correlated with each other and less correlated with curvature. Thus, PDB appears to contribute to the curvature-dependent portion of AS11 activity (Fig. 5F).
AS11 receives 15% of its synapses from PDB. Because PDB is correlated with dorsal curvature (r = 0.29±0.19) (Fig. 5F, S1) but not velocity (r = −0.03±0.23), PDB contributes the curvature-dependent portion of AS11 activity but not its direction-dependent portion. PDB has a similar effect on the VD13 moto-neuron, which relaxes ventral muscles. During scanning, VD13 is correlated with PDB and with curvature. PDB ablation lessens the correlation between VD13 and curvature (Fig. 5F).
Both PDB and PVV provide mechanisms for context-dependent posture control. These interneurons collect sensory input that provide spatial cues about the vulva and hermaphrodite ends, and target overlapping sets of motoneurons to control dorsal and ventral bending for different purposes.
Excretory pore detection
When the tail reaches the hermaphrodite’s excretory pore while scanning, the PHA and PHB phasmid sensory neurons become active (Fig. 5G, Fig. S5A, S1). The phasmid neurons have sex-specific synaptic connectivity (13, 14, 32). The hermaphrodite uses her phasmid neurons for chemotactic responses (33). The male might use his phasmid neurons to detect excretory pore secretions to prevent mistaking the pore for the vulva (34) or as a spatial cue to guide him to the vulva.
The excretory pore is anterior to the vulva on the ventral side of the hermaphrodite. If the excretory pore is a guidance cue, its detection should affect movement decisions on the ventral side of the hermaphrodite. Because the vulva is the dominant feature that affects movement decisions on the ventral side, we examined male behavior with vulvaless hermaphrodites (let-23 mutants, Fig. S5B, C). During scanning with vulvaless hermaphrodites, males pause during 36% of scans on the anterior ventral side but only 8% of scans on the anterior dorsal side (t(28.26) = 3.67, p < 0.001) (Fig. 5H). Pauses near the excretory pore are sometimes followed by forward slides that returns the tail to where the vulva should be. Thus, the excretory pore provides a guidance cue for course correction when the male overshoots the vulva.
Mutant ceh-14 males have defects in phasmid neuron development (35, 36). These males do not respond to the excretory pore, pausing in only 9% of backward scans on either side of the hermaphrodite (t(24.77) = 0.03, p = 0.97) (Fig. 5H). The phasmid neurons thus likely contribute to triggering pauses. The PGA interneuron is also specifically active when the tail is near the excretory pore, and is thus functionally correlated with the phasmid neurons (Fig. 3B, C, S1). The wiring diagram does not have direct synaptic connections from the phasmid neurons to PGA, but the circuit for excretory pore detection extends from sensory neurons to interneurons.
Vulva recognition
When the male reaches the vulva, he stops scanning and transitions to another behavioral motif, vulva recognition. During vulva recognition, the male actively reduces his relative movement with respect to the hermaphrodite while pushing his spicules toward the vulva in repeated thrusts. Successfully breaching the vulva leads to copulation. Often, however, the male is unable to insert spicules and loses contact with the vulva. When this happens, he transitions to scanning. Mating can involve many transitions between scanning and vulva recognition.
The PCB and PCC postcloacal sensilla neurons and the HOA and HOB hook neurons are strongly associated with detecting the vulva (Fig. 1B, D). These neurons were previously shown via ablation experiments to help stopping at the vulva (15). Our brain-wide imaging revealed many additional neurons for vulva recognition including the R2B sensory neuron, the PVZ and PVX interneurons, the PDB inter/motoneuron, and the VD13 motoneuron (Fig. 3B–D, G, Fig. 5I). As discussed above, PDB and VD13 contribute to dorsal bending near the vulva. When the tail is aligned with the vulva for copulation, the second ray pair is closest to the vulva suggesting that R2B might be specialized to detect the vulva and trigger the transition to vulva recognition behavior (Fig. S6). Indeed, R2B ablation reduced the likelihood and duration of stopping at the vulva (t(24.29) = 2.54, p = 0.02, t(21.61) = 2.2, p = 0.04) (Fig. 5J).
HOA mediates a behavioral switch between scanning and vulva recognition
Previous ablation studies suggested that HOA contributes to both scanning and vulva recognition but in different ways. Near the vulva, HOA contributes to stopping and spicule insertion. Away from the vulva, HOA is thought to suppress other vulva-sensing neurons because its ablation causes the male to spuriously pause anywhere on the hermaphrodite and initiate spicule thrusts (15, 37). To determine how HOA contributes to switching between scanning and vulva recognition, we combined cell-specific neuron ablation with brain-wide imaging (Table S3).
In control animals, a group of vulva-detecting neurons – PCB, PCC, R2B, and PVX – is specifically active when the tail is at the vulva (Fig. 6A, B). In HOA-ablated males, these neurons exhibited frequent bursts of correlated activity. These bursts coincided with spurious pauses and spicule thrusts away from the vulva (Fig. 6C, Fig. S7). Spurious pauses interfered with reaching the vulva. When HOA-ablated animals did reach the vulva, they were often unable to maintain contact. During scanning, HOA is needed to inhibit other vulva-detecting neurons. During vulva recognition, HOA is needed to maintain contact and initiate copulation. How does HOA enable distinct functional correlations within the mating circuit during different behavioral motifs?
HOA makes both electrical and chemical synapses to the PCB vulva-detecting neuron (Fig. 6A). Thus, both hyperpolarization or depolarization of HOA may propagate to PCB and hence to other other vulva-detecting neurons. Glutamatergic inhibition from PCA has been shown to hyperpolarize HOA (37). We found that the PCA is active during backward scanning away from the vulva. PCA may thus hyperpolarize HOA during backward scanning. Near the vulva, HOA is directly activated by sensory cues from the vulva. The mating circuit thus contains mechanisms by which HOA excites other vulva-detecting neurons near the vulva and inhibits the same neurons away from the vulva.
To test whether PCA is part of a context-dependent switch that regulates HOA, we examined PCA-ablated animals. The phenotypes caused by HOA and PCA ablations were qualitatively similar but different in magnitude. Like HOA-ablated animals, PCA-ablated animals exhibited spurious activity in the neurons for vulva-recognition (Fig. 6D, Fig. S7). This spurious activity was more common with HOA-ablation than with PCA-ablation, suggesting that other neurons might also inhibit HOA during scanning. The PHC sensory neuron has the second strongest synaptic input to HOA (Fig. 6A). Like PCA, PHC is glutamatergic but is active during forward movement.
We conclude that HOA is both a positive and a negative regulator of the vulva-detecting circuit. HOA changes its effect on synaptic partners in a context-dependent manner. Near the vulva, HOA is activated by vulva detection, and further activates other vulva-detecting neurons. During scanning, PCA and PHC provide glutamatergic inhibition to HOA, which leads to hyper-polarization of other vulva-detecting neurons through electrical synapses.
Recurrently-connected sensory neurons and a self-reinforced activity state
After HOA ablation, the vulva-detecting sensory neurons – PCB, PCC, HOB, and R2B – exhibited correlated bursts of activity during spurious pauses and spicule thrusts. Because this activity occurs away from the vulva, it might be triggered by the hermaphrodite cuticle itself. One possibility is that the cuticle fully activates one or more of the vulva-detecting neurons away from the vulva. Alternatively, the cuticle might not fully activate one neuron, but, when some neurons become activated at a low level, recurrent excitation amplifies sub-threshold signals into a burst. The wiring diagram reveals many synapses initiate defecation (38, 40). In the male, defecation and ejacula-between vulva-detecting neurons that might allow recurrent excitation (13, 14) (Fig. 6A).
To test whether recurrent excitation occurs, we released the vulva-detecting circuit from inhibition away from the vulva by ablating HOA. If recurrent excitation plays a role, removing additional neurons should reduce the spurious activation of others. We found that additionally ablating either PCB or PCC reduced spurious activation of the rest of the vulva-detecting circuit (Fig. 6E, F, Fig. S7) – remaining sensory neurons were less activated by the cuticle, but were activated by the vulva. However, additionally ablating HOB did not suppress the spurious activity of remaining neurons (Fig. 6G, Fig. S7). PCB and PCC appear to contribute to recurrent excitation, but not HOB.
Recurrent excitation and signal amplification may facilitate the all-or-none switch of circuit activity from scanning to vulva-recognition. To confine its activity to the vulva, the vulva-detecting circuit must be under strong context-dependent inhibition. Integrated mechanisms for recurrent excitation and context-dependent inhibition enable sensitive, robust, and abrupt switching between temporally-adjacent behaviors.
Copulation
Breaching the vulva leads to the transition from vulva recognition to copulation behavior. Copulation involves full spicule insertion, sperm release, and withdrawal. Previous experiments showed that several sensory and motoneurons contribute to the different steps of copulation (15, 18, 38, 39). Here, we directly visualized the temporal sequence in neuronal activity during copulation (Fig. 3H–J). Several mechanisms, including chemosensory and mechanosensory feedback, shape the functional correlations and temporal progression of neuronal activities during copulation.
The first neuron involved in copulation, SPD, is activated before full spicule insertion. SPD has sensory endings at the spicule tips. The next neurons to be activated are the SPC sensory/motoneuron and DVB inter/motoneuron. SPC sends sensory endings to the base of the spicules, suggesting a role in detecting spicule movement. SPC is also a motoneuron that innervates the spicule protractor muscles and the gonad. The spicule protractor muscles are innervated by both SPC and DVB. Both SPC and DVB exhibit a tightly-correlated spike-like activation upon spicule protraction (Fig. 3H, J), and are required for spicule insertion (15, 38).
Following spicule protraction, the next neuron to be activated is SPV, another sensory neuron with endings at the spicule tips. The timing of SPV activation is consistent with its proposed roles in detecting the internal environment of the uterus and controlling sperm release. SPV ablation interferes with the precise timing of sperm release (15, 18).
HOA is active during vulva detection, but exhibits peak activity shortly after spicule insertion. The PVZ interneuron has similar activity to HOA but with slower dynamics, active during vulva detection and peaking after spicule insertion. The wiring diagram predicts multiple synapses between HOA and PVZ (13, 14).
Approximately two seconds after spicule insertion, calcium transients occur in multiple intestinal cells including Int9R. Anterograde calcium transients across intestinal cells are known to tion motor sequences have shared components and circuitry (38, 39). We hypothesize that intestinal calcium transients might have dual roles in initiating ejaculation and defecation in the male (but see (38)). The PCA postcloacal sensilla neuron becomes active following these intestinal calcium transients. The exact role of PCA in copulation is unclear, but it might be involved in the movements of the gubernaculum, a sclerotized structure involved in mating. PCA directly innervates the gubernaculum erector and retractor muscles (13, 14, 18).
The activities of the CA8 and CA9 inter/motoneurons start increasing several seconds after spicule insertion, peak roughly when the male detaches from the vulva, and decrease with spicule retraction (Fig. 3J). This activity pattern is consistent with the proposed role of CA neurons in initiation and continuation of sperm transfer (41).
Four vulva-detecting sensory neurons – PCB, PCC, HOB, and R2B – decrease their activity upon sperm release even when maintaining contact with the vulva (Fig. 3I). As the male transitions to ejaculation, several neurons that are involved in an earlier step in the temporal sequence are deactivated by the circuit. These vulva-detecting neurons might interfere with later steps in copulation requiring their deactivation. The pathway for this deactivation might involve dopamine release from dopaminergic socket cells, which has been implicated in the switch between pre- and postejaculation behaviors (18).
In summary, brain-wide imaging has revealed sequential patterns of circuit activity that are driven by sensory inputs and feedback along the step-wise progression of copulation behavior.
Resting
After copulation, the male rests for several minutes, during which his motor activity is suppressed (18). Resting coincides with decreased global activity of the mating circuit (Fig. S8). Few neurons are active during resting, but these have distinct activity patterns. DVB, which becomes active when copulation begins, is the only neuron with sustained activity throughout rest (Fig. 3J). The PVZ and CA8-9 interneurons, which become active later during copulation, remain active until spicule retraction.
Searching
After resting, the male searches for another partner. Most neurons previously associated with searching are in the head (16, 18, 42, 43). We discovered that several neurons in the posterior brain are also associated with searching (Fig. 3C). Almost all ray sensory neurons are associated with motifs involving physical contact with the hermaphrodite. However, one pair of ray neurons, R8B, shows higher activity without contact. Several interneurons – PDA, PVPR, and PVT – are also active during searching, as well as several ventral cord motoneurons – DB7, VD11, and VD12 – that drive forward swimming (27).
Interestingly, the PLM mechanosensory neuron is more active during searching than during contact with a hermaphrodite. PLM is ordinarily required to initiate forward movement in an escape response when either males or hermaphrodites are touched at the posterior (44). We found that PLM activity drops sharply when scanning begins. PLM activity does not immediately rise when the male loses contact. PLM may be suppressed when the male contacts a hermaphrodite, allowing mating behavior to be sustained by inactivating the circuit for escape response behavior.
Discussion
Natural multi-step behaviors challenge the brain to perform diverse tasks across the range of what the brain evolved to do (2, 45). Here, we analyze, with single-neuron resolution, how the entire posterior brain drives the full performance of mating by the male C. elegans.
Each mating between a male and hermaphrodite unfolds differently because of the complex and dynamic interactions of two animals. The sequence, timing, and detailed performance of different steps of mating differ for each trial. However, continuous brain-wide recordings reveal that the neuronal activities associated with the many recurring steps of mating are strikingly consistent. The brain operates in the same way between instances of the same component behavior, whether recurring in one animal or occurring in different animals. Neuronal activity that is specific to each step of behavior appears at all levels of signal processing from sensory to inter-to motoneurons.
When the full behavior is taken into account, we find little redundancy in the activities of different neurons. Nearly every neuron has a different set of correlations with respect to the rest of the circuit and to behavioral dynamics. Some neurons are specialized for single behavioral motifs. Other neurons participate in multiple motifs. Each motif engages a unique set of neurons, but different motifs often engage overlapping neurons. During the execution of each motif, neurons may be activated in a temporal sequence, revealing step-wise functional contributions as behavior unfolds. When brain-wide activity is considered in the context of an entire natural behavior, nearly every neuron exhibits a unique activity pattern.
Functional correlations between neurons in the brain are not fixed, but change with shifting contexts as a natural behavior unfolds. These functional correlations are produced by the dynamic interactions between the animal, the nervous system, and the environment. A prominent mechanism that produces context-dependent functional correlations is the stimulus-evoked recruitment of sensorimotor pathways. The hermaphrodite presents different stimulus patterns to the male with different parts of her body and at different steps during mating. These stimulus patterns create context-dependent correlations among the sensory neurons of the posterior brain. The diversity of these correlations underlies the diversity of sensorimotor responses in an entire behavior (Fig. 7).
The richness of natural sensory context increases the variety of stimulus patterns that translate into diverse task-specific sensorimotor transformations. In recent studies of C. elegans that focused on a small behavioral repertoire and small space of fictive or real motor output, brain-wide dynamics exhibited low diversity (3, 19, 46, 47). But across the entirety of mating behavior, the brain orchestrates many different components of behavior. Each component involves different brain dynamics even when using the same motoneurons and muscle cells to produce movement. One example of diverse context-dependent circuit function is the control of tail posture. During mating, tail posture is controlled in different ways in different contexts. This is accomplished by motif-specific computations by partly overlapping circuits that converge on a common set of motoneurons and musculature, thereby producing dorsal bending, ventral bending, or undulatory movement at different times.
One set of functional correlations does not describe the diversity of brain-wide activity across the many steps of mating. Because one wiring diagram supports many patterns of functional correlation, the relationship between the connectome and brain-wide activity cannot be one-to-one. Throughout the brain, neurons have synaptic connectivity both to other neurons that participate in the same components of behavior as well as connectivity to neurons that participate in other components. Some of the significance of in-group and out-group connectivity is revealed by temporally adjacent motifs like scanning and vulva-detection. For example, in-group connectivity among vulva-detecting neurons (13) provides recurrent excitation that amplifies circuit activity during copulation attempts (Fig. 6). Signal amplification within the vulva-detecting circuit presumably enhances its all-or-none sensitivity, but then requires context-dependent inhibition to prevent spurious activation. This context-dependent inhibition is provided by out-group connectivity from the scanning circuit. Circuits for different steps of behavior are not isolated, but instead continuously interact to stabilize individual behaviors or mediate transitions between behaviors.
We conclude that diverse brain-wide dynamics emerge from the complex interactions between a male and his mating partner (Fig. 7). The mating circuit recognizes different sets of sensory inputs that only arise in their natural context. These inputs are manifested in brain-wide functional correlations, starting from the diverse properties of sensory neurons. Diverse sensory patterns act on the wiring diagram to recruit different sensorimotor pathways and different communities of neurons for different steps of behavior. Brain-wide dynamics during a natural behavior are not a phenomenon of an isolated nervous system, but are shaped by the flow of sensory inputs and motor actions as behavior unfolds. Behavioral dynamics must be integrated with neuronal dynamics and wiring to understand how the brain does what it evolved to do.
Methods
Growing conditions
All C. elegans strains (Table S5) were grown at 23°C on nematode growth medium (NGM) plates seeded with E. coli OP50. All strains were allowed to recover from starvation and freezing for at least two generations before experiments.
Molecular biology
A C. elegans imaging strain ZM9624 was designed to co-express GCaMP6s and mNeptune in all neuronal nuclei. For this, lin-15(n765) hermaphrodites were co-injected with lin-15 rescuing plasmid and pJH3971(Prgef − 1 :: GCaM P 6s :: 3xN LS :: mN eptune). A transgenic line (hpEx3880) with consistent expression of GCaMP6s and mNeptune was selected for the UV-mediated transgene integration. The integrated line was out-crossed four times with N2.
ADS1002 was created by co-injecting lin-15(n765) with lin-15 rescuing plasmid and pJH34038(Prgef − 1 :: GCaM P 6s :: 3xN LS). A stable transgenic line (hpEx3931) was generated and outcrossed three times with N2.
Brain-wide recordings of neuronal activity
We sought to capture multiple motifs of mating behavior within each recording session. The number and order of behavioral motifs varied from trial to trial. For comprehensive analyses, we selected seven datasets capturing a wide range of motifs. Additionally, we collected 11 datasets focusing on specific neurons and behavioral motifs and 23 datasets using ablated males (see below). It was impossible to image both the head and tail simultaneously. In this study, we focused on the neurons in the tail, most of which are male-specific and form a posterior brain that drives mating (12–14).
Virgin L4 males were selected and kept on a separate plate for 24 to 40 hours before imaging. This allowed GCaMP6s and mNeptune to accumulate in the neurons of the tail, many of which are born during the L4 stage (12). For the imaging experiments, a single adult male was placed on an NGM agar plate with 2-5 hermaphrodites and a small amount of OP50. We used hermaphrodites that expressed red fluorescent markers in either their muscles or epidermis for tracking (Table S1). The assay plate was covered with a coverslip for oil immersion. Animals could swim freely under the coverslip.
Imaging was performed using a custom spinning-disc con-focal microscope described in Venkatachalam et al. (2016), with some modifications (19). Briefly, the emitted light from the samples was split into the red and green channels and images were captured using two Andor Zyla 4.2 sCMOS cameras. Each camera recorded 256 × 512 pixel area of interest at 200 Hz and with the system pixel size of 0.45 µm. Volumetric imaging was done using a 40x, 0.95 NA Nikon Plan Apo Lambda objective mounted on a piezoelectric stage. We sampled 10 brain volumes per second, each volume consisting of 20 optical sections approximately 1.75 µm apart. The tail of the freely-swimming male was tracked continuously by adjusting the microscope stage position with a stage controller.
Extracting activity traces
Neuronal activity traces were extracted from raw image volumes following image pre-processing and registration. All red channel volumes were registered to the green channel through rigid transformation. A difference of Gaussian filter was applied to both channels to suppress the background noise. The datasets were subsampled to include every other volume. The volumes were converted into 5D big-data-viewer arrays and used for neuronal segmentation and tracking with MaMuT 0.27, a Fiji plugin (48, 49). Segmentation and tracking were done manually, with some help of the MaMuT’s automated tracking. We tracked all visible neurons for six out of seven main datasets. For the seventh dataset, we tracked all identifiable neuron types (see below). For the 11 additional and 23 ablation datasets, only neurons of interest were tracked. Fluorescent intensities (F(red) and F(green)) were extracted by computing mean pixel values for the 2.25 × 2.25 × 3.5 µm volumes surrounding the center of each nucleus in the green and red channels. Savitzky-Golay filtering (polynomial order of 1 and frame length 13) was applied to intensity traces from each channel for noise-reduction (50). We computed neuronal activity as the ratio F(green)/F(red) to minimize the effects of correlated noise and motion artifacts. To mitigate remaining motion artifacts, a singular value decomposition was applied to the main datasets retaining 2/3 of components.
Quantifying behavior
We parameterized several continuous features of male behavior. These included swimming velocity and speed, sliding velocity and speed (tail velocity and speed relative to the hermaphrodite body when in contact), tail curvature, distance of the male tail to the head and tail of the hermaphrodite and to the vulva, and spicule protraction. To parameterize velocity, we computed the centroid of the tail from coordinates of three tail neurons (AS11, PLM, EF1). Centroid positions were extracted for each volume and converted into velocity of the worm in the egocentric coordinates (Fig. S9). Negative velocity values correspond to swimming forwards, and positive values to swimming backwards. Tail curvature was estimated using the angle between two rays diverging from the center of PVY and intersecting centers of AS11 and PLM (Fig. S9). When the tail is relaxed, the angle formed by the rays is nearly straight. Spicule protraction was estimated indirectly by measuring the distance between SPC, which moves with the spicules, and PCB. As the spicules become protracted, the distance between SPC and PCB sharply decreases.
To map the position of the tail to the hermaphrodite, we extracted maximum intensity projections (MIPs) of the volumes in which large parts of the hermaphrodite were visible. The images were tiled to cover the entire body and aligned with rigid rotations and translations to produce a straightened representation of the hermaphrodite (Fig. S10A–C). For each data volume, we mapped the position of the tail to the straightened hermaphrodite by matching uniquely identifiable MIP features (Fig. S10D). Finally, we estimated the best fit for an ellipse of aspect ratio 10 given the x and y coordinates of the tail position on the hermaphrodite, generating a representation of the tail trajectory on an idealized elliptical hermaphrodite (Fig. S10E). Using this map, we calculated the male’s scanning velocity and speed and its distance to the vulva and to the head and tail of the hermaphrodite.
The distance of the tail to the vulva is the arc length of the shortest path between the tail and the vulva along a section of the ellipse representing the hermaphrodite. The distance of the tail to the hermaphrodite tips is the arc length of the shortest path between the male tail and either the head or the tail of the hermaphrodite along a section of the ellipse.
Neuron identification
Neurons were identified based on a combination of features, including their position, morphology, and expression of specific fluorescent markers. Table S2 lists key criteria for assigning IDs to specific neurons. Anatomical drawings in Sulston et al. (1980) were a primary reference for the neurons’ relative positions and morphology (12). Neuronal positions were additionally cross-checked with the annotated electron microscopy data for the N2Y male shared by Scott Emmons. Among other sources, we used fluorescent microphotographs in Serrano-Saiz et al. (2017) which provided a comprehensive account of the expression patterns of multiple sparse markers (51). In many instances, to confirm neuronal IDs, we crossed existing well-characterized marker strains with panneuronal ADS1002 or ZM9624. This approach worked well for the regions with stereotyped cell positions. Positions of some neurons are variable (12). To confirm identities of such neurons we performed panneuronal imaging using sparsely labeled strains, and tested if neuron-specific activity patterns matched. In total, we were able to identify 76 neurons across all datasets.
Cross-correlation analysis and hierarchical clustering
Left-right symmetric pairs of sensory neurons showed positively correlated activity (r = 0.73 ±0.19), with one exception – R1A (Fig. S2). We considered each left-right correlated pair to represent a distinct neuronal type and compiled datasets to include the activity traces of 57 neuron types and one non-neuronal cell (int9R). We used 58 activivty traces and eight continuous behavioral parameters for cross-correlation analyses. Pairwise cross-correlations between time series were calculated for each dataset, with the lag parameter set to 5 (corresponding to one second). For each pairwise comparison, we calculated mean cross-correlations at each time lag, and the highest mean cross correlation value was included in the consensus cross-correlation matrix. This consensus correlation matrix was used to calculate pairwise Euclidian distances for hierarchical clustering with the Ward’s minimum variance method (52).
Event-triggered activity averages
We tested how neurons of the mating circuit responded to the start of specific behavioral events (Fig. 3D, S1). Events included were: ventral contact with the hermaphrodite (both the initial contact and any contact preceded by more than 6 seconds of separation); hermaphrodite loss lasting for more than 6 seconds; turning; failed turning attempts; vulva contact, copulation (as identified by increased calcium signals in the intestinal cells); switching from forward to backward swimming (tabulated for the entire behavior, and separately for searching, and scanning); switching from backward to forward swimming (tabulated for the entire behavior, and separately for searching, and scanning). Switching from forward to backward sliding (movement of the tail relative to the hermaphrodite); switching from backward to forward sliding. Neuronal signals were extracted for a window spanning 6 seconds before and after the events, and dataset-averaged response curves were calculated for each neuron and event. We then calculated cross-correlations between these response curves and binarized event traces, with the lag parameter set to 5. The lag with the maximum absolute mean correlation was selected. One-sample t-test was used to test whether the correlation estimate between the neurons’ response curves at that lag and behaviors was greater than zero. p-values were adjusted using the FDR method to correct for multiple tests. The FDR adjusted significance cut-off was set at 0.05. Activity changes at the onset of discrete behavioral events (i.e. significant increases, decreases, no changes) were used to calculate the fraction of neurons with unique activity patterns.
Decoding behavior from neuronal activity
To predict behavior from neuronal activity traces, we used generalized linear models with elastic-net regularization (53). The procedure was adapted from Scholz et al. (2018) with modifications (6). We sought predictions across different individuals. Activity traces of all neurons were centered and scaled to have a zero sample mean and unit sample variance, and concatenated for all datasets. We also concatenated time series of all behavioral features. Traces of several neurons were absent from some datasets. Missing traces were imputed if they were missing from single datasets. Activity traces missing from more than one dataset were excluded. To instantiate short-term memory, we used time-lags in the neuronal activity traces. Three time lags were used (t = 0, t = 0.6, and t = 1.2 seconds), that maximized the accuracy of predictions.
We partitioned concatenated time series into training and testing sets. For each modeling iteration, we selected six datasets for training and one for testing the resulting model’s out-of-sample prediction accuracy. The analysis was repeated to include all possible combinations of training and testing data. Model training and evaluation was performed using R packages ‘Caret’ version 6.0-84 (54) and ‘glmnet’ version 2.0-18 (53, 55). The algorithm fits a generalized linear model via penalized maximum likelihood. Tuning parameters include the penalty term λ, controlling the penalty strength, and the elastic-net mixing parameter α (where α = 0 is the ridge penalty and α = 1 is the lasso penalty). We tuned the model’s parameters by searching 101 α values (α ∈ [0, 1]) and 101 logarithmically-spaced λ values (λ ∈ [10−5, 101]). The best tuning parameters were selected based on the root mean square error and 5-fold cross-validation. The models’ prediction accuracy was estimated by calculating the mean R2 between out-of-sample predictions and target variables.
To better understand contributions of individual neurons, we ranked neurons by their weight, averaging the weight of all included time lags for a given neuron. We also evaluated additional models which were trained leaving out traces of single neurons, as well as models trained on traces of individual neurons and their time lags.
State-specific correlations
To compare correlation structure across behavioral states, we calculated neuron-neuron correlation matrices for each individual and mating state (searching, scanning, copulation, and resting) (Fig. 5). We calculated the Euclidian distances between all pairs of correlation matrices and applied non-metric multidimensional scaling using Sammon’s non-linear mapping to generate a 2-dimentional representation of the similarity/ dissimilarity between correlation matrices (56). We also compared correlations between neurons and continuous behavioral features (velocity, curvature, and spicules position) across behavioral states and datasets.
Comparisons between functional and synaptic connectivity
As a measure of functional weight, we used consensus cross-correlations (Fig. 3B). When both members of a left-right neuron pair were included in the analyses, their activity was assumed to be perfectly correlated, except in the case of R1A. As a measure of synaptic connectivity, we used the number of synapses between neurons from https://wormwiring.org/ (13, 14). Identifying connections between neurons, particularly gap junctions, can involve a degree of subjectivity (57), so we additionally validated gap junctions of the male tail by screening EM photographs of all annotated gap junctions in the N2Y male. We assigned a confidence score from 1 to 5 to each gap junction. Synapses with confidence scores 3 and higher were used to compile a validated gap junction connectivity matrix. To minimize the effects of observational noise, we also symmetrized the connectivity for all neurons that are bilaterally symmetrical, except R1A. Only connections involving more than one synapse were used for all analyses.
To test for the correlation between functional and synaptic connectivity, we calculated Pearson and partial correlation coefficients between the functional weight and the number of shared electrical and chemical synapses. To test for the correlation between the functional weight and the number of chemical synapses, we used the absolute value of functional connectivity. We tested for significance using 10000 shuffled functional connectivity matrices. To test if the results were sensitive to a particular choice of the connectivity hyperparameters, the analyses were performed using 16 variants of connectivity matrices. These matrices were generated using (i) synapse number or weight as a measure of connectivity ((13)), (ii) validated or original gap junctions, (iii) symmetrized or original connectivity, and (iv) both neurons of left-right pairs or only one neuron of each pair. The results of these analyses are summarized in Table S4.
Functional communities and community interaction types
To extract overlapping community structure we used link clustering (20, 21). For link clustering, functional correlations higher than 0.3 were selected from the the consensus cross-correlation matrix; left-right pairs of laterally symmetrical neurons were included. Extracted link communities were clustered themselves with the Ward’s minimum variance method (52) and a deprogram cut-off parameter set at 0.85, resulting in eleven meta-communities. Community interaction motifs were identified as described in Betzel et al., 2018 (22). Synaptic connectivity density was computed using the number of chemical and electrical synaptic connections, including connections between nodes present in both communities.
Neuronal ablations
All ablations were performed in young adult males, 1-4 hours after they completed their final molt. Ablations were done using a MicroPoint pulsed laser system (Andor) mounted on a Nikon microscope equipped with Nomarski optics and a 100x 0.95 NA Nikon Plan Apo objective. Males were placed on a 10% agar pad and immobilized with 0.01 µm latex beads (Polysciences, Inc). Target neurons were identified based on the expression of fluorescent markers. The neuronal nuclei were targeted until a visible damage appeared. Mock ablations were performed by placing males on a slide with latex beads for 5-10 minutes. Males were left to recover overnight and behavioral assays and imaging experiments were performed on the next day.
Mating assays
Behavioral arenas were 6 cm NGM agar plates seeded with a thin layer of E. coli OP50 forming a spot approximately 0.5 cm in diameter. One to three young adult hermaphrodites and one male were placed onto each assay plate. Behavior of the male was recorded at 5 frames per second for 30 to 60 minutes using a Grasshopper3 camera and Spinnaker software (Point Grey). Treatment and control trials were recorded on the same day. The recordings were analyzed blindly in MaMuT. Two-sided t-tests were used to compare group means.
For the PVV ablations, we tabulated successful turns and failed turning attempts. A turn was considered failed when the turn initiation was followed by either a permanent or temporary loss of contact.
To quantify pausing at the excretory pore, we performed mating assays with vulvaless let-23 hermaphrodites. We recorded when the male stopped backward scanning for more than 0.2 seconds on the anterior ventral side opposite the terminal bulb of the pharynx. This location corresponds to the excretory pore opening (Fig. S5A). For comparison, we tabulated pausing on the anterior dorsal side. Pausing was recorded during backward scanning towards the tip of the hermaphrodite’s head (Fig. S5B).
For the R2B ablations, we tested whether vulva detection and retention were compromised. We calculated the fraction of successful vulva detection events. Vulva detection was considered successful if the male paused scanning at the vulva for more than 0.2 seconds. We also calculated the average vulva retention time. Assays with more than five vulva detection events were included; vulva contacts during copulation were excluded.
Competing interests
The authors declare no competing interests.
Supplementary Materials for
Acknowledgements
We thank Alkmini Chalofti and Noah Milstein for help with neuronal tracking, Albert Lin for creating hpEx3931, Oliver Hobert for sharing strains, Scott Emmons for sharing EM photographs of the male nervous system. We thank Scott Linderman, Paul Sternberg, and members of the Samuel lab for their comments on the manuscript. Some strains were provided by the CGC, which is funded by NIH Office of Research Infrastructure Programs (P40 OD010440). This work was supported by NSF (IOS-1452593), NIH (R01 NS082525, R01 GM130842-01, and U01-NS111697), Canadian Institutes of Health Research (Foundation Scheme 154274), Natural Sciences and Engineering Research Council of Canada (RGPIN-2017-06738), and Bur-roughs Wellcome Fund CASI (VV).