Level 1 function that creates the specified number of caste individuals from the colony with a mated queens. If csd locus is active, it takes it into account and any csd homozygotes are removed and counted towards homozygous brood.
createCastePop(
  x,
  caste = NULL,
  nInd = NULL,
  exact = TRUE,
  year = NULL,
  editCsd = TRUE,
  csdAlleles = NULL,
  simParamBee = NULL,
  ...
)
createWorkers(x, nInd = NULL, exact = FALSE, simParamBee = NULL, ...)
createDrones(x, nInd = NULL, simParamBee = NULL, ...)
createVirginQueens(
  x,
  nInd = NULL,
  year = NULL,
  editCsd = TRUE,
  csdAlleles = NULL,
  simParamBee = NULL,
  ...
)link{MapPop-class} (only if caste is "virginQueens"), or
Pop (only if caste is "drones") or Colony-class
or MultiColony-class
character, "workers", "drones", or "virginQueens"
numeric or function, number of caste individuals; if NULL then
SimParamBee$nWorkers,  SimParamBee$nDrones
or SimParamBee$nVirginQueens is used depending on the caste;
only used when x is Colony-class or
MultiColony-class, when x is link{MapPop-class}
all individuals in x are converted into virgin queens
logical, only relevant when creating workers,
if the csd locus is active and exact is TRUE,
create the exactly specified number of viable workers (heterozygous on the
csd locus)
numeric, year of birth for virgin queens
logical (only active when x is link{MapPop-class}),
whether the csd locus should be edited to ensure heterozygosity at the csd
locus (to get viable virgin queens); see csdAlleles
NULL or list (only active when x is link{MapPop-class});
If NULL, then the function samples a heterozygous csd genotype for
each virgin queen from all possible csd alleles.
If not NULL, the user provides a list of length nInd with each
node holding a matrix or a data.frame, each having two rows and n columns.
Each row must hold one csd haplotype (allele) that will be assigned to a
virgin queen. The n columns span the length of the csd locus as specified
in SimParamBee. The two csd alleles must be different to
ensure heterozygosity at the csd locus.
SimParamBee, global simulation parameters
additional arguments passed to nInd when this argument is a function
when x is link{MapPop-class} returns
virginQueens (a Pop-class);
  when x is Colony-class returns
virginQueens (a Pop-class);
  when x is MultiColony-class
return is a named list of virginQueens (a Pop-class);
  named by colony ID
createWorkers(): Create workers from a colony
createDrones(): Create drones from a colony
createVirginQueens(): Create virgin queens from a colony
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50)
SP <- SimParamBee$new(founderGenomes)
SP$nThreads = 1L
SP$setTrackRec(TRUE)
SP$setTrackPed(isTrackPed = TRUE)
# Create virgin queens on a MapPop
basePop <- createCastePop(founderGenomes, caste = "virginQueens")
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
# Or alias
createVirginQueens(founderGenomes)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
# Same aliases exist for all the castes!!!
# Create drones on a Pop
drones <- createDrones(x = basePop[1],  nInd = 200)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
# Or create unequal number of drones from multiple virgin queens
drones <- createDrones(basePop[1:2], nInd = c(100, 200))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
droneGroups <- pullDroneGroupsFromDCA(drones, n = 3, 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
apiary <- createMultiColony(basePop[3:4], n = 2)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
apiary <- cross(apiary, drones = droneGroups[c(2, 3)])
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
# Using default nInd in SP
colony@virginQueens <- createVirginQueens(colony)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
colony@workers <- createWorkers(colony)$workers
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
colony@drones <- createDrones(colony)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
# Usually, you would use functions buildUp() or addCastePop()
# These populations hold individual information
# Example on the virgin queens (same holds for all castes!)
virginQueens <- colony@virginQueens
#> Error in eval(expr, envir, enclos): object 'colony' not found
virginQueens@id
#> Error in eval(expr, envir, enclos): object 'virginQueens' not found
virginQueens@sex
#> Error in eval(expr, envir, enclos): object 'virginQueens' not found
virginQueens@mother
#> Error in eval(expr, envir, enclos): object 'virginQueens' not found
virginQueens@father
#> Error in eval(expr, envir, enclos): object 'virginQueens' not found
# Specify own number
SP$nVirginQueens <- 15
SP$nWorkers <- 100
SP$nDrones <- 10
createVirginQueens(colony)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
createVirginQueens(apiary)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
# Or creating unequal numbers
createVirginQueens(apiary, nInd = c(5, 10))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
# nVirginQueens will NOT vary between function calls when a constant is used
# Specify a function that will give a number
createVirginQueens(colony, nInd = nVirginQueensPoisson)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
createVirginQueens(apiary, nInd = nVirginQueensPoisson)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
# No. of individuals will vary between function calls when a function is used
# Store a function or a value in the SP object
SP$nVirginQueens <- nVirginQueensPoisson
createVirginQueens(colony)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
createVirginQueens(colony)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
createVirginQueens(apiary)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
createVirginQueens(apiary)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
# No. of individuals will vary between function calls when a function is used
# csd homozygosity - relevant when creating virgin queens
SP <- SimParamBee$new(founderGenomes, csdChr = 1, nCsdAlleles = 8)
SP$nThreads = 1L
basePop <- createVirginQueens(founderGenomes, editCsd = FALSE)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
all(isCsdHeterozygous(basePop))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
basePop <- createVirginQueens(founderGenomes, editCsd = TRUE)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
all(isCsdHeterozygous(basePop))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found