HostSwitch: An R Package to simulate host switching by a parasite
R/HostSwitch is an R package that uses an individual-based model to simulate dispersion and host switch events by a consumer. The host-consumer association refers to any type of symbiotic (sensu lato) biological interaction.
Install R/HostSwitch from CRAN using:
install.packages("HostSwitch")
or from GitHub using:
devtools::install_github(repo <- "berndpanassiti/HostSwitch",build_vignettes = TRUE)
Try the following example to simulate dispersal and host switch events by a consumer. You can set up a maximum of 20 generations and 3 simulations:
library(HostSwitch)
simulated_quantities <- simHostSwitch(seed=123,n_sim=3,n_generation=20)
Also try summaryHostSwitch
function to get summary statistics of simulated quantities of interest: optimum phenotypes that Consumers should have to be favored by the current Resource (pRes_sim), optimum phenotypes 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).
summaryHostSwitch(simulated_quantities)
Finally, try plotHostSwitch
to plot of the simulated quantities and to select a specific simulation use the parameter "n_sim":
plotHostSwitch(simulated_quantities, sim_n = 1)
You can compare two "simHostSwitch" objects using the function testHostSwitch
. The comparison is between three estimated quantities: "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. The The available tests are:”t” for t-test (parametric), and ”w” for Wilcoxon-test (non-parametric). For this comparison the number of simulation need to be greater than 1.
m1 <- simHostSwitch(seed=123,n_sim=100,b=10)
m2 <- simHostSwitch(seed=123,n_sim=100,b=15)
testHostSwitch(simulated_quantities1=m1,simulated_quantities2=m2,parameter="j",test="t",plot=FALSE)
Using Shiny application for R, it is possible to run an interactive plot to simulate host switching on the web without detailed knowledge of the underlying code:
shinyHostSwitch()
The R/HostSwitch package as a whole is distributed under GPL-3 (GNU General Public License version 3).