Level 3 function that pulls out some colonies from the MultiColony based on colony ID or random selection.

pullColonies(
  multicolony,
  ID = NULL,
  n = NULL,
  p = NULL,
  by = NULL,
  pullTop = TRUE
)

Arguments

multicolony

MultiColony-class

ID

character or numeric, ID of a colony (one or more) to be pulled out

n

numeric, number of colonies to select

p

numeric, percentage of colonies pulled out (takes precedence over n)

by

matrix, matrix of values to select by with names being colony IDs (can be obtained with calcColonyValue. If NULL, the colonies are pulled at random. This parameter is used in combination with n or p to determine the number of pulled colonies, and pullTop to determine whether to pull the best or the worst colonies.

pullTop

logical, pull highest (lowest) values if TRUE (FALSE)

Value

list with two MultiColony-class, the pulled

and the remnant

Examples

founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 100)
SP <- SimParamBee$new(founderGenomes)
mean <- c(10, 10 / SP$nWorkers)
varA <- c(1, 1 / SP$nWorkers)
corA <- matrix(data = c(
  1.0, -0.5,
  -0.5, 1.0
), nrow = 2, byrow = TRUE)
varE <- c(3, 3 / SP$nWorkers)
varA / (varA + varE)
#> [1] 0.25 0.25
SP$addTraitADE(nQtlPerChr = 100,
               mean = mean,
               var = varA, corA = corA,
               meanDD = 0.1, varDD = 0.2, corD = corA,
               relAA = 0.1, corAA = corA)
SP$setVarE(varE = varE)

basePop <- createVirginQueens(founderGenomes)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found

drones <- createDrones(x = basePop[1:4], nInd = 100)
#> 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
apiary <- createMultiColony(basePop[2:5], n = 4)
#> Error in createMultiColony(basePop[2:5], n = 4): object 'basePop' not found
apiary <- cross(apiary, drones = droneGroups[1:4])
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
apiary <- buildUp(apiary)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
getId(apiary)
#> Error in getId(apiary): object 'apiary' not found

tmp <- pullColonies(apiary, ID = c(1, 2))
#> Error in is(x, class2 = "MultiColony"): object 'apiary' not found
getId(tmp$pulled)
#> Error in getId(tmp$pulled): object 'tmp' not found
getId(tmp$remnant)
#> Error in getId(tmp$remnant): object 'tmp' not found

tmp <- pullColonies(apiary, ID = c("3", "4"))
#> Error in is(x, class2 = "MultiColony"): object 'apiary' not found
getId(tmp$pulled)
#> Error in getId(tmp$pulled): object 'tmp' not found
getId(tmp$remnant)
#> Error in getId(tmp$remnant): object 'tmp' not found

tmp <- pullColonies(apiary, n = 2)
#> Error in is(x, class2 = "MultiColony"): object 'apiary' not found
getId(tmp$pulled)
#> Error in getId(tmp$pulled): object 'tmp' not found
getId(tmp$remnant)
#> Error in getId(tmp$remnant): object 'tmp' not found

tmp <- pullColonies(apiary, p = 0.75)
#> Error in is(x, class2 = "MultiColony"): object 'apiary' not found
getId(tmp$pulled)
#> Error in getId(tmp$pulled): object 'tmp' not found
getId(tmp$remnant)
#> Error in getId(tmp$remnant): object 'tmp' not found

# How to pull out colonies based on colony values?
colonyGv <- calcColonyGv(apiary)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
pullColonies(apiary, n = 1, by = colonyGv)
#> Error in is(x, class2 = "MultiColony"): object 'apiary' not found