Thank you for visiting nature.com. You are using a browser version with limited support for CSS. To obtain the best experience, we recommend you use a more up to date browser (or turn off compatibility mode in Internet Explorer). In the meantime, to ensure continued support, we are displaying the site without styles and JavaScript.

# Balancing selection via life-history trade-offs maintains an inversion polymorphism in a seaweed fly

## Abstract

How natural diversity is maintained is an evolutionary puzzle. Genetic variation can be eroded by drift and directional selection but some polymorphisms persist for long time periods, implicating a role for balancing selection. Here, we investigate the maintenance of a chromosomal inversion polymorphism in the seaweed fly Coelopa frigida. Using experimental evolution and quantifying fitness, we show that the inversion underlies a life-history trade-off, whereby each haplotype has opposing effects on larval survival and adult reproduction. Numerical simulations confirm that such antagonistic pleiotropy can maintain polymorphism. Our results also highlight the importance of sex-specific effects, dominance and environmental heterogeneity, whose interaction enhances the maintenance of polymorphism through antagonistic pleiotropy. Overall, our findings directly demonstrate how overdominance and sexual antagonism can emerge from a life-history trade-off, inviting reconsideration of antagonistic pleiotropy as a key part of multi-headed balancing selection processes that enable the persistence of genetic variation.

## Introduction

The selective mechanisms involved in the maintenance of long-term polymorphism in the face of genetic drift often remain unknown. Early assessments of heritable diversity, as well as recent empirical genomic and theoretical studies, all emphasise the importance of balancing selection in promoting within-species diversity and maintaining intermediate allele frequencies1,2,3,4. The best-documented forms of balancing selection are overdominance, where heterozygotes benefit from a higher survival compared to homozygotes, and negative frequency-dependent selection, where allelic fitness decreases with increasing frequency, resulting in the protection of rare alleles. Balancing selection may also arise from the combination of opposing selection pressures, each favouring different alleles at polymorphic loci5, for example via spatially or temporally varying selection, where the fitness of the different alleles varies among habitats or seasons6,7,8, or sexually antagonistic selection, where allelic fitness varies between sexes9,10,11.

However, the mechanisms underlying balanced polymorphisms are still largely unidentified, partly because the fitness associated with different genotypes is affected by several interacting life-history factors. Individual fitness results from complex trait combinations of survival, longevity, reproductive success and fecundity, which can be under opposed selective pressures. For example, one allele can increase survival but weaken reproductive success, while the alternative allele can confer high fertility at the cost of decreasing survival, creating a life-history trade-off12,13. Such antagonistic pleiotropy increases genetic variation via the maintenance of intra-locus polymorphism14,15. Antagonistic pleiotropy has long been considered as a minor contributor to balancing selection because theoretical studies predicted it enables persistent polymorphism only for a limited range of parameters16,17,18. Nevertheless, recent models suggest that the role of antagonistic pleiotropy has been underestimated19,20,21,22 by showing that several factors, realistic in natural populations, can promote polymorphism persistence. These factors include trait-specific dominance (i.e. when the level of dominance varies between fitness components22,23), sex-specific selection (i.e. selection strength on each fitness component differs between sexes19) and spatially and temporally varying selection20,21.

These recent theoretical developments urge for a re-examination of the mechanisms allowing polymorphism maintenance in natural systems and to disentangle their effects on the different components of fitness. For example, detailed work on phenotypic variation in horn size in Soay sheep (Ovis aries) shows that antagonistic pleiotropy due to a life-history trade-off between survival and reproductive success at a single locus maintains polymorphism by causing an overall net heterozygote advantage13. Horn size is also under sex-specific selection and involves trait-specific dominance, two factors predicted to contribute to the maintenance of genetic variation. Similarly, in the yellow monkeyflower (Mimulus guttatus) variability in flower size is related to antagonistic pleiotropy due to a trade-off between viability and fecundity, with the persistence of the polymorphism being further enhanced by spatial and temporal environmental heterogeneity20,24,25. However, direct empirical evidence of antagonistic pleiotropy enabling long-term polymorphism remains scarce, in part because the different components of fitness are rarely estimated separately.

Here, we focus on the seaweed fly Coelopa frigida, whose natural populations are all polymorphic at a large chromosomal inversion on chromosome I, representing about 10% of the genome, 25 MB and containing one thousand genes26,27,28. Recombination within large inversions is suppressed between the different rearrangements. Consequently, inversions behave as a single locus, with alleles corresponding to the different haplotypic rearrangements29,30,31. In C. frigida, the two alleles, referred to as α and β, differ by more than 2.5% in coding regions and are observed at stable and intermediate frequencies in both European and North American C. frigida populations, suggesting that the haplotypic rearrangements diverged a long time ago and have been maintained ever since by balancing selection26,27,28. The widespread excess of αβ heterozygotes and the higher egg-to-adult survival of heterozygotes compared to αα and ββ homozygotes implicates that this polymorphism is partly maintained by overdominance, possibly due to deleterious alleles captured by the inversion32,33. Moreover, inversion frequencies correlate with environmental factors, suggesting that spatially varying selection combined with migration also contributes to maintain this polymorphism26,27,34. Previous work has also shown that the inversion strongly affects adult size, which is linked to female fertility and male reproductive success35,36,37, as well as development time38 which could modulate egg-to-adult survival. While the phenotypic effect on females is moderate, αα males can be up to three times larger than ββ males, but αα males can also take up twice as long to develop than ββ males26,38. This pattern suggests a trade-off between adult size and egg-to-adult development, which may result in a trade-off between fertility and survival. These findings make the inversion polymorphism in C. frigida a relevant empirical case to investigate the role of antagonistic pleiotropy in promoting polymorphism and to specifically test interactions with other mechanisms favouring the maintenance of variation, such as sex-specific effect, overdominance and spatially varying selection.

We combine experimental evolution and simulations to investigate the mechanisms of balancing selection underlying the maintenance of the inversion polymorphism in C. frigida (Fig. 1a) and to decipher the role of antagonistic pleiotropy in this process by estimating the effect of inversion alleles on different fitness components. First, we use experimental evolution (Fig. 1b) to follow the inversion frequencies over five generations and to estimate the relative fitness associated with each genotype. We determine the inversion genotypes in the eggs to specifically dissect the different components of fitness, such as egg-to-adult survival and reproductive bias. Second, realistic numerical simulations based on these experimentally estimated parameters allow quantifying the contribution of antagonistic pleiotropy in the maintenance of this inversion polymorphism. Both the experiments and simulations support that the life-history trade-off mediates balancing selection maintaining the inversion polymorphism, in interaction with other factors, namely sex-specific selection, trait-specific dominance and environment. Finally, we expand our simulation model to characterize how the combination of different selective mechanisms favours the persistence of polymorphism via antagonistic pleiotropy.

## Results

### Inversion dynamics during in vivo experimental evolution

