Level 3 function that removes some colonies from the MultiColony object based on their ID.

removeColonies(
  multicolony,
  ID = NULL,
  n = NULL,
  p = NULL,
  by = NULL,
  removeTop = FALSE,
  simParamBee = NULL
)

Arguments

multicolony

MultiColony-class

ID

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

n

numeric, number of colonies to remove

p

numeric, percentage of colonies removed (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 removed at random. This parameter is used in combination with n or p to determine the number of removed colonies, and removeTop to determine whether to remove the best or the worst colonies.

removeTop

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

simParamBee

SimParamBee, global simulation parameters

Value

MultiColony-class with some colonies removed

Examples

founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 100)
SP <- SimParamBee$new(founderGenomes)
SP$nThreads = 1L
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 get(x = "SP", envir = .GlobalEnv): object 'SP' 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 eval(expr, envir, enclos): object 'apiary' not found

getId(removeColonies(apiary, ID = 1))
#> Error in eval(expr, envir, enclos): object 'apiary' not found
getId(removeColonies(apiary, ID = c("3", "4")))
#> Error in eval(expr, envir, enclos): object 'apiary' not found

nColonies(apiary)
#> Error in eval(expr, envir, enclos): object 'apiary' not found
apiary <- removeColonies(apiary, ID = "2")
#> Error in eval(expr, envir, enclos): object 'apiary' not found
nColonies(apiary)
#> Error in eval(expr, envir, enclos): object 'apiary' not found

# How to remove colonies based on colony values?
# Obtain colony phenotype
colonyPheno <- calcColonyPheno(apiary)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
# Remove the worst colony
removeColonies(apiary, n = 1, by = colonyPheno)
#> Error in eval(expr, envir, enclos): object 'apiary' not found