Level 2 function that swarms a Colony or MultiColony object - an event where the queen leaves with a proportion of workers to create a new colony (the swarm). The remnant colony retains the other proportion of workers and all drones, and the workers raise virgin queens, of which only one prevails. Location of the swarm is the same as for the remnant or sampled as deviation from the remnant.

swarm(
  x,
  p = NULL,
  year = NULL,
  nVirginQueens = NULL,
  sampleLocation = TRUE,
  radius = NULL,
  simParamBee = NULL,
  ...
)

Arguments

x

Colony-class or MultiColony-class

p

numeric, proportion of workers that will leave with the swarm colony; if NULL then SimParamBee$swarmP is used. If input is MultiColony-class, the input could also be a vector of the same length as the number of colonies. If a single value is provided, the same value will be applied to all the colonies

year

numeric, year of birth for virgin queens

nVirginQueens

integer, the number of virgin queens to be created in the colony; of these one is randomly selected as the new virgin queen of the remnant colony. If NULL, the value from simParamBee$nVirginQueens is used

sampleLocation

logical, sample location of the swarm by taking the current colony location and adding deviates to each coordinate using rcircle

radius

numeric, radius of a circle within which swarm will go; if NULL then SimParamBee$swarmRadius is used (which uses 0, so by default swarm does not fly far away)

simParamBee

SimParamBee, global simulation parameters

...

additional arguments passed to p or nVirginQueens when these arguments are functions

Value

list with two Colony-class or MultiColony-class, the swarm and the remnant (see the description what each colony holds!); both outputs have the swarm event set to TRUE

Examples

founderGenomes <- quickHaplo(nInd = 8, nChr = 1, segSites = 50)
SP <- SimParamBee$new(founderGenomes)
basePop <- createVirginQueens(founderGenomes)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
drones <- createDrones(basePop[1], n = 1000)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = 10)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found

# Create Colony and MultiColony class
colony <- createColony(x = basePop[2])
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
colony <- cross(colony, drones = droneGroups[[1]])
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
(colony <- buildUp(colony, nWorkers = 100))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
apiary <- createMultiColony(basePop[3:8], n = 6)
#> Error in createMultiColony(basePop[3:8], n = 6): object 'basePop' not found
apiary <- cross(apiary, drones = droneGroups[2:7])
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
apiary <- buildUp(apiary, nWorkers = 100)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found

# Swarm a colony
tmp <- swarm(colony)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
tmp$swarm
#> Error in eval(expr, envir, enclos): object 'tmp' not found
tmp$remnant
#> Error in eval(expr, envir, enclos): object 'tmp' not found

# Swarm all colonies in the apiary with p = 0.6 (60% of workers leave)
tmp <- swarm(apiary, p = 0.6)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
nWorkers(tmp$swarm)
#> Error in is(x, class2 = "Colony"): object 'tmp' not found
nWorkers(tmp$remnant)
#> Error in is(x, class2 = "Colony"): object 'tmp' not found
# Swarm with different proportions
nWorkers(apiary)
#> Error in is(x, class2 = "Colony"): object 'apiary' not found
tmp <- swarm(apiary, p = c(0.4, 0.6, 0.5, 0.5, 0.34, 0.56))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
nWorkers(tmp$swarm)
#> Error in is(x, class2 = "Colony"): object 'tmp' not found
nWorkers(tmp$remnant)
#> Error in is(x, class2 = "Colony"): object 'tmp' not found

# Sample colonies from the apiary that will swarm (sample with probability of 0.2)
tmp <- pullColonies(apiary, p = 0.2)
#> Error in is(x, class2 = "MultiColony"): object 'apiary' not found
# Swarm only the pulled colonies
(swarm(tmp$pulled, p = 0.6))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found