The frequency of the α allele, originally at 27–36% in natural populations, increased significantly between generations 1 and 5 from 28–56% to 58–75% (glm z = 10.6, p < 0.001, Fig. 1c, Supplementary Tables 1 and 2). This was observed in all 16 replicates, with no significant effect of the substrate (glm p = 0.27, Supplementary Table 2). Initial differences in frequency between the two origins were lost at generation 5 (Fig. 1c–f, Supplementary Table 2). The increase in α frequency stemmed from a sharp and significant increase of αα homozygotes from 4–24% to 25–57% (glm z = 8.8, p < 0.001, Fig. 1d) and a reduction in ββ homozygotes from 12–48% to 0–15% between generation 1 and 5 (glm z = −7.9, p < 0.001, Fig. 1f). Proportions of αβ heterozygotes remained stable around 50% [36–73%] between generations 1 and 5 (glm z = −1.4, p = 0.16, Fig. 1e).

To disentangle the fitness components for the three genotypes and explore dominance effects, we genotyped the adults and the eggs at each generation for a subset of four replicates (Supplementary Table 1) and monitored frequency deviations due to biased survival or non-random reproduction. In combination with follow-up experiments and simulations, we evaluated four fitness parameters in the three genotypes: egg-to-adult survival, development time, female fecundity, and male reproductive success.

### The β allele confers a viability advantage to larvae

Egg-to-adult relative survival was significantly affected by genotype (lmm df = 2, F = 4.7, p< 0.01, Fig. 2a, Table 1, Supplementary Table 4, Supplementary Fig. 2). Survival of αα homozygotes was on average 21% lower than αβ heterozygote and l0% lower than ββ homozygote survival. Therefore, the increase of αα frequency during the experiments is a paradox given the lower viability of this genotype. Here, ββ and αβ relative survival rate did not differ significantly (mean difference 2%, t-test p = 0.99), suggesting a dominance effect of the β allele on egg-to-adult survival. This contrasts with the general finding of overdominance in European populations of C. frigida, where αβ heterozygote larvae survive better than both homozygotes32,33,39. Yet, the high αβ relative survival is known to be enhanced by increased competitive conditions33. Therefore, the performance of homozygotes in our data may be explained by the low-density conditions maintained in our experiment. We also calculated relative sex-specific survival rate of the three genotypes (Table 1). Although these estimates should be interpreted cautiously given their large variance, our data were consistent with previous estimates on C. frigida populations raised at low density33: overdominance of αβ was observed for male survival while ββ females tended to outperform αβ females (Table 1, Supplementary Fig. 1, Supplementary Table 3), suggesting that the effects of the inversion on viability as well as the dominance relationship differs between sexes.

The inversion also showed a sex-specific effect on the duration of the larval stage, with no significant difference among female genotypes (on average, αα: 9.0 days, αβ: 8.7 days, ββ: 9.0 days; glmm p = 0.57) but highly significant differences among males (glmm p < 0.001, Fig. 2b Supplementary Table 5, Supplementary Fig. 3). In our experimental conditions, (i.e. 25 °C and low-density) the development time was on average 50% longer for αα males (12.8 days), and 25% longer for αβ males (10.3 days) compared to ββ males (8.8 days). Such ordering between genotypes is consistent with previous studies, although absolute values are larger at higher density38,40 or lower temperature (pers. obs.). Therefore, the α allele is expected to confer an additional mortality risk in the natural environment for males by delaying sexual maturity, although this effect is challenging to quantify in the laboratory where the substrate is not limiting.

### The α allele confers a reproductive advantage

Egg genotype proportions significantly deviated from proportions expected under random mating, i.e. based on the Hardy–Weinberg proportions of the previous generation (combined probabilities of Χ² tests, p = 0.003). The deviation from random mating expectation in the eggs was significantly different between genotypes (lmm df = 2, F = 24.9, p < 0.001; Fig. 2c, Supplementary Table 6, Supplementary Fig. 4). It consistently corresponded to an excess of αα eggs (on average +43%), a slight excess of αβ eggs (+11%) and a strong deficit of ββ eggs (−44%). Those deviations mean that the α allele provided an important advantage for reproduction potentially underlying the increase of α frequency in our experiment.

The excess of the α allele in the eggs was partly explained by a higher fecundity of the females bearing the α allele. In a follow-up experiment on 90 females, αα and αβ females laid significantly more eggs than ββ females in their first clutch (t-test p = 0.03), with 15% more eggs on average (αα: 70 eggs, αβ: 68 eggs, ββ: 61 eggs—Fig. 2d), possibly due to the larger size associated with α also observed in females35. The number of eggs laid by αβ females and αα females did not differ significantly (t-test p = 0.60, Fig. 2d), suggesting that the advantage in female fecundity associated with the α allele may be dominant.

The excess of α in the eggs may also result from non-random mating favouring α males because of their larger body size. Previous experiments in C. frigida with two males and one female demonstrated that the largest male sires a disproportionately higher number of the progeny37. The reasons are two-fold: smaller males lose male–male competition by being dislodged by larger males41; and, even in single-pair experiments, smaller males are more likely to be rejected by females during mating than larger males, with ββ males being 30% and 20% less attractive than αα and αβ males, respectively36,39,42. To estimate male reproductive success in our experiment, we built an individual-based model simulating the evolution of inversion frequencies in silico over five generations with all parameters drawn from the experiment except for the male relative reproductive success (Fig. 3a, Table 1, Supplementary Table 7). A scenario with equal male reproductive success across genotypes did not fit our experimental data (Fig. 3b), meaning that the difference in female fecundity is not sufficient to explain the observed rise in α frequency and the excess of αα in the eggs. The best model fit was achieved by a 10-fold higher mating success in αα compared to ββ males (Tββm = 0.1, Fig. 3b, c, Supplementary Table 8), with co-dominant, intermediate values for αβ. Models involving dominance were explored but generally exhibited a lower model fit (Supplementary Table 8). Models including a negative frequency-dependent effect on mating success were also explored to account for a possible higher male–male competition between large-size males when the proportions of αα increased. Although those models adequately fit the experimental data, the global fit was not significantly better compared to simpler models (Supplementary Fig. 5, Supplementary Table 8).

### Modelling the impact of the trade-off on inversion dynamics

To explore how a life-history trade-off modulates inversion frequencies dynamics in nature and to test whether they can contribute to the maintenance of the polymorphism over time, we expanded the individual-based model to 200 generations and used a larger population size (K = 10,000). Our experiment provided realistic values for the different life-history parameters. Yet, the increase of α frequency to 50–75% in the experiment departs sharply from the lower α frequencies generally observed in natural populations (30–50%26,34). This means that there were key differences between wild and experimental conditions that the model needed to take into account. We identified three main differences: (i) our experimental boxes were likely less densely crowded than natural wrackbeds and density is known to affect relative egg-to-adult survival33, (ii) during the experiment, male–male competition was likely stronger than in nature because of restricted space and synchronized reproduction, which may have favoured large αα males over smaller ββ males, (iii) the experimental substrate was unlimited while, in nature, access to the resource is frequently disrupted by tides or storm-induced waves, which may prevent slow-developing males from reaching adulthood43. We thus explored how genotype proportions are affected by the following three parameters: (i) relative egg-to-adult survival, (ii) male relative reproductive success, and (iii) duration of habitat availability. We then estimated the probability of maintaining polymorphism vs. fixing one allele within both a realistic and theoretical (less constrained) parameter space.

