Introduction

The social environment is a source of information about potential mates and rivals. Males in particular are predicted to use social information to gauge the level of reproductive, or sperm competition, in the environment and allocate reproductive effort in a particular mating accordingly (Parker 1970; Parker and Pizzari 2010). Plasticity in reproductive strategies such as behavior (Bretman et al. 2011) and ejaculate traits (Wedell et al. 2002) under differing sperm competition environments has been observed in many species. Matching reproductive investment to the prevailing competitive environment may be cognitively challenging, as, for example, it can involve the integration of multiple sensory cues (Bretman et al. 2011) and require the capacity for memory (Rouse et al. 2018). In general, variable conditions are thought to stimulate increased investment in cognitive processes (Sol 2009), and social context can be highly variable, both spatially and temporally (Kasumovic et al. 2008). Indeed, it has been suggested that selection for plastic sperm competition strategies that are responsive to the number of competitors has influenced the evolution of quantity estimation (Shifferman 2012). Moreover, sexual selection has been shown to influence cognition in D. melanogaster, with lines kept under monogamous conditions showing decreased learning ability compared to polygamous lines (Hollis and Kawecki 2014).

Whilst an increased ability to process cues relating to the sperm competition environment may be beneficial, increasing cognition could represent distinct costs as neural tissue is energetically expensive to produce (Niven and Laughlin 2008). Furthermore, it has been suggested that there could be a trade-off in investment in costly neural versus reproductive tissues (the “expensive sexual tissue hypothesis”) (Pitnick et al. 2006). For example, in echolocating bats, brain size appears to be negatively correlated with testes mass (Pitnick et al. 2006). As such, reducing investment into cognition may be advantageous when conditions are less heterogeneous (Sol 2009).

Developmental plasticity in response to conditions experienced during early life could have critical consequences for adult cognitive ability. For example, honey bees, Apis mellifera, have slowed growth in the mushroom bodies, which are olfactory learning centres of the brain, when reared in social isolation (Maleszka et al. 2009). Social isolation in young prairie voles, Microtus ochrogaster, results in reduced social discrimination in a socio-spatial task, which can be rescued by group-housing at a later stage (Prounis et al. 2015). Further, jumping spiders, Marpissa muscosa, reared in socially enriched conditions enhance their learning ability compared to those reared in isolation (Liedtke and Schneider 2017). Social enrichment, however, may not impact on all aspects of cognition equally. For example, rat pups subject to maternal deprivation have reduced social but not spatial learning compared to socially stimulated individuals (Lévy et al. 2003). These studies suggest that early life conditions, and in particular social conditions, alter cognitive development.

The fruit fly, Drosophila melanogaster, is an established invertebrate model for learning studies (Dukas 2008). Social enrichment in adult flies induces the growth of synapses of the lateral ventral neurons, with a corresponding increase in sleep (Donlea et al. 2014), and the mushroom bodies can vary in size with changes in social context (Heisenberg et al. 1995). They are, therefore, generally socially-sensitive and are also one of the best studied examples of an animal using social cues to anticipate sperm competition environments. Manipulating the larval social conditions experienced by D. melanogaster by increasing larval density or adding adult males into the larval environment induces the growth of larger accessory glands in adult males, an anticipatory response to future reproductive competition (Bretman et al. 2016). As adults, males adjust mating duration (Bretman et al. 2009) and ejaculate content (Wigby et al. 2009). This requires detection of a combination of sensory cues (Bretman et al. 2011) and these cues alter the speed and accuracy with which males respond (Rouse and Bretman 2016; Bretman et al. 2017). Moreover, the response requires the anaesthesia sensitive memory pathway (Rouse et al. 2018). Therefore, in order to process cues relating to potential future sperm competition and produce their response, an enhanced cognitive ability may be required.

