Introduction

A central theme in ecology concerns the composition of an ecological community in terms of specialist species, which utilise a narrow range of resources, and generalist species, which utilise a wide range of resources. It is often assumed that a trade-off exists between niche breadth (the range of resources that a particular species can utilise) and the maximum efficiency of resource utilisation: specialists can outperform generalists, but only when they are in a habitat that provides optimal resources (Dykhuizen and Davies 1980; Futuyma and Moreno 1988; van Tienderen 1991; Wilson and Yoshimura 1994; Kassen 2002; Devictor et al. 2010). Specialist and generalist species coexist in many environments, but the relative abundance of specialists and generalists (the specialist-generalist balance) may vary between environments (Hulburt 1985; Rohde 1992; Jonsen and Fahrig 1997; Kassen 2002; Clavero and Brotons 2010; Davey et al. 2012). A number of factors are thought to influence the specialist-generalist balance. These include environmental factors such as the degree of environmental disturbance and habitat heterogeneity (in space and time), both of which are predicted to favour generalists (Futuyma and Moreno 1988; Kassen 2002; Marvier et al. 2004; Devictor et al. 2008; Nurmi and Parvinen 2008; Débarre and Lenormand 2011; Nagelkerke and Menken 2013) and life-history traits such as differential competitive and dispersal ability between specialists and generalists (Kisdi 2002; Nurmi and Parvinen 2008; Büchi and Vuilleumier 2014). The degree of specialisation of a species can also affect the selection of other ecological traits, in an environment-dependent matter (Büchi and Vuilleumier 2016).

In this work, we focus on how resources (e.g. food size May and Macarthur 1972) are distributed along a niche axis and how this affects the specialist-generalist balance. Previous studies have shown, both theoretically (Nagelkerke and Menken 2013) and experimentally (Dykhuizen and Davies 1980; Kassen 2002), that the spatial or temporal distribution of resources in an environment can affect the specialist-generalist balance, such that specialists prosper in homogeneous environments, whereas generalists are favoured by heterogeneous environments. In particular, Nagelkerke and Menken (2013) showed theoretically that an environment that consists of large homogeneous patches tends to be occupied by specialist species (one per patch), but an environment that consists of many small patches is more likely to be occupied by a single generalist species. Here, we show that even in an environment that is spatially and temporally homogeneous, the ‘resource spectrum’, or the distribution of resources along a niche axis (Austin 1985), can have a strong effect on the specialist-generalist balance. An empirical example of such a resource spectrum is the distribution of seed sizes, which resulted in the classic case of niche partitioning in finch beak sizes (Weiner 1994). Another example is the continuous distribution of light frequencies available for phytoplankton growth in underwater environments, which is predicted to change from a smooth frequency distribution to a distribution containing spectral gaps with increasing water depth (Stomp et al. 2007). A resource spectrum can be smooth, by which we mean that it provides a continuously varying range of resources, or ‘grainy’, by which we mean that there are gaps in the spectrum, such an an absence of seeds of a particular size, or an absence of light at a particular wavelength. Our results show that a transition from a community dominated by generalists to one dominated by specialists can arise on changing the graininess of the resource spectrum in a well-mixed environment. Generalists are favoured by an environment with a smooth resource spectrum, while specialists are favoured when the resource spectrum contains gaps. We further show that a grainy resource spectrum favours specialists via a feedback mechanism which we term ‘resource spectrum engineering’, in which the presence of a small number of specialist species in a community creates gaps in the effective resource spectrum experienced by other species, and these gaps favour the proliferation of other specialists over generalists. Depending on how the resources are distributed, this effect can lead either to a broad coexistence of a range of strategies in the community or it can lead to a situation in which specialists ultimately take over the whole community. We term the specialists which catalyse this process ‘resource spectrum engineers’ in analogy with the concept of ecosystem engineers, which are species that alter the environment in a way that has a significant impact on other species (Jones et al. 1994).

Importantly, we use a model which includes not only a spectrum of resources but also a wide range of specialist-generalist strategies, from extreme specialists that can only utilise around 0.2% of the total resource spectrum, to generalists that can utilise all resources equally. Empirical studies have observed a continuous range of specialist-generalist strategies in natural communities (Thompson et al. 1998; Aguilar et al. 2006), yet most theoretical work (with certain exceptions, such as Weiner and Xiao 2012; Büchi and Vuilleumier 2014) has assumed a dichotomy between pure specialism and pure generalism (van Tienderen 1991; Wilson and Yoshimura 1994; McPeek 1996; Egas et al. 2004; Abrams 2006; Nagelkerke and Menken 2013). Inclusion of the full range of specialist-generalist strategies in our model reveals the resource spectrum engineering mechanism, since this mechanism is initiated by the occupation of specific niches in the resource spectrum by extreme specialists. We show that even a few such occupied niches can drastically reduce the competitiveness of generalists across the entire environment.

First, we will outline the details of the individual-based simulation model that we use in this work, which builds on similar models that have been used to study related ecological questions (Gravel et al. 2006; Kadmon and Allouche 2007; Büchi et al. 2009; Bar-Massada et al. 2014). We will then discuss the results of our simulations for two types of environmental resource spectrum. First, we investigate a continuous resource spectrum whose graininess we can vary by changing a single control parameter. For this model, we observe a shift from generalism to specialism with increasing resource spectrum graininess, and we find that this shift depends on the presence of highly specialised species in the community.

