getCasteId {SIMplyBee}R Documentation

Get IDs of individuals of a caste, or ID of all members of colony

Description

Level 0 function that returns the ID individuals of a caste. To get the individuals, use getCastePop. To get individuals' caste, use getCaste.

Usage

getCasteId(x, caste = "all", collapse = FALSE, simParamBee = NULL)

Arguments

x

Pop-class, Colony-class, or MultiColony-class

caste

character, "queen", "fathers", "workers", "drones", "virginQueens", or "all"

collapse

logical, if all IDs should be returned as a single vector

simParamBee

SimParamBee, global simulation parameters

Value

when x is Pop-class for caste != "all" or list for caste == "all" with ID nodes named by caste; when x is Colony-class return is a named list of Pop-class for caste != "all" or named list for caste == "all" indluding caste members IDs; when x is MultiColony-class return is a named list of Pop-class for caste != "all" or named list of lists of Pop-class for caste == "all" indluding caste members IDs

See Also

getCaste

getCastePop and getCaste

Examples

founderGenomes <- quickHaplo(nInd = 8, nChr = 1, segSites = 100)
SP <- SimParamBee$new(founderGenomes)
basePop <- createVirginQueens(founderGenomes)

drones <- createDrones(x = basePop[1], nInd = 1000)
droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = nFathersPoisson)

# Create a Colony and a MultiColony class
colony <- createColony(x = basePop[2])
colony <- cross(colony, drones = droneGroups[[1]])
colony <- buildUp(x = colony, nWorkers = 20, nDrones = 5)

apiary <- createMultiColony(basePop[3:4], n = 2)
apiary <- cross(apiary, drones = droneGroups[c(2, 3)])
apiary <- buildUp(x = apiary, nWorkers = 10, nDrones = 2)
apiary <- addVirginQueens(apiary, nInd = 4)

getCasteId(x = drones)
getCasteId(x = colony)
getCasteId(x = apiary, caste = "workers")
getCasteId(x = apiary)
getCasteId(x = apiary, caste = "virginQueens")
# Get all IDs as a single vector
getCasteId(x = colony, caste = "all", collapse = TRUE)
getCasteId(x = apiary, caste = "workers", collapse = TRUE)
getCasteId(x = apiary, caste = "drones", collapse = TRUE)
getCasteId(x = apiary, caste = "all", collapse = TRUE)

# Create a data.frame with id, colony, and caste information
(tmpC <- getCaste(apiary[[1]]))
(tmpI <- getCasteId(apiary[[1]]))
tmp <- data.frame(caste = unlist(tmpC), id = unlist(tmpI))
head(tmp)
tail(tmp)

(tmpC <- getCaste(apiary))
(tmpI <- getCasteId(apiary))
(tmp <- data.frame(caste = unlist(tmpC), id = unlist(tmpI)))
tmp$colony <- sapply(
  X = strsplit(
    x = rownames(tmp), split = ".",
    fixed = TRUE
  ),
  FUN = function(z) z[[1]]
)
head(tmp)
tail(tmp)

[Package SIMplyBee version 0.3.0 Index]