The larval social environment could influence cognition in two ways. Increased social contact during larval stages could stimulate cognition directly or in anticipation of an increased requirement to process sperm competition cues when adults. Alternatively, there could be a resource trade-off between reproduction and cognition. In order to test this, we assessed the learning ability of young adult males reared under differing larval density or with or without the presence of adult males (Bretman et al. 2016), using two established learning assays (Tully and Quinn 1985; Hollis and Kawecki 2014). The first of these tested olfactory learning in a non-social task, and the second examined learning in a sexual context by testing the ability of a male to find and court a virgin female in a group of mated females (Hollis and Kawecki 2014). To examine potential underlying mechanisms of this response, we also investigated changes in expression of genes that have been linked to cognition and have been shown to change in adult males kept in the presence of a rival (Mohorianu et al. 2017). We hypothesised that if cues of future sperm competition stimulated cognitive processes, then males reared at high density or in the presence of adult males would show increased adult learning ability (i.e. they would be quicker to learn the olfactory task and show a greater ability to focus courtship on virgin females) and an increase in the relative expression of the cognition-related genes compared to individuals from less social larval conditions. Conversely, if there is a trade-off between investment in neural processes or reproductive tissue, then adults that had been raised at low density or without adults present should show increased cognitive abilities.

Methods

All flies used were Drosophila melanogaster wild type Dahomey strain as used previously in our studies (Bretman et al. 2016; Rouse and Bretman 2016; Leech et al. 2017). Flies were reared at 25 °C in a humidified room, under a 12:12 light: dark cycle on an agar-sugar-yeast diet. Adults were provided with purple grape juice agar plates on which to lay eggs, and the larvae were transferred approximately 24 h later to larval social treatments in plastic vials containing 7 ml of fresh sugar-yeast medium, supplemented with live yeast paste. Allocation to larval treatment groups was haphazard. In order to test how rearing density affected cognition, larvae were kept at low (20 larvae per vial) or high (200 larvae per vial) density on a concentrated food medium to prevent this becoming limiting at high density (Bretman et al. 2016). In order to test the effect of adult male presence, larvae were reared at a standard density (100 larvae per vial) with or without 20 adult males aspirated into the vial. These adult males were collected from standard density vials approximately 5 days prior to the experiment, and had been kept in single-sex groups of 10 until this point. They were removed from the vials the day before eclosion of experimental flies. Experimental flies were collected within 8 h of eclosion, anaesthetized on ice and sexed. Males were kept in single sex groups of 10 until they were used in the learning assays. For body mass measurements, groups of 10 1-day-old flies were frozen at -20 °C, thawed at 25 °C for 30 min, then their wet weight measured three times, and the mean of these used in subsequent analysis.

Learning Ability in a Sexual Context

Adult males were tested in a complex sexual context assay for their ability to find and court a virgin female contained in a group of 4 mated females at 5–6 days old, hereafter “virgin-finding assay,” as described by Hollis and Kawecki (2014). Since female flies become unreceptive to male advances after mating due to the transfer of seminal fluid proteins (Wolfner 1997), males should learn which females have been mated and focus their courtship behavior on the virgin female. Virgin females were collected from separate standard vials and kept in groups of 10. The day before the assay, these females were anaesthetized using CO2, and had the tips of their wings clipped to allow identification during the assay, as per previous studies (Bretman et al. 2012; Leech et al. 2017). This does not appear to influence the response of male flies to rivals (Bretman et al. 2009). To produce mated females, 10 adult males were aspirated into separate vials containing virgin females the day before the assay and left overnight to mate. In total, 4 mated females and 1 virgin female were aspirated into a new vial and left for 5 min to acclimate. One male from each larval treatment was then added to a single vial. Vials were scanned for a total of 20 min, with each male observed once per minute for approximately 6 s each. The male was scored on whether he was courting, and if this courting was directed toward the correct (virgin) female. Males and virgin females were removed after each run, and mated females swapped every two runs. The order of treatment males was reversed such that the group added first during the initial run was added second to reduce the possibility for timing and mated female effects. The assay was carried out in a humidified room at 25 °C and in total, three independent replicates, each consisting of 30 males per treatment, were carried out.

Learning Ability in a Non-Sexual Context

