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

getCasteSex(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 TRUE, the function will return a single vector with sex information

simParamBee

SimParamBee, global simulation parameters

Value

when x is Pop-class for caste != "all"

or list for caste == "all" with sex 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 sexes; 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 sexes

Examples

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

getCasteSex(x = drones)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
getCasteSex(x = colony)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
getCasteSex(x = apiary, caste = "workers")
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
getCasteSex(x = apiary)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
getCasteSex(x = apiary, caste = "virginQueens")
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
# Collapse information into a single vector
getCasteSex(colony, caste = "all", collapse = TRUE)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found

# Create a data.frame with sex, colony, and caste information
(tmpC <- getCaste(apiary[[1]]))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
(tmpS <- getCasteSex(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), sex = unlist(tmpS), 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
(tmpS <- getCasteSex(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), sex = unlist(tmpS), 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