The effect of density on egg-to-adult survival (i) could not account for frequency differences between the wild and the experiment (Fig. 4a). Yet, higher densities shifted the equilibrium proportions towards an excess of heterozygotes as observed in some natural populations (Fig. 4a, d).

Simulations reducing the relative reproductive success of αα males (ii) to about 2-fold (instead of 10-fold in our experiment) recovered an equilibrium of genotypic proportions close to values observed in the wild (Fig. 4b, d), confirming that the increase of α frequency in our experiments could be linked to a large reproductive advantage of males carrying the α allele, possibly intensified by male–male competition due to restricted experimental space and synchronised reproduction. In the wild, ββ males may also have easier access to females by reaching adulthood earlier than αα and αβ males. However, equal male reproductive success between the three genotypes led to higher ββ proportions than what is generally observed in nature and removing the α-female fecundity advantage led to the fixation of β allele. This suggests that the reproductive advantage conferred by the α allele in both males and females may also contribute to the persistence of α/β polymorphism in the wild.

Finally, the duration of habitat availability (iii) appeared to be a prominent factor affecting genotypic proportions and explaining the difference in genotype frequencies between our experiment and wild populations (Fig. 4c). This was mediated by a different balance between survival and reproductive advantage. When the habitat availability was shorter, relative survival of αα males, and to a lesser extent of αβ males, was reduced in comparison to the faster-developing females (all three genotypes) and ββ males (Fig. 5b, Supplementary Fig. 6). It is noteworthy that variation in the duration of habitat availability tended to cover the natural variability in genotypic proportions (Fig. 4c, d), suggesting that spatio-temporal heterogeneity in habitat availability could explain the variable balance of genotypes observed in nature.

### Polymorphism maintenance through antagonistic pleiotropy

Taken together, the antagonistic pleiotropy among inversion-associated fitness components, as revealed by our experimental evolution approach, can explain the maintenance of the inversion polymorphism in nature, albeit considering a different tuning of the trade-off between survival and reproduction. Simulations exploring these different factors simultaneously showed that the polymorphism is maintained for a wide parameter space of male reproductive success and environmental conditions (Fig. 5a, Supplementary Fig. 7), even at low density conditions, where heterozygote survival advantage is very weak (Fig. 5b, Supplementary Fig. 6). Remarkably, when the duration of the habitat availability was more variable, the range of conditions maintaining polymorphism was considerably expanded (Fig. 5c). Also, the frequency of the inversion was buffered around intermediate values (Supplementary Fig. 8), which suggests that spatially varying selection resulting from environmental heterogeneity strongly favours the coexistence of alternative life-history strategies and thus the underlying genetic polymorphism. As expected, in models accounting for strong overdominance in survival (medium density conditions, Supplementary Fig. 9) or negative frequency-dependant effect on male success (Supplementary Fig. 10), most combinations of parameter values led to a protected polymorphism.

Estimating total fitness, defined as the combination of egg-to-adult survival and reproductive success for each genotype and sex, showed that antagonistic pleiotropy translates into two mechanisms of balancing selection: overdominance and sexual antagonism (Fig. 5a). Overdominance naturally emerges from antagonistic pleiotropy, even in the absence of dominance for any given trait, particularly when selection is strong (Fig. 5d). In the case of C. frigida, heterozygotes benefit from the combination of a survival advantage associated with β and increased reproductive success associated with α. Variation in the strength and direction of dominance between fitness components, as observed in our experiment, with for instance overdominance in αβ male survival and dominance of β allele in female larval survival (Fig. 2), considerably expanded the parameter space leading to overdominance and polymorphism maintenance (Fig. 5d). Sexual antagonism emerges from the sex-specific effects of each allele on survival and reproduction (Fig. 5e), and expands the range of conditions allowing polymorphism.

## Discussion

Results from the experimental evolution trial coupled with simulations show that the inversion dynamics in C. frigida can be largely explained by an antagonistic relationship between viability and fecundity. Individual-based simulations revealed that this antagonism is probably stronger in natural conditions and contributes to the widespread maintenance of inversion polymorphism in the wild. Both empirical results and simulations emphasize the importance of accounting for the reproductive phase and sexual selection. In fact, when considering viability alone, the persistence of the α haplotype, and its increase in our experiment, represents a paradox that is only resolved by considering female fecundity and the reproductive bias favouring larger males37,42. The antagonistic pleiotropy between growth and reproduction observed in C. frigida at the inversion also corroborates the evidence for trade-offs mediated by body size44,45,46. Such trade-offs frequently emerge because a bigger size either requires prolonged development time or a faster growth rate, both mechanisms associated with a lower likelihood to reach the reproductive stage. For instance, artificial selection for large body size in the yellow dung fly (Scathophaga stercoraria) increases juvenile mortality, particularly in stressful environments, as well as development time, leading to mortality before reproduction due to winter frost47. For a wide range of species, environmental factors impose such limits to development time. For example, in snow voles (Chionomys nivalis) the benefits of higher body size are counteracted by the need to reach adult size before the first snowfall48,49. Similarly, in many annual plants, delayed flowering allows investment in vegetative growth and a subsequently higher number of seeds, but is constrained by the duration of the reproductive window20,24,50. In C. frigida, this effect is relevant given the instability of the wrackbed habitat due to tide and wind induced waves (here modelled as limited habitat availability). By disproportionately increasing mortality of the genotypes with larger reproductive success, the effect of the environment is expected to exacerbate the trade-offs reported during the experimental trials.