Flies from the different larval conditions were tested in an associative learning assay for their ability to associate an aversive shock stimulus with an odor in a T-maze (Hollis and Kawecki 2014). The assay was carried out under a lamp covered with a red lighting filter to reduce visual cues and at a temperature of 23 ± 2 °C. The odors used were 3-octanol (OCT) and 4-methylcyclohexanol (MCH) at concentrations of 27 μl and 10 μl respectively diluted in 10 ml of light mineral oil. These odors are commonly used in studies to test olfactory learning ability in D. melanogaster (Tully and Quinn 1985; Mery and Kawecki 2005; Hollis and Kawecki 2014). Odor concentrations had been balanced prior to the start of the assay to ensure one odor was not more influential on fly behavior than the other. To do this, flies were tested in groups, and the odor concentrations were considered balanced when the flies were distributed evenly between the two odors. The odors were pulled through a T-maze using a vacuum pump and the shock stimulus was administered by applying the holding tube containing the fly to a mechanical vortex mixer. Flies were initially given an odor preference test by measuring how long they spent in each arm of the T-maze over 2 min. The preferred odor was then paired with the shock stimulus during the training period (Claridge-Chang et al. 2009). Training cycles consisted of 1 min odor exposure paired with a mechanical shock given for 1 s every 5 s, followed by 30s of air only, then 1 min of exposure to the alternate odor without shock, followed by another 30s of air. This was repeated twice. Flies were immediately tested for learning ability by giving a choice between both odors in the T-maze for 2 min, and the amount of time spent in each arm (rather than the mid-section which was considered no choice) was recorded. Larval treatment groups were tested alternately, and the side of odor presentation was changed after every second fly. The odors were replenished approximately every 10 flies, and the experimenter was blind to treatment group during the assay. As learning ability increases during the first week of adulthood (Guo et al. 1996), flies were either tested at 1 day old or at a later stage. For larval density flies, this was at 4–8 days old, and for adult presence flies, this was at 5 days old.

RT-qPCR of Learning and Memory-Associated Genes

Expression of genes involved in learning and memory that had been identified as differing in the presence of rival males in adult D. melanogaster (Mohorianu et al. 2017) were examined in 1-day-old adult males reared under different larval conditions using RT-qPCR. Genes involved in learning and memory, namely dikar which is involved in long-term memory formation (Akalal et al. 2011), and dunce which produces an enzyme involved in learning (Gervasi et al. 2010) were examined; bruchpilot, a cytoskeletal protein gene involved in the release of neurotransmitters (Kittel et al. 2006), futsch and Neurexin-1, which are both involved in the structural formation and growth of synapses (Roos et al. 2000; Zeng et al. 2007) were also investigated. Primers were designed with a melting temperature of 60 ± 1 °C, and a CG content of 20–80%, with an efficiency between 90 and 110% in dilution series and pipetting accuracy greater than 0.99. Flies were snap frozen in liquid nitrogen, and heads were removed. Each sample consisted of approximately 50 heads per treatment group. These were stored at −80 °C. Seven independent replicates for each group were collected. RNA was extracted from the samples by grinding the heads using a micropestle and using Direct-zol™ RNA miniprep kit as per the manufacturer’s protocol. The RNA was checked on a Nanodrop for purity and 1% agarose gel to check for degradation. This was then converted to cDNA using the First Strand cDNA synthesis kit (Thermo Fisher) following the manufacturer’s protocol. A negative control containing no reverse transcriptase was also produced. Relative quantities were calculated by subtracting the Cq of each sample from that of the same reference sample and raising the primer efficiency to this number. Normalized expression for each gene was calculated by dividing the relative quantity by the geometric mean of two housekeeper genes. These were Ef1 (eukaryotic translation elongation factor 1) and Rap21 (Ras-associated protein 2-like), and had previously been identified as candidate reference genes (Ling and Salvaterra 2011).

Statistical Analyses

