Get sex of individuals of a caste, or sex of all members of colony
Get sex of individuals of a caste, or sex of all members of colony
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
Returns
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)basePop <- createVirginQueens(founderGenomes)drones <- createDrones(x = basePop[1], nInd =1000)droneGroups <- pullDroneGroupsFromDCA(drones, n =10, nDrones = nFathersPoisson)# Create a Colony and a MultiColony classcolony <- createColony(x = basePop[2])colony <- cross(colony, drones = droneGroups[[1]])colony <- buildUp(x = colony, nWorkers =20, nDrones =5)colony <- addVirginQueens(colony, nInd =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)getCasteSex(x = drones)getCasteSex(x = colony)getCasteSex(x = apiary, caste ="workers")getCasteSex(x = apiary)getCasteSex(x = apiary, caste ="virginQueens")# Collapse information into a single vectorgetCasteSex(colony, caste ="all", collapse =TRUE)# Create a data.frame with sex, colony, and caste information(tmpC <- getCaste(apiary[[1]]))(tmpS <- getCasteSex(apiary[[1]]))(tmpI <- getCasteId(apiary[[1]]))tmp <- data.frame(caste = unlist(tmpC), sex = unlist(tmpS), id = unlist(tmpI))head(tmp)tail(tmp)(tmpC <- getCaste(apiary))(tmpS <- getCasteSex(apiary))(tmpI <- getCasteId(apiary))tmp <- data.frame(caste = unlist(tmpC), sex = unlist(tmpS), id = unlist(tmpI))tmp$colony <- sapply( X = strsplit( x = rownames(tmp), split =".", fixed =TRUE), FUN =function(z) z[[1]])head(tmp)tail(tmp)