When life-history trade-offs are affected by external factors, environmental heterogeneity in space and time strongly contributes to the maintenance of variation by locally favouring different life-history strategies. For instance, in the yellow monkeyflower Mimulus spp., spatial heterogeneity in wetness and seasonal variation alternatively favours alleles determining early-flowering/low fecundity or late-flowering/high fecundity20,24,25. In C. frigida, wrackbed stability varies between locations and across seasons depending on the exposure of the beach to tidal and storm-induced waves. Such heterogeneity is expected to generate fluctuating selection regimes between a slow-development/high fertility strategy (αα) or a fast-development/low fertility strategy (ββ), leading to variations in inversion frequency, and enhancing the maintenance of polymorphism. This hypothesis, originally proposed by Day, Butlin et al.27,34, is supported by field observations reporting geographic variation in genotypic proportions coinciding with tidal pattern in Scandinavia27 and temporal variation in genotypic proportions in Great Britain, with the α allele increasing in frequency in summer when the wrackbed was less frequently disturbed by storms34. Geographic variation in genotypic proportions in natural populations of C. frigida are also associated with environmental variations, such as air temperature, depth and temperature of the wrackbed and substrate composition26,27,34. Although those factors may correlate with the duration of the wrackbed stability, they are also known to modulate the genotype–phenotype relationships and therefore the associated fitness. Controlled experiments in C. frigida show that substrate composition, temperature and density affect the relationship between genotype and survival, development time, body weight and body size (G × E effect)33,38,51,52. In nature, this translates to geographic variation in male and female sizes, as well as variation in size difference among genotypes and between the sexes26,36. This is non-trivial because adult size, and size difference between sexes or between competitors may modify the reproductive advantage associated with the α allele. For instance, experiments showed that a larger size difference between two competitor males relates to a higher success of the larger male37. In other words, local environmental conditions are expected to affect genotype-associated fitness values both for viability and reproductive success. This may enhance the effect of spatial or temporal heterogeneity by changing the slope of the trade-off between survival and fertility in C. frigida. This feature is likely more general and many life-history trade-offs are probably modulated by environmental effects, since genetic correlations are known to vary in direction and strength between environments53. Spatio-temporal environmental heterogeneity thus appears to have a bivalent effect, by causing not only fluctuations in selection but also in the intensity of the trade-off. Both of these aspects interact and favour the maintenance of genetic variation.

Polymorphism generated by antagonistic pleiotropy is also predicted to be enhanced by different trade-off intensities for each sex19. Sex-specific selection on different fitness components frequently occurs in nature, since optimal age/size at maturity or the physiological state to achieve high fertility often differs between sexes9,54. C. frigida provides an empirical case of antagonistic pleiotropy whereby the strength of selection, but not the direction, differs between sexes for each fitness component. Differences between genotypes in size, development time, fertility and survival are stronger for males than for females33,35,36,52. Within a range of realistic parameters, sex-specific effects, even without antagonism for each fitness components, results in sexual antagonism for total fitness, therefore strongly protecting polymorphism19. Moreover, even without sexual antagonism in total fitness, our simulations suggest that sex-specific selection varying between components of fitness delays the fixation of alleles (Supplementary Fig. 11). While this mechanism cannot on its own protect long-term polymorphism, the slower rate of allelic fixation might allow additional factors, such as environmental heterogeneity, to prevent allele fixation22,55.

Inversions are frequently reported as polymorphic and maintained over long evolutionary timescales by balancing selection30,31,61,62. While one of the reasons could be the genetic load linked to the lack of recombination, we argue that antagonistic pleiotropy may also be a more important feature of the inversion systems than previously acknowledged. In fact, the particular architecture of inversions leads them to behave as a single-locus because of the stark reduction of recombination between rearrangements, but they are composed of dozens to hundreds of genes, sometimes interacting in a so-called “supergene” complex29,63,64, where combinations of alleles at different genes lead to highly differentiated phenotypes. Inversion haplotypic rearrangements can thus have large, pleiotropic effects on complex phenotypes, which will be under various selective pressures, possibly in opposing direction30. For example, in the longwing butterfly Heliconius numata an inversion polymorphism determining wing colour pattern is under opposing pleiotropic selection, with survival under positive frequency-dependent selection and reproduction under negative frequency-dependent selection65. In the ruff Calidris pugnax, a polymorphic inversion that determines male reproductive morphs carries inverted alleles with lethal effect on survival but positive effects on testis size, indicating a possibly higher reproductive success, which is also under frequency-dependent selection66. In the rainbow trout Oncorhynchus mykiss, alternate reproductive tactics are determined by a large polymorphic inversion, which involves a trade-off between reproductive output and longevity67. The accumulating evidence from the literature combined with our results on C. frigida thus indicate that contrasted effects of inversions on different fitness components may represent a non-negligible process involved in the maintenance of inversion polymorphism. Clearly, antagonistic pleiotropy and the effect of a wide spectrum of fitness traits on pleiotropic interactions must be considered more carefully when studying the evolutionary importance of structural genomic variants, which are currently increasingly documented to underlie complex phenotypes30,31,61.

## Methods

### Experimental evolution in vivo

Wild C. frigida adults were collected at two locations along the Canadian Atlantic coast, in May 2017 at Cap Espoir, Québec (CE: 48.43087, −64.32778) and in June 2017 at Kamouraska, Québec (KA: 47.56294, −69.87375). The two populations (KA and CE) were kept separated and represented two distinct experimental lines. Wild-caught flies (KA: 303 females, 218 males, CE: 396 females, 570 males) constituted the generation 0 of the experimental evolution and were used to initiate 20 replicates of experimental evolution (2 populations × 2 substrates × 5 replicates).

To disentangle the fitness components, the generations were non-overlapping and we explicitly separated the growing phase from the reproductive phase. For reproduction, the pool of adults was left overnight at 25 °C on a layer of seaweeds, either Laminariaceae or Fucaceae. After 16–20 h, adults were preserved in ethanol. Eggs were collected by flooding the seaweed substrate with 3% salt water in each box. Egg density in the salt water solution was counted over a grid in three subsets of 3 mL each and a volume corresponding to an estimated 1000 eggs was filtered over a dark piece of linen. This subset of 1000 eggs was transferred to a controlled mass of seaweeds to start the growing phase of the next generation, and a subset of the remaining eggs was preserved in ethanol or RNAlater for subsequent genotyping. Upon emergence, adults were collected every day by aspiration and kept in conditions favouring high survival but without reproduction (5 °C, dark, with a solution of Mannitol 0.5%). When all adults emerged, we initiated the following generation with the same procedure, allowing free mating between all adults emerging from one replicate.

Each replicate was kept isolated and maintained for five generations under semi-natural conditions, controlling for density, temperature (25 °C), humidity (50%), light duration (12 h) and substrate. Raising boxes were identical plastic boxes measuring 12 × 8 × 18 cm closed with a hermetic lid perforated with four holes filled with sponge to allow air exchange but preventing adult flies to escape. Stones and sand were put in the bottom of the box to facilitate drainage. Half of the replicates were kept on 90% Laminariaceae/10% Fucaceae and the other half on 90% Fucaceae/10% Laminariaceae, the two main substrates on which C. frigida flies are naturally found in this region (Fig. 1b). Seaweeds were collected (either attached to the substrate or floating in the sea) in Métis sur Mer, Québec (48.66408, −68.07221) repeatedly over the course of the experiment. Seaweed were transported to Laval University and frozen for subsequent use as substrate in the experiment. Freezing allows a good conservation of the seaweed and destroys any eggs, parasites or larvae. The 1000 eggs started on 500 g unfrozen and cut seaweed substrate with subsequent addition of 200 g of seaweeds after ~6 days. This procedure ensured a controlled larval density between replicates.

Only 16 replicates (8 replicates per population) were kept until generation 5 due to stochastic crashes in population size experienced by some replicates because, to avoid founder effects, we allowed reproduction and the initiation of a subsequent generation only for those replicates in which more than 100 adults emerged per generation.