Second, to investigate this phenomenon in greater detail and in a more systematic way, we construct a more idealised model that has a stepped resource spectrum containing discrete grains, each of which has a distinct value of an environmental parameter. This model shows a sharp transition from generalism to specialism, with greater variability in grain size favouring specialists (similar results are also obtained for a model in which the grain size remains constant but the size of the environmental gaps between grains is allowed to vary, as we discuss in Appendix 2). An advantage of the stepped resource spectrum model is that it allows us to treat each grain separately, so that we can dynamically track the occupancy of different parts of the resource spectrum in our simulations, allowing us to observe the effects of resource spectrum engineering in a more direct way than is possible with our first (more naturalistic) model. The fact that similar results are found in both of these models suggests that the phenomena which emerge from our study are generic and may be relevant to real ecosystems. Our results may have implications for ecosystem management, which we briefly discuss at the end of the paper.

Model of community dynamics

The model of community dynamics used in this work is similar to that employed by Tilman (2004), Gravel et al. (2006) and Büchi and Vuilleumier (2014, 2016). We use an individual-based model in which individuals of many species compete with each other to occupy a fixed number of sites on a lattice. The environment is defined by assigning to each site a value of an environmental parameter E; in our work, the resource spectrum is then the frequency distribution of values of E across the sites. Each species has a preferred value of E, as well as a range of E values that it can tolerate: for generalists, this range is large whereas for specialists, it is small. Although simple, this model allows exploration of the effect of a wide variety of inputs on community assembly. For example, previous work has focused on the immigration rate (Gravel et al. 2006), habitat heterogeneity (Kadmon and Allouche 2007; Bar-Massada et al. 2014) and dispersal of species (Büchi et al. 2009). Here, we are interested in the effects of the resource spectrum, in the non-spatial case where the dispersal range between sites is infinite.

More formally, the model is defined as follows. Our system is composed of N = 10,000 sites, each of which is characterised by a value of the environmental parameter E which lies in the range 0 to 1. At any given time, each site is occupied by a single individual. As in Büchi and Vuilleumier (2014), each individual has a strategy defined by two parameters: μ, its preferred value of E, and σ, which defines the habitable range of E values (or niche breadth) for that species. A large value of σ corresponds to a generalist strategy, and a small value of σ to a specialist strategy. Two individuals with the same strategy (μ, σ) are assumed to belong to the same species. In contrast to previous work (e.g. Büchi and Vuilleumier 2014), we model a very wide range of specialist-generalist strategies: the values of σ sampled in our simulations range from σ = 10− 3 (such that a species can use only about 0.2% of the total resource spectrum) to σ = 10 (such that a species can use the entire resource spectrum and the preferred resource, i.e. value of μ, is irrelevant).

Our simulations are initialised by populating each site with an individual whose value of μ is drawn uniformly from the range 0 to 1 and whose value of σ is drawn uniformly in logarithmic space from the range 10− 3 to 10. In practice, we initialise our simulations by creating a pool of 200 species with values of μ and σ sampled as detailed in the text, and filling the sites by sampling from this pool. The logarithmic sampling of σ is achieved by sampling a random number u uniformly from the range − 3 to 1 and then setting the niche breadth σ = 10u. The geometric mean σ value at the start of our simulations is thus 10− 1.

At each generation, we repopulate each site either by an immigrant or by an offspring of the previous generation. The immigration rate in our simulations is kept fixed at I = 20 per generation; i.e. at each generation, 20 randomly chosen sites are replaced by individuals with new values of μ and σ sampled as described above. This immigration rate is chosen to allow reasonably rapid approach to a steady state while preserving the effects of interspecies competition (see Discussion).

The remaining NI = 9980 sites are populated by offspring of the previous generation, which compete such that the probability Pi that an offspring of a parent i with strategy μ, σ occupies a site with environmental parameter value E, is given by

$$ P_{i} = \frac{F_{i}}{\sum_{j=1}^{N}(F_{j})}, $$
(1)

where Fi is the value of a ‘competitiveness function’ for that parent. The sum in the denominator is over the values of this function for all individuals present in the previous generation. The competitiveness function F is given by

$$ F(\mu,\sigma; E) = \frac{ \exp\left( -\frac{{\Delta}^{2}}{2\sigma^{2}}\right) }{ \int_{-\frac{1}{2}}^{\frac{1}{2}} \mathrm{d} x \exp\left( -\frac{x^{2}}{2\sigma^{2}}\right)} $$
(2)

where Δ measures the distance between the preferred value μ of the environmental parameter and its actual value E at that site. This form of the competitiveness function, which is plotted in Fig. 1, incorporates a trade-off between niche breadth and maximal fecundity (Futuyma and Moreno 1988; Wilson and Yoshimura 1994; Marvier et al. 2004). In particular, the normalisation in (2) ensures that generalist species (large σ) are less competitive in their optimal habitat than specialist species (small σ). To avoid edge effects at the boundaries of the resource spectrum, we implement periodic boundary conditions in the environmental parameter; in other words, we define the distance Δ as Δ(μ, E) = min{|μE|,1 −|μE|}. This construction is illustrated in Fig. 1; its effect can be seen for species (b), where the competitiveness function ‘wraps around’ from the right-hand side of the E axis to the left-hand side. Although such periodicity is rarely (if ever) a feature of a real habitat, it is important in terms of understanding the effects of varying the resource spectrum. Without this periodicity, a species with a value of μ close to \(\frac {1}{2}\) would have a built-in advantage relative to those with μ close to 0 or 1, because the area under its competitiveness function F would be larger (see Fig. 1). It would be difficult to disentangle this ‘edge effect’ from effects arising from the structure of the resource spectrum.

