knitr::opts_chunk$set(fig.width=8.5, fig.height=5.5, fig.align='center', warning=FALSE, message=FALSE, cache = T)
The evolution of the biological associations may include several concatenated events of speciation affecting one or both species and it is driven by four main processes: cospeciation, host switch, failure to speciate and "missing the boat" [@page2002tangled]. While the prevalent paradigm wants the cospeciation to be the main process driving the coevolution of most of the biological associations, recent evidence showed that host-switching, favored by the intrinsic capability of adaptation in the sub-optimal environment, may explain rapid novel associations (i.e. colonization of novel hosts at the ecological time scale) eventually followed by speciation (at the evolutionary time) as well the observed incongruences of the paired phylogenies (see [@brooks2019stockholm] for a review).
The simulation model of HostSwitch aims to measure the dynamics of the host switch (extent and frequency) in the population of an organism (hereafter Consumer) that interacts with current and potential hosts (hereafter Resource) over the generations. A host switch implies that a Consumer may colonize new Resource, which in turn imposes selection pressure that impacts the Consumers' survival. The host-switching relies on a mechanism of ecological readjustment or ecological fitting, i.e. the capability of the Consumer to use a similar Resource even if sub-optimal [@janzen1985ecological] [@agosta2008ecological]. The fundamental aspect of the HostSwitch simulation model is to track, summarize and compare the dispersion and successful host switch events in a new Resource by the populations of the Consumer.
The HostSwitch package offers simple functions to evaluate the role of the single parameters included in the model in defining the probability and the amplitude of the host switch. The extension in R code allows the users to choose among different consumer-resource scenarios which accommodate all the symbiotic (sensu lato) associations.
This package will be expanded with further scenarios of biological interactions. Please feel free to contact the authors to contribute by making suggestions, or sending bug fixes or extension proposals.
Install the recent release of HostSwitch package using GitHub
devtools::install_github(repo = "berndpanassiti/HostSwitch",build_vignettes = TRUE)
Loading and citation
This function opens a new window with an interactive plot of the HostSwitch simulation model. This plot can be used to interact with the model and explore how different settings affect dispersion and host switch events by a consumer.
# using only 20 generations and 1 simulation, others arguments left to default values # see ?simHostSwitch for more arguments simulated_quantities = simHostSwitch(seed=123,n_sim=1,n_generation=20)
The function simHostSwitch generates a list containing all quantities of interest which can be used for summary statistics or plots. Quantities of interest are optimum phenotypes that Consumers should have to be favored by the current Resource (pRes_sim), that Consumers should have to be favored by the novel Resource (pRes_new_sim), individual phenotype values of the Consumers (pInd), number of migrating individuals at each generation (pInd_jump_sim), individual phenotype values of the Consumers who disperse in a novel Resource (pInd_whichjump_sim), and individual phenotype values of the Consumers who successful colonize a novel Resource (pInd_whichsurv_sim). These parameters are available for each generation step.
The function summaryHostSwitch creates a summary of basic statistics for phenotypes, dispersion and host switch events.
gg1 = plotHostSwitch(simulated_quantities, sim_n = 1) # use n_sim to select a specific simulation gg1 #gg1 + xlim(0,10) # limit x-axis from 0 to 10 generations
The S3 method plotHostSwitch function graphically summarize the simulated output.
To investigate the effect of selected parameters on dispersal and host switch events, the testHostSwitch function can be used to compare estimated quantities from two HostSwitch objects.
The three estimated quantities are: j total number of dispersing events; s total number of successful host switch events; *d distance between the pRes_sim andpRes_new_sim for the generations where a successful host switch occurs, or phenotype distance.
In the example below, we investigated how different values of net reproduction rate (parameter b) affect the average number of dispersal and host switch events to a new resource by a consumer.
First, we created two HostSwitch objects with different b (m1 and m2), other parameters set to default values. Second, we compared m1 and m2 choosing the estimated quantity of interest. If plot = TRUE a boxplot will be generated in the plot pane in RStudio.
# see ?simHostSwitch for more arguments m1 = simHostSwitch(seed=123,n_sim=100,b=10) m2 = simHostSwitch(seed=123,n_sim=100,b=15) # see ?testHostSwitch for more arguments testHostSwitch(simulated_quantities1=m1,simulated_quantities2=m2,parameter="j",test="t",plot=FALSE)
Note, to test for differences between HostSwitch objects a reasonable high number of simulations is recommended (e.g., n_sim >= 100).
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.