The frequency of the inversion and the proportions of the three inversion genotypes (αα, αβ, ββ) were estimated by genotyping adults (40–95 per replicate) and eggs (28–51 per replicate), using a diagnostic SNP assay26 after having extracted genomic DNA for each individual adult/egg with a lysis procedure. Variation in allele or genotype proportions between generations 1 and 5 was analysed with a generalized linear-mixed model for binomial data in the R package lme468 and lmerTest69 taking into account the identity of the replicate as a random factor and substrate or population as covariates.

### Estimates of fitness

Relative survival rate of each genotype (and sex) was calculated by comparing the genotypic proportions in adults to the genotypic proportions observed in the eggs. The ratio of these values is expected to be 1 if all genotypes survive equally. Survival rate was calculated in 32 replicates (16 replicates at generation 1, 4 replicates at generation 2, 3, 4 and 5). Similarly, we calculated the deviation from random mating in the eggs as the ratio of genotypic proportions observed in the eggs over the expected proportions under random mating, i.e. Hardy–Weinberg proportions of the previous generation. This ratio is expected to be around 1 if mating occurs randomly and if all genotypes reproduce equally. Deviation from random mating in the eggs was estimated in 18 replicates (2 populations at generation 1, and 4 replicates at generations 2, 3, 4 and 5). Differences between genotypes and between sexes in survival rate or in the deviation from random mating in the eggs were tested with a linear mixed model, taking into account the identity of the replicate as random factor, and a paired post-hoc t-test corrected following Benjamini and Hochberg70.

Development time was measured at generation 5 on 757 adults as the number of days between the day of oviposition and adult emergence. Differences in development time between genotypes and sex were tested with a generalized linear-mixed model, based on a Poisson distribution, taking into account the identity of the replicate as a random factor. Each factor and interaction was added sequentially and nested models were built with the R package lme468 and compared to each other with a χ²-test to determine whether the additional factor significantly improved the explicative power of the model.

Female fecundity was assessed in a follow-up experiment on a laboratory population established from eggs laid by wild-caught females from Kamouraska, Québec, raised under the same conditions as described for the previous experiment (25 °C, substrate of 90% Laminariaceae–10% Fucaceae, low density). After 7 days, pupae were collected every day and kept isolated in a 2 mL tube with cotton soaked in 0.05% Mannitol. Upon emergence, adults were kept for a few days at 5 °C in the dark. A total of 161 pairs of one male and one female were formed. On the day of the experiment, each pair was transferred into a small box (5 × 5 × 5 cm) with a mix of Laminariaceae and Fucaceae, and left overnight (for 16 h) at 25 °C (identical conditions as used in the previous experiment for mating and egg laying). After 16 h, if a clutch of eggs was observed, it was collected and preserved on a dark-linen in a 1.5 mL tube of RNAlater, and the parents were preserved in ethanol. If no eggs were observed, the pair was kept in the same experimental box and the eggs were checked again after an extra 8 h. We did this to maximize the number of females for which we could count eggs (eggs after 16 h: 69 females, eggs after 24 h: 120 females). We genotyped 90 females for the inversion using the method described above and counted their eggs under a binocular magnifier (Zeiss Stemi 2000C). Variation in the number of eggs per female in relation to female genotype (αα, αβ, ββ) and time of laying (16 h/24 h) was analysed with a linear model and post hoc pairwise t-test (adjusted following Benjamini and Hochberg70). Whether eggs were laid after 16 or 24 h did not significantly affect the number of eggs per female (F1,88 = 0.09, p = 0.76), or the interaction with genotype (F2,84 = 1.96, p = 0.15), and we therefore pooled the data for all subsequent analyses to derive female fitness parameters in the model.

All statistical analyses were performed using the software R 3.5.071.

### Simulating evolution in silico

To evaluate how fitness differences between genotypes based on a different investment in the trade-off between survival and reproduction modulates the evolution of the inversion frequency, we developed an individual-based model inspired by the results of the experimental evolution trials and by the biological characteristics of C. frigida (Fig. 3a).

The model is fully described in Supplementary Methods following the ODD protocol72 and the basic principles of the model are as follows: generations are non-overlapping, the time step is one generation and each generation proceeds in two phases, growth and reproduction. Growth phase: Each egg goes through a growing period, during which its survival is determined by chance following a binomial law with a survival probability determined by the product between global egg-to-adult survival rate (30%) and relative genotype-sex-specific survival (SXX-s) depending on its sex (s = f or m) and genotype (XX = αα or αβ or ββ). The surviving larva then matures into an adult if its development time is shorter than the duration of its habitat. Individual development time (Di), is calculated for each individual larva as the cubic root of three values randomly drawn from a uniform distribution whose mean and range depends on sex and genotype (means are the experimental estimates reported in the result section for each genotype and sex, and range is determined with a variation coefficient of 0.5). We chose this distribution as the one fitting best the measured experimental data of the development time. The duration of habitat availability is randomly drawn for each individual larva from a uniform distribution determined by two parameters: mean duration (Amean) and variability (Avar). Mean duration is shared by all individuals of a given simulation, and thus takes into account the non-independence in the availability of the habitat, i.e. the fact that when the wrackbed is removed by a high tide or a storm, all individuals are affected at the same time. Variability represents individual heterogeneity in the total duration before the wrackbed is removed, which depends for instance, at which date a given egg was laid or whether all patches of wrackbed are deposited or removed at the same time. Reproduction phase: All females reproduce once and lay a number of eggs determined by the product between the number of eggs laid by a female (70 eggs) and genotype-specific female fertility (TXX-f). For each female, a male partner is randomly drawn from the pool of reproductive males. This pool of reproductive males is generated at each reproductive step based on the distribution of adult males {Nαα-m; Nαβ-m; Nββ-m}, corrected by genotype-specific male reproductive success (TXX-m). Note that this procedure allows to account for the fact that each male can mate several times. Additional models taking into account a frequency-dependant effect are presented in Supplementary Information. Egg genotype is determined by Mendelian inheritance from parental genotypes, by randomly drawing one allele from the mother, and one allele from the father, and egg sex is determined by chance with no bias (sex-ratio = 0.5). A subset of K eggs initiates the next generation, mirroring the census made in the experiment or a limited carrying capacity in the wild. At each generation, we record the proportions of the three genotypes in the eggs and the adults. The model was implemented in Rust 1.32.0 (9fda7c223 2019-01-16).

The model outcomes were analysed at three levels.

1. (i)

First, we ran the model for five generations with parameters drawn from the experiment (Table 1, Supplementary Table 7) and no limited duration of habitat availability (Amean = 30 days) while varying the relative male reproductive success (30 replicates per set of parameters). The fit of each simulation to empirical data was quantified by computing the normalized root‐mean‐squared error (nRMSE) for each genotypic proportion from generation 1 to 5. The average nRMSE over the six variables (αα/αβ/ββ proportions in the eggs and the adults), and over the 30 replicates, was taken as an index of fit, with the best predicting scenarios having the smallest values. Difference of mean nRMSE between the best scenarios was tested with a t-test based on the 30 replicates, corrected following70.