Fig. 1
figure 1

Competitiveness function F(μ, σ;E), plotted for three model species, a, b and c, with decreasing degrees of specialism (increasing σ: the parameters (μ, σ) for species a, b and c are, respectively, (0.3,0.03), (0.95,0.1) and (0.5,10). The area under the curve, representing overall competitiveness, is equal for all species. The competitiveness function is periodic on the E axis, so that there is no competitive advantage for species whose preferred μ is close to the middle of the spectrum

Our simulations are run for 30,000 generations to allow us to investigate the long-time specialist-generalist balance in our models. To characterise community composition, we use two measures. The mean value of σ allows us to detect shifts in the specialist-generalist balance. Because we sample over a wide range of σ values, from a logarithmic distribution, it is most appropriate to measure the geometric mean value of σ, defined as \(\left ({\Pi }_{i=1}^{N}\sigma _{i}\right )^{1/N}\), where σi is the value of σ for the i-th individual in the community. However, use of the arithmetic mean would produce qualitatively similar results. We also characterise community diversity by computing the Shannon index (Lande 1996). This is defined as \(-\sum _{j=1}^{M}p_{j}\ln {p_{j}}\), where the sum (1…M) is over all species present in the community and pj is the relative abundance of species j within the community. Table 1 lists the parameters used in our work.

Table 1 List of parameters used in our simulations and their values/range of values

Our model is similar to that used previously by Tilman (2004), who used a fixed value of σ to simulate community assembly, Gravel et al. (2006), who used the model to investigate a continuum between niche and neutral models, Büchi and Vuilleumier (2014), who used it to investigate the effects of dispersal on the specialist-generalist balance, and Büchi and Vuilleumier (2016), who used it to investigate trait associations between specialisation and other ecological strategies. However, our implementation differs from previous work in two important ways. First, although it is defined in terms of sites, this is a non-spatial model: the only factor that governs whether an offspring can occupy a given site is its strategy, because the dispersal range of all species extends across the entire habitat. Second, we use periodic boundary conditions in the environmental parameter to avoid edge effects. Previous work (e.g. Büchi and Vuilleumier 2014) achieved a similar end by restricting the allowed values of μ to a subset of the full environmental space. However, this approach has the disadvantage that niche breadths must be kept sufficiently small that no unwanted boundary effects arise: in other words, the degree of generalism that is possible is restricted. By contrast, with a periodic environment axis, we can accommodate any degree of specialism or generalism and the structure of the community that emerges depends only on the distribution of environmental values E and the pool of immigrant strategies.

A continuous resource spectrum with tunable coarse-graining

The aim of our study is to investigate how the resource spectrum, i.e. the distribution of values of the resource parameter E across the sites, affects the emergent balance between specialism and generalism. We begin with a model in which the resource parameter E varies continuously, as it generally does in nature. This model is constructed such that the graininess of the resource spectrum can be tuned by adjusting a single parameter.

Assignment of resource values

To achieve easily tunable graininess of the resource spectrum, we set the resource value of site i (for i = 1…N) to

$$ E_{i} = \frac{\sum_{j=1}^{i} x_{j}}{\sum_{j=1}^{N} x_{j}} , $$
(3)

where the xi values, which are proportional to the gaps in the resource spectrum between adjacent sites, are chosen from the power-law probability distribution

$$ p(x) = \frac{1/\rho - 1}{x^{1/\rho}} \enspace \enspace ; \enspace \enspace x>1. $$
(4)

The resulting resource spectra are illustrated in Fig. 2. Choosing a small value of the parameter ρ produces a fine-grained resource spectrum (Fig. 2(a)), in which the value of E varies smoothly and continuously. Choosing a larger value of ρ produces a grainier resource spectrum (Fig. 2(b)), in which multiple sites have similar values of E (the flatter parts of the spectrum in Fig. 2(c)). We term these clusters of similar sites ‘grains’. There are also values of E that are under-represented in the resource spectrum; we term these ‘gaps’. The power-law distribution, Eq. 4, has the feature that its variance is undefined when \(\rho >\frac {1}{3}\); in this regime, very large gaps appear in the resource spectrum (e.g. Fig. 2(c)).

Fig. 2
figure 2

Illustration of the distribution of values of resource parameter E in the continuous resource spectrum model, where we have chosen to order the sites according to their E values (this ordering is arbitrary since our model has universal dispersion). Each panel shows a fraction of the total resource spectrum, for increasing heterogeneity control parameter ρ. Panels a, b and c correspond to ρ values 0.01, 0.3 and 0.4, respectively

Simulating this model over a range of values of the parameter ρ, we find that a steady state is reached over timescales of less than 5000 generations (Appendix 1, Fig. 7). We nevertheless report results measured after 30,000 generations, for consistency with the step-like model which we will discuss later in the paper, where the dynamics are slower.

A shift from generalism to specialism with increasing graininess of the resource spectrum

Figure 3 analyses the long-time community composition of our model (after a simulation time of 30,000 generations), as a function of the graininess of the resource spectrum. As the graininess parameter ρ is increased, we observe a shift in the long-time community composition from generalist-dominated for a fine-grained resource spectrum, to specialist-dominated when the resource spectrum is coarse-grained. This shift is manifested in a change in the geometric mean value of σ as the parameter ρ is increased; Fig. 3(a) shows that the mean σ is high (∼ 10) for small ρ, indicating domination by generalists, but becomes low (∼ 10− 3) for large values of ρ, indicating domination by specialists.

Fig. 3
figure 3

Community composition, measured after 30,000 generations, for the continuous resource spectrum model. Thirty simulation runs were performed for each value of ρ. (a) The geometric mean niche breadth σ (averaged over the 30 runs for each ρ), plotted as a function of ρ; we observe a shift from a generalist community (high mean σ) at small ρ to a specialist community (low mean σ) at large ρ. (b) Shannon index (community diversity) plotted against ρ (again, averaged over the 30 runs for each ρ). We observe a peak in diversity for intermediate values of ρ. (c) Species are categorised into 4 types according to their value of σ: extreme specialists (ES), intermediate specialists (IS), mild specialists (MS) and generalists (G). In the fine-grained limit, ρ → 0, we expect our model to behave like a neutral community model (Hubbell 2001). For the neutral model, the Shannon index is given approximately by \(\log {(\theta + 0.5)}+0.5772\) for 𝜃 > 2 (Chao et al. 2015), where 𝜃 = 2Nν depends on the population size N (which is here 10,000) and the immigration rate ν (which is here ν = I/N = 2 × 10− 3). Therefore, for our model, 𝜃 = 40 and the predicted Shannon index for the neutral model is approximately 4.28. (b) shows that our simulations do produce results close to this value for ρ → 0. (d), (e) and (f) Distribution of σ values for the case where ρ= 0.2. These data are representative results from single simulation runs. ρ= 0.2 was chosen because it results in a final community composed of a wide range of σ when the full range of σ is permitted. In (d), we plot the distribution of σ values for a simulation which includes species sampled from the full range of σ values 10− 3 < σ < 101; in (e), we plot the equivalent results for a simulation with species sampled from a narrower range 10− 2 < σ < 101 that excludes extreme and intermediate specialists and in (f), we plot equivalent results for a simulation with species sampled from the range 10− 3 < σ < 10− 1 that excludes generalists. The results are colour-coded according to the species types defined in (c)

For the coarse-grained resource spectrum (large values of ρ), our results suggest a picture in which particular grains in the resource spectrum are dominated by particular specialist species, with other species being excluded due to competitive exclusion (Colwell and Fuentes 1975; Hulburt 1985; Pulliam 2000; Kassen 2002). Consistent with this ‘one specialist per grain’ picture, in the coarse-grained regime (ρ > 0.3), community diversity decreases as the resource spectrum becomes more grainy (Fig. 3(b)). As the grain size increases, the number of grains decreases, and consequently the number of specialist species that can be supported by the environment decreases.

By contrast, if the resource spectrum is fine-grained (small values of ρ, Fig. 2(a)), generalist species with a broad environmental tolerance are favoured because they can colonise parts of the resource spectrum where the environmental parameter varies continuously. The grainy parts that do exist, harbouring specialists with a narrow range of environmental tolerance, are small, making the specialists that inhabit them vulnerable to stochastic extinction events. This picture echoes previous suggestions, made in a spatial context, that a minimal spatial habitat size is needed to support specialists (Forman 1995); a similar effect was also seen in the more minimal model of Nagelkerke and Menken (2013). In our model, in the fine-grained generalist-dominated regime, neither the mean niche breath nor the species diversity change with the grain size (ρ < 0.1 in Fig. 3(a, b)). This reflects the fact that the dominant generalist species, with σ > 1, are able to colonise the entire resource range (0 < E < 1) so that the details of the structure of the resource spectrum are unimportant. Indeed, investigating in more detail, we find that the community composition, as defined by the distribution of μ and σ values, varies only weakly with the parameter ρ in this regime. In this regime, one might expect the community as a whole to exhibit the characteristics of a neutral model (Hubbell 2001). Indeed, as ρ → 0, the value of the Shannon index in our simulations does become close to the prediction of 4.28 for a neutral model with the equivalent immigration rate (𝜃 = 40; see caption of Fig. 3).

Resource spectrum engineering by specialist species

Our simulations also reveal that specialist species can play a key role in controlling community composition. To elucidate the role played by specialist and generalist species, we carried out a series of simulations for a specific value of the graininess parameter ρ = 0.2, in which we changed the range of σ values from which we sampled, so as to exclude either specialist or generalist species. We then compared the community composition (i.e. the distribution of σ values) after 30,000 generations with that obtained in our simulations in which species were sampled from the full range of σ values. To clarify our analysis, we divide the community into four categories according to degree of specialisation, as illustrated in Fig. 3(c). These categories are extreme specialists (10− 3 < σ < 10− 2.9), intermediate specialists (10− 2.9 < σ < 10− 2), mild specialists (10− 2 < σ < 10− 1) and generalists (10− 1 < σ < 101).

Figure 3(d, e and f) show the distribution of σ values obtained in our simulations, when we include the full range of strategies (10− 3 < σ < 101; Fig. 3(d)), compared with those where we exclude extreme and intermediate specialists (10− 2 < σ < 101; Fig. 3(e)), and those where we exclude generalists (10− 3 < σ < 10− 1 Fig. 3(f)). When we include the full range of strategies, the community is dominated by mild specialists (Fig. 3(d)). This is also the case when we run the simulation without generalists (Fig. 3(f)); apart from the absence of the generalists, the distribution of σ values is qualitatively the same. However, removing the extreme and intermediate specialist species results in a qualitative change in community composition (Fig. 3(e)): the community becomes dominated by generalists rather than by mild specialists. Thus, the presence of highly specialised species in our simulations has a strong effect on the composition of the entire community, favouring mild specialists and disfavouring generalists.

We hypothesise that this effect could occur by a mechanism which we term “resource spectrum engineering”. In this mechanism, highly specialised species occupy particularly large, homogeneous grains in the resource spectrum. As these specialists can exert a large competition pressure, these sites become effectively off-limits to less specialised species, resulting in gaps in the effective resource spectrum that is available to these less specialised species. This disfavours generalists, because their competitiveness relies on their ability to colonise sites with a wide range of environmental conditions; thus, the presence of extreme specialists on large grains in the resource spectrum decreases the number of sites that are available for generalists. Mild specialists, by contrast, are less disadvantaged by the presence of the extreme specialists, as they can inhabit other parts of the resource spectrum, that fall between the gaps.

To test this hypothesis, we plot in Fig. 4 the probability Pμ, σ(E) that a hypothetical invader with strategy (μ, σ) will succeed in replicating into a given site with environmental parameter value E (computed using Eq. 1). We associate this probability, which depends on the presence of competing organisms within the community, with the effective resource spectrum. To measure the effect of community composition on the effective resource spectrum, we compare Pμ, σ(E) for a community obtained after 30,000 generations in our simulations (purple data points in Fig. 4) with that for a community composed entirely of generalists (green data points in Fig. 4, σ = 101).

Fig. 4
figure 4

Probability of establishment Pμ, σ(E), for ρ= 0.2, for a hypothetical invader with strategy (μ, σ), with μ = 0.5, on a site with environmental parameter value E. This probability is computed using Eq. 1, for a community taken from the end point of one of our simulations, with ρ= 0.2 (green data points), and for a community composed entirely of generalists with σ = 101 (purple data points). (a) shows results when the invader is an extreme specalists (σ = 10− 3); (b) shows results when the invader is an intermediate specialist (σ = 10− 2); (c) shows results when the invader is a mild specialist (σ = 10− 1) and (d) shows results when the invader is a generalist (σ = 101). For an invading extreme specialist, the composition of the competing community has little impact, but for an invading generalist, the effective resource spectrum Pμ, σ(E) depends strongly on the composition of the competing community

Figure 4(a) shows Pμ, σ(E) for the case where the hypothetical invader is an extreme specialist, with σ = 10− 3 (and μ = 0.5). Here, Pμ, σ(E) takes the Gaussian form of Eq. 1 regardless of the structure of the community; this is as expected since an extreme specialist can outcompete any competing organisms on its favoured sites. However, the situation is different when the invading organism is less specialised (Fig. 4(b–d)). If the invader is an intermediate specialist (Fig. 4(b)), the effective resource spectrum Pμ, σ(E) is quite different under the competition pressure in our simulations (purple data points) compared with that under uniform competition pressure from generalists (green data points). This effect is even more pronounced for a mild specialist (Fig. 4(c)) and a generalist (Fig. 4(d)), whose effective resource spectrum Pμ, σ(E) becomes highly structured under the competition pressure found in our simulations, whereas it follows the smooth Gaussian form of Eq. 1 under uniform competition from generalists. Thus, these results show that competition from competing organisms within the community has little effect on extreme specialists, but has a strong effect on less specialised species.

A step-like resource spectrum

To investigate in more detail the dynamics of community assembly in our simulations, we also simulated a model with a resource spectrum that is step-like, with fixed gaps in E-space between the grains, as illustrated in Fig. 5. Here, the environmental parameter takes a specific set of discrete values (mimicking, for example, an aquatic system exposed to light at a specific set of wavelengths (Stomp et al. 2007)). This model provides a much clearer definition of a ‘grain’: here this is a set of sites having identical values of the environmental parameter E. By varying the distribution of grain sizes, we can control the degree of graininess of the resource spectrum in this model. We can also track the occupation of grains of different sizes by species with different degrees of specialisation, during our simulations.

Fig. 5
figure 5

Illustration of the model with step-like resource spectrum. (a) Environmental parameter value E for a series of sites, ranked by increasing E value. Note that this only shows a fraction of the total sites in the model. (b) Distribution of grain sizes g for several values of the heterogeneity parameter 𝜃, keeping the mean grain size \(\bar {g}=36\)

Assignment of environmental values

In this model, we fix the total number of grains, k. Since the environmental parameter E ranges from 0 to 1, the size in E-space of the gaps between grains is then 1/k. We draw k grain sizes from the gamma distribution

$$ p(x) \!=\! \frac{x^{\theta-1}e^{-x}}{{\Gamma}(\theta)} ~~~\text{where}~~~ {\Gamma}(a) \!= \int^{\infty}_{0} t^{a-1}e^{-t} \mathrm{d} t \enspace ; \enspace x>1 $$
(5)

and normalise them so that the sum of all k grain sizes is equal to N, the number of sites, and they are rounded to the nearest integer. By changing the value of k, we can control the mean grain size \(\bar {g}\); a larger value of k results in a smaller mean grain size. This model also allows us to control the variability of the grain size, via the parameter 𝜃 of the gamma distribution. In this distribution, the ratio of the standard deviation to the mean is \(1/\sqrt {\theta }\). Hence, when 𝜃 is large, there is only limited variation in grain size; when 𝜃 is small, we expect to see both large and small grains in the resource spectrum. As 𝜃, the ratio of the standard deviation to the mean vanishes and all grains have the same size. Figure 5 illustrates the assignment of E values for this model, and the resulting distribution of grain sizes for the case when \(\bar {g}=36\), for several values of 𝜃.

Shift from generalism to specialism with increasing grain size

For the step-like resource spectrum, our simulations reveal a shift in community composition (measured after 30,000 generations) from generalism to specialism as we increase the mean grain size \(\bar g\). This shift is analogous to that seen in the continuous resource spectrum model upon increasing the graininess parameter ρ. Figure 6(a) shows that in the step-like model, for a fine-grained resource spectrum (small \(\bar g\)), the community is dominated by generalists (large mean σ), while specialists dominate (leading to small mean σ) when the resource spectrum is coarse-grained (large \(\bar g\)). Moreover, we observe that a broader distribution of grain size (smaller value of the parameter 𝜃) results in the shift to specialism occurring at lower mean grain size \(\bar {g}\): in other words, more variability in grain size results in specialists becoming established more easily.

Fig. 6
figure 6

Community composition for the step-like resource spectrum model. (a) Geometric mean value of the σ parameter after simulations of 30,000 steps, plotted as a function of the mean grain size \(\bar {g}\) (varied by varying the number of grains k), for various values of 𝜃, which controls the variability in grain size. For small mean grain size, the community is dominated by generalists, but it is dominated by specialists for large mean grain size. The shift happens at lower \(\bar g\) as the grain size variability increases (i.e. as the variability parameter 𝜃 decreases). (b) Dynamical trajectory from a simulation with \(\bar {g} = 36\) and 𝜃 = 40, showing the populations of extreme specialists (red), intermediate specialists (yellow), mild specialists (green) and generalists (blue) as a function of time. These groups are defined as in Fig. 3(b). Generalists are initially the most abundant type, until around 10,000 generations when the generalist population collapses. From then on, increasingly specialist populations come to dominate in a successive fashion. Extreme specialists increase in number steadily from the start of the simulation and come to almost completely dominate by the end of the simulation. (c) and (d) Dynamical trajectories showing the fractional occupation of grains of different size by extreme (c) and intermediate (d) specialists for simulations with \(\bar {g} = 36\) and 𝜃 = 40. Here, grains are classified by size into 4 groups, by taking equal quartiles across the whole range of grain sizes present. The different lines in the plot show occupation by a particular organism type (extreme specialists for (c), intermediate specialists for (d)) of grains in a particular size group. In (c), extreme specialists occupy only large grains initially, and we hypothesise that their occupation of these grains may trigger the loss of generalists. By contrast, in the early stages of the simulation, intermediate specialists (d) are low in abundance early in the simulation but occupy smaller grains later in the simulation, once the generalists have been eliminated

We are also interested in the dynamics of community assembly during our simulations. To investigate how the community assembles, we plot in Fig. 6(b) a typical dynamical trajectory for a simulation with the parameter set \(\bar {g} = 36\), 𝜃= 40. In this simulation, the community initially contains predominantly generalists (since we sample σ evenly in log space and generalists occupy the largest range of σ values in Fig. 3(b)). As suggested by our resource spectrum engineering hypothesis, we see that the abundance of extreme specialists increases steadily from the start of the simulation, and that after around 10,000 generations, a transition occurs in which generalists are replaced by mild specialists. Following this transition, the abundance of extreme specialists increases more rapidly, and extreme specialists eventually come to replace the mild specialists, dominating the community at long times.

To understand this dynamics in more detail, we also track which grains are occupied by extreme specialists. Our resource spectrum engineering hypothesis would suggest that the largest grains should be the ones that are initially colonised by extreme specialists, with smaller grains later becoming available to specialist species, once the generalists have been eliminated. In Fig. 3(c), we categorise grains by size and plot the fractional occupancy by extreme specialists, for each category of grain size. During the early stages of the simulation (before 10,000 generations), we see that indeed, it is the largest grains that are likely to be occupied by extreme specialists, while later in the simulation (after 10,000 generations), smaller grains also become occupied by extreme specialists.

This dynamical analysis can be interpreted in the light of our resource spectrum engineering hypothesis. Initially, extreme specialists, which arrive by immigration, colonise the largest grains in the resource spectrum, since they can outcompete the generalists on these grains. This creates gaps in the resource spectrum that is available for other species. Because generalists need to occupy multiple grains in order to compete, gaps in the resource spectrum disfavour generalists disproportionately, leading to a transition at around 10,000 generations in which mild specialists replace the generalist population. This in turn reduces the competition pressure for other specialists, leading to an increase in intermediate specialists, which inhabit the remaining small grains (Fig. 3(d)). With time, extreme specialists encroach on the intermediate specialists, eventually resulting in domination by extreme specialists.

Our discussion here has focused on a step-like model with fixed gap size and variable grain size, in which we find that large grains allow extreme specialists to become established, catalysing a transition to specialism, via a resource spectrum engineering mechanism. We have also simulated a model with fixed grain size, but with variable gap sizes between the grains. This model shows that isolated grains (those surrounded by large gaps) can also provide a favourable habitat for specialists, leading to similar results, as we describe in Appendix 2.

Discussion

We have used an individual-based model of community dynamics, with a broad and continuous range of specialist-generalist strategies, to investigate the interplay between the spectrum of resources that are present in an environment and community composition. Our first result is that the graininess of the resource spectrum can have a strong effect on community composition, even in the absence of spatial structure. A coarse-grained resource spectrum containing gaps favours specialists, whereas a fine-grained, more continuous spectrum favours generalists. Secondly, our results suggest that this effect occurs by a community assembly process that we call “resource spectrum engineering”, in which extreme specialists pay a catalytic role. Occupation of larger, more homogeneous grains in the resource spectrum by highly specialised species changes the effective resource spectrum which is available to other species, in a way which favours other specialists.

Our model is similar to that used by others to investigate effects of immigration rate (Gravel et al. 2006), habitat heterogeneity (Kadmon and Allouche 2007; Bar-Massada et al. 2014; Büchi and Vuilleumier 2014) and dispersal (Büchi et al. 2009; Büchi and Vuilleumier 2014), but our implementation is somewhat different, since we consider the non-spatial case, where the dispersal range between sites is infinite. Even in this well-mixed model, coexistence between species is possible because different specialist species can occupy different parts of the resource spectrum. Our results should be most relevant to natural environments where dispersal rates are high (e.g. birds foraging in a heterogeneous forest or aquatic environments with high mixing rates) or where a spectrum of resources is available in a single location (e.g. the light spectrum, or food particles of a range of sizes or types).

Effect of resource spectrum graininess on specialist-generalist balance and diversity

Our results show that, for several different models, an increase in the graininess of the resource spectrum causes a shift from a generalist-dominated state to one that is dominated by specialist species. This is a gradual shift in a model with a continuous resource spectrum with stochastic niches; in a model with a step-like resource spectrum, the shift is more abrupt. This observation echoes the established view in the ecology literature that large homogeneous ‘patches’ of habitat or of a particular resource tend to be occupied by a single species which is highly specialised to that resource or habitat (Dykhuizen and Davies 1980; Futuyma and Moreno 1988; Morris 1996; Amarasekare 2003). Our results also complement previous model predictions that spatially coarse-grained habitats should favour specialists (Brown and Pavlovic 1992; Nagelkerke and Menken 2013). Here we show that the same phenomenon also occurs in a well-mixed system where it is the resource spectrum, rather than the spatial habitat, which is coarse-grained.

Additionally, our work shows that for specialist-dominated communities, an increase in the graininess of the resource spectrum is associated with a decrease in diversity. From the perspective of spatial habitat structure, this supports the view that habitat heterogeneity results in more diversity (Lundholm and Larson 2003). More recently, however, it has also been suggested that habitat ‘microfragmentation’ may result in a unimodal distribution, where diversity peaks at intermediate heterogeneity, and is lower for either very low or very high levels of heterogeneity (Kadmon and Allouche 2007; Laanisto et al. 2012). This is because very high levels of heterogeneity result in smaller habitat areas, which are not large enough to support individual specialist species, so that instead a single generalist may take over the habitat. Indeed, we see this effect both in our continuous and stepped resource spectrum models. Taken together, our results support the general hypothesis of a peak in diversity at intermediate levels of environmental coarse-graining.

Interestingly, in the generalist-dominated limit, for the fine-grained resource spectra, our system shows characteristics of a neutral model, in that its composition is essentially independent of the environment. In contrast, for coarse-grained resource spectra, our model is highly niche-dominated, with individual niches being occupied by specialists which exclude other species by competitive exclusion. Thus, our models could provide a convenient way to explore the crossover between niche theory and neutral theory, a topic which has been of increasing interest to theoretical ecologists in recent years (Tilman 2004; Schwilk and Ackerly 2005; Gravel et al. 2006; Kadmon and Allouche 2007; Bar-Massada et al. 2014; Noble and Fagan 2015).

Resource spectrum engineering

Based on simulations in which we manipulate the allowed range of specialist/generalist strategies, and in which we track community composition in time, we postulate that the dominance of specialists at high resource spectrum graininess can be attributed to a ‘resource spectrum engineering’ community assembly mechanism. In this mechanism, the occupation of a few large grains by highly specialised species can favour the occupation of other, smaller, grains by specialists, by creating gaps in the effective resource spectrum such that it is less favourable to generalists. Thus, the interplay between resource spectrum and community composition occurs not at the level of individual grains, but rather at the level of the entire resource spectrum. The presence of highly specialised species on a few grains increases the size of the gaps between the remaining available grains, making them more isolated and thus less favourable for generalists, which prosper by occupying a broad range of resource space. This picture is somewhat reminiscent of the concept of ecosystem engineers—species that modify the environment in a way that has a significant impact on other species (Jones et al. 1994); however, here the effect is not directly on an environmental parameter but rather on the distribution of the environmental variable across the entire habitat.

Although to our knowledge this concept of resource spectrum engineering has not previously been discussed in ecological models, similar effects have been noted in the empirical literature. For example, in a study of bird communities, Julliard et al. (2006) found that specialised species are more abundant if the rest of the local community is specialised to the same degree.

We have shown that this phenomenon occurs in several different resource spectrum models, suggesting that it may be quite general. It is also important to note that this is a phenomenon that can only be seen in models which include a continuum of strategies, from extreme specialism to generalism; we do not expect it to be evident in simpler models which include only the interplay between discrete, idealised, ‘specialist species’ and ‘generalist species’. However, we note that resource spectrum engineering relies on the trade-off between niche breadth and maximum fecundity that is implicit in the competitiveness function; it is this trade-off that ensures that extreme specialists are able to outcompete other species on their preferred grains. While the existence of such a trade-off is widely accepted in ecological modelling (Futuyma and Moreno 1988; Wilson and Yoshimura 1994; Marvier et al. 2004), it would be interesting in future to test models in which it can be tuned.

Importance of niche isolation as well as niche size

In Appendix 2, we present results for a model with a step-like resource spectrum, in which the grains are of equal size but the size of the gaps between grains varies stochastically. Two interesting findings emerge from this model. Firstly, variability in gap size changes the balance between generalism and specialism in a similar way to variability in grain size, suggesting that any kind of variation or heterogeneity in the resource spectrum may be advantageous to specialists. Secondly, if the community is specialist-dominated, the degree of isolation of grains becomes very important in determining which species can survive on them. Extreme specialists are more likely to be found on isolated grains with a large gap adjacent to them. This is because those species that specialise on a particularly isolated type of resource face less competition from intermediate specialists than those which specialise on a resource that is surrounded by similar resources. This mirrors the general view that specialists appear in peculiar or extreme environments (Thompson et al. 1998; Boulangeat et al. 2012), such as those that are particularly dry or high altitude. It also provides further evidence for our resource spectrum engineering hypothesis—the formation of gaps in the resource spectrum mean that the areas between them are more isolated for mild specialists, which are then advantaged.

Immigration rate

In this work, new species are assumed to enter the model by immigration at a fixed rate, which we hold constant for simplicity. It is important to note, however, that the immigration rate can play an important role in metapopulation models (see, e.g. Hubbell 2001; Gravel et al. 2006). Upon varying the immigration rate in our simulations, we find quantitative, but not qualitative, changes in our results. Specifically, a higher immigration rate tends to lead to more coexistence between specialists and generalists, whereas a lower immigration rate tends to result in a more uniform population. However, we leave a detailed investigation of the effects of immigration rate to a future study.

Timescales in our simulations

We have analysed the behaviour of our model over long timescales: our simulations were run for 30,000 generations, such that the community composition at the start becomes largely irrelevant. On such timescales, ‘immigration’ essentially refers to speciation. For organisms such as animals or plants, 30,000 generations is ecologically unrealistic, although for microbes this may not be the case (Lenski’s famous long-running Escherichia coli experiment has achieved more than double this number of generations Lenski et al. 1991; Good et al. 2017). Our rationale here has been to understand the behaviour of our model in full. Although Fig. 7 shows that for the continuous resource spectrum, both the diversity and the mean σ value reach steady state relatively rapidly, Fig. 6 shows that for the step-like resource spectrum, very long simulations are required to reveal the succession of changes in the community as it is taken over by specialists. On more realistic ecological timescales, one might expect to see only part of this succession, corresponding to the earlier stages of the dynamics in Fig. 6—for example replacement of generalists by mild specialists.

Relevance to natural communities and ecosystem management

Here, for simplicity, we have considered a static environment. Previous work shows that static environments favour specialists, while temporally fluctuating environments favour generalists (Vázquez and Simberloff 2002; Wilson et al. 2008). We do not believe that small temporal fluctuations would affect our overall findings, although the effect of large fluctuations (such as a mass extinction event) on our results would be a very interesting area for further study.

Our work relies on the assumption, often made in ecological models, that specialists and generalists can be classified by their niche breadth along a single niche axis, and that a trade-off exists between niche breadth and fecundity under optimal conditions ((Dykhuizen and Davies 1980; Futuyma and Moreno 1988; van Tienderen 1991; Wilson and Yoshimura 1994; Kassen 2002; Devictor et al. 2010)). In nature, of course, the situation is more complicated: species will experience resource spectra along several niche axes simultaneously and may specialise or generalise on different ones. Indeed, measuring and comparing niche breadth between different species and environments in a quantitative way is notoriously difficult (Futuyma and Moreno 1988; Kassen 2002; Devictor et al. 2010). Moreover, difficulties also exist in quantifying the heterogeneity of an environment; one might classify the nature of an environment in terms of species requirements, i.e. its ‘functional heterogeneity’ (Fahrig et al. 2011), or in terms of natural versus managed patches and their connectivity, or in terms of their fragmentation with regard to species movements, etc. (Fahrig et al. 2011). Our aim in this work has been to provide basic understanding rather than direct applications to real-life ecosystems.

Nevertheless, we believe that our work does have potential implications for ecosystem management. Attempts to prevent species loss sometimes involve the creation of specific habitats aimed at supporting at-risk species (Mitsch et al. 1998; Boorman 1999; Ronia et al. 2002). Our work suggests that this may have implications not only for the specialist species that are targeted but also for the entire ecosystem, since creating such highly specialised niches (grains in our model) may crowd out generalist species also from other niches that are not well suited to the specialists (a.k.a. the small grains in our models).

Taken more broadly, our work highlights the fact that specialist-generalist competition does not simply happen on a local scale over specific resources but can have wide-reaching implications across the entire resource spectrum of an ecosystem.