R/Functions_L0_auxilary.R
getCasteId.Rd
Level 0 function that returns the ID individuals of a caste. To
get the individuals, use getCastePop
. To get individuals'
caste, use getCaste
.
getCasteId(x, caste = "all", collapse = FALSE, simParamBee = NULL)
Pop-class
, Colony-class
, or
MultiColony-class
character, "queen", "fathers", "workers", "drones", "virginQueens", or "all"
logical, if all IDs should be returned as a single vector
SimParamBee
, global simulation parameters
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
founderGenomes <- quickHaplo(nInd = 8, nChr = 1, segSites = 100)
SP <- SimParamBee$new(founderGenomes)
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
apiary <- createMultiColony(basePop[3:4], n = 2)
#> Error in createMultiColony(basePop[3:4], n = 2): object 'basePop' 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
getCasteId(x = drones)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
getCasteId(x = colony)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
getCasteId(x = apiary, caste = "workers")
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
getCasteId(x = apiary)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
getCasteId(x = apiary, caste = "virginQueens")
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
# Get all IDs as a single vector
getCasteId(x = colony, caste = "all", collapse = TRUE)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
getCasteId(x = apiary, caste = "workers", collapse = TRUE)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
getCasteId(x = apiary, caste = "drones", collapse = TRUE)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
getCasteId(x = apiary, caste = "all", collapse = TRUE)
#> 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 unlist(tmpC): object 'tmpC' not found
head(tmp)
#> Error in head(tmp): object 'tmp' not found
tail(tmp)
#> Error in tail(tmp): 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 unlist(tmpC): object 'tmpC' not found
tmp$colony <- sapply(
X = strsplit(
x = rownames(tmp), split = ".",
fixed = TRUE
),
FUN = function(z) z[[1]]
)
#> Error in rownames(tmp): object 'tmp' not found
head(tmp)
#> Error in head(tmp): object 'tmp' not found
tail(tmp)
#> Error in tail(tmp): object 'tmp' not found