Fly stocks and handling
Wildtype D. melanogaster flies were from a large laboratory population originally collected in the 1970s in Dahomey (Benin) and maintained in stock cages with overlapping generations. Wildtype D. simulans and D. yakuba were obtained from the San Diego Drosophila Stock Center and KYORIN-Fly Drosophila species stock centre (stock #k-s03), respectively. Flies were reared on standard sugar yeast (SY) medium (100 g brewer’s yeast, 50 g sugar, 15 g agar, 30 ml Nipagin (10% w/v solution), and 3 ml propionic acid, per litre of medium) in a controlled environment (25°C, 50% humidity, 12:12-h light:dark cycle). For the Sudan Red food medium, 800 ppm Sudan Red 7B (Sigma Aldrich) dye was added to the SY diet before dispensing. Eggs were collected from population cages on grape juice agar plates (50 g agar, 600 ml red grape juice, 42 ml 10% w/v Nipagin solution per 1.1 l H2O) supplemented with fresh yeast paste, and first instar larvae were transferred to SY medium at a standard density of 100 per vial (glass, 75×25mm, each containing 7ml medium). Male and female adults were separated within 6h of eclosion under ice anaesthesia and stored in single sex groups of 10/vial. White females were from a stock carrying the w1118 allele that had been backcrossed three times into the Dahomey wildtype. Orco females were generated from backcrossing Orco1 (Bloomington Drosophila Stock Centre, stock #23129) stock for three generations into a Dahomey stock carrying the TM3 Sb ry balancer on chromosome 3. Eggless females were generated by crossing males from the OvoD1 stock  with wildtype Dahomey females.
Effect on female mating behaviour and fecundity of variation in pre-mating social environment
In all experiments, virgin focal D. melanogaster females were CO2 anaesthetised at 3–4 days old, pooled from across storage vials and then randomly assigned to isolation (1 female per vial) or group (1 focal and 3 virgin non-focal females per vial) social treatments. Females were exposed to these social environments for a period of 72h (unless stated otherwise) prior to mating. Wildtype males were aspirated individually into fresh SY vials the day prior to the mating trial. Mating trials were conducted at 25°C at 50% RH, always starting at 9am in the morning unless otherwise stated. On the day of mating, focal females were aspirated into vials containing a single male. Pairs were observed and the introduction time, start and end of mating were recorded. Any flies that did not start mating within 90 min were discarded. Males were removed immediately following the end of copulation and females left to oviposit for 24h before being discarded. Eggs laid on the surface of the SY medium in this 24-h period were counted under a Leica MZ7.5 stereomicroscope. Final sample sizes (number of biological replicates) for all experiments are shown in Additional file 1: Tables S1-S7 and range from 37 to 62 depending on the experiment.
Female fecundity responses to variation in the pre-mating social environment and effect of exposure to con- vs heterospecific females
Following the protocol above, focal wildtype D. melanogaster females were kept in isolation or housed with 3 non-focal females of the same or two different Drosophila species prior to mating. We chose as heterospecific treatments two species of the melanogaster subgroup—D. simulans and D. yakuba, which shared their last common ancestor with D. melanogaster ~5 MYA and ~13 MYA, respectively . Non-focal females were wing-clipped under CO2 anaesthesia prior to setting up the social exposure treatments, in order to distinguish them from the focal D. melanogaster individuals.
Effect of length of pre-mating social exposure period on post-mating fecundity
The experiment was set up following the standard protocol above, with wildtype Dahomey focal and non-focal females, but with varying lengths of social exposure before mating. To test the effect on post-mating female fecundity from shorter-term exposure, all females were placed into the social environments in parallel (between 9 and 10am on the day of the mating trials), then subsets of focal females were mated after 2, 4 or 8h. Therefore, these matings were conducted at different times of the day (2h at 12pm, 4h at 2pm and 8h at 6pm). Longer-term exposure was tested in a separate experiment. Again, all social environments were set up in parallel, then mating trials on subsets of focal females were conducted after 24, 48 and 72h, all at 9am each day.
Investigation of whether exposure to eggs or to non-egg deposits is required for socially induced fecundity plasticity
This experiment was carried out in two parts. In the first, we tested whether exposure to eggs of other females, or deposits of other females in the absence of eggs, was required for females to show plastic fecundity responses after mating. To do this, we used non-focal females from the OvoD1 (eggless) genotype. Wildtype focal females were kept alone (isolation), exposed to 3 wildtype non-focal conspecifics (group), 3 eggless OvoD1 non-focal females (group—eggless females) or an SY vial that had previously housed 3 eggless OvoD1 females for the preceding 24h (isolation—female deposits). In the second set, wildtype focal females were again kept alone (isolation), exposed to 3 wildtype non-focal conspecifics (group) or exposed to eggs laid in the previous 24h by three wildtype non-focals (isolation—egg-spiked). In both experiment sets, all focal females were moved to ‘fresh’ (deposits, egg-spiked or clean food) vials every 24h of the exposure period to maintain the strength of the specific cues involved.
Investigation of the sensory pathways required to detect cues of pre-mating social exposure effects on socially induced fecundity plasticity
To identify the sensory pathways used by females to detect female presence described above, we conducted three sets of experiments, each with standard isolation and group control treatments. To test the effect on post-mating fecundity of manipulating visual inputs, we used either wildtype females held in darkness or visually defective white focal females held under normal light conditions . The white line was derived by repeatedly backcrossing w1118 into the Dahomey wildtype genetic background . Non-focal females were all wildtype. To test the effect of manipulating olfactory cues, we used focal females with a knockout mutation in the Orco gene (encoding a broadly expressed odorant receptor, essential for olfaction of a wide range of stimulants ), or we surgically removed the third antennal segment of wildtype focal females under CO2 anaesthesia 1 day prior to setting up the social treatments. The antennal segment contains sensillae bearing odorant receptors, but also aristae that detect sound [57, 58]. Non-focal females for both olfactory experiments were wildtype females with intact antennae, which were wing-clipped under CO2 anaesthesia 1 day prior to social exposure. Finally, to test the effect of manipulating tactile cues, we physically separated wildtype focal females from non-focals using a perforated acetate divider to create two chambers within a standard vial. Perforations allowed the transmission of sound and odours, and the dividers were translucent which allowed for the perception of visual cues.
Effect of social environment on virgin egg retention
In the final experiment, we used a novel egg marking procedure to test the effect of isolation and group treatments on pre-mating (virgin) egg production and retention. Wildtype focal females were reared according to the standard protocol. Non-focal females were reared from the 1st instar larval stage on SY food containing 800 ppm oil-based Sudan Red dye, which stains lipids, resulting in the production and laying of visibly pink eggs as adults. Dyed females were collected upon eclosion and maintained on Sudan Red food for 3–4 days prior to setting up the social treatments. Social treatments were set up according to the standard protocol, above. For the group treatment, one focal female was housed in a vial with three dyed non-focals. Females were then moved every 24h to fresh food until mating. The number of white and dyed (pink) eggs laid by the focal and non-focal females, respectively, was recorded for each 24-h period of social exposure. Mating trials and post-mating egg counts were conducted as above.
Statistical analyses were carried out in R v 3.6.3 , using the ‘stats’ package for conducting generalised linear models (GLMs), ANOVAs of models and t-tests, the ‘pscl’ package for hurdle models, the ‘survival’ package for cox proportional hazard models and ‘emmeans’ package for post hoc testing. Figures were made using ‘ggplot2’ and ‘ggpubr’ packages.
The number of post-mating eggs was analysed using a GLM with social environment (four levels: isolated, melanogaster, simulans and yakuba) as the fixed dependent variable, a log link and quasi-Poisson errors to account for over-dispersion. Significance values were derived from an ANOVA of the model compared with a null model, using an F-test (Additional file 1: Table S1).
This experiment was conducted in two separate parts (short-term: 2, 4 and 8h and long-term 24, 48 and 72h) and so two separate analyses were carried out. For both experiments, the number of post-mating eggs was analysed using a GLM with social environment (two levels: isolated, grouped), timepoint (three levels, as factors) and their interaction as dependent variables, a log link and quasi-Poisson errors. Models with and without the interaction term were compared using anova() and the interaction was dropped from the model if there was no significant difference between the full and reduced model. Pairwise post hoc tests were conducted on the final models using emmeans() (Additional file 1: Table S2).
This experiment consisted of two parts, so two analyses were carried out. In each analysis, post-mating eggs were analysed in a GLM as for experiment 1, with social treatment as a fixed effect. In the first analysis, social treatment had four levels (isolation, group, female deposits and eggless), and in the second, social treatment had three levels (isolation, group, egg-spiked). Significance values were derived using an anova() as described for experiment 1 (Additional file 1: Table S3).
For each sensory manipulation (four separate experiments and therefore analyses), the number of post-mating eggs was analysed using a GLM as above. In each analysis, we tested specifically for an interaction between social treatment (two levels: isolation, group) and sensory manipulation (two levels: intact, manipulated). In the vision experiment, sensory manipulation had three levels since there were two types of manipulation—dark and white. Models with and without the interaction term were compared using anova() as described for experiment 2. Pairwise post hoc tests were conducted on models containing the interaction term using emmeans() (Additional file 1: Table S4).
The number of virgin eggs was analysed using a hurdle model, with social treatment (two levels: isolation and group), day (three levels: 1, 2, 3) as a factor and the interaction between them as dependent variables. Positive counts were tested using a truncated negative binomial with a log link, and zero counts with a binomial with logit link. Models with and without the interaction term were compared using waldtest() from the ‘lmtest’ package. Pairwise post hoc tests were conducted for each part of the hurdle model (binomial, or negative binomial) using emmeans() (Additional file 1: Table S5).
Mating latency and duration
Mating latency was analysed using Cox proportional hazards models, fitted using the coxph() function. Individuals that did not mate within 90 min were treated as censors. For mating duration, times of < 6 min and > 30 min were excluded from the analysis. These data points represent extremely short copulations, in which genitalia were unlikely to have been fully engaged or sperm transferred . Very long copulations can result if genitalia become ‘stuck’ and flies fail to disengage. In total, 11 such outliers were removed from across five of the mating duration experiments (Additional file 1: Table S7). Mating duration data were normally distributed for each experiment (Shapiro-Wilk tests, p > 0.05) and were analysed using Welch two-sample t-tests.