Analysis was conducted using R v.3.3.3 (R Core Team 2013) and SPSS v21. For Generalised Linear Models (GLM) or Generalised Linear Mixed Models (GLMMs) using the package lme4, the maximal model was simplified using Analysis of Deviance (AOD) to assess the effect of removing terms. For the virgin-finding assay, the number of males courting and, of those courting males, the number of males courting the virgin female, were totalled per minute for each repeat. Individuals that mated during the assay were removed from the remainder of the analysis so that these numbers were calculated from the numbers available for courting. Flies were scored as courting or not courting, and courting correct or incorrect female, therefore GLMMs with binomial error distribution were used, with larval social treatment and time as fixed factors, and replicate assay as a random effect. An interaction between social treatment and time would suggest a change in courtship speed of males from one of the treatments. The overall correct courting for each group was also analysed with Mann Whitney U tests.

For the associative learning assay, flies that did not make a choice within the 2 min were excluded from the analysis. Whether the naïve flies showed a pre-training preference for either odor was tested using a GLM with a Gamma error structure, with age and social treatment as factors predicting time spent in the unconditioned odor. We also tested whether then there was a bias in which was used as the aversive odor using Chi-square tests. Post-training, we classified flies as having learnt if they spent any time in the unconditioned (i.e. previously non-preferred) odor, and tested whether there was a difference in number of learners based on age or social treatment using Chi-square tests. We also tested whether the proportion of time spent in the unconditioned odor was altered using GLMMs with binomial errors and logit link function. Social treatment and age were fixed factors, time spent during the pre-training in the unconditioned odor as a covariate and initial odor preference (OCT or MCH) as a random effect.

Log normalized gene expression was analysed using a GLMM with gene identity and social environment as fixed effects, and biological replicate as a random factor. Where an effect of social environment was found, expression for each gene separately was analysed with post hoc tests using lsmeans and corrected for multiple testing using the Bonferroni method.

Results

Effect of Larval Density

Larval density had no effect on adult body mass (low density mean ± S.E.M. = 0.94 mg ± 0.008, high density = 0.93 mg ± 0.01; MWU = 1744.5; n = 60; p = 0.892). For the virgin-finding assay, there was no significant interaction between time and larval density for the proportion of males courting females (Analysis of Deviance χ2 = 0.628; df = 1, 5; p = 0.428; Fig.1a). Larval density did not affect the proportion of males courting (AOD χ2 = 2.508; df = 1, 4; p = 0.113), but the proportion of males courting increased over the assay period (AOD χ2 = 162.220; df = 1, 3; p < 0.001). There was no interaction between time and larval density for the proportion of males courting the virgin female (AOD χ2 = 0.001; df = 1, 5; p = 0.973; Fig. 1b), but there was a general increase in correct courting over time (AOD χ2 = 13.877; df = 1, 4; p < 0.001). Larval density had a significant effect on correct courting (AOD χ2 = 4.853; df = 1, 4; p = 0.028), with a larger percentage of males from low density vials correctly courting, particularly during the middle period of the assay. Combining across the whole observation period showed males raised at low density spent more time courting the virgin female (U = 1388, N = 60, p = 0.030; Fig. 1c).

Fig. 1
figure 1

Effect of larval density on male ability to correctly court virgin females. The mean percentage of three independent assays of 30 males of (a) males courting any female and (b) males courting the virgin female at each minute following male introduction, and (c) overall mean % males courting the virgin female. Males were reared as larvae at high or low density and tested at 5–6 days post-eclosion. Error bars represent 1 ± S.E. * denotes significant differences (p < 0.05)