2. (ii)

Second, to simulate evolution in a natural population, we then ran the model with larger K (10,000) for 200 generations, with 30 replicates per set of parameters, and included variation in habitat availability (Supplementary Table 7). The equilibrium in genotypic proportions was compared to the frequencies observed in nature and we explored the combination of parameters possibly influencing the frequency of the inversion. The proportion of the three genotypes under each scenario was visualized in ternary plots built with the R package ggtern73. We tested the role of density by exploring several sets of survival values based on previous laboratory studies33 (Supplementary Table 3). For relative male reproductive success, the full range of parameters was explored because this parameter could not be estimated empirically and possibly varies between populations with natural variation in adult size26,51. Habitat availability was set between 7 and 20 days, i.e. the range of development time found in our experimental conditions, to estimate the interplay between those two factors. Yet, in natural conditions, both the range of wrackbed availability and development time are expected to be wider. Development time varies with density and temperature, although the ordering of emergence between the three male genotypes remains unchanged. Wrackbeds are expected to be removed cyclically by spring tides, so the actual availability would be slightly less than 14 or 28 days, but they are sometimes observed to last shorter because of storms43. Finally, for the parameters that are more likely to vary in natural populations (male relative success, duration of habitat availability, density, variability in the duration of habitat availability), we explored which combinations of realistic parameters maintained polymorphism after 200 generations, what was the mean frequency of the inversion at equilibrium after 100 replicates, which portion of the parameter space lead to polymorphism and whether overdominance or sexual antagonism emerged for total fitness.

3. (iii)

Third, the backbone of the model was used to theoretically explore the range of conditions under which antagonistic pleiotropy could maintain polymorphism at evolutionary time-scales when combined with sex-specific effects and dominance, (K = 10,000, 500 generations, 100 replicates per set of parameters, initial proportions were set to Hardy–Weinberg proportions, with the frequency of α being 0.5).These simulations explored the whole theoretical parameter range for survival and reproduction (Table 1, Supplementary Table 7), with either various scenarios of dominance, coded by the parameters Hs/Ht, or sex-specific effects with independent values for sm/tm and sf/tf ranging between 0 and 1. We surveyed the proportions of the simulations that led to maintenance of polymorphism vs. the simulations in which one of the genotypes got fixed, as well as the emerging mechanism at the level of total fitness (overdominance in one/both sex, sexual antagonism).

Total fitness (WXX-s) was calculated as the product of relative survival rate and reproductive success, for each genotype or allele as

$$W_{xx - s} = S_{xx - s} \cdot T_{xx - s}$$
(1)
$$w_{\alpha - s} = w_{\alpha a - s} \, + \, \frac{1}{2} \, \cdot \, w_{\alpha \beta - s}$$
(2)
$$w_{\beta - s} = w_{\beta \beta - s} \, + \, \frac{1}{2} \, \cdot \, w_{\alpha \beta - s}$$
(3)

Overdominance for total fitness corresponded to cases in which

$$w_{a\beta - s} \, > \, w_{\alpha \alpha - s}\,\, \& \,\, w_{a\beta - s} \, > \, w_{\beta \beta - s}$$
(4)

Sexual antagonism for total fitness emerged in cases under which

$$w_{a - m} \, > \, w_{\beta - m}\,\, \& \,\, w_{a - f} \, < \, w_{\beta - f}$$
(5)

or

$$w_{a - m} \, < \, w_{\beta - m}\,\, \& \,\, w_{a - f} \, > \, w_{\beta - f}$$
(6)

### Reporting summary

Further information on research design is available in the Nature Research Reporting Summary linked to this article.

## Data availability

The authors declare that all data supporting the findings of this study are available within the paper and its supplementary information files. The experimental and simulated data underlying all figures and all supplementary figures are provided as a Source Data file.

## Code availability

Simulation code and parameters files are available at https://github.com/enormandeau/coelopa_fastsim.

## References

1. 1.

Brian, Charlesworth & Hugues, K. A. The maintenance of genetic variation in life-history traits. In Evolutionary Genetics from Molecules to Morphology (eds Singh, R. S. & Krimbas, C. B.) 369–392 (Cambridge University Press, Cambridge, 2000).

2. 2.

Charlesworth, B. Causes of natural variation in fitness: evidence from studies of Drosophila populations. Proc. Natl Acad. Sci. USA 112, 1662–1669 (2015).

3. 3.

Llaurens, V., Whibley, A. & Joron, M. Genetic architecture and balancing selection: the life and death of differentiated variants. Mol. Ecol. 26, 2430–2448 (2017).

4. 4.

Gloss, A. D. & Whiteman, N. K. Balancing selection: walking a tightrope. Curr. Biol. 26, R73–R76 (2016).

5. 5.

Prout, Timothy. How well does opposing selection maintain variation? In Evolutionary Genetics From Molecules to Morphology (eds Singh, R. S. & Krimbas, C. B.) 157–181 (Cambridge University Press, Cambridge, 2000).

6. 6.

Levene, H. Genetic equilibrium when more than one ecological niche is available. Am. Nat. 87, 331–333 (1953).

7. 7.

Hedrick, P. W. Genetic polymorphism in heterogeneous environments: the age of genomics. Annu. Rev. Ecol. Evol. Syst. 37, 67–93 (2006).

8. 8.

Wittmann, M. J., Bergland, A. O., Feldman, M. W., Schmidt, P. S. & Petrov, D. A. Seasonally fluctuating selection can maintain polymorphism at many loci via segregation lift. Proc. Natl Acad. Sci. USA 114, E9932–E9941 (2017).

9. 9.

Barson, N. J. et al. Sex-dependent dominance at a single locus maintains variation in age at maturity in salmon. Nature 528, 405 (2015).

10. 10.

Grieshop, K. & Arnqvist, G. Sex-specific dominance reversal of genetic variation for fitness. PLoS Biol. 16, e2006810 (2018).

11. 11.

Pearse, D. E. et al. Sex-dependent dominance maintains migration supergene in rainbow trout. Nat. Ecol. Evol. 3, 1731–1742 (2019).

12. 12.

Stearns, S. C. Trade-offs in life-history evolution. Funct. Ecol. 3, 259–268 (1989).

13. 13.

Johnston, S. E. et al. Life history trade-offs at a single locus maintain sexually selected genetic variation. Nature 502, 93–95 (2013).

14. 14.

Rose, M. R. Antagonistic pleiotropy, dominance, and genetic variation. Heredity 48, 63 (1982).

15. 15.

Rose, M. R. Life history evolution with antagonistic pleiotropy and overlapping generations. Theor. Popul. Biol. 28, 342–358 (1985).

16. 16.

Hedrick, P. W. Antagonistic pleiotropy and genetic polymorphism: a perspective. Heredity 82, 126–133 (1999).

17. 17.

Rose, M. R., Service, P. M. & Hutchinson, E. W. Three approaches to trade-offs in life-history evolution. In Genetic Constraints on Adaptive Evolution (ed Loeschcke, V.) 91–105 (1987).

