Level 0 function that reports caste of an individual
getCaste(x, collapse = FALSE, simParamBee = NULL)
Pop-class
, Colony-class
, or
MultiColony-class
logical, if TRUE
, the function will return a single
vector with caste information
SimParamBee
, global simulation parameters
When x is Pop-class
, character of caste status; if you
get NA
note that this is not supposed to happen. When x is
Colony-class
, list with character vectors (list is named with
caste). When x is MultiColony-class
, list of lists with
character vectors (list is named with colony id).
founderGenomes <- quickHaplo(nInd = 8, nChr = 1, segSites = 100)
SP <- SimParamBee$new(founderGenomes)
SP$nThreads = 1L
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
colony <- buildUp(x = colony, nWorkers = 20, nDrones = 5)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
colony <- addVirginQueens(colony, nInd = 5)
#> 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
apiary <- buildUp(x = apiary, nWorkers = 10, nDrones = 2)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
apiary <- addVirginQueens(apiary, nInd = 4)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
getCaste(getQueen(colony))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
getCaste(getFathers(colony))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
getCaste(getWorkers(colony))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
getCaste(getDrones(colony))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
getCaste(getVirginQueens(colony))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
bees <- c(
getQueen(colony),
getFathers(colony, nInd = 2),
getWorkers(colony, nInd = 2),
getDrones(colony, nInd = 2),
getVirginQueens(colony, nInd = 2)
)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
getCaste(bees)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
getCaste(colony)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
# Collapse information into a single vector
getCaste(colony, collapse = TRUE)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
getCaste(apiary)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
# Create a data.frame with id, colony, and caste information
(tmpC <- getCaste(apiary[[1]]))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
(tmpI <- getCasteId(apiary[[1]]))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
tmp <- data.frame(caste = unlist(tmpC), id = unlist(tmpI))
#> Error in eval(expr, envir, enclos): object 'tmpC' not found
head(tmp)
#> Error in eval(expr, envir, enclos): object 'tmp' not found
tail(tmp)
#> Error in eval(expr, envir, enclos): object 'tmp' not found
(tmpC <- getCaste(apiary))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
(tmpI <- getCasteId(apiary))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
(tmp <- data.frame(caste = unlist(tmpC), id = unlist(tmpI)))
#> Error in eval(expr, envir, enclos): object 'tmpC' not found
tmp$colony <- sapply(
X = strsplit(
x = rownames(tmp), split = ".",
fixed = TRUE
),
FUN = function(z) z[[1]]
)
#> Error in eval(expr, envir, enclos): object 'tmp' not found
head(tmp)
#> Error in eval(expr, envir, enclos): object 'tmp' not found
tail(tmp)
#> Error in eval(expr, envir, enclos): object 'tmp' not found