For the associative learning T-maze assay, before training there was no effect of density or age on the proportion of time in the subsequently unconditioned odor (density x age χ2 = 0.010, df = 1, p = 0.226; age χ2 = 0.023; df = 1; p = 0.065; density χ2 = 0.002, df = 1, 145; p = 0.552). There was no significant difference in the number of flies selecting each odor pre-training between larval densities at 1 day old (χ2 = 0.070; df = 1; p = 0.792) or 4–8 days old (χ2 = 1.377; df = 1; p = 0.241). This suggests that there were no inherent sensory biases or preferences for the odors with respect to age and social treatment. After training, the proportion of flies that had learnt was not affected by either density or age. At 1 day old 46% of low density and 43% of high density flies had learnt (χ2 = 0.820; df = 1; p = 0.365), for 4–8 day old flies this was 63% of low density flies and 47% of high density flies (χ2 = 1.270; df = 1; p = 0.171). The proportion of time spent in the unconditioned odor was not affected by density (AOD χ2 = 0.545; df = 1; p = 0.461), but there was a significant effect of an interaction between age and pre-training preference (AOD χ2 = 4.874; df = 1; p = 0.027). Younger flies that showed a stronger pre-training preference subsequently spent less time in the unconditioned odor, but this pattern was reversed in older flies. Hence larval density did not affect adult learning ability in this simple odor-association assay.

Using normalized gene expression across all genes of interest, there is no interaction between gene identity and social environment (Analysis of Deviance: χ2 = 6.705; df = 4, 12; p = 0.152), but significant effects of gene identity (χ2 = 26.051; df = 4, 8; p < 0.001) and of larval density (χ2 = 14.982; df = 1, 8; p < 0.001), with a general pattern of relatively higher expression in low density flies (Fig. 2). Comparisons within genes using post hoc tests corrected for multiple testing, revealed only a significant increase in expression in Neurexin-1 and futsch in low density flies (bruchpilot p = 0.436; dikar p = 0.108; dunce p = 0.660; futsch p = 0.005; Neurexin-1 p = 0.003).

Fig. 2
figure 2

Log Normalized Expression for genes in the heads of adult male flies reared at low or high larval density. Flies were 1 day old post-eclosion when frozen, and the genes examined were bruchpilot; dikar; dunce; futsch and Neurexin-1. Extreme outliers (more than 1.5x Interquartile Range) were removed

Effect of Adult Presence

The presence of adult males during the larval stage had no effect on adult body mass (without adults present mean ± S.E. M. = 0.91 mg ± 0.008 g, with adults present = 0.90 mg ± 0.008; t = 1.008; df = 118; p = 0.315). There was no interaction between time and adult presence on the proportion of males courting females in the virgin-finding assay (AOD χ2 = 0.022; df = 1, 5; p = 0.881; Fig. 3a) or for the proportion of males courting the virgin female (AOD χ2 = 0.133; df = 1, 5; p = 0.716; Fig. 3b). The presence of adults during the larval stages did not affect the number of males courting (AOD χ2 = 0.388; df = 1, 4; p = 0.561; Fig. 3a) or the number of males correctly courting the virgin female (AOD χ2 = 0.681; df = 1, 4; p = 0.409; Fig. 3b). However, there was a significant effect of time, as the number of males courting (AOD χ2 = 191.46; df = 1, 3; p < 0.001; Fig. 3a) and correct courting (AOD χ2 = 11.534; df = 1, 3; p < 0.001; Fig. 3b) significantly increased over the assay period. Overall correct courting was not significantly different between the groups (U = 1570, N = 60, p = 0.227; Fig. 3c).

Fig. 3
figure 3

Effect of adult presence during larval stage on adult male ability to correctly court virgin females. The mean percentage of three independent assays of 30 males of (a) males courting any female and (b) males courting the virgin female at each minute following male introduction, and (c) overall mean % males courting the virgin female. Males were reared as larvae with or without adult males present, and tested at 5–6 days post-eclosion. Error bars represent 1 ± S.E