18. 18.

Curtsinger, J. W., Service, P. M. & Prout, T. Antagonistic pleiotropy, reversal of dominance, and genetic polymorphism. Am. Nat. 144, 210–228 (1994).

19. 19.

Zajitschek, F. & Connallon, T. Antagonistic pleiotropy in species with separate sexes, and the maintenance of genetic variation in life‐history traits and fitness. Evolution, 72, 1306–1316 (2018).

20. 20.

Brown, K. & Kelly, J. Antagonistic pleiotropy can maintain fitness variation in annual plants. J. Evol. Biol. 31, 46–56 (2018).

21. 21.

Tellier, A., Villaréal, L. M. M. A. & Giraud, T. Antagonistic pleiotropy may help population-level selection in maintaining genetic polymorphism for transmission rate in a model phytopathogenic fungus. Heredity 98, 45 (2006).

22. 22.

Connallon, T. & Chenoweth, S. F. Dominance reversals and the maintenance of genetic variation for fitness. PLoS Biol. 17, e3000118 (2019).

23. 23.

Dooren, T. J. V. Protected polymorphism and evolutionary stability in pleiotropic models with trait‐specific dominance. Evolution 60, 1991–2003 (2006).

24. 24.

Troth, A., Puzey, J. R., Kim, R. S., Willis, J. H. & Kelly, J. K. Selective trade-offs maintain alleles underpinning complex trait variation in plants. Science 361, 475–478 (2018).

25. 25.

Mojica, J. P., Lee, Y. W., Willis, J. H. & Kelly, J. K. Spatially and temporally varying selection on intrapopulation quantitative trait loci for a life history trade‐off in Mimulus guttatus. Mol. Ecol. 21, 3718–3728 (2012).

26. 26.

Mérot, C. et al. Intercontinental karyotype–environment parallelism supports a role for a chromosomal inversion in local adaptation in a seaweed fly. Proc. R. Soc. B Biol. Sci. 285, 20180519 (2018).

27. 27.

Day, T., Dawe, C., Dobson, T. & Hillier, P. A chromosomal inversion polymorphism in Scandinavian populations of the seaweed fly, Coelopa frigida. Hereditas 99, 135–145 (1983).

28. 28.

Butlin, R., Collins, P., Skevington, S. & Day, T. Genetic variation at the alcohol dehydrogenase locus in natural populations of the seaweed fly, Coelopa frigida. Heredity 48, 45–55 (1982).

29. 29.

Hoffmann, A. A. & Rieseberg, L. H. Revisiting the impact of inversions in evolution: from population genetic markers to drivers of adaptive shifts and speciation? Annu. Rev. Ecol. Evol. Syst. 39, 21–42 (2008).

30. 30.

Faria, R., Johannesson, K., Butlin, R. K. & Westram, A. M. Evolving inversions. Trends Ecol. Evol. 34, 239–248 (2019).

31. 31.

Wellenreuther, M. & Bernatchez, L. Eco-evolutionary genomics of chromosomal inversions. Trends Ecol. Evol. 33, 427–440 (2018).

32. 32.

Butlin, R. & Day, T. Genic and karyotypic selection on an inversion polymorphism in the seaweed fly, Coelopa frigida. Heredity 54, 267–274 (1985).

33. 33.

Butlin, R., Collins, P. & Day, T. The effect of larval density on an inversion polymorphism in the seaweed fly, Coelopa frigida. Heredity 52, 415–423 (1984).

34. 34.

Butlin, R. & Day, T. Environmental correlates of inversion frequencies in natural populations of seaweed flies (Coelopa frigida). Heredity 62, 223–232 (1989).

35. 35.

Butlin, R. & Day, T. Adult size, longevity and fecundity in the seaweed fly, Coelopa frigida. Heredity 54, 107–110 (1985).

36. 36.

Gilburn, A. S. & Day, T. H. Sexual dimorphism, sexual selection and the αβ chromosomal inversion polymorphism in the seaweed fly, Coelopa frigida. Proc. R. Soc. Lond. B Biol. Sci. 257, 303–309 (1994).

37. 37.

Butlin, R., Read, I. & Day, T. The effects of a chromosomal inversion on adult size and male mating success in the seaweed fly, Coelopa frigida. Heredity 49, 51–62 (1982).

38. 38.

Butlin, R. & Day, T. The effect of larval competition on development time and adult size in the seaweed fly, Coelopa frigida. Oecologia 63, 122–127 (1984).

39. 39.

Gilburn, A. S., Crean, C. S. & Day, T. H. Sexual selection in natural populations of seaweed flies: variation in the offspring fitness of females carrying different inversion karyotypes. Proc. R. Soc. Lond. B 263, 249–256 (1996).

40. 40.

Day, T., Dobson, T., Hillier, P., Parkin, D. & Clarke, B. Different rates of development associated with the alcohol dehydrogenase locus in the seaweed fly, Coelopa frigida. Heredity 44, 321 (1980).

41. 41.

Day, T. H., Foster, S. P. & Engelhard, G. Mating behavior in seaweed flies (Coelopa frigida). J. Insect Behav. 3, 105–120 (1990).

42. 42.

Gilburn, A. S. & Day, T. H. Female mating behaviour, sexual selection and chromosome I inversion karyotype in the seaweed fly, Coelopa frigida. Heredity 82, 276–281 (1999).

43. 43.

Dobson, T. Studies on the biology of the kelp-fly Coelopa in Great Britain. J. Nat. Hist. 8, 155–177 (1974).

44. 44.

Roff, D. & Fairbairn, D. The evolution of trade‐offs: where are we? J. Evol. Biol. 20, 433–447 (2007).

45. 45.

Roff, D. Trade-offs between growth and reproduction: an analysis of the quantitative genetic evidence. J. Evol. Biol. 13, 434–445 (2000).

46. 46.

Kingsolver, J. G. & Diamond, S. E. Phenotypic selection in natural populations: what limits directional selection? Am. Nat. 177, 346–357 (2011).

47. 47.

Teuschl, Y., Reim, C. & Blanckenhorn, W. Correlated responses to artificial body size selection in growth, development, phenotypic plasticity and juvenile viability in yellow dung flies. J. Evol. Biol. 20, 87–103 (2007).

48. 48.

Kruuk, L. E. A new explanation for unexpected evolution in body size. PLoS Biol. 15, e2001832 (2017).

49. 49.

Bonnet, T., Wandeler, P., Camenisch, G. & Postma, E. Bigger is fitter? Quantitative genetic decomposition of selection reveals an adaptive evolutionary decline of body mass in a wild rodent population. PLoS Biol. 15, e1002592 (2017).

50. 50.

Fournier‐Level, A. et al. Paths to selection on life history loci in different natural environments across the native range of Arabidopsis thaliana. Mol. Ecol. 22, 3552–3566 (2013).

51. 51.

