R/Functions_L2_Colony.R
buildUp.Rd
Level 2 function that builds up a Colony or MultiColony object by adding (raising) workers and drones usually in spring or after events such as split or swarming.
buildUp(
x,
nWorkers = NULL,
nDrones = NULL,
new = TRUE,
exact = FALSE,
resetEvents = FALSE,
simParamBee = NULL,
...
)
numeric or function, number of worker to add to the colony,
but see new
; if NULL
then SimParamBee$nWorkers
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.
numeric or function, number of drones to add to the colony,
but see new
; if NULL
then SimParamBee$nDrones
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.
logical, should the number of workers and drones be added anew or
should we only top-up the existing number of workers and drones to
nWorkers
and nDrones
(see details)
logical, if the csd locus is turned on and exact is TRUE
,
create the exact specified number of only viable workers (heterozygous on
the csd locus)
logical, call resetEvents
as part of the
build up
SimParamBee
, global simulation parameters
additional arguments passed to nWorkers
or nDrones
when these arguments are a function
Colony-class
or MultiColony-class
with workers and
drones replaced or added
This function increases queen's nWorkers
, nHomBrood
,
and nDrones
counters. It also turns production on.
Argument new
enables simulation of two common cases. First,
if you are modelling year-to-year cycle, you will likely want
new = TRUE
, so that, say, in spring you will replace old (from last
year) workers and drones with the new ones. This is the case that we are
targeting and hence new = TRUE
is default. Second, if you are
modelling shorter period cycles, you will likely want new = FALSE
to
just top up the current workers and drones - you might also want to look at
replaceWorkers
and replaceDrones
.
TODO: Discuss on how to model day-to-day variation with new = FALSE
.
We are not sure this is easy to achieve with current implementation
just now, but could be expanded.
https://github.com/HighlanderLab/SIMplyBee/issues/176
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50)
SP <- SimParamBee$new(founderGenomes)
basePop <- createVirginQueens(founderGenomes)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
drones <- createDrones(x = basePop[1], nInd = 1000)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = nFathersPoisson)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
# Create a Colony and a 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
isProductive(colony)
#> Error in is(x, class2 = "Colony"): object 'colony' not found
apiary <- createMultiColony(basePop[3:4], n = 2)
#> Error in createMultiColony(basePop[3:4], n = 2): object 'basePop' not found
apiary <- cross(apiary, drones = droneGroups[c(2, 3)])
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
isProductive(apiary)
#> Error in is(x, class2 = "Colony"): object 'apiary' not found
# Build up
# Using defaults in SP$nWorkers & SP$nDrones
(colony <- buildUp(colony))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
isProductive(colony)
#> Error in is(x, class2 = "Colony"): object 'colony' not found
# Build-up a MultiColony class
(apiary <- buildUp(apiary))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
isProductive(apiary)
#> Error in is(x, class2 = "Colony"): object 'apiary' not found
# The user can also specify a function that will give a number
colony <- removeWorkers(colony) # Remove workers to start from fresh
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
colony <- removeDrones(colony) # Remove drones to start from fresh
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
buildUp(colony, nWorkers = nWorkersPoisson, nDrones = nDronesPoisson)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
buildUp(colony, nWorkers = nWorkersPoisson, nDrones = nDronesPoisson)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
# nWorkers and nDrones will vary between function calls when a function is used
# You can store these functions or a values in the SP object
SP$nWorkers <- nWorkersPoisson
SP$nDrones <- nDronesPoisson
# Specifying own number
colony <- buildUp(colony, nWorkers = 100)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
# Build up a MultiColony class
apiary <- buildUp(apiary, nWorkers = 250)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
# Build up with different numbers
apiary <- buildUp(apiary, nWorkers = c(1000, 2000), nDrones = c(100, 150))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
nWorkers(apiary)
#> Error in is(x, class2 = "Colony"): object 'apiary' not found
nDrones(apiary)
#> Error in is(x, class2 = "Colony"): object 'apiary' not found
# Queen's counters
getMisc(getQueen(buildUp(colony)))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found