For the associative learning T-maze assay, before training there was no effect of adult presence or age on the proportion of time in the subsequently unconditioned odor (adult presence x age χ2 = 0.00003, df = 1, p = 0.582; age χ2 = 0.019; df = 1; p = 0.080; adult presence χ2 = 0.002, df = 1, 145; p = 0.552). There was no significant difference in the number of flies selecting each odor pre-training between adult presence at 1 day old (χ2 = 0.070; df = 1; p = 0.792) or 5 days old (χ2 = 1.377; df = 1; p = 0.241). Again, this suggests that there were no inherent sensory biases or preferences for the odors with respect to age and social treatment. After training, the percentage of flies that had learnt was not affected by either adult presence or age. At 1 day old, 61% of adult absence and 68% of adult presence flies had learnt (χ2 = 0.156; df = 1; p = 0.693); for 5 day old flies this was 68% for both treatments. The proportion of time spent in the unconditioned odor was not affected by adult presence (AOD χ2 = 1.067; df = 1,4; p = 302), age (AOD χ2 = 0.867; df = 1,4; p = 0.352) or pre-training time spent in the unconditioned odor (AOD χ2 = 0.146; df = 1, 4; p = 0.703).

Using normalized gene expression across all genes of interest (Fig. 4), there is no interaction between gene identity and social environment (χ2 = 0.667; df = 4, 12; p = 0.955), but differences in expression between genes (χ2 = 1.998, df = 4, 8, p = 0.027), and no effect of adult presence (χ2 = 2.777, df = 1, 8, p = 0.096). Post hoc analysis for within gene effects likewise showed there was no effect of adult presence on normalized expression (bruchpilot p = 0.545; dikar p = 0.347; dunce p = 0.789; futsch p = 0.234; Neurexin-1 p = 0.632; Fig. 4). Therefore we find no evidence for the presence of adults affecting learning in either behavioral assay or on the expression of neuronal genes.

Fig. 4
figure 4

Log Normalized Expression for genes in the heads of adult male flies reared with or without adult males in the larval environment. Flies were 1 day old post-eclosion when frozen, and the genes examined were bruchpilot; dikar; dunce; futsch and Neurexin-1. Extreme outliers (more than 1.5x Interquartile Range) were removed

Discussion

These results suggest that larval social conditions can affect adult learning in male D. melanogaster. However, this was dependent on both the type of larval conditions and the learning assay used. Contrary to our predictions that high larval density and the presence of adults during larval stages would increase overall learning ability in young adult males through increased social stimulation, we observed that males from low larval densities had higher learning ability in the virgin-finding assay compared to those from high densities. This was not simply due to a difference in activity, as density did not affect the amount of courting per se. However, there was no significant difference in an associative learning assay. There was a general trend for increased expression of learning and memory-associated genes in males from low densities, but when genes were analysed individually this was only significant for futsch and Neurexin-1. The presence of adult males in the larval environment had no significant effect on learning ability of adult males in either of the learning assays used and no effect on expression of any of the genes examined.

Larval Density Affects Adult Learning

We had expected that high density males would show an increased learning ability due to the provision of cues that indicate future sperm competition stimulating cognitive processes, and the greater requirement for processing of these cues. Despite high density males increasing accessory gland size in response to these larval conditions (Bretman et al. 2016), these individuals had poorer overall correct courting scores in the virgin finding assay than those from low larval densities. Therefore, it is possible that adult flies kept at high density as larvae are allocating resources to factors other than cognition, such as increased accessory gland size. For example, bees, Apis mellifera, that are immune-challenged have decreased ability to learn an association than those that have not been challenged (Mallon et al. 2003). Moreover, formation of long-term memory in fruit flies results in decreased stress tolerance (Mery and Kawecki 2005), and fly lines selected for learning ability have reduced lifespans (Burger et al. 2008). Previously, Mery and Kawecki (2004) have found a reproductive cost of learning, measured as egg laying rate, in individuals subjected to conditioning from lines selected for high learning under poor nutritional conditions compared to those not subjected to the conditioning. Therefore, it is possible that investment in reproduction, such as the production of larger accessory glands, could represent a trade-off against cognition in high density flies. Evidence for trade-offs between reproduction and cognition have been found in, for example, butterflies, Pieris rapae, (Snell-Rood et al. 2011), and bats (Pitnick et al. 2006). Therefore, it is possible that the production of larger accessory glands in high density males diverts resources to the production of this reproductive trait, and decreases the availability of energy for cognition. A trade-off such as this may be expected to be particularly significant under stressful conditions, for example, fly lines selected for adaptation to poor quality food sources show a reduced learning ability (Kolss and Kawecki 2008). Further, an absence of sexual selection in fruit flies results in a decreased learning ability (Hollis and Kawecki 2014). As cognition is important for males to identify and assess both mating partners and potential rivals, an increased investment in cognition would be beneficial under such social conditions. However, where there is a requirement for increased reproductive tissue, for example, in the presence of rival males, this could necessitate investment into reproductive tissue. Therefore increased mating competition might select for increased investment in various traits and tissues, and how resources are differentially directed into each requires further investigation.