Berdan, E., Rosenquist, H., Larson, K. & Wellenreuther, M. Inversion frequencies and phenotypic effects are modulated by the environment: insights from a reciprocal transplant study in Coelopa frigida. Evol. Ecol. 32, 683–698 (2018).

52. 52.

Edward, D. A. & Gilburn, A. S. Male‐specific genotype by environment interactions influence viability selection acting on a sexually selected inversion system in the seaweed fly, Coelopa frigida. Evolution 67, 295–302 (2013).

53. 53.

Sgro, C. & Hoffmann, A. Genetic correlations, tradeoffs and environmental variation. Heredity 93, 241 (2004).

54. 54.

Cornwallis, C. K., Dean, R. & Pizzari, T. Sex-specific patterns of aging in sexual ornaments and gametes. Am. Nat. 184, E66–E78 (2014).

55. 55.

Connallon, T. & Clark, A. G. A general population genetic framework for antagonistic selection that accounts for demography and recurrent mutation. Genetics 190, 1477–1489 (2012).

56. 56.

Le Poul, Y. et al. Evolution of dominance mechanisms at a butterfly mimicry supergene. Nat. Commun. 5, 5644 (2014).

57. 57.

Kenney‐Hunt, J. P. & Cheverud, J. M. Differential dominance of pleiotropic loci for mouse skeletal traits. Evol. Int. J. Org. Evol. 63, 1845–1851 (2009).

58. 58.

Wang, J. et al. A Y-like social chromosome causes alternative colony organization in fire ants. Nature 493, 664–668 (2013).

59. 59.

Kirkpatrick, M. How and why chromosome inversions evolve. PLoS Biol. 8, e1000501 (2010).

60. 60.

Berdan, E. L., Blanckaert, A., Butlin, R. K. & Bank, C. Muller’s Ratchet and the long-term fate of chromosomal inversions. Prepint at https://doi.org/10.1101/606012 (2019).

61. 61.

Wellenreuther, M., Mérot, C., Berdan, E. & Bernatchez, L. Going beyond SNPs: the role of structural genomic variants in adaptive evolution and species diversification. Mol. Ecol. 28, 1203–1209 (2019).

62. 62.

Hoffmann, A. A., Sgrò, C. M. & Weeks, A. R. Chromosomal inversion polymorphisms and adaptation. Trends Ecol. Evol. 19, 482–488 (2004).

63. 63.

Schwander, T., Libbrecht, R. & Keller, L. Supergenes and complex phenotypes. Curr. Biol. 24, R288–R294 (2014).

64. 64.

Kirkpatrick, M. The evolution of genome structure by natural and sexual selection. J. Hered. 108, 3–11 (2017).

65. 65.

Chouteau, M., Llaurens, V., Piron-Prunier, F. & Joron, M. Polymorphism at a mimicry supergene maintained by opposing frequency-dependent selection pressures. Proc. Natl Acad. Sci. USA 114, 8325–8329 (2017).

66. 66.

Küpper, C. et al. A supergene determines highly divergent male reproductive morphs in the ruff. Nat. Genet. 48, 79–83 (2016).

67. 67.

Christie, M. R., McNickle, G. G., French, R. A. & Blouin, M. S. Life history variation is maintained by fitness trade-offs and negative frequency-dependent selection. Proc. Natl Acad. Sci. USA 115, 4441–4446 (2018).

68. 68.

Bates, D., Maechler, M., Bolker, B. & Walker, S. lme4: linear mixed-effects models using Eigen and S4. R. Package Version 1, 1–23 (2014).

69. 69.

Kuznetsova, A., Brockhoff, P. B. & Christensen, R. H. B. lmerTest package: tests in linear mixed effects models. J. Stat. Softw. 82 (2017).

70. 70.

Benjamini, Y. & Hochberg, Y. Controlling the false discovery rate: a practical and powerful approach to multiple testing. J. R. Stat. Soc. Ser. B Methodol. 57, 289–300 (1995).

71. 71.

R Core Team. R: A Language and Environment for Statistical Computing (R Foundation for Statistical Computing, Vienna, Austria, 2018).

72. 72.

Grimm, V. et al. The ODD protocol: a review and first update. Ecol. Model. 221, 2760–2768 (2010).

73. 73.

Hamilton, N. E. & Ferry, M. ggtern: ternary diagrams using ggplot2. J. Stat. Softw. 87, 1–17 (2018).

## Acknowledgements

We are very grateful to C. Babin, B. Labbé and L. Logacheva for help in the field and with raising and genotyping the flies. We would like to thank F. Larochelle, L. Johnson and J.-C. Therrien for their support in establishing the fly rearing conditions. We would also like to thank E. Berdan for valuable discussion about Coelopa frigida biology and the inversion dynamics. M. Laporte and H. Cayuela provided constructive comments on the manuscript. This research was supported by a Discovery research grant from the Natural Sciences and Engineering Research Council of Canada (NSERC) to L.B., by the Canadian Research Chair in genomics and conservation of aquatic resources held by L.B. and by the Swedish Research Council grant 2012-3996 to M.W. C.M. was supported by a post-doctoral fellowship from the FRQNT and Fond de Recherche Québec (FRQS) and a Banting Postdoctoral Fellowship from the NSERC.

## Author information

Authors

### Contributions

C.M., M.W. and L.B. designed the research. C.M. performed the research and analyzed the data. E.N., C.M. and V.L. developed the model. C.M., V.L., E.N., M.W. and L.B. wrote the manuscript.

### Corresponding author

Correspondence to Claire Mérot.

## Ethics declarations

### Competing interests

The authors declare no competing interests.

Peer review information Nature Communications thanks the anonymous reviewers for their contribution to the peer review of this work. Peer reviewer reports are available.

Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

## Rights and permissions

Reprints and Permissions

Mérot, C., Llaurens, V., Normandeau, E. et al. Balancing selection via life-history trade-offs maintains an inversion polymorphism in a seaweed fly. Nat Commun 11, 670 (2020). https://doi.org/10.1038/s41467-020-14479-7

• Accepted:

• Published:

• ### Metamorphosis of a butterfly inversion

• Clemens Küpper

Nature Genetics (2021)

• ### Mutation load at a mimicry supergene sheds new light on the evolution of inversion polymorphisms

• Paul Jay
• , Mathieu Chouteau
• , Annabel Whibley
• , Héloïse Bastide
• , Hugues Parrinello
• , Violaine Llaurens
•  & Mathieu Joron

Nature Genetics (2021)

• ### Evidence for opposing selective forces operating on human-specific duplicated TCAF genes in Neanderthals and humans

• PingHsun Hsieh
• , Vy Dang
• , Mitchell R. Vollger
• , Yafei Mao
• , Tzu-Hsueh Huang
• , Philip C. Dishuck
• , Carl Baker
• , Stuart Cantsilieris
• , Alexandra P. Lewis
• , Katherine M. Munson
• , Melanie Sorensen
• , AnneMarie E. Welch
• , Jason G. Underwood
•  & Evan E. Eichler

Nature Communications (2021)