Another possible explanation for changed cognitive output is that, even in the presence of excess food, larvae at high density could interfere with the feeding of others. This could, for example, increase stress or reduce food consumption (Goss-Custard 2002), resulting in an overall reduction in available energy and coupled with increased investment in accessory gland growth, decrease the energy for cognitive investment. However, it is worth noting that our manipulations did not alter adult body mass, suggesting that food consumption was not limited. Additionally, for populations reared at high larval densities faster development times have been connected to both feeding rates and tolerance to waste build-up (Joshi and Mueller 1988; Mueller et al. 1991; Joshi 2001). There may also be an effect on the microbial community on the food which could alter the microbiome of flies between treatments. It is therefore possible that an increased build-up of waste products at high densities could impact cognitive development in some manner.

However, it seems likely that high density larvae are in contact with one another more or less constantly, but the low density individuals may not be. The variability in the frequency of contact for larvae kept at low densities would create inconsistent, variable social cues and may result in an increased requirement for neural plasticity (Fawcett and Frankenhuis 2015). Intriguingly, low density flies had non-significant higher average learning indices in the associative learning task than high density flies, which was a consistent trend over the assay sessions. However, the virgin-finding assay is more likely to represent a natural situation than the associative learning task, and it may be argued, therefore, that it is the more relevant assay for this reason. However, instead of rather than a difference in learning ability per se, the differences observed between low and high larval density flies could be a result of a difference in sensory perception. Fruit flies are known to use multiple cues in the detection of rivals (Bretman et al. 2011; Maguire et al. 2015), and social experience in adult flies can affect behavior in male-male interactions, which is at least partly mediated by perception of pheromones (Svetec and Ferveur 2005). Indeed, courtship conditioning responses, whereby experience with a mated female alters male behavior towards a virgin female (Siegel and Hall 1979), is known to be largely dependent on detection of the pheromone cis-vaccenyl acetate (cVA) (Ejima et al. 2007). Thus, it is possible that a difference in sensory ability to perceive cues, such as cVA could be having an influence in the learning assays, and it would be interesting to explore this possibility in more detail, including utilising flies with defective sensory structures.

We analysed expression of genes involved in a number of aspects of learning, memory and synaptic plasticity that had previously been shown to socially responsive in adult flies (Mohorianu, Bretman et al. 2017). We found a general pattern of increased relative expression in flies raised at low density. In particular, futsch and Neurexin-1, which are both involved in synapse formation (Roos et al. 2000; Zeng et al. 2007), showed an increased expression in low density flies. An enhancement in synaptic plasticity through expression changes in these genes could underpin the enhanced ability of low density flies in the virgin-finding assay. Futsch is involved in the growth of synapses by the regulation of microtubule cytoskeleton organisation (Roos et al. 2000), and mutants display neurodegeneration and reduced learning abilities (Bettencourt da Cruz et al. 2005). Neurexin-1 expression is associated with sleep (Larkin et al. 2015), a socially responsive behavior that has been linked to synaptic plasticity in adults (Ganguly-Fitzgerald et al. 2006; Donlea et al. 2014). Taken with our work this suggests that synaptic plasticity mediated by Neurexin-1 could be affected by changes in social conditions across life stages in fruit flies. However, it should be noted that there could be other explanations for the pattern of higher relative expression from low density males. For example, larval crowding increases lipid stores in the bodies of adult flies (Borash and Ho 2001). We have not determined whether this is the case for our manipulations, though we do not find that they alter body mass overall. Nevertheless, an increased lipid store in the heads of the males from high densities could potentially influence the proportion of mRNA that is specifically taken from the brain, although the potential contribution of this is currently undetermined.

Adult Presence during Larval Stages Does Not Affect Adult Learning Ability

There was no significant effect of adult presence on learning ability for either of the assays used here or on the expression of any of the genes examined. We had expected that these individuals would have an increased learning ability due to the processing of cues that indicate future reproductive competition and results in increased accessory gland size of these males, or, instead, that a trade-off between these responses would occur. Possibly in contrast to the differences observed in the density groups, there does not seem to be a trade-off between the production of larger accessory glands and cognition. Similarly to the high density group, however, adult male presence may provide a consistent, stable level of information provision that does not require an increase in synaptic plasticity (Fawcett and Frankenhuis 2015). These results may be unsurprising as another study found no effect of rearing larvae in complex feeding environments on adult learning ability (Durisko and Dukas 2013). There was, however, an extremely consistent trend for non-significant higher learning scores across assay sessions in the associative learning task for the adult presence males.

Adult D. melanogaster increase their learning ability during the first week of adulthood (Guo et al. 1996). The associative learning task was carried out at 1 day as we envisaged that any difference would be more likely to be detectable at this stage, but was also tested later in the first week when learning ability is expected to have increased (Guo et al. 1996). However, there was no difference at either age examined in density or adult presence groups. Changes in environmental conditions that result in a mismatch of phenotype to environment could be costly (DeWitt et al. 1998). Further, as neural structures are energetically expensive to produce (Niven and Laughlin 2008), and as D. melanogaster brains continue to show plasticity into adulthood (Donlea et al. 2014), it may be more beneficial, if there are changes in cognition in response to reproductive cues, that this is largely affected during the adult stage. As the social environment can be variable, plasticity at sexual maturity could represent a route that is less likely to result in mismatches for males responding to these types of cues, and may be particularly important at these stages.

Due to the differences in experimental setup, we cannot directly compare between the density and adult presence social environments, but taking both sets of results into consideration, it appears that the type of cues available may have distinct effects. As group burrowing appears to require both visual and mechanosensory cues (Dombrovski et al. 2017), these cues may be important for the larvae, and as our learning paradigms both largely involve olfactory learning, it may be speculated that differences in other aspects of cognition, for example, visual learning, which would not be specifically identified in these assays, could vary. Additionally, despite both high density and adult presence males showing the same phenotype of increased accessory gland growth, there does appear to be differences between these groups. If the presence of individuals of a similar age represents a more accurate predictor of future sperm competition than the presence of individuals from an earlier cohort, this may affect investment into cognition to process these cues. Larvae of the same age are more likely to be direct reproductive competitors, so investing more to process cues under these circumstances could be beneficial. Alternatively, these larval social conditions may be differentially stressful, and this could impact on cognition. For example, early life stress in rats can influence neurogenesis (Mirescu et al. 2004), and the formation of long-term memory has been found to decrease stress tolerance in D. melanogaster (Mery and Kawecki 2005).

In conclusion, we have found evidence that larval social conditions can affect adult male learning ability in Drosophila melanogaster. Flies from low density larval environments performed better in a learning assay than those from high density conditions. We found an overall effect on gene expression, suggesting larval density could affect synaptic plasticity. It is unclear whether this represents enhanced responses to variable cues in low density males, or reduced cognition in high density males, perhaps through a reproduction-cognition trade-off. The presence of adult males in the larval environment had no significant effect on learning ability of adult males. These results suggest that the type of cues available may have distinct effects on the development of certain aspects of cognition. Processing information about the sperm competition environment and responding appropriately can have important fitness effects (Bretman et al. 2009; Wigby et al. 2009), and it appears that the social conditions experienced during early life stages could have potential implications for the cognitive abilities of these individuals into adulthood. Whether cues of sperm competition received during adulthood also influence cognitive abilities remains to be tested.