Title: | 'AlphaSimR' Extension for Simulating Honeybee Populations and Breeding Programmes |
---|---|
Description: | An extension of the 'AlphaSimR' package (<https://cran.r-project.org/package=AlphaSimR>) for stochastic simulations of honeybee populations and breeding programmes. 'SIMplyBee' enables simulation of individual bees that form a colony, which includes a queen, fathers (drones the queen mated with), virgin queens, workers, and drones. Multiple colony can be merged into a population of colonies, such as an apiary or a whole country of colonies. Functions enable operations on castes, colony, or colonies, to ease 'R' scripting of whole populations. All 'AlphaSimR' functionality with respect to genomes and genetic and phenotype values is available and further extended for honeybees, including haplo-diploidy, complementary sex determiner locus, colony events (swarming, supersedure, etc.), and colony phenotype values. |
Authors: | Jana Obšteter [aut, cre] , Laura Strachan [aut] , Jernej Bubnič [aut] , Gregor Gorjanc [aut] |
Maintainer: | Jana Obšteter <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.4.1 |
Built: | 2024-11-20 06:57:58 UTC |
Source: | CRAN |
Level 2 function that adds (raises) the specified number of a specific caste individuals to a Colony or MultiColony object by producing offspring from a mated queen. If there are already some individuals present in the caste, new and present individuals are combined.
addCastePop( x, caste = NULL, nInd = NULL, new = FALSE, exact = FALSE, year = NULL, simParamBee = NULL, ... ) addWorkers(x, nInd = NULL, new = FALSE, exact = FALSE, simParamBee = NULL, ...) addDrones(x, nInd = NULL, new = FALSE, simParamBee = NULL, ...) addVirginQueens( x, nInd = NULL, new = FALSE, year = NULL, simParamBee = NULL, ... )
addCastePop( x, caste = NULL, nInd = NULL, new = FALSE, exact = FALSE, year = NULL, simParamBee = NULL, ... ) addWorkers(x, nInd = NULL, new = FALSE, exact = FALSE, simParamBee = NULL, ...) addDrones(x, nInd = NULL, new = FALSE, simParamBee = NULL, ...) addVirginQueens( x, nInd = NULL, new = FALSE, year = NULL, simParamBee = NULL, ... )
x |
|
caste |
character, "workers", "drones", or "virginQueens" |
nInd |
numeric or function, number of workers to be added, but see
|
new |
logical, should the number of individuals be added to the caste population
anew or should we only top-up the existing number of individuals to |
exact |
logical, only relevant when adding workers - if the csd locus is turned
on and exact is |
year |
numeric, only relevant when adding virgin queens - year of birth for virgin queens |
simParamBee |
|
... |
additional arguments passed to |
This function increases queen's nWorkers
and nHomBrood
counters.
Colony-class
or MultiColony-class
with
workers added
addWorkers()
: Add workers to a colony
addDrones()
: Add drones to a colony
addVirginQueens()
: Add virgin queens to a colony
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 100) droneGroups <- pullDroneGroupsFromDCA(drones, n = 5, nDrones = nFathersPoisson) # Create and cross Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) apiary <- createMultiColony(basePop[4:5], n = 2) apiary <- cross(apiary, drones = droneGroups[3:4]) #Here we show an example for workers, but same holds for drones and virgin queens! # Add workers addCastePop(colony, caste = "workers", nInd = 20) # Or use a alias function addWorkers(colony, nInd = 20) # Same aliases exist for drones and virgin queens! # If nInd is NULL, the functions uses the default in SP$nWorkers # We can change this default SP$nWorkers <- 15 nWorkers(addWorkers(colony)) # nVirginQueens/nWorkers/nDrones will NOT vary between function calls when a constant is used # Specify a function that will give a number nWorkers(addWorkers(colony, nInd = nWorkersPoisson)) nWorkers(addWorkers(colony, nInd = nWorkersPoisson)) # nVirginQueens/nWorkers/nDrones will vary between function calls when a function is used # Store a function or a value in the SP object SP$nWorkers <- nWorkersPoisson (addWorkers(colony)) # nVirginQueens/nWorkers/nDrones will vary between function calls when a function is used # Queen's counters getMisc(getQueen(addWorkers(colony))) # Add individuals to a MultiColony object apiary <- addWorkers(apiary) # Add different number of workers to colonies nWorkers(addWorkers(apiary, nInd = c(50, 100)))
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 100) droneGroups <- pullDroneGroupsFromDCA(drones, n = 5, nDrones = nFathersPoisson) # Create and cross Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) apiary <- createMultiColony(basePop[4:5], n = 2) apiary <- cross(apiary, drones = droneGroups[3:4]) #Here we show an example for workers, but same holds for drones and virgin queens! # Add workers addCastePop(colony, caste = "workers", nInd = 20) # Or use a alias function addWorkers(colony, nInd = 20) # Same aliases exist for drones and virgin queens! # If nInd is NULL, the functions uses the default in SP$nWorkers # We can change this default SP$nWorkers <- 15 nWorkers(addWorkers(colony)) # nVirginQueens/nWorkers/nDrones will NOT vary between function calls when a constant is used # Specify a function that will give a number nWorkers(addWorkers(colony, nInd = nWorkersPoisson)) nWorkers(addWorkers(colony, nInd = nWorkersPoisson)) # nVirginQueens/nWorkers/nDrones will vary between function calls when a function is used # Store a function or a value in the SP object SP$nWorkers <- nWorkersPoisson (addWorkers(colony)) # nVirginQueens/nWorkers/nDrones will vary between function calls when a function is used # Queen's counters getMisc(getQueen(addWorkers(colony))) # Add individuals to a MultiColony object apiary <- addWorkers(apiary) # Add different number of workers to colonies nWorkers(addWorkers(apiary, nInd = c(50, 100)))
Level 2 function that builds up a Colony or MultiColony object by adding (raising) workers and drones usually in spring or after events such as split or swarming.
buildUp( x, nWorkers = NULL, nDrones = NULL, new = TRUE, exact = FALSE, resetEvents = FALSE, simParamBee = NULL, ... )
buildUp( x, nWorkers = NULL, nDrones = NULL, new = TRUE, exact = FALSE, resetEvents = FALSE, simParamBee = NULL, ... )
x |
|
nWorkers |
numeric or function, number of worker to add to the colony,
but see |
nDrones |
numeric or function, number of drones to add to the colony,
but see |
new |
logical, should the number of workers and drones be added anew or
should we only top-up the existing number of workers and drones to
|
exact |
logical, if the csd locus is turned on and exact is |
resetEvents |
logical, call |
simParamBee |
|
... |
additional arguments passed to |
This function increases queen's nWorkers
, nHomBrood
,
and nDrones
counters. It also turns production on.
Argument new
enables simulation of two common cases. First,
if you are modelling year-to-year cycle, you will likely want
new = TRUE
, so that, say, in spring you will replace old (from last
year) workers and drones with the new ones. This is the case that we are
targeting and hence new = TRUE
is default. Second, if you are
modelling shorter period cycles, you will likely want new = FALSE
to
just top up the current workers and drones - you might also want to look at
replaceWorkers
and replaceDrones
.
TODO: Discuss on how to model day-to-day variation with new = FALSE
.
We are not sure this is easy to achieve with current implementation
just now, but could be expanded.
https://github.com/HighlanderLab/SIMplyBee/issues/176
Colony-class
or MultiColony-class
with workers and
drones replaced or added
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) 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]]) isProductive(colony) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) isProductive(apiary) # Build up # Using defaults in SP$nWorkers & SP$nDrones (colony <- buildUp(colony)) isProductive(colony) # Build-up a MultiColony class (apiary <- buildUp(apiary)) isProductive(apiary) # The user can also specify a function that will give a number colony <- removeWorkers(colony) # Remove workers to start from fresh colony <- removeDrones(colony) # Remove drones to start from fresh buildUp(colony, nWorkers = nWorkersPoisson, nDrones = nDronesPoisson) buildUp(colony, nWorkers = nWorkersPoisson, nDrones = nDronesPoisson) # nWorkers and nDrones will vary between function calls when a function is used # You can store these functions or a values in the SP object SP$nWorkers <- nWorkersPoisson SP$nDrones <- nDronesPoisson # Specifying own number colony <- buildUp(colony, nWorkers = 100) # Build up a MultiColony class apiary <- buildUp(apiary, nWorkers = 250) # Build up with different numbers apiary <- buildUp(apiary, nWorkers = c(1000, 2000), nDrones = c(100, 150)) nWorkers(apiary) nDrones(apiary) # Queen's counters getMisc(getQueen(buildUp(colony)))
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) 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]]) isProductive(colony) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) isProductive(apiary) # Build up # Using defaults in SP$nWorkers & SP$nDrones (colony <- buildUp(colony)) isProductive(colony) # Build-up a MultiColony class (apiary <- buildUp(apiary)) isProductive(apiary) # The user can also specify a function that will give a number colony <- removeWorkers(colony) # Remove workers to start from fresh colony <- removeDrones(colony) # Remove drones to start from fresh buildUp(colony, nWorkers = nWorkersPoisson, nDrones = nDronesPoisson) buildUp(colony, nWorkers = nWorkersPoisson, nDrones = nDronesPoisson) # nWorkers and nDrones will vary between function calls when a function is used # You can store these functions or a values in the SP object SP$nWorkers <- nWorkersPoisson SP$nDrones <- nDronesPoisson # Specifying own number colony <- buildUp(colony, nWorkers = 100) # Build up a MultiColony class apiary <- buildUp(apiary, nWorkers = 250) # Build up with different numbers apiary <- buildUp(apiary, nWorkers = c(1000, 2000), nDrones = c(100, 150)) nWorkers(apiary) nDrones(apiary) # Queen's counters getMisc(getQueen(buildUp(colony)))
This combine c()
method is a hack to combine NULL and an
AlphaSimR population object c(NULL, pop)
(c(pop, NULL)
works
already with AlphaSimR package code).
## S4 method for signature 'NULLOrPop' c(x, ...)
## S4 method for signature 'NULLOrPop' c(x, ...)
x |
NULL or |
... |
list of NULL or |
Level 0 function that returns Genomic Relatedness Matrix (GRM) for honeybees from Identical By Descent genomic data (tracked alleles since the founders) - see references on the background theory.
calcBeeGRMIbd(x)
calcBeeGRMIbd(x)
x |
|
a list with a matrix of gametic relatedness coefficients (genome) and a matrix of individual relatedness coefficients (indiv)
Grossman and Eisen (1989) Inbreeding, coancestry, and covariance between relatives for X-chromosomal loci. The Journal of Heredity, doi:10.1093/oxfordjournals.jhered.a110812
Fernando and Grossman (1989) Covariance between relatives for X-chromosomal loci in a population in disequilibrium. Theoretical and Applied Genetics, doi:10.1007/bf00305821
Fernando and Grossman (1990) Genetic evaluation with autosomal and X-chromosomal inheritance. Theoretical and Applied Genetics, doi:10.1007/bf00224018
Van Arendonk, Tier, and Kinghorn (1994) Use of multiple genetic markers in prediction of breeding values. Genetics, doi:10.1093/genetics/137.1.319
Hill and Weir (2011) Variation in actual relationship as a consequence of Mendelian sampling and linkage. Genetics Research, doi:10.1017/s0016672310000480
founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) SP$setTrackRec(TRUE) SP$setTrackPed(isTrackPed = TRUE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 1, nDrones = nFathersPoisson) colony <- createColony(basePop[2]) colony <- cross(x = colony, drones = droneGroups[[1]]) colony <- buildUp(x = colony, nWorkers = 6, nDrones = 3) haploQ <- getQueenIbdHaplo(colony) haploW <- getWorkersIbdHaplo(colony) haploD <- getDronesIbdHaplo(colony) SP$pedigree haplo <- rbind(haploQ, haploW, haploD) GRMs <- calcBeeGRMIbd(x = haplo) # You can visualise this matrix with the image() functions from the "Matrix" package # Inspect the diagonal of the relationship matrix between individuals x <- diag(GRMs$indiv) hist(x) summary(x) # Inspect the off-diagonal of the relationship matrix between individuals x <- GRMs$indiv[lower.tri(x = GRMs$indiv, diag = FALSE)] hist(x) summary(x) ids <- getCasteId(colony) qI <- ids$queen wI <- sort(ids$workers) dI <- sort(ids$drones) qG <- c(t(outer(X = qI, Y = 1:2, FUN = paste, sep = "_"))) wG <- c(t(outer(X = wI, Y = 1:2, FUN = paste, sep = "_"))) dG <- paste(dI, 1, sep = "_") # Queen vs workers GRMs$genome[wG, qG] GRMs$indiv[wI, qI] # Queen vs drones GRMs$genome[dG, qG] GRMs$indiv[dI, qI] # Workers vs workers GRMs$genome[wG, wG] GRMs$indiv[wI, wI] # Workers vs drones GRMs$genome[dG, wG] GRMs$indiv[dI, wI]
founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) SP$setTrackRec(TRUE) SP$setTrackPed(isTrackPed = TRUE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 1, nDrones = nFathersPoisson) colony <- createColony(basePop[2]) colony <- cross(x = colony, drones = droneGroups[[1]]) colony <- buildUp(x = colony, nWorkers = 6, nDrones = 3) haploQ <- getQueenIbdHaplo(colony) haploW <- getWorkersIbdHaplo(colony) haploD <- getDronesIbdHaplo(colony) SP$pedigree haplo <- rbind(haploQ, haploW, haploD) GRMs <- calcBeeGRMIbd(x = haplo) # You can visualise this matrix with the image() functions from the "Matrix" package # Inspect the diagonal of the relationship matrix between individuals x <- diag(GRMs$indiv) hist(x) summary(x) # Inspect the off-diagonal of the relationship matrix between individuals x <- GRMs$indiv[lower.tri(x = GRMs$indiv, diag = FALSE)] hist(x) summary(x) ids <- getCasteId(colony) qI <- ids$queen wI <- sort(ids$workers) dI <- sort(ids$drones) qG <- c(t(outer(X = qI, Y = 1:2, FUN = paste, sep = "_"))) wG <- c(t(outer(X = wI, Y = 1:2, FUN = paste, sep = "_"))) dG <- paste(dI, 1, sep = "_") # Queen vs workers GRMs$genome[wG, qG] GRMs$indiv[wI, qI] # Queen vs drones GRMs$genome[dG, qG] GRMs$indiv[dI, qI] # Workers vs workers GRMs$genome[wG, wG] GRMs$indiv[wI, wI] # Workers vs drones GRMs$genome[dG, wG] GRMs$indiv[dI, wI]
Level 0 function that returns Genomic Relatedness Matrix (GRM) for honeybees from Identical By State genomic data (bi-allelic SNP represented as allele dosages) following the method for the sex X chromosome (Druet and Legarra, 2020)
calcBeeGRMIbs(x, sex, alleleFreq = NULL) calcBeeAlleleFreq(x, sex)
calcBeeGRMIbs(x, sex, alleleFreq = NULL) calcBeeAlleleFreq(x, sex)
x |
|
sex |
character vector denoting sex for individuals with genotypes in
|
alleleFreq |
numeric, vector of allele frequencies for the sites in
|
matrix of genomic relatedness coefficients
calcBeeAlleleFreq()
: Calculate allele frequencies from honeybee genotypes
Druet and Legarra (2020) Theoretical and empirical comparisons of expected and realized relationships for the X-chromosome. Genetics Selection Evolution, 52:50 doi:10.1186/s12711-020-00570-6
founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) SP$setTrackRec(TRUE) SP$setTrackPed(isTrackPed = TRUE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 1, nDrones = nFathersPoisson) colony <- createColony(basePop[2]) colony <- cross(x = colony, drones = droneGroups[[1]]) colony <- buildUp(x = colony, nWorkers = 6, nDrones = 3) geno <- getSegSiteGeno(colony, collapse = TRUE) sex <- getCasteSex(x = colony, collapse = TRUE) GRM <- calcBeeGRMIbs(x = geno, sex = sex) # You can visualise this matrix with the function image() from the package 'Matrix' #Look at the diagonal at the relationship matrix x <- diag(GRM) hist(x) summary(x) #Look at the off-diagonal at the relationship matrix x <- GRM[lower.tri(x = GRM, diag = FALSE)] hist(x) summary(x) # Compare relationship between castes ids <- getCasteId(colony) idQueen <- ids$queen idWorkers <- ids$workers idDrones <- ids$drones # Queen vs others GRM[idQueen, idWorkers] GRM[idQueen, idDrones] # Workers vs worker GRM[idWorkers, idWorkers] # Workers vs drones GRM[idWorkers, idDrones] # Calculating allele frequencies ourselves (say, to "shift" base population) aF <- calcBeeAlleleFreq(x = geno, sex = sex) hist(aF) GRM2 <- calcBeeGRMIbs(x = geno, sex = sex, alleleFreq = aF) stopifnot(identical(GRM2, GRM)) # You can also create relationships with pooled genomes pooledGenoW <- getPooledGeno(getWorkersSegSiteGeno(colony), type = "mean", sex = getCasteSex(colony, caste="workers")) queenGeno <- getQueenSegSiteGeno(colony) # Compute relationship between pooled workers genotype and the queen calcBeeGRMIbs(x = rbind(queenGeno, pooledGenoW), sex = c("F","F")) # You can now compare how this compare to relationships between the queen # individual workers!
founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) SP$setTrackRec(TRUE) SP$setTrackPed(isTrackPed = TRUE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 1, nDrones = nFathersPoisson) colony <- createColony(basePop[2]) colony <- cross(x = colony, drones = droneGroups[[1]]) colony <- buildUp(x = colony, nWorkers = 6, nDrones = 3) geno <- getSegSiteGeno(colony, collapse = TRUE) sex <- getCasteSex(x = colony, collapse = TRUE) GRM <- calcBeeGRMIbs(x = geno, sex = sex) # You can visualise this matrix with the function image() from the package 'Matrix' #Look at the diagonal at the relationship matrix x <- diag(GRM) hist(x) summary(x) #Look at the off-diagonal at the relationship matrix x <- GRM[lower.tri(x = GRM, diag = FALSE)] hist(x) summary(x) # Compare relationship between castes ids <- getCasteId(colony) idQueen <- ids$queen idWorkers <- ids$workers idDrones <- ids$drones # Queen vs others GRM[idQueen, idWorkers] GRM[idQueen, idDrones] # Workers vs worker GRM[idWorkers, idWorkers] # Workers vs drones GRM[idWorkers, idDrones] # Calculating allele frequencies ourselves (say, to "shift" base population) aF <- calcBeeAlleleFreq(x = geno, sex = sex) hist(aF) GRM2 <- calcBeeGRMIbs(x = geno, sex = sex, alleleFreq = aF) stopifnot(identical(GRM2, GRM)) # You can also create relationships with pooled genomes pooledGenoW <- getPooledGeno(getWorkersSegSiteGeno(colony), type = "mean", sex = getCasteSex(colony, caste="workers")) queenGeno <- getQueenSegSiteGeno(colony) # Compute relationship between pooled workers genotype and the queen calcBeeGRMIbs(x = rbind(queenGeno, pooledGenoW), sex = c("F","F")) # You can now compare how this compare to relationships between the queen # individual workers!
Level 0 function that calculate value(s) of a colony.
calcColonyValue(x, FUN = NULL, simParamBee = NULL, ...) calcColonyPheno(x, FUN = mapCasteToColonyPheno, simParamBee = NULL, ...) calcColonyGv(x, FUN = mapCasteToColonyGv, simParamBee = NULL, ...) calcColonyBv(x, FUN = mapCasteToColonyBv, simParamBee = NULL, ...) calcColonyDd(x, FUN = mapCasteToColonyDd, simParamBee = NULL, ...) calcColonyAa(x, FUN = mapCasteToColonyAa, simParamBee = NULL, ...)
calcColonyValue(x, FUN = NULL, simParamBee = NULL, ...) calcColonyPheno(x, FUN = mapCasteToColonyPheno, simParamBee = NULL, ...) calcColonyGv(x, FUN = mapCasteToColonyGv, simParamBee = NULL, ...) calcColonyBv(x, FUN = mapCasteToColonyBv, simParamBee = NULL, ...) calcColonyDd(x, FUN = mapCasteToColonyDd, simParamBee = NULL, ...) calcColonyAa(x, FUN = mapCasteToColonyAa, simParamBee = NULL, ...)
x |
|
FUN |
function, that calculates colony value from values of colony members |
simParamBee |
|
... |
other arguments of |
a matrix with one value or a row of values when x
is
Colony-class
and a row-named matrix when x
is
MultiColony-class
, where names are colony IDs
calcColonyPheno()
: Calculate colony phenotype value from caste individuals' phenotype values
calcColonyGv()
: Calculate colony genetic value from caste individuals' genetic values
calcColonyBv()
: Calculate colony breeding value from caste individuals' breeding values
calcColonyDd()
: Calculate colony dominance value from caste individuals' dominance values
calcColonyAa()
: Calculate colony epistasis value from caste individuals' epistasis value
mapCasteToColonyValue
as an example of FUN
,
selectColonies
for example for to select colonies based
on these values, and
vignette(topic = "QuantitativeGenetics", package = "SIMplyBee")
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) # Define two traits that collectively affect colony honey yield: # 1) queen's effect on colony honey yield, say via pheromone secretion phenotype # 2) workers' effect on colony honey yield, say via foraging ability phenotype # The traits will have a negative genetic correlation of -0.5 and heritability # of 0.25 (on an individual level) nWorkers <- 10 mean <- c(10, 10 / nWorkers) varA <- c(1, 1 / nWorkers) corA <- matrix(data = c( 1.0, -0.5, -0.5, 1.0 ), nrow = 2, byrow = TRUE) varE <- c(3, 3 / nWorkers) varA / (varA + varE) SP$addTraitADE(nQtlPerChr = 100, mean = mean, var = varA, corA = corA, meanDD = 0.1, varDD = 0.2, corD = corA, relAA = 0.1, corAA = corA) SP$setVarE(varE = varE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 200) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = nFathersPoisson) # Create and cross Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) colony <- buildUp(colony, nWorkers = nWorkers, nDrones = 3) apiary <- createMultiColony(basePop[3:5], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(apiary, nWorkers = nWorkers, nDrones = 3) # Colony value - shorthand version # (using the default mapCasteToColony*() functions - you can provide yours instead!) # Phenotype value calcColonyPheno(colony) calcColonyPheno(apiary) # Genetic value calcColonyGv(colony) calcColonyGv(apiary) # Colony value - long version # (using the default mapCasteToColony*() function - you can provide yours instead!) calcColonyValue(colony, FUN = mapCasteToColonyPheno) calcColonyValue(apiary, FUN = mapCasteToColonyPheno) # Colony value - long version - using a function stored in SimParamBee (SP) # (using the default mapCasteToColony*() function - you can provide yours instead!) SP$colonyValueFUN <- mapCasteToColonyPheno calcColonyValue(colony) calcColonyValue(apiary)
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) # Define two traits that collectively affect colony honey yield: # 1) queen's effect on colony honey yield, say via pheromone secretion phenotype # 2) workers' effect on colony honey yield, say via foraging ability phenotype # The traits will have a negative genetic correlation of -0.5 and heritability # of 0.25 (on an individual level) nWorkers <- 10 mean <- c(10, 10 / nWorkers) varA <- c(1, 1 / nWorkers) corA <- matrix(data = c( 1.0, -0.5, -0.5, 1.0 ), nrow = 2, byrow = TRUE) varE <- c(3, 3 / nWorkers) varA / (varA + varE) SP$addTraitADE(nQtlPerChr = 100, mean = mean, var = varA, corA = corA, meanDD = 0.1, varDD = 0.2, corD = corA, relAA = 0.1, corAA = corA) SP$setVarE(varE = varE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 200) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = nFathersPoisson) # Create and cross Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) colony <- buildUp(colony, nWorkers = nWorkers, nDrones = 3) apiary <- createMultiColony(basePop[3:5], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(apiary, nWorkers = nWorkers, nDrones = 3) # Colony value - shorthand version # (using the default mapCasteToColony*() functions - you can provide yours instead!) # Phenotype value calcColonyPheno(colony) calcColonyPheno(apiary) # Genetic value calcColonyGv(colony) calcColonyGv(apiary) # Colony value - long version # (using the default mapCasteToColony*() function - you can provide yours instead!) calcColonyValue(colony, FUN = mapCasteToColonyPheno) calcColonyValue(apiary, FUN = mapCasteToColonyPheno) # Colony value - long version - using a function stored in SimParamBee (SP) # (using the default mapCasteToColony*() function - you can provide yours instead!) SP$colonyValueFUN <- mapCasteToColonyPheno calcColonyValue(colony) calcColonyValue(apiary)
Level 0 function that calculates the inheritance criterion as the sum of the queen (maternal) and workers (direct) effect from the queen, as defined by Du et al. (2021). This can be seen as the expected value of drones from the queen or half the expected value of virgin queens from the queen.
calcInheritanceCriterion( x, queenTrait = 1, workersTrait = 2, use = "gv", simParamBee = NULL )
calcInheritanceCriterion( x, queenTrait = 1, workersTrait = 2, use = "gv", simParamBee = NULL )
x |
|
queenTrait |
numeric (column position) or character (column name), trait
that represents queen's effect on the colony value; if |
workersTrait |
numeric (column position) or character (column name), trait
that represents workers' effect on the colony value; if |
use |
character, the measure to use for the calculation, being either "gv" (genetic value), "ebv" (estimated breeding value), or "pheno" (phenotypic value) |
simParamBee |
|
integer when x
is
Colony-class
and a named list when x
is
MultiColony-class
, where names are colony IDs
Du, M., et al. (2021) Short-term effects of controlled mating and selection on the genetic variance of honeybee populations. Heredity 126, 733–747. doi:10.1038/s41437-021-00411-2
calcSelectionCriterion
and
calcPerformanceCriterion
and as well as
vignette(topic = "QuantitativeGenetics", package = "SIMplyBee")
founderGenomes <- quickHaplo(nInd = 8, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) meanA <- c(10, 10 / SP$nWorkers) varA <- c(1, 1 / SP$nWorkers) corA <- matrix(data = c( 1.0, -0.5, -0.5, 1.0), nrow = 2, byrow = TRUE) SP$addTraitA(nQtlPerChr = 100, mean = meanA, var = varA, corA = corA, name = c("queenTrait", "workersTrait")) varE <- c(3, 3 / SP$nWorkers) corE <- matrix(data = c(1.0, 0.3, 0.3, 1.0), nrow = 2, byrow = TRUE) SP$setVarE(varE = varE, corE = corE) 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]]) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) calcInheritanceCriterion(colony, queenTrait = 1, workersTrait = 2) calcInheritanceCriterion(apiary, queenTrait = 1, workersTrait = 2) apiary[[2]] <- removeQueen(apiary[[2]]) calcInheritanceCriterion(apiary, queenTrait = 1, workersTrait = 2)
founderGenomes <- quickHaplo(nInd = 8, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) meanA <- c(10, 10 / SP$nWorkers) varA <- c(1, 1 / SP$nWorkers) corA <- matrix(data = c( 1.0, -0.5, -0.5, 1.0), nrow = 2, byrow = TRUE) SP$addTraitA(nQtlPerChr = 100, mean = meanA, var = varA, corA = corA, name = c("queenTrait", "workersTrait")) varE <- c(3, 3 / SP$nWorkers) corE <- matrix(data = c(1.0, 0.3, 0.3, 1.0), nrow = 2, byrow = TRUE) SP$setVarE(varE = varE, corE = corE) 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]]) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) calcInheritanceCriterion(colony, queenTrait = 1, workersTrait = 2) calcInheritanceCriterion(apiary, queenTrait = 1, workersTrait = 2) apiary[[2]] <- removeQueen(apiary[[2]]) calcInheritanceCriterion(apiary, queenTrait = 1, workersTrait = 2)
Level 0 function that calculates the performance criterion as the sum of the queen (maternal) effect from the queen and the workers (direct) effect from her workers, as defined by Du et al. (2021). This can be seen as the expected value of the colony.
calcPerformanceCriterion( x, queenTrait = 1, workersTrait = 2, workersTraitFUN = sum, use = "gv", simParamBee = NULL )
calcPerformanceCriterion( x, queenTrait = 1, workersTrait = 2, workersTraitFUN = sum, use = "gv", simParamBee = NULL )
x |
|
queenTrait |
numeric (column position) or character (column name), trait
that represents queen's effect on the colony value; if |
workersTrait |
numeric (column position) or character (column name), trait
that represents workers' effect on the colony value; if |
workersTraitFUN |
function, that will be applied to the workers effect values of workers, default is sum (see examples), but note that the correct function will depend on how you will setup simulation! |
use |
character, the measure to use for the calculation, being either "gv" (genetic value),"ebv" (estimated breeding value), or "pheno" (phenotypic value) |
simParamBee |
|
integer when x
is
Colony-class
and a named list when x
is
MultiColony-class
, where names are colony IDs
Du, M., et al. (2021) Short-term effects of controlled mating and selection on the genetic variance of honeybee populations. Heredity 126, 733–747. doi:10.1038/s41437-021-00411-2
calcSelectionCriterion
and
calcInheritanceCriterion
and as well as
vignette(topic = "QuantitativeGenetics", package = "SIMplyBee")
founderGenomes <- quickHaplo(nInd = 8, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) meanA <- c(10, 10 / SP$nWorkers) varA <- c(1, 1 / SP$nWorkers) corA <- matrix(data = c( 1.0, -0.5, -0.5, 1.0), nrow = 2, byrow = TRUE) SP$addTraitA(nQtlPerChr = 100, mean = meanA, var = varA, corA = corA, name = c("queenTrait", "workersTrait")) varE <- c(3, 3 / SP$nWorkers) corE <- matrix(data = c(1.0, 0.3, 0.3, 1.0), nrow = 2, byrow = TRUE) SP$setVarE(varE = varE, corE = corE) 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(colony) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(apiary) calcPerformanceCriterion(colony, queenTrait = 1, workersTrait = 2, workersTraitFUN = sum) calcPerformanceCriterion(apiary, queenTrait = 1, workersTrait = 2, workersTraitFUN = sum) apiary[[2]] <- removeQueen(apiary[[2]]) calcPerformanceCriterion(apiary, queenTrait = 1, workersTrait = 2, workersTraitFUN = sum)
founderGenomes <- quickHaplo(nInd = 8, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) meanA <- c(10, 10 / SP$nWorkers) varA <- c(1, 1 / SP$nWorkers) corA <- matrix(data = c( 1.0, -0.5, -0.5, 1.0), nrow = 2, byrow = TRUE) SP$addTraitA(nQtlPerChr = 100, mean = meanA, var = varA, corA = corA, name = c("queenTrait", "workersTrait")) varE <- c(3, 3 / SP$nWorkers) corE <- matrix(data = c(1.0, 0.3, 0.3, 1.0), nrow = 2, byrow = TRUE) SP$setVarE(varE = varE, corE = corE) 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(colony) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(apiary) calcPerformanceCriterion(colony, queenTrait = 1, workersTrait = 2, workersTraitFUN = sum) calcPerformanceCriterion(apiary, queenTrait = 1, workersTrait = 2, workersTraitFUN = sum) apiary[[2]] <- removeQueen(apiary[[2]]) calcPerformanceCriterion(apiary, queenTrait = 1, workersTrait = 2, workersTraitFUN = sum)
Level 0 functions that calculate or report the proportion of csd
homozygous brood of a queen or a colony. The csd locus determines viability
of fertilised eggs (brood) - homozygous brood is removed by workers. These
functions 1) calculate the expected proportion of homozygous brood from the
csd allele of the queen and fathers, 2) report the expected proportion of
homozygous brood, or 3) report a realised number of homozygous brood due to
inheritance process. See vignette(package = "SIMplyBee")
for more
details.
calcQueensPHomBrood(x, simParamBee = NULL) pHomBrood(x, simParamBee = NULL) nHomBrood(x, simParamBee = NULL)
calcQueensPHomBrood(x, simParamBee = NULL) pHomBrood(x, simParamBee = NULL) nHomBrood(x, simParamBee = NULL)
x |
|
simParamBee |
|
numeric, expected csd homozygosity named by colony id when x
is MultiColony-class
pHomBrood()
: Expected percentage of csd homozygous brood
of a queen / colony
nHomBrood()
: Realised number of csd homozygous brood
produced by a queen
Demo in the introductory vignette
vignette("Honeybee_biology", package="SIMplyBee")
# This is a bit long example - the key is at the end! 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 = 120, nDrones = 20) colony <- addVirginQueens(x = colony, nInd = 1) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 100, nDrones = 10) # Virgin queen try(calcQueensPHomBrood(basePop[5])) # Queens of colony calcQueensPHomBrood(colony) # Queens of apiary calcQueensPHomBrood(apiary) # Inbreed virgin queen with her brothers to generate csd homozygous brood colony2 <- createColony(x = getVirginQueens(colony)) colony2 <- cross(x = colony2, drones = pullDrones(x = colony, nInd = nFathersPoisson())[[1]]) # Calculate the expected csd homozygosity calcQueensPHomBrood(getQueen(colony2)) pHomBrood(colony2) # Evaluate a realised csd homozygosity nHomBrood(addWorkers(colony2, nInd = 100)) nHomBrood(addWorkers(colony2, nInd = 100)) # nHomBrood will vary between function calls due to inheritance process
# This is a bit long example - the key is at the end! 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 = 120, nDrones = 20) colony <- addVirginQueens(x = colony, nInd = 1) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 100, nDrones = 10) # Virgin queen try(calcQueensPHomBrood(basePop[5])) # Queens of colony calcQueensPHomBrood(colony) # Queens of apiary calcQueensPHomBrood(apiary) # Inbreed virgin queen with her brothers to generate csd homozygous brood colony2 <- createColony(x = getVirginQueens(colony)) colony2 <- cross(x = colony2, drones = pullDrones(x = colony, nInd = nFathersPoisson())[[1]]) # Calculate the expected csd homozygosity calcQueensPHomBrood(getQueen(colony2)) pHomBrood(colony2) # Evaluate a realised csd homozygosity nHomBrood(addWorkers(colony2, nInd = 100)) nHomBrood(addWorkers(colony2, nInd = 100)) # nHomBrood will vary between function calls due to inheritance process
Level 0 function that calculates the selection criterion as the sum of workers (direct) and queen (maternal) effects of workers, as defined by Du et al. (2021). This can be seen as the expected value of virgin queens from the queen (as well as workers, but we would not be selecting workers).
calcSelectionCriterion( x, queenTrait = 1, queenTraitFUN = sum, workersTrait = 2, workersTraitFUN = sum, use = "gv", simParamBee = NULL )
calcSelectionCriterion( x, queenTrait = 1, queenTraitFUN = sum, workersTrait = 2, workersTraitFUN = sum, use = "gv", simParamBee = NULL )
x |
|
queenTrait |
numeric (column position) or character (column name), trait
that represents queen's effect on the colony value; if |
queenTraitFUN |
function, that will be applied to the queen effect values of workers, default is sum (see examples), but note that the correct function will depend on how you will setup simulation! |
workersTrait |
numeric (column position) or character (column name), trait
that represents workers' effect on the colony value; if |
workersTraitFUN |
function, that will be applied to the workers effect values of workers, default is sum (see examples), but note that the correct function will depend on how you will setup simulation! |
use |
character, the measure to use for the calculation, being either "gv" (genetic value), "ebv" (estimated breeding value), or "pheno" (phenotypic value) |
simParamBee |
|
integer when x
is
Colony-class
and a named list when x
is
MultiColony-class
, where names are colony IDs
Du, M., et al. (2021) Short-term effects of controlled mating and selection on the genetic variance of honeybee populations. Heredity 126, 733–747. doi:10.1038/s41437-021-00411-2
calcInheritanceCriterion
and
calcPerformanceCriterion
and as well as
founderGenomes <- quickHaplo(nInd = 8, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) meanA <- c(10, 10 / SP$nWorkers) varA <- c(1, 1 / SP$nWorkers) corA <- matrix(data = c( 1.0, -0.5, -0.5, 1.0), nrow = 2, byrow = TRUE) SP$addTraitA(nQtlPerChr = 100, mean = meanA, var = varA, corA = corA, name = c("queenTrait", "workersTrait")) varE <- c(3, 3 / SP$nWorkers) corE <- matrix(data = c(1.0, 0.3, 0.3, 1.0), nrow = 2, byrow = TRUE) SP$setVarE(varE = varE, corE = corE) 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(colony) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(apiary) calcSelectionCriterion(colony, queenTrait = 1, queenTraitFUN = sum, workersTrait = 2, workersTraitFUN = sum) calcSelectionCriterion(apiary, queenTrait = 1, queenTraitFUN = sum, workersTrait = 2, workersTraitFUN = sum) apiary[[2]] <- removeQueen(apiary[[2]]) calcSelectionCriterion(apiary, queenTrait = 1, workersTrait = 2, workersTraitFUN = sum)
founderGenomes <- quickHaplo(nInd = 8, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) meanA <- c(10, 10 / SP$nWorkers) varA <- c(1, 1 / SP$nWorkers) corA <- matrix(data = c( 1.0, -0.5, -0.5, 1.0), nrow = 2, byrow = TRUE) SP$addTraitA(nQtlPerChr = 100, mean = meanA, var = varA, corA = corA, name = c("queenTrait", "workersTrait")) varE <- c(3, 3 / SP$nWorkers) corE <- matrix(data = c(1.0, 0.3, 0.3, 1.0), nrow = 2, byrow = TRUE) SP$setVarE(varE = varE, corE = corE) 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(colony) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(apiary) calcSelectionCriterion(colony, queenTrait = 1, queenTraitFUN = sum, workersTrait = 2, workersTraitFUN = sum) calcSelectionCriterion(apiary, queenTrait = 1, queenTraitFUN = sum, workersTrait = 2, workersTraitFUN = sum) apiary[[2]] <- removeQueen(apiary[[2]]) calcSelectionCriterion(apiary, queenTrait = 1, workersTrait = 2, workersTraitFUN = sum)
Level 2 function that collapses a Colony or MultiColony object
by setting the collapse event slot to TRUE
. The production status
slot is also changed (to FALSE
).
collapse(x)
collapse(x)
x |
You should use this function in an edge-case when you want to indicate that the colony has collapsed, but you still want to collect some values from the colony for a retrospective analysis. It resembles a situation where the colony has collapsed, but dead bees are still in the hive.
Colony-class
or MultiColony-class
with the collapse
event set to TRUE
founderGenomes <- quickHaplo(nInd = 10, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(basePop[1], n = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = 10) # Create Colony and MultiColony class colony <- createColony(x = basePop[1]) colony <- cross(colony, drones = droneGroups[[1]]) apiary <- createMultiColony(x = basePop[2:10], n = 9) apiary <- cross(apiary, drones = droneGroups[2:10]) # Collapse hasCollapsed(colony) colony <- collapse(colony) hasCollapsed(colony) hasCollapsed(apiary) tmp <- pullColonies(apiary, n = 2) tmp apiaryLost <- collapse(tmp$pulled) hasCollapsed(apiaryLost) apiaryLeft <- tmp$remnant hasCollapsed(apiaryLeft)
founderGenomes <- quickHaplo(nInd = 10, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(basePop[1], n = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = 10) # Create Colony and MultiColony class colony <- createColony(x = basePop[1]) colony <- cross(colony, drones = droneGroups[[1]]) apiary <- createMultiColony(x = basePop[2:10], n = 9) apiary <- cross(apiary, drones = droneGroups[2:10]) # Collapse hasCollapsed(colony) colony <- collapse(colony) hasCollapsed(colony) hasCollapsed(apiary) tmp <- pullColonies(apiary, n = 2) tmp apiaryLost <- collapse(tmp$pulled) hasCollapsed(apiaryLost) apiaryLeft <- tmp$remnant hasCollapsed(apiaryLeft)
An object holding honeybee colony
isColony(x) ## S4 method for signature 'Colony' show(object) ## S4 method for signature 'ColonyOrNULL' c(x, ...)
isColony(x) ## S4 method for signature 'Colony' show(object) ## S4 method for signature 'ColonyOrNULL' c(x, ...)
x |
|
object |
|
... |
|
Colony-class
or MultiColony-class
isColony()
: Test if x is a Colony class object
show(Colony)
: Show colony object
c(ColonyOrNULL)
: Combine multiple colony objects
id
integer, unique ID of the colony
location
numeric, location of the colony (x, y)
queen
Pop-class
, the queen of the colony (we use
its misc slot for queen's age and drones (fathers) she mated with)
virginQueens
Pop-class
, virgin queens of the
colony
drones
Pop-class
, drones of the colony
workers
Pop-class
, workers of the colony
split
logical, has colony split
swarm
logical, has colony swarmed
supersedure
logical, has colony superseded
collapse
logical, has colony collapsed
production
logical, is colony productive
misc
list, available for storing extra information about the colony
founderGenomes <- quickHaplo(nInd = 4, 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) colony1 <- createColony(x = basePop[2]) colony1 <- cross(colony1, drones = droneGroups[[1]]) colony2 <- createColony(x = basePop[3]) colony2 <- cross(colony2, drones = droneGroups[[2]]) colony3 <- createColony(x = basePop[4]) colony3 <- cross(colony3, drones = droneGroups[[3]]) colony1 show(colony1) is(colony1) isColony(colony1) apiary <- c(colony1, colony2) is(apiary) isMultiColony(apiary) c(apiary, colony3) c(colony3, apiary)
founderGenomes <- quickHaplo(nInd = 4, 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) colony1 <- createColony(x = basePop[2]) colony1 <- cross(colony1, drones = droneGroups[[1]]) colony2 <- createColony(x = basePop[3]) colony2 <- cross(colony2, drones = droneGroups[[2]]) colony3 <- createColony(x = basePop[4]) colony3 <- cross(colony3, drones = droneGroups[[3]]) colony1 show(colony1) is(colony1) isColony(colony1) apiary <- c(colony1, colony2) is(apiary) isMultiColony(apiary) c(apiary, colony3) c(colony3, apiary)
Level 2 function that combines two Colony or MultiColony objects into one or two colonies objects of the same length to one. For example, to combine a weak and a strong colony (or MultiColony). Workers and drones of the weak colony are added to the strong. User has to remove the weak colony (or MultiColony) from the workspace.
combine(strong, weak)
combine(strong, weak)
strong |
|
weak |
a combined Colony-class
or MultiColony-class
founderGenomes <- quickHaplo(nInd = 10, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(basePop[1], n = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = 10) # Create weak and strong Colony and MultiColony class colony1 <- createColony(x = basePop[2]) colony1 <- cross(colony1, drones = droneGroups[[1]]) colony2 <- createColony(x = basePop[3]) colony2 <- cross(colony2, drones = droneGroups[[2]]) apiary1 <- createMultiColony(basePop[4:6], n = 3) apiary1 <- cross(apiary1, drones = droneGroups[3:5]) apiary2 <- createMultiColony(basePop[7:9], n = 3) apiary2 <- cross(apiary2, drones = droneGroups[6:8]) # Build-up colony1 <- buildUp(x = colony1, nWorkers = 100, nDrones = 20) colony2 <- buildUp(x = colony2, nWorkers = 20, nDrones = 5) apiary1 <- buildUp(x = apiary1, nWorkers = 100, nDrones = 20) apiary2 <- buildUp(x = apiary2, nWorkers = 20, nDrones = 5) # Combine nWorkers(colony1); nWorkers(colony2) nDrones(colony1); nDrones(colony2) colony1 <- combine(strong = colony1, weak = colony2) nWorkers(colony1); nWorkers(colony2) nDrones(colony1); nDrones(colony2) rm(colony2) nWorkers(apiary1); nWorkers(apiary2) nDrones(apiary1); nDrones(apiary2) apiary1 <- combine(strong = apiary1, weak = apiary2) nWorkers(apiary1); nWorkers(apiary2) nDrones(apiary1); nDrones(apiary2) rm(apiary2)
founderGenomes <- quickHaplo(nInd = 10, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(basePop[1], n = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = 10) # Create weak and strong Colony and MultiColony class colony1 <- createColony(x = basePop[2]) colony1 <- cross(colony1, drones = droneGroups[[1]]) colony2 <- createColony(x = basePop[3]) colony2 <- cross(colony2, drones = droneGroups[[2]]) apiary1 <- createMultiColony(basePop[4:6], n = 3) apiary1 <- cross(apiary1, drones = droneGroups[3:5]) apiary2 <- createMultiColony(basePop[7:9], n = 3) apiary2 <- cross(apiary2, drones = droneGroups[6:8]) # Build-up colony1 <- buildUp(x = colony1, nWorkers = 100, nDrones = 20) colony2 <- buildUp(x = colony2, nWorkers = 20, nDrones = 5) apiary1 <- buildUp(x = apiary1, nWorkers = 100, nDrones = 20) apiary2 <- buildUp(x = apiary2, nWorkers = 20, nDrones = 5) # Combine nWorkers(colony1); nWorkers(colony2) nDrones(colony1); nDrones(colony2) colony1 <- combine(strong = colony1, weak = colony2) nWorkers(colony1); nWorkers(colony2) nDrones(colony1); nDrones(colony2) rm(colony2) nWorkers(apiary1); nWorkers(apiary2) nDrones(apiary1); nDrones(apiary2) apiary1 <- combine(strong = apiary1, weak = apiary2) nWorkers(apiary1); nWorkers(apiary2) nDrones(apiary1); nDrones(apiary2) rm(apiary2)
Level 1 function that produces diploid offspring from a mated queen.
Queen is diploid, while drones are double haploids so we use AlphaSimR diploid
functionality to make this cross, but since drones are double haploids we
get the desired outcome. This is an utility function, and you most likely
want to use the cross
functions.
combineBeeGametes(queen, drones, nProgeny = 1, simParamBee = NULL)
combineBeeGametes(queen, drones, nProgeny = 1, simParamBee = NULL)
queen |
|
drones |
|
nProgeny |
integer, number of progeny to create per cross |
simParamBee |
|
Pop-class
with diploid individuals
# Not exporting this function, since its just a helper
Level 1 function that produces diploid offspring from a mated queen.
Drones are haploid, while the queen is diploid, so we first generate gametes
(with recombination) from her and merge them with drone genomes (=gametes),
where we randomly re-sample drones to get the desired number of progeny.
This is an utility function, and you most likely want to use the
cross
function.
combineBeeGametesHaploDiploid(queen, drones, nProgeny = 1, simParamBee = NULL)
combineBeeGametesHaploDiploid(queen, drones, nProgeny = 1, simParamBee = NULL)
queen |
|
drones |
|
nProgeny |
integer, number of progeny to create per cross |
simParamBee |
|
This would be the right approach to handle haplo-diploid inheritance in bees, but it causes a raft of downstream issues, since AlphaSimR assumes that individuals have the same ploidy. Hence, we don't use this function.
Pop-class
with diploid individuals
Level 1 function that creates the specified number of caste individuals from the colony with a mated queens. If csd locus is active, it takes it into account and any csd homozygotes are removed and counted towards homozygous brood.
createCastePop( x, caste = NULL, nInd = NULL, exact = TRUE, year = NULL, editCsd = TRUE, csdAlleles = NULL, simParamBee = NULL, ... ) createWorkers(x, nInd = NULL, exact = FALSE, simParamBee = NULL, ...) createDrones(x, nInd = NULL, simParamBee = NULL, ...) createVirginQueens( x, nInd = NULL, year = NULL, editCsd = TRUE, csdAlleles = NULL, simParamBee = NULL, ... )
createCastePop( x, caste = NULL, nInd = NULL, exact = TRUE, year = NULL, editCsd = TRUE, csdAlleles = NULL, simParamBee = NULL, ... ) createWorkers(x, nInd = NULL, exact = FALSE, simParamBee = NULL, ...) createDrones(x, nInd = NULL, simParamBee = NULL, ...) createVirginQueens( x, nInd = NULL, year = NULL, editCsd = TRUE, csdAlleles = NULL, simParamBee = NULL, ... )
x |
|
caste |
character, "workers", "drones", or "virginQueens" |
nInd |
numeric or function, number of caste individuals; if |
exact |
logical, only relevant when creating workers,
if the csd locus is active and exact is |
year |
numeric, year of birth for virgin queens |
editCsd |
logical (only active when |
csdAlleles |
|
simParamBee |
|
... |
additional arguments passed to |
when x
is MapPop-class
returns
virginQueens
(a Pop-class
);
when x
is Colony-class
returns
virginQueens
(a Pop-class
);
when x
is MultiColony-class
return is a named list of virginQueens
(a Pop-class
);
named by colony ID
createWorkers()
: Create workers from a colony
createDrones()
: Create drones from a colony
createVirginQueens()
: Create virgin queens from a colony
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) SP$setTrackRec(TRUE) SP$setTrackPed(isTrackPed = TRUE) # Create virgin queens on a MapPop basePop <- createCastePop(founderGenomes, caste = "virginQueens") # Or alias createVirginQueens(founderGenomes) # Same aliases exist for all the castes!!! # Create drones on a Pop drones <- createDrones(x = basePop[1], nInd = 200) # Or create unequal number of drones from multiple virgin queens drones <- createDrones(basePop[1:2], nInd = c(100, 200)) droneGroups <- pullDroneGroupsFromDCA(drones, n = 3, nDrones = nFathersPoisson) # Create a Colony and a MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) # Using default nInd in SP colony@virginQueens <- createVirginQueens(colony) colony@workers <- createWorkers(colony)$workers colony@drones <- createDrones(colony) # Usually, you would use functions buildUp() or addCastePop() # These populations hold individual information # Example on the virgin queens (same holds for all castes!) virginQueens <- colony@virginQueens virginQueens@id virginQueens@sex virginQueens@mother virginQueens@father # Specify own number SP$nVirginQueens <- 15 SP$nWorkers <- 100 SP$nDrones <- 10 createVirginQueens(colony) createVirginQueens(apiary) # Or creating unequal numbers createVirginQueens(apiary, nInd = c(5, 10)) # nVirginQueens will NOT vary between function calls when a constant is used # Specify a function that will give a number createVirginQueens(colony, nInd = nVirginQueensPoisson) createVirginQueens(apiary, nInd = nVirginQueensPoisson) # No. of individuals will vary between function calls when a function is used # Store a function or a value in the SP object SP$nVirginQueens <- nVirginQueensPoisson createVirginQueens(colony) createVirginQueens(colony) createVirginQueens(apiary) createVirginQueens(apiary) # No. of individuals will vary between function calls when a function is used # csd homozygosity - relevant when creating virgin queens SP <- SimParamBee$new(founderGenomes, csdChr = 1, nCsdAlleles = 8) basePop <- createVirginQueens(founderGenomes, editCsd = FALSE) all(isCsdHeterozygous(basePop)) basePop <- createVirginQueens(founderGenomes, editCsd = TRUE) all(isCsdHeterozygous(basePop))
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) SP$setTrackRec(TRUE) SP$setTrackPed(isTrackPed = TRUE) # Create virgin queens on a MapPop basePop <- createCastePop(founderGenomes, caste = "virginQueens") # Or alias createVirginQueens(founderGenomes) # Same aliases exist for all the castes!!! # Create drones on a Pop drones <- createDrones(x = basePop[1], nInd = 200) # Or create unequal number of drones from multiple virgin queens drones <- createDrones(basePop[1:2], nInd = c(100, 200)) droneGroups <- pullDroneGroupsFromDCA(drones, n = 3, nDrones = nFathersPoisson) # Create a Colony and a MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) # Using default nInd in SP colony@virginQueens <- createVirginQueens(colony) colony@workers <- createWorkers(colony)$workers colony@drones <- createDrones(colony) # Usually, you would use functions buildUp() or addCastePop() # These populations hold individual information # Example on the virgin queens (same holds for all castes!) virginQueens <- colony@virginQueens virginQueens@id virginQueens@sex virginQueens@mother virginQueens@father # Specify own number SP$nVirginQueens <- 15 SP$nWorkers <- 100 SP$nDrones <- 10 createVirginQueens(colony) createVirginQueens(apiary) # Or creating unequal numbers createVirginQueens(apiary, nInd = c(5, 10)) # nVirginQueens will NOT vary between function calls when a constant is used # Specify a function that will give a number createVirginQueens(colony, nInd = nVirginQueensPoisson) createVirginQueens(apiary, nInd = nVirginQueensPoisson) # No. of individuals will vary between function calls when a function is used # Store a function or a value in the SP object SP$nVirginQueens <- nVirginQueensPoisson createVirginQueens(colony) createVirginQueens(colony) createVirginQueens(apiary) createVirginQueens(apiary) # No. of individuals will vary between function calls when a function is used # csd homozygosity - relevant when creating virgin queens SP <- SimParamBee$new(founderGenomes, csdChr = 1, nCsdAlleles = 8) basePop <- createVirginQueens(founderGenomes, editCsd = FALSE) all(isCsdHeterozygous(basePop)) basePop <- createVirginQueens(founderGenomes, editCsd = TRUE) all(isCsdHeterozygous(basePop))
Level 2 function that creates a new Colony-class
to initiate simulations.
createColony(x = NULL, simParamBee = NULL)
createColony(x = NULL, simParamBee = NULL)
x |
|
simParamBee |
|
new Colony-class
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 15) # Create an empty Colony class colony <- createColony() # Create Colony class with one or multiple virgin queens colony1 <- createColony(x = basePop[2]) colony1 colony2 <- createColony(x = basePop[3:4]) colony2 # Create a mated Colony colony1 <- cross(colony1, drones = drones) colony1
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 15) # Create an empty Colony class colony <- createColony() # Create Colony class with one or multiple virgin queens colony1 <- createColony(x = basePop[2]) colony1 colony2 <- createColony(x = basePop[3:4]) colony2 # Create a mated Colony colony1 <- cross(colony1, drones = drones) colony1
Level 0 function that creates a plan for crossing virgin queens or
virgin colonies by sampling drones or drone producing colonies to mate with a the
virgin queens/colonies either at random (spatial = FALSE
)
or according to the distance between colonies (spatial = TRUE
).
createCrossPlan( x, drones = NULL, droneColonies = NULL, nDrones = NULL, spatial = FALSE, radius, simParamBee = NULL, ... )
createCrossPlan( x, drones = NULL, droneColonies = NULL, nDrones = NULL, spatial = FALSE, radius, simParamBee = NULL, ... )
x |
|
drones |
|
droneColonies |
|
nDrones |
integer or function, number of drones to sample for each crossing. You need to provide this to provide this argument even when sampling drone producing colonies (otherwise, the default value will be used) |
spatial |
logical, whether the drone producing colonies should be sampled according to their distance from the virgin colony (that is, in a radius) |
radius |
numeric, the radius from the virgin colony in which to sample mating partners,
only needed when |
simParamBee |
|
... |
other arguments for |
named list with names being virgin queens/colonies IDs with each list element holding the IDs of selected drones or drone producing colonies
founderGenomes <- quickHaplo(nInd = 1000, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) # Create three virgin MultiColony objects with locations virginColonies1 <- createMultiColony(basePop[1:30]) virginColonies1 <- setLocation(virginColonies1, location = Map(c, runif(30, 0, 2*pi), runif(30, 0, 2*pi))) virginColonies2 <- createMultiColony(basePop[31:60]) virginColonies2 <- setLocation(virginColonies2, location = Map(c, runif(30, 0, 2*pi), runif(30, 0, 2*pi))) virginColonies3 <- createMultiColony(basePop[61:90]) virginColonies3 <- setLocation(virginColonies3, location = Map(c, runif(30, 0, 2*pi), runif(30, 0, 2*pi))) # Create drone colonies droneColonies <- createMultiColony(basePop[121:200]) droneColonies <- setLocation(droneColonies, location = Map(c, runif(80, 0, 2*pi), runif(80, 0, 2*pi))) # Create some drones to mate initial drone colonies with DCA <- createDrones(basePop[201:300], nInd = 20) # Cross initial virgin drone colonies to the DCA with a random cross plan randomCrossPlan <- createCrossPlan(x = droneColonies, drones = DCA, nDrones = nFathersPoisson, spatial = FALSE) droneColonies <- cross(droneColonies, drones = DCA, nDrones = nFathersPoisson, crossPlan = randomCrossPlan) # Plot the colonies in space virginLocations <- as.data.frame(getLocation(c(virginColonies1, virginColonies2, virginColonies3), collapse= TRUE)) virginLocations$Type <- "Virgin" droneLocations <- as.data.frame(getLocation(droneColonies, collapse= TRUE)) droneLocations$Type <- "Drone" locations <- rbind(virginLocations, droneLocations) plot(x = locations$V1, y = locations$V2, col = c("red", "blue")[as.numeric(as.factor(locations$Type))]) # Cross according to a spatial cross plan according to the colonies' locations crossPlanSpatial <- createCrossPlan(x = virginColonies1, droneColonies = droneColonies, nDrones = nFathersPoisson, spatial = TRUE, radius = 1.5) # Plot the crossing for the first colony in the crossPlan virginLocations1 <- as.data.frame(getLocation(virginColonies1, collapse= TRUE)) virginLocations1$Type <- "Virgin" droneLocations <- as.data.frame(getLocation(droneColonies, collapse= TRUE)) droneLocations$Type <- "Drone" locations1 <- rbind(virginLocations1, droneLocations) # Blue marks the target virgin colony and blue marks the drone colonies in the chosen radius plot(x = locations1$V1, y = locations1$V2, pch = c(1, 2)[as.numeric(as.factor(locations1$Type))], col = ifelse(rownames(locations1) %in% crossPlanSpatial[[1]], "red", ifelse(rownames(locations1) == names(crossPlanSpatial)[[1]], "blue", "black"))) colonies1 <- cross(x = virginColonies1, crossPlan = crossPlanSpatial, droneColonies = droneColonies, nDrones = nFathersPoisson) nFathers(colonies1) # Cross according to a cross plan that is created internally within the cross function # The cross plan is created at random, regardless the location of the colonies colonies2 <- cross(x = virginColonies2, droneColonies = droneColonies, nDrones = nFathersPoisson, crossPlan = "create") # Mate spatially with cross plan created internally by the cross function colonies3 <- cross(x = virginColonies3, droneColonies = droneColonies, crossPlan = "create", checkCross = "warning", spatial = TRUE, radius = 1)
founderGenomes <- quickHaplo(nInd = 1000, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) # Create three virgin MultiColony objects with locations virginColonies1 <- createMultiColony(basePop[1:30]) virginColonies1 <- setLocation(virginColonies1, location = Map(c, runif(30, 0, 2*pi), runif(30, 0, 2*pi))) virginColonies2 <- createMultiColony(basePop[31:60]) virginColonies2 <- setLocation(virginColonies2, location = Map(c, runif(30, 0, 2*pi), runif(30, 0, 2*pi))) virginColonies3 <- createMultiColony(basePop[61:90]) virginColonies3 <- setLocation(virginColonies3, location = Map(c, runif(30, 0, 2*pi), runif(30, 0, 2*pi))) # Create drone colonies droneColonies <- createMultiColony(basePop[121:200]) droneColonies <- setLocation(droneColonies, location = Map(c, runif(80, 0, 2*pi), runif(80, 0, 2*pi))) # Create some drones to mate initial drone colonies with DCA <- createDrones(basePop[201:300], nInd = 20) # Cross initial virgin drone colonies to the DCA with a random cross plan randomCrossPlan <- createCrossPlan(x = droneColonies, drones = DCA, nDrones = nFathersPoisson, spatial = FALSE) droneColonies <- cross(droneColonies, drones = DCA, nDrones = nFathersPoisson, crossPlan = randomCrossPlan) # Plot the colonies in space virginLocations <- as.data.frame(getLocation(c(virginColonies1, virginColonies2, virginColonies3), collapse= TRUE)) virginLocations$Type <- "Virgin" droneLocations <- as.data.frame(getLocation(droneColonies, collapse= TRUE)) droneLocations$Type <- "Drone" locations <- rbind(virginLocations, droneLocations) plot(x = locations$V1, y = locations$V2, col = c("red", "blue")[as.numeric(as.factor(locations$Type))]) # Cross according to a spatial cross plan according to the colonies' locations crossPlanSpatial <- createCrossPlan(x = virginColonies1, droneColonies = droneColonies, nDrones = nFathersPoisson, spatial = TRUE, radius = 1.5) # Plot the crossing for the first colony in the crossPlan virginLocations1 <- as.data.frame(getLocation(virginColonies1, collapse= TRUE)) virginLocations1$Type <- "Virgin" droneLocations <- as.data.frame(getLocation(droneColonies, collapse= TRUE)) droneLocations$Type <- "Drone" locations1 <- rbind(virginLocations1, droneLocations) # Blue marks the target virgin colony and blue marks the drone colonies in the chosen radius plot(x = locations1$V1, y = locations1$V2, pch = c(1, 2)[as.numeric(as.factor(locations1$Type))], col = ifelse(rownames(locations1) %in% crossPlanSpatial[[1]], "red", ifelse(rownames(locations1) == names(crossPlanSpatial)[[1]], "blue", "black"))) colonies1 <- cross(x = virginColonies1, crossPlan = crossPlanSpatial, droneColonies = droneColonies, nDrones = nFathersPoisson) nFathers(colonies1) # Cross according to a cross plan that is created internally within the cross function # The cross plan is created at random, regardless the location of the colonies colonies2 <- cross(x = virginColonies2, droneColonies = droneColonies, nDrones = nFathersPoisson, crossPlan = "create") # Mate spatially with cross plan created internally by the cross function colonies3 <- cross(x = virginColonies3, droneColonies = droneColonies, crossPlan = "create", checkCross = "warning", spatial = TRUE, radius = 1)
Level 1 function that creates a population of drones from a Colony or MultiColony. Such a population is often referred to as a drone congregation area (DCA).
createDCA(x, nInd = NULL, removeFathers = TRUE, simParamBee = NULL)
createDCA(x, nInd = NULL, removeFathers = TRUE, simParamBee = NULL)
x |
|
nInd |
numeric, number of random drones to pull from each colony,
if |
removeFathers |
logical, removes |
simParamBee |
|
In reality, drones leave the colony to mate. They die after that.
In this function we only get a copy of drones from x
, for
computational efficiency and ease of use. However, any mating will change
the caste of drones to fathers, and they won't be available for future
matings (see cross
). Not unless
removeFathers = FALSE
.
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]]) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) colony <- addDrones(colony, nInd = 10) createDCA(colony) createDCA(colony, nInd = 10)@id apiary <- addDrones(apiary) createDCA(apiary) createDCA(apiary, nInd = 10)
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]]) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) colony <- addDrones(colony, nInd = 10) createDCA(colony) createDCA(colony, nInd = 10)@id apiary <- addDrones(apiary) createDCA(apiary) createDCA(apiary, nInd = 10)
Level 1 function that creates a DCA at a classical honeybee mating station of several sister drone producing queens. The functions first creates multiple drone producing queens (DPQs) from one colony; and second, produces drones from the DPQs. All the created drones form a DCA at a mating station.
createMatingStationDCA( colony, nDPQs = 20, nDronePerDPQ = NULL, simParamBee = NULL )
createMatingStationDCA( colony, nDPQs = 20, nDronePerDPQ = NULL, simParamBee = NULL )
colony |
|
nDPQs |
integer, the number of drone producing queens |
nDronePerDPQ |
integer, number of drones each DPQ contributed to the DCA |
simParamBee |
|
Pop-class
with created drones resembling a DCA at a mating station
founderGenomes <- quickHaplo(nInd = 10, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(basePop[1], n = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = 10) # Create a colony and cross it colony1 <- createColony(x = basePop[2]) colony1 <- cross(colony1, drones = droneGroups[[1]]) # Create a empty colony colony2 <- createColony(x = basePop[3]) # Create a mating station from colony1 matingStation <- createMatingStationDCA(colony1, nDPQs = 20, nDronePerDPQ = 10) # Cross colony2 on the mating station fathers <- pullDroneGroupsFromDCA(matingStation, n = 1, nDrones = 15) colony2 <- cross(colony2, drones = fathers[[1]]) nFathers(colony2)
founderGenomes <- quickHaplo(nInd = 10, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(basePop[1], n = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = 10) # Create a colony and cross it colony1 <- createColony(x = basePop[2]) colony1 <- cross(colony1, drones = droneGroups[[1]]) # Create a empty colony colony2 <- createColony(x = basePop[3]) # Create a mating station from colony1 matingStation <- createMatingStationDCA(colony1, nDPQs = 20, nDronePerDPQ = 10) # Cross colony2 on the mating station fathers <- pullDroneGroupsFromDCA(matingStation, n = 1, nDrones = 15) colony2 <- cross(colony2, drones = fathers[[1]]) nFathers(colony2)
Level 3 function that creates a set of colonies. Usually to start a simulation.
createMultiColony(x = NULL, n = NULL, simParamBee = NULL)
createMultiColony(x = NULL, n = NULL, simParamBee = NULL)
x |
|
n |
integer, number of colonies to create (if only |
simParamBee |
|
When both x
and n
are NULL
, then a
MultiColony-class
with 0 colonies is created.
founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) # Create 2 empty (NULL) colonies apiary <- createMultiColony(n = 2) apiary apiary[[1]] apiary[[2]] # Create 3 virgin colonies apiary <- createMultiColony(x = basePop, n = 3) # specify n apiary <- createMultiColony(x = basePop[1:3]) # take all provided apiary apiary[[1]] apiary[[2]] # Create mated colonies by crossing apiary <- createMultiColony(x = basePop[1:2], n = 2) drones <- createDrones(x = basePop[3], n = 30) droneGroups <- pullDroneGroupsFromDCA(drones, n = 2, nDrones = 15) apiary <- cross(apiary, drones = droneGroups) apiary apiary[[1]] apiary[[2]]
founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) # Create 2 empty (NULL) colonies apiary <- createMultiColony(n = 2) apiary apiary[[1]] apiary[[2]] # Create 3 virgin colonies apiary <- createMultiColony(x = basePop, n = 3) # specify n apiary <- createMultiColony(x = basePop[1:3]) # take all provided apiary apiary[[1]] apiary[[2]] # Create mated colonies by crossing apiary <- createMultiColony(x = basePop[1:2], n = 2) drones <- createDrones(x = basePop[3], n = 30) droneGroups <- pullDroneGroupsFromDCA(drones, n = 2, nDrones = 15) apiary <- cross(apiary, drones = droneGroups) apiary apiary[[1]] apiary[[2]]
Level 1 function that crosses (mates) a virgin queen to a group
of drones. The virgin queen(s) could be within a population (Pop-class
),
in a colony (Colony-class
), or multi-colony (MultiColony-class
).
This function does not create any progeny, it only stores the mated drones
(fathers) so we can later create progeny as needed. When input is a
(Colony-class
) or (MultiColony-class
), one
virgin queens is selected at random, mated, and promoted to the queen of
the colony. Other virgin queens are destroyed. Mated drones (fathers) are
stored for producing progeny at a later stage. For a better understanding
of crossing and the functions have a look at the "Crossing" vignette.
cross( x, crossPlan = NULL, drones = NULL, droneColonies = NULL, nDrones = NULL, spatial = FALSE, radius = NULL, checkCross = "error", simParamBee = NULL, ... )
cross( x, crossPlan = NULL, drones = NULL, droneColonies = NULL, nDrones = NULL, spatial = FALSE, radius = NULL, checkCross = "error", simParamBee = NULL, ... )
x |
|
crossPlan |
named list with names being virgin queen or colony IDs with
each list element holding the IDs of either selected drones or selected
drone producing colonies, OR a string "create" if you want the cross plan to be created
internally. The function can create a random ( |
drones |
a |
droneColonies |
|
nDrones |
numeric of function, the number of drones to sample to mate with each virgin queen when using a cross plan |
spatial |
logical, whether the drone producing colonies should be sampled according to their distance from the virgin colony (that is, in a radius) |
radius |
numeric, the radius around the virgin colony in which to sample mating partners,
only needed when |
checkCross |
character, throw a warning (when |
simParamBee |
|
... |
other arguments for |
This function changes caste for the mated drones to fathers, and mated virgin queens to queens. See examples. This means that you can not use these individuals in matings any more!
If the supplied drone population is empty (has 0 individuals), which
can happen in edge cases or when nFathersPoisson
is used
instead of nFathersTruncPoisson
, or when performing spatially-aware mating
and no drone producing colonies are found in the vicinity, then mating of a virgin
queen will fail and she will stay virgin. This can happen for just a few
of many virgin queens, which can be annoying to track down, but you can use
isQueen
or isVirginQueen
to find such virgin
queens. You can use checkCross
to alert you about this situation.
Pop-class
with mated queen(s). The misc slot of the
queens contains additional information about the number of workers, drones,
and homozygous brood produced, and the expected percentage of csd homozygous
brood.
Colony-class
on how we store the fathers along the
queen. For more examples for mating with either externally or internally created cross plan,
please see createCrossPlan
For crossing virgin queens according to a cross plan, see
createCrossPlan
.
For crossing virgin queens on a mating stations, see
createMatingStationDCA
founderGenomes <- quickHaplo(nInd = 30, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 20, nDrones = nFathersPoisson) # If input is a Pop class of virgin queen(s) virginQueen <- basePop[2] isQueen(virginQueen) (matedQueen <- cross( x = virginQueen, drones = droneGroups[1] )) isQueen(virginQueen) isQueen(matedQueen) nFathers(matedQueen) isDrone(getFathers(matedQueen)) isFather(getFathers(matedQueen)) virginQueens <- basePop[4:5] matedQueens <- cross( x = virginQueens, drones = droneGroups[c(3, 4)] ) isQueen(matedQueens) nFathers(matedQueens) getFathers(matedQueens) # Inbred mated queen (mated with her own sons) matedQueen2 <- cross( x = basePop[1], drones = droneGroups[5] ) # Check the expected csd homozygosity pHomBrood(matedQueen2) # If input is a Colony or MultiColony class # Create Colony and MultiColony class colony <- createColony(basePop[6]) isVirginQueen(getVirginQueens(colony)) apiary <- createMultiColony(basePop[7:8]) all(isVirginQueen(mergePops(getVirginQueens(apiary)))) # Cross colony <- cross(colony, drones = droneGroups[[6]]) isQueenPresent(colony) apiary <- cross(apiary, drones = droneGroups[c(7, 8)]) all(isQueenPresent(apiary)) nFathers(apiary) # Try mating with drones that were already used for mating colony <- createColony(basePop[9]) try((matedColony <- cross(x = colony, drones = droneGroups[[1]]))) # Create new drones and mate the colony with them drones <- createDrones(x = basePop[1], nInd = 15) all(isDrone(drones)) any(isFather(drones)) (matedColony <- cross(x = colony, drones = drones)) isQueenPresent(matedColony) # Mate with drone producing colonies and a given cross plan droneColonies <- createMultiColony(basePop[10:15]) droneColonies <- cross(droneColonies, drones = droneGroups[10:15]) nFathers(droneColonies) apiary2 <- createMultiColony(basePop[16:20]) apiary3 <- createMultiColony(basePop[21:25]) apiary4 <- createMultiColony(basePop[26:30]) # Create a random cross plan randomCrossPlan <- createCrossPlan(x = apiary2, droneColonies = droneColonies, nDrones = nFathersPoisson, spatial = FALSE) apiary2 <- cross(x = apiary2, droneColonies = droneColonies, crossPlan = randomCrossPlan, nDrones = 15) nFathers(apiary2) # Mate colonies according to a cross plan that is created internally within the cross function apiary3 <- cross(x = apiary3, droneColonies = droneColonies, crossPlan = "create", nDrones = 15) nFathers(apiary3) # Mate colonies according to a cross plan that is created internally within the cross function # For this, all the colonies have to have a set location droneColonies <- setLocation(droneColonies, location = Map(c, runif(6, 0, 2*pi), runif(6, 0, 2*pi))) apiary4 <- setLocation(apiary4, location = Map(c, runif(5, 0, 2*pi), runif(5, 0, 2*pi))) apiary4 <- cross(x = apiary4, droneColonies = droneColonies, crossPlan = "create", nDrones = nFathersPoisson, spatial = TRUE, checkCross = "warning", radius = 3) nFathers(apiary4)
founderGenomes <- quickHaplo(nInd = 30, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 20, nDrones = nFathersPoisson) # If input is a Pop class of virgin queen(s) virginQueen <- basePop[2] isQueen(virginQueen) (matedQueen <- cross( x = virginQueen, drones = droneGroups[1] )) isQueen(virginQueen) isQueen(matedQueen) nFathers(matedQueen) isDrone(getFathers(matedQueen)) isFather(getFathers(matedQueen)) virginQueens <- basePop[4:5] matedQueens <- cross( x = virginQueens, drones = droneGroups[c(3, 4)] ) isQueen(matedQueens) nFathers(matedQueens) getFathers(matedQueens) # Inbred mated queen (mated with her own sons) matedQueen2 <- cross( x = basePop[1], drones = droneGroups[5] ) # Check the expected csd homozygosity pHomBrood(matedQueen2) # If input is a Colony or MultiColony class # Create Colony and MultiColony class colony <- createColony(basePop[6]) isVirginQueen(getVirginQueens(colony)) apiary <- createMultiColony(basePop[7:8]) all(isVirginQueen(mergePops(getVirginQueens(apiary)))) # Cross colony <- cross(colony, drones = droneGroups[[6]]) isQueenPresent(colony) apiary <- cross(apiary, drones = droneGroups[c(7, 8)]) all(isQueenPresent(apiary)) nFathers(apiary) # Try mating with drones that were already used for mating colony <- createColony(basePop[9]) try((matedColony <- cross(x = colony, drones = droneGroups[[1]]))) # Create new drones and mate the colony with them drones <- createDrones(x = basePop[1], nInd = 15) all(isDrone(drones)) any(isFather(drones)) (matedColony <- cross(x = colony, drones = drones)) isQueenPresent(matedColony) # Mate with drone producing colonies and a given cross plan droneColonies <- createMultiColony(basePop[10:15]) droneColonies <- cross(droneColonies, drones = droneGroups[10:15]) nFathers(droneColonies) apiary2 <- createMultiColony(basePop[16:20]) apiary3 <- createMultiColony(basePop[21:25]) apiary4 <- createMultiColony(basePop[26:30]) # Create a random cross plan randomCrossPlan <- createCrossPlan(x = apiary2, droneColonies = droneColonies, nDrones = nFathersPoisson, spatial = FALSE) apiary2 <- cross(x = apiary2, droneColonies = droneColonies, crossPlan = randomCrossPlan, nDrones = 15) nFathers(apiary2) # Mate colonies according to a cross plan that is created internally within the cross function apiary3 <- cross(x = apiary3, droneColonies = droneColonies, crossPlan = "create", nDrones = 15) nFathers(apiary3) # Mate colonies according to a cross plan that is created internally within the cross function # For this, all the colonies have to have a set location droneColonies <- setLocation(droneColonies, location = Map(c, runif(6, 0, 2*pi), runif(6, 0, 2*pi))) apiary4 <- setLocation(apiary4, location = Map(c, runif(5, 0, 2*pi), runif(5, 0, 2*pi))) apiary4 <- cross(x = apiary4, droneColonies = droneColonies, crossPlan = "create", nDrones = nFathersPoisson, spatial = TRUE, checkCross = "warning", radius = 3) nFathers(apiary4)
Level 2 function that downsizes a Colony or MultiColony object by removing a proportion of workers, all drones and all virgin queens. Usually in the autumn, such an event occurs in preparation for the winter months.
downsize(x, p = NULL, use = "rand", new = FALSE, simParamBee = NULL, ...)
downsize(x, p = NULL, use = "rand", new = FALSE, simParamBee = NULL, ...)
x |
|
p |
numeric, proportion of workers to be removed from the colony; if
|
use |
character, all the options provided by |
new |
logical, should we remove all current workers and add a targeted proportion anew (say, create winter workers) |
simParamBee |
|
... |
additional arguments passed to |
Colony-class
or MultiColony-class
with workers reduced and
drones/virgin queens removed
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 100) droneGroups <- pullDroneGroupsFromDCA(drones, n = 3, nDrones = 12) # Create and cross Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) colony <- buildUp(colony) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(apiary) # Downsize colony <- downsize(x = colony, new = TRUE, use = "rand") colony apiary <- downsize(x = apiary, new = TRUE, use = "rand") apiary[[1]] # Downsize with different numbers nWorkers(apiary); nDrones(apiary) apiary <- downsize(x = apiary, p = c(0.5, 0.1), new = TRUE, use = "rand") nWorkers(apiary); nDrones(apiary)
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 100) droneGroups <- pullDroneGroupsFromDCA(drones, n = 3, nDrones = 12) # Create and cross Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) colony <- buildUp(colony) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(apiary) # Downsize colony <- downsize(x = colony, new = TRUE, use = "rand") colony apiary <- downsize(x = apiary, new = TRUE, use = "rand") apiary[[1]] # Downsize with different numbers nWorkers(apiary); nDrones(apiary) apiary <- downsize(x = apiary, p = c(0.5, 0.1), new = TRUE, use = "rand") nWorkers(apiary); nDrones(apiary)
Sample the downsize proportion - proportion of removed workers
in downsizing - used when p = NULL
(see
SimParamBee$downsizeP
).
This is just an example. You can provide your own functions that satisfy your needs!
downsizePUnif(colony, n = 1, min = 0.8, max = 0.9)
downsizePUnif(colony, n = 1, min = 0.8, max = 0.9)
colony |
|
n |
integer, number of samples |
min |
numeric, lower limit for |
max |
numeric, upper limit for |
numeric, downsize proportion
SimParamBee
field downsizeP
downsizePUnif() downsizePUnif() p <- downsizePUnif(n = 1000) hist(p, breaks = seq(from = 0, to = 1, by = 0.01), xlim = c(0, 1))
downsizePUnif() downsizePUnif() p <- downsizePUnif(n = 1000) hist(p, breaks = seq(from = 0, to = 1, by = 0.01), xlim = c(0, 1))
Edits the csd locus in an entire population of individuals to ensure heterozygosity. The user can provide a list of csd alleles for each individual or, alternatively, the function samples a heterozygous genotype for each individual from all possible csd alleles. The gv slot is recalculated to reflect the any changes due to editing, but other slots remain the same.
editCsdLocus(pop, alleles = NULL, simParamBee = NULL)
editCsdLocus(pop, alleles = NULL, simParamBee = NULL)
pop |
|
alleles |
|
simParamBee |
global simulation parameters. |
Returns an object of Pop-class
Level 0 function that returns epistasis values of individuals in a caste.
getAa(x, caste = NULL, nInd = NULL, collapse = FALSE, simParamBee = NULL) getQueenAa(x, collapse = FALSE, simParamBee = NULL) getFathersAa(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getVirginQueensAa(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getWorkersAa(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getDronesAa(x, nInd = NULL, collapse = FALSE, simParamBee = NULL)
getAa(x, caste = NULL, nInd = NULL, collapse = FALSE, simParamBee = NULL) getQueenAa(x, collapse = FALSE, simParamBee = NULL) getFathersAa(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getVirginQueensAa(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getWorkersAa(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getDronesAa(x, nInd = NULL, collapse = FALSE, simParamBee = NULL)
x |
|
caste |
NULL or character, NULL when |
nInd |
numeric, number of individuals to access, if |
collapse |
logical, if the return value should be a single matrix with epistatic values of all the individuals |
simParamBee |
|
vector of epistasis values when x
is
Colony-class
and list of vectors of epistasis values when
x
is MultiColony-class
, named by colony id when x
is MultiColony-class
# Not exporting this function, since the theory behind it is not fully developed
getQueenAa()
: Access epistasis value of the queen
getFathersAa()
: Access epistasis values of fathers
getVirginQueensAa()
: Access epistasis values of virgin queens
getWorkersAa()
: Access epistasis values of workers
getDronesAa()
: Access epistasis values of drones
dd
and
vignette(topic = "QuantitativeGenetics", package = "SIMplyBee")
Level 0 function that returns breeding values of individuals in a caste.
getBv(x, caste = NULL, nInd = NULL, collapse = FALSE, simParamBee = NULL) getQueenBv(x, collapse = FALSE, simParamBee = NULL) getFathersBv(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getVirginQueensBv(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getWorkersBv(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getDronesBv(x, nInd = NULL, collapse = FALSE, simParamBee = NULL)
getBv(x, caste = NULL, nInd = NULL, collapse = FALSE, simParamBee = NULL) getQueenBv(x, collapse = FALSE, simParamBee = NULL) getFathersBv(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getVirginQueensBv(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getWorkersBv(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getDronesBv(x, nInd = NULL, collapse = FALSE, simParamBee = NULL)
x |
|
caste |
NULL or character, NULL when |
nInd |
numeric, number of individuals to access, if |
collapse |
logical, if the return value should be a single matrix with breeding valued of all the individuals |
simParamBee |
|
vector of breeding values when x
is Colony-class
and list of vectors of breeding values when x
is
MultiColony-class
, named by colony id when x
is
MultiColony-class
# Not exporting this function, since the theory behind it is not fully developed
getQueenBv()
: Access breeding value of the queen
getFathersBv()
: Access breeding values of fathers
getVirginQueensBv()
: Access breeding values of virgin queens
getWorkersBv()
: Access breeding values of workers
getDronesBv()
: Access breeding values of drones
bv
and
vignette(topic = "QuantitativeGenetics", package = "SIMplyBee")
Level 0 function that reports caste of an individual
getCaste(x, collapse = FALSE, simParamBee = NULL)
getCaste(x, collapse = FALSE, simParamBee = NULL)
x |
|
collapse |
logical, if |
simParamBee |
|
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) 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) 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) getCaste(getQueen(colony)) getCaste(getFathers(colony)) getCaste(getWorkers(colony)) getCaste(getDrones(colony)) getCaste(getVirginQueens(colony)) bees <- c( getQueen(colony), getFathers(colony, nInd = 2), getWorkers(colony, nInd = 2), getDrones(colony, nInd = 2), getVirginQueens(colony, nInd = 2) ) getCaste(bees) getCaste(colony) # Collapse information into a single vector getCaste(colony, collapse = TRUE) getCaste(apiary) # 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)
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) 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) getCaste(getQueen(colony)) getCaste(getFathers(colony)) getCaste(getWorkers(colony)) getCaste(getDrones(colony)) getCaste(getVirginQueens(colony)) bees <- c( getQueen(colony), getFathers(colony, nInd = 2), getWorkers(colony, nInd = 2), getDrones(colony, nInd = 2), getVirginQueens(colony, nInd = 2) ) getCaste(bees) getCaste(colony) # Collapse information into a single vector getCaste(colony, collapse = TRUE) getCaste(apiary) # 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)
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)
getCasteId(x, caste = "all", collapse = FALSE, simParamBee = NULL)
x |
|
caste |
character, "queen", "fathers", "workers", "drones", "virginQueens", or "all" |
collapse |
logical, if all IDs should be returned as a single vector |
simParamBee |
|
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
getCastePop
and getCaste
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)
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)
Level 1 function that returns individuals of a caste. These
individuals stay in the colony (compared to pullCastePop
).
getCastePop( x, caste = "all", nInd = NULL, use = "rand", removeFathers = TRUE, collapse = FALSE, simParamBee = NULL ) getQueen(x, collapse = FALSE, simParamBee = NULL) getFathers(x, nInd = NULL, use = "rand", collapse = FALSE, simParamBee = NULL) getWorkers(x, nInd = NULL, use = "rand", collapse = FALSE, simParamBee = NULL) getDrones( x, nInd = NULL, use = "rand", removeFathers = TRUE, collapse = FALSE, simParamBee = NULL ) getVirginQueens( x, nInd = NULL, use = "rand", collapse = FALSE, simParamBee = NULL )
getCastePop( x, caste = "all", nInd = NULL, use = "rand", removeFathers = TRUE, collapse = FALSE, simParamBee = NULL ) getQueen(x, collapse = FALSE, simParamBee = NULL) getFathers(x, nInd = NULL, use = "rand", collapse = FALSE, simParamBee = NULL) getWorkers(x, nInd = NULL, use = "rand", collapse = FALSE, simParamBee = NULL) getDrones( x, nInd = NULL, use = "rand", removeFathers = TRUE, collapse = FALSE, simParamBee = NULL ) getVirginQueens( x, nInd = NULL, use = "rand", collapse = FALSE, simParamBee = NULL )
x |
|
caste |
character, "queen", "fathers", "workers", "drones", "virginQueens", or "all" |
nInd |
numeric, number of individuals to access, if |
use |
character, all options provided by |
removeFathers |
logical, removes |
collapse |
logical, whether to return a single merged population |
simParamBee |
|
when x
is Colony-class
return is
Pop-class
for caste != "all"
or list for caste
== "all"
with nodes named by caste; 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"
. You can merge
all the populations in the list with mergePops
function.
getQueen()
: Access the queen
getFathers()
: Access fathers (drones the queen mated with)
getWorkers()
: Access workers
getDrones()
: Access drones
getVirginQueens()
: Access virgin queens
getQueen
, getFathers
,
getVirginQueens
, getWorkers
, and
getDrones
getCasteId
and getCaste
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]]) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) # Build-up and add virgin queens colony <- buildUp(x = colony) apiary <- buildUp(x = apiary) colony <- addVirginQueens(x = colony) apiary <- addVirginQueens(x = apiary) # Get the queen of the colony getCastePop(colony, caste = "queen") getQueen(colony) # Comparison of getCastePop() and getWorkers() getCastePop(colony, caste = "workers") getCastePop(colony, caste = "workers") getCastePop(colony, caste = "workers", nInd = 2) # Or aliases getWorkers(colony) # Same aliases exist for all the castes! # Input is a MultiColony class - same behaviour as for the Colony! getCastePop(apiary, caste = "queen") # Or alias getQueen(apiary) # Sample individuals from all the castes getCastePop(colony, nInd = 5, caste = "all") # Get different number of workers per colony getCastePop(apiary, caste = "workers", nInd = c(10, 20)) # Or alias getWorkers(apiary, nInd = c(10, 20)) # Obtain individuals from MultiColony as a single population getCastePop(apiary, caste = "queen", collapse = TRUE) getQueen(apiary, collapse = TRUE) getWorkers(apiary, nInd = 10, collapse = TRUE) getDrones(apiary, nInd = 3, collapse = TRUE)
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]]) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) # Build-up and add virgin queens colony <- buildUp(x = colony) apiary <- buildUp(x = apiary) colony <- addVirginQueens(x = colony) apiary <- addVirginQueens(x = apiary) # Get the queen of the colony getCastePop(colony, caste = "queen") getQueen(colony) # Comparison of getCastePop() and getWorkers() getCastePop(colony, caste = "workers") getCastePop(colony, caste = "workers") getCastePop(colony, caste = "workers", nInd = 2) # Or aliases getWorkers(colony) # Same aliases exist for all the castes! # Input is a MultiColony class - same behaviour as for the Colony! getCastePop(apiary, caste = "queen") # Or alias getQueen(apiary) # Sample individuals from all the castes getCastePop(colony, nInd = 5, caste = "all") # Get different number of workers per colony getCastePop(apiary, caste = "workers", nInd = c(10, 20)) # Or alias getWorkers(apiary, nInd = c(10, 20)) # Obtain individuals from MultiColony as a single population getCastePop(apiary, caste = "queen", collapse = TRUE) getQueen(apiary, collapse = TRUE) getWorkers(apiary, nInd = 10, collapse = TRUE) getDrones(apiary, nInd = 3, collapse = TRUE)
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)
getCasteSex(x, caste = "all", collapse = FALSE, simParamBee = NULL)
x |
|
caste |
character, "queen", "fathers", "workers", "drones", "virginQueens", or "all" |
collapse |
logical, if |
simParamBee |
|
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
getCastePop
and getCaste
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) 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 vector getCasteSex(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)
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) 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 vector getCasteSex(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)
Level 0 function that returns alleles from the csd locus. See
SimParamBee
for more information about the csd locus.
getCsdAlleles( x, caste = NULL, nInd = NULL, allele = "all", dronesHaploid = TRUE, collapse = FALSE, unique = FALSE, simParamBee = NULL ) getQueenCsdAlleles( x, allele = "all", unique = FALSE, collapse = FALSE, simParamBee = NULL ) getFathersCsdAlleles( x, nInd = NULL, allele = "all", dronesHaploid = TRUE, unique = FALSE, collapse = FALSE, simParamBee = NULL ) getVirginQueensCsdAlleles( x, nInd = NULL, allele = "all", unique = FALSE, collapse = FALSE, simParamBee = NULL ) getWorkersCsdAlleles( x, nInd = NULL, allele = "all", unique = FALSE, collapse = FALSE, simParamBee = NULL ) getDronesCsdAlleles( x, nInd = NULL, allele = "all", dronesHaploid = TRUE, unique = FALSE, collapse = FALSE, simParamBee = NULL )
getCsdAlleles( x, caste = NULL, nInd = NULL, allele = "all", dronesHaploid = TRUE, collapse = FALSE, unique = FALSE, simParamBee = NULL ) getQueenCsdAlleles( x, allele = "all", unique = FALSE, collapse = FALSE, simParamBee = NULL ) getFathersCsdAlleles( x, nInd = NULL, allele = "all", dronesHaploid = TRUE, unique = FALSE, collapse = FALSE, simParamBee = NULL ) getVirginQueensCsdAlleles( x, nInd = NULL, allele = "all", unique = FALSE, collapse = FALSE, simParamBee = NULL ) getWorkersCsdAlleles( x, nInd = NULL, allele = "all", unique = FALSE, collapse = FALSE, simParamBee = NULL ) getDronesCsdAlleles( x, nInd = NULL, allele = "all", dronesHaploid = TRUE, unique = FALSE, collapse = FALSE, simParamBee = NULL )
x |
|
caste |
NULL or character, NULL when |
nInd |
numeric, for how many individuals; if |
allele |
character, either "all" for both alleles or an integer for a single allele, use a value of 1 for female allele and a value of 2 for male allele |
dronesHaploid |
logical, return haploid result for drones? |
collapse |
logical, if |
unique |
logical, return only the unique set of csd alleles. This argument
interacts with |
simParamBee |
|
If both collapse and unique are TRUE
, the function returns a
unique set of csd alleles in the entire population, colony, or multicolony
matrix with haplotypes when x
is Pop-class
, list
of matrices with haplotypes when x
is Colony-class
(list nodes named by caste) and list of a list of matrices with haplotypes
when x
is MultiColony-class
, outer list is named by
colony id when x
is MultiColony-class
; NULL
when
x
is NULL
getQueenCsdAlleles()
: Access csd alleles of the queen
getFathersCsdAlleles()
: Access csd alleles of the fathers
getVirginQueensCsdAlleles()
: Access csd alleles of the virgin queens
getWorkersCsdAlleles()
: Access csd alleles of the workers
getDronesCsdAlleles()
: Access csd alleles of the drones
founderGenomes <- quickHaplo(nInd = 8, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes, nCsdAlleles = 5) 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 = 6, nDrones = 3) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) # Use getCsdAlleles on a Population getCsdAlleles(getQueen(colony)) getCsdAlleles(getWorkers(colony)) # Use getCsdAlleles on a Colony getCsdAlleles(colony) getCsdAlleles(colony, caste = "queen") getQueenCsdAlleles(colony) getCsdAlleles(colony, caste = "workers") getWorkersCsdAlleles(colony) # Same aliases exist for all the castes! getCsdAlleles(colony, unique = TRUE) getCsdAlleles(colony, collapse = TRUE) getCsdAlleles(colony, collapse = TRUE, unique = TRUE) # Use getCsdAlleles on a MultiColony getCsdAlleles(apiary) getCsdAlleles(apiary, unique = TRUE) getCsdAlleles(apiary, collapse = TRUE, unique = TRUE) getCsdAlleles(apiary, nInd = 2)
founderGenomes <- quickHaplo(nInd = 8, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes, nCsdAlleles = 5) 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 = 6, nDrones = 3) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) # Use getCsdAlleles on a Population getCsdAlleles(getQueen(colony)) getCsdAlleles(getWorkers(colony)) # Use getCsdAlleles on a Colony getCsdAlleles(colony) getCsdAlleles(colony, caste = "queen") getQueenCsdAlleles(colony) getCsdAlleles(colony, caste = "workers") getWorkersCsdAlleles(colony) # Same aliases exist for all the castes! getCsdAlleles(colony, unique = TRUE) getCsdAlleles(colony, collapse = TRUE) getCsdAlleles(colony, collapse = TRUE, unique = TRUE) # Use getCsdAlleles on a MultiColony getCsdAlleles(apiary) getCsdAlleles(apiary, unique = TRUE) getCsdAlleles(apiary, collapse = TRUE, unique = TRUE) getCsdAlleles(apiary, nInd = 2)
Level 0 function that returns genotypes from the csd locus. See
SimParamBee
for more information about the csd locus and how
we have implemented it.
getCsdGeno( x, caste = NULL, nInd = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getQueenCsdGeno(x, collapse = FALSE, simParamBee = NULL) getFathersCsdGeno( x, nInd = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getVirginQueensCsdGeno(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getWorkersCsdGeno(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getDronesCsdGeno( x, nInd = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL )
getCsdGeno( x, caste = NULL, nInd = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getQueenCsdGeno(x, collapse = FALSE, simParamBee = NULL) getFathersCsdGeno( x, nInd = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getVirginQueensCsdGeno(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getWorkersCsdGeno(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getDronesCsdGeno( x, nInd = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL )
x |
|
caste |
NULL or character, NULL when |
nInd |
numeric, for how many individuals; if |
dronesHaploid |
logical, return haploid result for drones? |
collapse |
logical, if the return value should be a single matrix with haplotypes of all the individuals |
simParamBee |
|
The returned genotypes are spanning multiple bi-allelic SNP of
a non-recombining csd locus / haplotype. In most cases you will want to use
getCsdAlleles
.
matrix with genotypes when x
is Pop-class
, list
of matrices with genotypes when x
is Colony-class
(list nodes named by caste) and list of a list of matrices with genotypes
when x
is MultiColony-class
, outer list is named by
colony id when x
is MultiColony-class
; NULL
when
x
is NULL
getQueenCsdGeno()
: Access csd genotypes of the queen
getFathersCsdGeno()
: Access csd genotypes of the fathers
getVirginQueensCsdGeno()
: Access csd genotypes of the virgin queens
getWorkersCsdGeno()
: Access csd genotypes of the virgin queens
getDronesCsdGeno()
: Access csd genotypes of the virgin queens
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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 4) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) # Use getCsdGeno on a Population getCsdGeno(getQueen(colony)) getCsdGeno(getWorkers(colony)) # Using dronesHaploid = TRUE returns drones as haploids instead of double haploids getCsdGeno(getDrones(colony), nInd = 3, dronesHaploid = TRUE) # Using dronesHaploid = FALSE returns drones as double haploids getCsdGeno(getDrones(colony), nInd = 3, dronesHaploid = FALSE) # Use getCsdGeno on a Colony getCsdGeno(colony) getCsdGeno(colony, caste = "queen") getQueenCsdGeno(colony) getCsdGeno(colony, caste = "workers") getWorkersCsdGeno(colony) # Same aliases exist for all the castes! # Use getCsdGeno on a MultiColony - same behaviour as for the Colony! getCsdGeno(apiary) getCsdGeno(apiary, nInd = 2)
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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 4) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) # Use getCsdGeno on a Population getCsdGeno(getQueen(colony)) getCsdGeno(getWorkers(colony)) # Using dronesHaploid = TRUE returns drones as haploids instead of double haploids getCsdGeno(getDrones(colony), nInd = 3, dronesHaploid = TRUE) # Using dronesHaploid = FALSE returns drones as double haploids getCsdGeno(getDrones(colony), nInd = 3, dronesHaploid = FALSE) # Use getCsdGeno on a Colony getCsdGeno(colony) getCsdGeno(colony, caste = "queen") getQueenCsdGeno(colony) getCsdGeno(colony, caste = "workers") getWorkersCsdGeno(colony) # Same aliases exist for all the castes! # Use getCsdGeno on a MultiColony - same behaviour as for the Colony! getCsdGeno(apiary) getCsdGeno(apiary, nInd = 2)
Level 0 function that returns dominance values of individuals in a caste.
getDd(x, caste = NULL, nInd = NULL, collapse = FALSE, simParamBee = NULL) getQueenDd(x, collapse = FALSE, simParamBee = NULL) getFathersDd(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getVirginQueensDd(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getWorkersDd(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getDronesDd(x, nInd = NULL, collapse = FALSE, simParamBee = NULL)
getDd(x, caste = NULL, nInd = NULL, collapse = FALSE, simParamBee = NULL) getQueenDd(x, collapse = FALSE, simParamBee = NULL) getFathersDd(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getVirginQueensDd(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getWorkersDd(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getDronesDd(x, nInd = NULL, collapse = FALSE, simParamBee = NULL)
x |
|
caste |
NULL or character, NULL when |
nInd |
numeric, number of individuals to access, if |
collapse |
logical, if the return value should be a single matrix with dominance values of all the individuals |
simParamBee |
|
vector of dominance values when x
is
Colony-class
and list of vectors of dominance values when
x
is MultiColony-class
, named by colony id when x
is MultiColony-class
# Not exporting this function, since the theory behind it is not fully developed
getQueenDd()
: Access dominance value of the queen
getFathersDd()
: Access dominance values of fathers
getVirginQueensDd()
: Access dominance values of virgin queens
getWorkersDd()
: Access dominance values of workers
getDronesDd()
: Access dominance values of drones
dd
and
vignette(topic = "QuantitativeGenetics", package = "SIMplyBee")
Level 0 function that returns a matrix of logicals reporting the status of the colony events. The events are: split, swarm, supersedure, collapse, and production. These events impact colony status, strength, and could also impact downstream phenotypes.
getEvents(x)
getEvents(x)
x |
matrix of logicals, named by colony id when x
is
MultiColony-class
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 = 6, nDrones = 3) 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 = 6, nDrones = 3) apiary <- addVirginQueens(apiary, nInd = 4) getEvents(colony) getEvents(apiary) tmp <- swarm(colony) getEvents(tmp$swarm) getEvents(tmp$remnant) apiary <- supersede(apiary) getEvents(apiary)
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 = 6, nDrones = 3) 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 = 6, nDrones = 3) apiary <- addVirginQueens(apiary, nInd = 4) getEvents(colony) getEvents(apiary) tmp <- swarm(colony) getEvents(tmp$swarm) getEvents(tmp$remnant) apiary <- supersede(apiary) getEvents(apiary)
Level 0 function that returns genetic values of individuals in a caste.
getGv(x, caste = NULL, nInd = NULL, collapse = FALSE, simParamBee = NULL) getQueenGv(x, collapse = FALSE, simParamBee = NULL) getFathersGv(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getVirginQueensGv(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getWorkersGv(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getDronesGv(x, nInd = NULL, collapse = FALSE, simParamBee = NULL)
getGv(x, caste = NULL, nInd = NULL, collapse = FALSE, simParamBee = NULL) getQueenGv(x, collapse = FALSE, simParamBee = NULL) getFathersGv(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getVirginQueensGv(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getWorkersGv(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getDronesGv(x, nInd = NULL, collapse = FALSE, simParamBee = NULL)
x |
|
caste |
NULL or character, NULL when |
nInd |
numeric, number of individuals to access, if |
collapse |
logical, if the return value should be a single matrix with genetic values of all the individuals |
simParamBee |
|
vector of phenotype values when x
is Colony-class
and list of vectors of genetic values when x
is
MultiColony-class
, named by colony id when x
is
MultiColony-class
getQueenGv()
: Access genetic value of the queen
getFathersGv()
: Access genetic values of fathers
getVirginQueensGv()
: Access genetic values of virgin queens
getWorkersGv()
: Access genetic values of workers
getDronesGv()
: Access genetic values of drones
gv
and
vignette(topic = "QuantitativeGenetics", package = "SIMplyBee")
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) SP$addTraitA(nQtlPerChr = 10, var = 1) SP$addSnpChip(5) 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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 5) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) # Input is a population getGv(x = getQueen(colony)) queens <- getQueen(apiary, collapse = TRUE) getGv(queens) # Input is a colony getGv(colony, caste = "queen") getQueenGv(colony) getGv(colony, caste = "workers") getWorkersGv(colony) # Same aliases exist for all the castes! # Get genetic values for all individuals getGv(colony, caste = "all") # Get all genetic values in a single matrix getGv(colony, caste = "all", collapse = TRUE) # Input is a MultiColony - same behaviour as for the Colony! getGv(apiary, caste = "queen") getQueenGv(apiary) # Get the genetic values of all individuals either by colony or in a single matrix getGv(apiary, caste = "all") getGv(apiary, caste = "all", collapse = TRUE)
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) SP$addTraitA(nQtlPerChr = 10, var = 1) SP$addSnpChip(5) 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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 5) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) # Input is a population getGv(x = getQueen(colony)) queens <- getQueen(apiary, collapse = TRUE) getGv(queens) # Input is a colony getGv(colony, caste = "queen") getQueenGv(colony) getGv(colony, caste = "workers") getWorkersGv(colony) # Same aliases exist for all the castes! # Get genetic values for all individuals getGv(colony, caste = "all") # Get all genetic values in a single matrix getGv(colony, caste = "all", collapse = TRUE) # Input is a MultiColony - same behaviour as for the Colony! getGv(apiary, caste = "queen") getQueenGv(apiary) # Get the genetic values of all individuals either by colony or in a single matrix getGv(apiary, caste = "all") getGv(apiary, caste = "all", collapse = TRUE)
Level 0 function that returns IBD (identity by descent) haplotypes of individuals in a caste.
getIbdHaplo( x, caste = NULL, nInd = NULL, chr = NULL, snpChip = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getQueenIbdHaplo( x, chr = NULL, snpChip = NULL, collapse = FALSE, simParamBee = NULL ) getFathersIbdHaplo( x, nInd = NULL, chr = NULL, snpChip = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getVirginQueensIbdHaplo( x, nInd = NULL, chr = NULL, snpChip = NULL, collapse = FALSE, simParamBee = NULL ) getWorkersIbdHaplo( x, nInd = NULL, chr = NULL, snpChip = NULL, collapse = FALSE, simParamBee = NULL ) getDronesIbdHaplo( x, nInd = NULL, chr = NULL, snpChip = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL )
getIbdHaplo( x, caste = NULL, nInd = NULL, chr = NULL, snpChip = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getQueenIbdHaplo( x, chr = NULL, snpChip = NULL, collapse = FALSE, simParamBee = NULL ) getFathersIbdHaplo( x, nInd = NULL, chr = NULL, snpChip = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getVirginQueensIbdHaplo( x, nInd = NULL, chr = NULL, snpChip = NULL, collapse = FALSE, simParamBee = NULL ) getWorkersIbdHaplo( x, nInd = NULL, chr = NULL, snpChip = NULL, collapse = FALSE, simParamBee = NULL ) getDronesIbdHaplo( x, nInd = NULL, chr = NULL, snpChip = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL )
x |
|
caste |
NULL or character, NULL when |
nInd |
numeric, number of individuals to access, if |
chr |
numeric, chromosomes to retrieve, if |
snpChip |
integer, indicating which SNP array loci are to be retrieved,
if |
dronesHaploid |
logical, return haploid result for drones? |
collapse |
logical, if the return value should be a single matrix with haplotypes of all the individuals |
simParamBee |
|
matrix with haplotypes when x
is Colony-class
and list of matrices with haplotypes when x
is
MultiColony-class
, named by colony id when x
is
MultiColony-class
getQueenIbdHaplo()
: Access IBD haplotype data of the queen
getFathersIbdHaplo()
: Access IBD haplotype data of fathers
getVirginQueensIbdHaplo()
: Access IBD haplotype data of virgin queens
getWorkersIbdHaplo()
: Access IBD haplotype data of workers
getDronesIbdHaplo()
: Access IBD haplotype data of drones
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) SP$setTrackRec(TRUE) SP$setTrackPed(isTrackPed = TRUE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 200) 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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 5) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) # Input is a population getIbdHaplo(x = getQueen(colony)) queens <- getQueen(apiary, collapse = TRUE) getIbdHaplo(queens) # Input is a colony getIbdHaplo(x = colony, caste = "queen") getQueenIbdHaplo(colony) getIbdHaplo(colony, caste = "workers", nInd = 3) getWorkersIbdHaplo(colony) # Same aliases exist for all castes! # Get haplotypes for all individuals getIbdHaplo(colony, caste = "all") # Get all haplotypes in a single matrix getIbdHaplo(colony, caste = "all", collapse = TRUE) # Input is a MultiColony getIbdHaplo(x = apiary, caste = "queen") getQueenIbdHaplo(apiary) # Or collapse all the haplotypes into a single matrix getQueenIbdHaplo(apiary, collapse = TRUE) # Get the haplotypes of all individuals either by colony or in a single matrix getIbdHaplo(apiary, caste = "all") getIbdHaplo(apiary, caste = "all", collapse = TRUE)
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) SP$setTrackRec(TRUE) SP$setTrackPed(isTrackPed = TRUE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 200) 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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 5) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) # Input is a population getIbdHaplo(x = getQueen(colony)) queens <- getQueen(apiary, collapse = TRUE) getIbdHaplo(queens) # Input is a colony getIbdHaplo(x = colony, caste = "queen") getQueenIbdHaplo(colony) getIbdHaplo(colony, caste = "workers", nInd = 3) getWorkersIbdHaplo(colony) # Same aliases exist for all castes! # Get haplotypes for all individuals getIbdHaplo(colony, caste = "all") # Get all haplotypes in a single matrix getIbdHaplo(colony, caste = "all", collapse = TRUE) # Input is a MultiColony getIbdHaplo(x = apiary, caste = "queen") getQueenIbdHaplo(apiary) # Or collapse all the haplotypes into a single matrix getQueenIbdHaplo(apiary, collapse = TRUE) # Get the haplotypes of all individuals either by colony or in a single matrix getIbdHaplo(apiary, caste = "all") getIbdHaplo(apiary, caste = "all", collapse = TRUE)
Level 0 function that returns the colony ID. This is by definition the ID of the queen.
getId(x)
getId(x)
x |
character, NA
when queen not present
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]]) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) getId(getQueen(colony)) # Pop class getId(colony) # Colony Class getId(apiary) # MultiColony Class colony2 <- removeQueen(colony) getId(colony2)
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]]) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) getId(getQueen(colony)) # Pop class getId(colony) # Colony Class getId(apiary) # MultiColony Class colony2 <- removeQueen(colony) getId(colony2)
Level 0 function that returns the colony location as (x, y) coordinates.
getLocation(x, collapse = FALSE)
getLocation(x, collapse = FALSE)
x |
|
collapse |
logical, if the return value should be a single matrix
with locations of all the colonies; only applicable when input
is a |
numeric with two values when x
is Colony-class
and a list of numeric with two values when x
is
MultiColony-class
(list named after colonies); c(NA, NA)
when location not set
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]]) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) getLocation(colony) getLocation(apiary[[1]]) getLocation(apiary) getLocation(apiary, collapse = TRUE) loc <- c(123, 456) colony <- setLocation(colony, location = loc) getLocation(colony) loc1 <- c(512, 722) colony1 <- setLocation(apiary[[1]], location = loc1) getLocation(colony1) loc2 <- c(189, 357) colony2 <- setLocation(apiary[[2]], location = loc2) getLocation(colony2) getLocation(c(colony1, colony2)) # Assuming one location (as in bringing colonies to an apiary at a location!) apiary <- setLocation(apiary, location = loc1) getLocation(apiary) # Assuming different locations (so tmp is not an apiary in one location!) tmp <- setLocation(c(colony1, colony2), location = list(loc1, loc2)) getLocation(tmp)
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]]) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) getLocation(colony) getLocation(apiary[[1]]) getLocation(apiary) getLocation(apiary, collapse = TRUE) loc <- c(123, 456) colony <- setLocation(colony, location = loc) getLocation(colony) loc1 <- c(512, 722) colony1 <- setLocation(apiary[[1]], location = loc1) getLocation(colony1) loc2 <- c(189, 357) colony2 <- setLocation(apiary[[2]], location = loc2) getLocation(colony2) getLocation(c(colony1, colony2)) # Assuming one location (as in bringing colonies to an apiary at a location!) apiary <- setLocation(apiary, location = loc1) getLocation(apiary) # Assuming different locations (so tmp is not an apiary in one location!) tmp <- setLocation(c(colony1, colony2), location = list(loc1, loc2)) getLocation(tmp)
Get miscellaneous information in a population
getMisc(x, node = NULL)
getMisc(x, node = NULL)
x |
|
node |
character, name of the node to get from the |
The x@misc
slot or its nodes x@misc[[*]][[node]]
Level 0 function that returns phenotype values of individuals in a caste.
getPheno(x, caste = NULL, nInd = NULL, collapse = FALSE, simParamBee = NULL) getQueenPheno(x, collapse = FALSE, simParamBee = NULL) getFathersPheno(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getVirginQueensPheno(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getWorkersPheno(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getDronesPheno(x, nInd = NULL, collapse = FALSE, simParamBee = NULL)
getPheno(x, caste = NULL, nInd = NULL, collapse = FALSE, simParamBee = NULL) getQueenPheno(x, collapse = FALSE, simParamBee = NULL) getFathersPheno(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getVirginQueensPheno(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getWorkersPheno(x, nInd = NULL, collapse = FALSE, simParamBee = NULL) getDronesPheno(x, nInd = NULL, collapse = FALSE, simParamBee = NULL)
x |
|
caste |
NULL or character, NULL when |
nInd |
numeric, number of individuals to access, if |
collapse |
logical, if the return value should be a single matrix with phenotypes of all the individuals |
simParamBee |
|
vector of genetic values when x
is Colony-class
and list of vectors of genetic values when x
is
MultiColony-class
, named by colony id when x
is
MultiColony-class
getQueenPheno()
: Access phenotype value of the queen
getFathersPheno()
: Access phenotype values of fathers
getVirginQueensPheno()
: Access phenotype values of virgin queens
getWorkersPheno()
: Access phenotype values of workers
getDronesPheno()
: Access phenotype values of drones
pheno
and
vignette(topic = "QuantitativeGenetics", package = "SIMplyBee")
founderGenomes <- quickHaplo(nInd = 8, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) SP$addTraitA(nQtlPerChr = 10, var = 1) SP$setVarE(varE = 1) 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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 5) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) # Input is a population getPheno(x = getQueen(colony)) queens <- getQueen(apiary, collapse = TRUE) getPheno(queens) # Input is a colony getPheno(colony, caste = "queen") getQueenPheno(colony) getPheno(colony, caste = "fathers") getPheno(colony, caste = "fathers", nInd = 2) getPheno(colony, caste = "fathers", nInd = 2) # random sample! getFathersPheno(colony) getFathersPheno(colony, nInd = 2) getPheno(colony, caste = "workers") getWorkersPheno(colony) # Same aliases exist for all the castes!!! # Get phenotypes for all individuals getPheno(colony, caste = "all") # Get all phenotypes in a single matrix getPheno(colony, caste = "all", collapse = TRUE) # Input is a MultiColony - same behaviour as for the Colony! getPheno(apiary, caste = "queen") getQueenPheno(apiary) # Get the phenotypes of all individuals either by colony or in a single matrix getPheno(apiary, caste = "all") getPheno(apiary, caste = "all", collapse = TRUE)
founderGenomes <- quickHaplo(nInd = 8, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) SP$addTraitA(nQtlPerChr = 10, var = 1) SP$setVarE(varE = 1) 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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 5) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) # Input is a population getPheno(x = getQueen(colony)) queens <- getQueen(apiary, collapse = TRUE) getPheno(queens) # Input is a colony getPheno(colony, caste = "queen") getQueenPheno(colony) getPheno(colony, caste = "fathers") getPheno(colony, caste = "fathers", nInd = 2) getPheno(colony, caste = "fathers", nInd = 2) # random sample! getFathersPheno(colony) getFathersPheno(colony, nInd = 2) getPheno(colony, caste = "workers") getWorkersPheno(colony) # Same aliases exist for all the castes!!! # Get phenotypes for all individuals getPheno(colony, caste = "all") # Get all phenotypes in a single matrix getPheno(colony, caste = "all", collapse = TRUE) # Input is a MultiColony - same behaviour as for the Colony! getPheno(apiary, caste = "queen") getQueenPheno(apiary) # Get the phenotypes of all individuals either by colony or in a single matrix getPheno(apiary, caste = "all") getPheno(apiary, caste = "all", collapse = TRUE)
Level 0 function that returns a pooled genotype from true genotypes to mimic genotyping of a pool of colony members.
getPooledGeno(x, type = NULL, sex = NULL)
getPooledGeno(x, type = NULL, sex = NULL)
x |
matrix, true genotypes with individuals in rows and sites in columns |
type |
character, "mean" for average genotype or "count" for the counts of reference and alternative alleles |
sex |
character, vector of "F" and "M" to denote the sex of individuals
in |
a numeric vector with average allele dosage when type = "mean"
and a two-row matrix with the counts of reference (1st row) and
alternative (2nd row) alleles
founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = nFathersPoisson) apiary <- createMultiColony(basePop[2:3], n = 2) apiary <- cross(x = apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) genoQ <- getQueenSegSiteGeno(apiary[[1]]) genoF <- getFathersSegSiteGeno(apiary[[1]]) genoW <- getWorkersSegSiteGeno(apiary[[1]]) genoD <- getDronesSegSiteGeno(apiary[[1]]) genoV <- getVirginQueensSegSiteGeno(apiary[[1]]) # Pool of drones sexD <- getCasteSex(apiary[[1]], caste = "drones") getPooledGeno(x = genoD, type = "count", sex = sexD)[, 1:10] (poolD <- getPooledGeno(x = genoD, type = "mean", sex = sexD))[, 1:10] # ... compare to queen's genotype genoQ[, 1:10] plot( y = poolD, x = genoQ, ylim = c(0, 2), xlim = c(0, 2), ylab = "Average allele dosage in drones", xlab = "Allele dosage in the queen" ) # As an exercise you could repeat the above with different numbers of drones! # Pool of workers getPooledGeno(x = genoW, type = "count")[, 1:10] (poolW <- getPooledGeno(x = genoW, type = "mean"))[, 1:10] # ... compare to fathers' and queen's avearage genotype sexF <- getCasteSex(apiary[[1]], caste = "fathers") sexQ <- rep(x = "F", times = nrow(genoF)) sexFQ <- c(sexF, sexQ) genoFQ <- rbind(genoF, genoQ[rep(x = 1, times = nrow(genoF)), ]) (poolFQ <- getPooledGeno(x = genoFQ, type = "mean", sex = sexFQ))[, 1:10] plot( y = poolW, x = poolFQ, ylim = c(0, 2), xlim = c(0, 2), ylab = "Average allele dosage in workers", xlab = "Average allele dosage in the queen and fathers" ) # As an exercise you could repeat the above with different numbers of workers!
founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = nFathersPoisson) apiary <- createMultiColony(basePop[2:3], n = 2) apiary <- cross(x = apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) genoQ <- getQueenSegSiteGeno(apiary[[1]]) genoF <- getFathersSegSiteGeno(apiary[[1]]) genoW <- getWorkersSegSiteGeno(apiary[[1]]) genoD <- getDronesSegSiteGeno(apiary[[1]]) genoV <- getVirginQueensSegSiteGeno(apiary[[1]]) # Pool of drones sexD <- getCasteSex(apiary[[1]], caste = "drones") getPooledGeno(x = genoD, type = "count", sex = sexD)[, 1:10] (poolD <- getPooledGeno(x = genoD, type = "mean", sex = sexD))[, 1:10] # ... compare to queen's genotype genoQ[, 1:10] plot( y = poolD, x = genoQ, ylim = c(0, 2), xlim = c(0, 2), ylab = "Average allele dosage in drones", xlab = "Allele dosage in the queen" ) # As an exercise you could repeat the above with different numbers of drones! # Pool of workers getPooledGeno(x = genoW, type = "count")[, 1:10] (poolW <- getPooledGeno(x = genoW, type = "mean"))[, 1:10] # ... compare to fathers' and queen's avearage genotype sexF <- getCasteSex(apiary[[1]], caste = "fathers") sexQ <- rep(x = "F", times = nrow(genoF)) sexFQ <- c(sexF, sexQ) genoFQ <- rbind(genoF, genoQ[rep(x = 1, times = nrow(genoF)), ]) (poolFQ <- getPooledGeno(x = genoFQ, type = "mean", sex = sexFQ))[, 1:10] plot( y = poolW, x = poolFQ, ylim = c(0, 2), xlim = c(0, 2), ylab = "Average allele dosage in workers", xlab = "Average allele dosage in the queen and fathers" ) # As an exercise you could repeat the above with different numbers of workers!
Level 0 function that returns QTL genotypes of individuals in a caste.
getQtlGeno( x, caste = NULL, nInd = NULL, trait = 1, chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getQueenQtlGeno(x, trait = 1, chr = NULL, collapse = FALSE, simParamBee = NULL) getFathersQtlGeno( x, nInd = NULL, trait = 1, chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getVirginQueensQtlGeno( x, nInd = NULL, trait = 1, chr = NULL, collapse = FALSE, simParamBee = NULL ) getWorkersQtlGeno( x, nInd = NULL, trait = 1, chr = NULL, collapse = FALSE, simParamBee = NULL ) getDronesQtlGeno( x, nInd = NULL, trait = 1, chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL )
getQtlGeno( x, caste = NULL, nInd = NULL, trait = 1, chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getQueenQtlGeno(x, trait = 1, chr = NULL, collapse = FALSE, simParamBee = NULL) getFathersQtlGeno( x, nInd = NULL, trait = 1, chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getVirginQueensQtlGeno( x, nInd = NULL, trait = 1, chr = NULL, collapse = FALSE, simParamBee = NULL ) getWorkersQtlGeno( x, nInd = NULL, trait = 1, chr = NULL, collapse = FALSE, simParamBee = NULL ) getDronesQtlGeno( x, nInd = NULL, trait = 1, chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL )
x |
|
caste |
NULL or character, NULL when |
nInd |
numeric, number of individuals to access, if |
trait |
numeric (trait position) or character (trait name), indicates which trait's QTL genotypes to retrieve |
chr |
numeric, chromosomes to retrieve, if |
dronesHaploid |
logical, return haploid result for drones? |
collapse |
logical, if the return value should be a single matrix with genotypes of all the individuals |
simParamBee |
|
matrix with genotypes when x
is Colony-class
and
list of matrices with genotypes when x
is
MultiColony-class
, named by colony id when x
is
MultiColony-class
getQueenQtlGeno()
: Access QTL genotype data of the queen
getFathersQtlGeno()
: Access QTL genotype data of fathers
getVirginQueensQtlGeno()
: Access QTL genotype data of virgin queens
getWorkersQtlGeno()
: Access QTL genotype data of workers
getDronesQtlGeno()
: Access QTL genotype data of drones
getQtlGeno
and pullQtlGeno
as well as
vignette(topic = "QuantitativeGenetics", package = "SIMplyBee")
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) SP$addTraitA(nQtlPerChr = 10) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 200) 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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 5) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) # Input is a population getQtlGeno(x = getQueen(colony)) queens <- getQueen(apiary, collapse = TRUE) getQtlGeno(queens) # Input is a colony getQtlGeno(colony, caste = "queen") getQueenQtlGeno(colony) getQtlGeno(colony, caste = "workers", nInd = 3) getWorkersQtlGeno(colony) # Same aliases exist for all the castes! # Get genotypes for all individuals getQtlGeno(colony, caste = "all") # Get all haplotypes in a single matrix getQtlGeno(colony, caste = "all", collapse = TRUE) # Input is a MultiColony - same behaviour as for the Colony! getQtlGeno(apiary, caste = "queen") getQueenQtlGeno(apiary) # Get the genotypes of all individuals either by colony or in a single matrix getQtlGeno(apiary, caste = "all") getQtlGeno(apiary, caste = "all", collapse = TRUE)
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) SP$addTraitA(nQtlPerChr = 10) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 200) 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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 5) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) # Input is a population getQtlGeno(x = getQueen(colony)) queens <- getQueen(apiary, collapse = TRUE) getQtlGeno(queens) # Input is a colony getQtlGeno(colony, caste = "queen") getQueenQtlGeno(colony) getQtlGeno(colony, caste = "workers", nInd = 3) getWorkersQtlGeno(colony) # Same aliases exist for all the castes! # Get genotypes for all individuals getQtlGeno(colony, caste = "all") # Get all haplotypes in a single matrix getQtlGeno(colony, caste = "all", collapse = TRUE) # Input is a MultiColony - same behaviour as for the Colony! getQtlGeno(apiary, caste = "queen") getQueenQtlGeno(apiary) # Get the genotypes of all individuals either by colony or in a single matrix getQtlGeno(apiary, caste = "all") getQtlGeno(apiary, caste = "all", collapse = TRUE)
Level 0 function that returns QTL haplotypes of individuals in a caste.
getQtlHaplo( x, caste = NULL, nInd = NULL, trait = 1, haplo = "all", chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getQueenQtlHaplo( x, trait = 1, haplo = "all", chr = NULL, collapse = FALSE, simParamBee = NULL ) getFathersQtlHaplo( x, nInd = NULL, trait = 1, haplo = "all", chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getVirginQueensQtlHaplo( x, nInd = NULL, trait = 1, haplo = "all", chr = NULL, collapse = FALSE, simParamBee = NULL ) getWorkersQtlHaplo( x, nInd = NULL, trait = 1, haplo = "all", chr = NULL, collapse = FALSE, simParamBee = NULL ) getDronesQtlHaplo( x, nInd = NULL, trait = 1, haplo = "all", chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL )
getQtlHaplo( x, caste = NULL, nInd = NULL, trait = 1, haplo = "all", chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getQueenQtlHaplo( x, trait = 1, haplo = "all", chr = NULL, collapse = FALSE, simParamBee = NULL ) getFathersQtlHaplo( x, nInd = NULL, trait = 1, haplo = "all", chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getVirginQueensQtlHaplo( x, nInd = NULL, trait = 1, haplo = "all", chr = NULL, collapse = FALSE, simParamBee = NULL ) getWorkersQtlHaplo( x, nInd = NULL, trait = 1, haplo = "all", chr = NULL, collapse = FALSE, simParamBee = NULL ) getDronesQtlHaplo( x, nInd = NULL, trait = 1, haplo = "all", chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL )
x |
|
caste |
NULL or character, NULL when |
nInd |
numeric, number of individuals to access, if |
trait |
numeric (trait position) or character (trait name), indicates which trait's QTL haplotypes to retrieve |
haplo |
character, either "all" for all haplotypes or an integer for a single set of haplotypes, use a value of 1 for female haplotypes and a value of 2 for male haplotypes |
chr |
numeric, chromosomes to retrieve, if |
dronesHaploid |
logical, return haploid result for drones? |
collapse |
logical, if the return value should be a single matrix with haplotypes of all the individuals |
simParamBee |
|
matrix with haplotypes when x
is Colony-class
and list of matrices with haplotypes when x
is
MultiColony-class
, named by colony id when x
is
MultiColony-class
getQueenQtlHaplo()
: Access QTL haplotype data of the queen
getFathersQtlHaplo()
: Access QTL haplotype data of fathers
getVirginQueensQtlHaplo()
: Access QTL haplotype data of virgin queens
getWorkersQtlHaplo()
: Access QTL haplotype of workers
getDronesQtlHaplo()
: Access QTL haplotype data of drones
getQtlHaplo
and pullQtlHaplo
as well as
vignette(topic = "QuantitativeGenetics", package = "SIMplyBee")
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) SP$addTraitA(nQtlPerChr = 10) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 200) 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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 5) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) # Input is a population getQtlHaplo(x = getQueen(colony)) queens <- getQueen(apiary, collapse = TRUE) getQtlHaplo(queens) # Input is a Colony getQtlHaplo(colony, caste = "queen") getQueenQtlHaplo(colony) getQtlHaplo(colony, caste = "workers", nInd = 3) getWorkersQtlHaplo(colony) # Same aliases exist for all the castes! # Get haplotypes for all individuals getQtlHaplo(colony, caste = "all") # Get all haplotypes in a single matrix getQtlHaplo(colony, caste = "all", collapse = TRUE) # Input is a MultiColony - same behaviour as for the Colony getQtlHaplo(apiary, caste = "queen") getQueenQtlHaplo(apiary) # Get the haplotypes of all individuals either by colony or in a single matrix getQtlHaplo(apiary, caste = "all") getQtlHaplo(apiary, caste = "all", collapse = TRUE)
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) SP$addTraitA(nQtlPerChr = 10) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 200) 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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 5) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) # Input is a population getQtlHaplo(x = getQueen(colony)) queens <- getQueen(apiary, collapse = TRUE) getQtlHaplo(queens) # Input is a Colony getQtlHaplo(colony, caste = "queen") getQueenQtlHaplo(colony) getQtlHaplo(colony, caste = "workers", nInd = 3) getWorkersQtlHaplo(colony) # Same aliases exist for all the castes! # Get haplotypes for all individuals getQtlHaplo(colony, caste = "all") # Get all haplotypes in a single matrix getQtlHaplo(colony, caste = "all", collapse = TRUE) # Input is a MultiColony - same behaviour as for the Colony getQtlHaplo(apiary, caste = "queen") getQueenQtlHaplo(apiary) # Get the haplotypes of all individuals either by colony or in a single matrix getQtlHaplo(apiary, caste = "all") getQtlHaplo(apiary, caste = "all", collapse = TRUE)
Level 0 function that returns the queen's age.
getQueenAge(x, currentYear, simParamBee = NULL)
getQueenAge(x, currentYear, simParamBee = NULL)
x |
|
currentYear |
integer, current year |
simParamBee |
|
numeric, the age of the queen(s); named when theres is more
than one queen; NA
if queen not present
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]]) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) queen <- getQueen(colony) queen <- setQueensYearOfBirth(queen, year = 2020) getQueenAge(queen, currentYear = 2022) colony <- setQueensYearOfBirth(colony, year = 2021) getQueenAge(colony, currentYear = 2022) apiary <- setQueensYearOfBirth(apiary, year = 2018) getQueenAge(apiary, currentYear = 2022)
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]]) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) queen <- getQueen(colony) queen <- setQueensYearOfBirth(queen, year = 2020) getQueenAge(queen, currentYear = 2022) colony <- setQueensYearOfBirth(colony, year = 2021) getQueenAge(colony, currentYear = 2022) apiary <- setQueensYearOfBirth(apiary, year = 2018) getQueenAge(apiary, currentYear = 2022)
Level 0 function that returns the queen's year of birth.
getQueenYearOfBirth(x, simParamBee = NULL)
getQueenYearOfBirth(x, simParamBee = NULL)
x |
|
simParamBee |
|
numeric, the year of birth of the queen(s); named when theres is more
than one queen; NA
if queen not present
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]]) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) queen <- getQueen(colony) queen <- setQueensYearOfBirth(queen, year = 2022) getQueenYearOfBirth(queen) getQueenYearOfBirth(getQueen(colony)) colony <- setQueensYearOfBirth(colony, year = 2030) getQueenYearOfBirth(colony) apiary <- setQueensYearOfBirth(apiary, year = 2022) getQueenYearOfBirth(apiary)
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]]) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) queen <- getQueen(colony) queen <- setQueensYearOfBirth(queen, year = 2022) getQueenYearOfBirth(queen) getQueenYearOfBirth(getQueen(colony)) colony <- setQueensYearOfBirth(colony, year = 2030) getQueenYearOfBirth(colony) apiary <- setQueensYearOfBirth(apiary, year = 2022) getQueenYearOfBirth(apiary)
Level 0 function that returns genotypes for all segregating sites of individuals in a caste.
getSegSiteGeno( x, caste = NULL, nInd = NULL, chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getQueenSegSiteGeno(x, chr = NULL, collapse = FALSE, simParamBee = NULL) getFathersSegSiteGeno( x, nInd = NULL, chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getVirginQueensSegSiteGeno( x, nInd = NULL, chr = NULL, collapse = FALSE, simParamBee = NULL ) getWorkersSegSiteGeno( x, nInd = NULL, chr = NULL, collapse = FALSE, simParamBee = NULL ) getDronesSegSiteGeno( x, nInd = NULL, chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL )
getSegSiteGeno( x, caste = NULL, nInd = NULL, chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getQueenSegSiteGeno(x, chr = NULL, collapse = FALSE, simParamBee = NULL) getFathersSegSiteGeno( x, nInd = NULL, chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getVirginQueensSegSiteGeno( x, nInd = NULL, chr = NULL, collapse = FALSE, simParamBee = NULL ) getWorkersSegSiteGeno( x, nInd = NULL, chr = NULL, collapse = FALSE, simParamBee = NULL ) getDronesSegSiteGeno( x, nInd = NULL, chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL )
x |
|
caste |
NULL or character, NULL when |
nInd |
numeric, number of individuals to access, if |
chr |
numeric, chromosomes to retrieve, if |
dronesHaploid |
logical, return haploid result for drones? |
collapse |
logical, if the return value should be a single matrix with genotypes of all the individuals |
simParamBee |
|
matrix with genotypes when x
is Colony-class
and
list of matrices with genotypes when x
is
MultiColony-class
, named by colony id when x
is
MultiColony-class
getQueenSegSiteGeno()
: Access genotype data for all segregating sites of the queen
getFathersSegSiteGeno()
: Access genotype data for all segregating sites of fathers
getVirginQueensSegSiteGeno()
: Access genotype data for all segregating sites of virgin queens
getWorkersSegSiteGeno()
: Access genotype data for all segregating sites of workers
getDronesSegSiteGeno()
: Access genotype data for all segregating sites of drones
getSegSiteGeno
and pullSegSiteGeno
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) 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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 5) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) # Input is a population getSegSiteGeno(x = getQueen(colony)) queens <- getQueen(apiary, collapse = TRUE) getSegSiteGeno(queens) # Input is a colony getSegSiteGeno(colony, caste = "queen") getQueenSegSiteGeno(colony) getSegSiteGeno(colony, caste = "workers", nInd = 3) getWorkersSegSiteGeno(colony) # same aliases exist for all the castes! # Get genotypes for all individuals getSegSiteGeno(colony, caste = "all") # Get all genotypes in a single matrix getSegSiteGeno(colony, caste = "all", collapse = TRUE) # Input is a MultiColony - same behaviour as for the Colony getSegSiteGeno(apiary, caste = "queen") getQueenSegSiteGeno(apiary) # Get the genotypes of all individuals either by colony or in a single matrix getSegSiteGeno(apiary, caste = "all") getSegSiteGeno(apiary, caste = "all", collapse = TRUE)
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) 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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 5) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) # Input is a population getSegSiteGeno(x = getQueen(colony)) queens <- getQueen(apiary, collapse = TRUE) getSegSiteGeno(queens) # Input is a colony getSegSiteGeno(colony, caste = "queen") getQueenSegSiteGeno(colony) getSegSiteGeno(colony, caste = "workers", nInd = 3) getWorkersSegSiteGeno(colony) # same aliases exist for all the castes! # Get genotypes for all individuals getSegSiteGeno(colony, caste = "all") # Get all genotypes in a single matrix getSegSiteGeno(colony, caste = "all", collapse = TRUE) # Input is a MultiColony - same behaviour as for the Colony getSegSiteGeno(apiary, caste = "queen") getQueenSegSiteGeno(apiary) # Get the genotypes of all individuals either by colony or in a single matrix getSegSiteGeno(apiary, caste = "all") getSegSiteGeno(apiary, caste = "all", collapse = TRUE)
Level 0 function that returns haplotypes for all segregating sites of individuals in a caste.
getSegSiteHaplo( x, caste = NULL, nInd = NULL, haplo = "all", chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getQueenSegSiteHaplo( x, haplo = "all", chr = NULL, collapse = FALSE, simParamBee = NULL ) getFathersSegSiteHaplo( x, nInd = NULL, haplo = "all", chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getVirginQueensSegSiteHaplo( x, nInd = NULL, haplo = "all", chr = NULL, collapse = FALSE, simParamBee = NULL ) getWorkersSegSiteHaplo( x, nInd = NULL, haplo = "all", chr = NULL, collapse = FALSE, simParamBee = NULL ) getDronesSegSiteHaplo( x, nInd = NULL, haplo = "all", chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL )
getSegSiteHaplo( x, caste = NULL, nInd = NULL, haplo = "all", chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getQueenSegSiteHaplo( x, haplo = "all", chr = NULL, collapse = FALSE, simParamBee = NULL ) getFathersSegSiteHaplo( x, nInd = NULL, haplo = "all", chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getVirginQueensSegSiteHaplo( x, nInd = NULL, haplo = "all", chr = NULL, collapse = FALSE, simParamBee = NULL ) getWorkersSegSiteHaplo( x, nInd = NULL, haplo = "all", chr = NULL, collapse = FALSE, simParamBee = NULL ) getDronesSegSiteHaplo( x, nInd = NULL, haplo = "all", chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL )
x |
|
caste |
NULL or character, NULL when |
nInd |
numeric, number of individuals to access, if |
haplo |
character, either "all" for all haplotypes or an integer for a single set of haplotypes, use a value of 1 for female haplotypes and a value of 2 for male haplotypes |
chr |
numeric, chromosomes to retrieve, if |
dronesHaploid |
logical, return haploid result for drones? |
collapse |
logical, if the return value should be a single matrix with haplotypes of all the individuals |
simParamBee |
|
matrix with haplotypes when x
is Colony-class
and list of matrices with haplotypes when x
is
MultiColony-class
, named by colony id when x
is
MultiColony-class
getQueenSegSiteHaplo()
: Access haplotype data for all segregating sites of the queen
getFathersSegSiteHaplo()
: Access haplotype data for all segregating sites of fathers
getVirginQueensSegSiteHaplo()
: Access haplotype data for all segregating sites of virgin queens
getWorkersSegSiteHaplo()
: Access haplotype data for all segregating sites of workers
getDronesSegSiteHaplo()
: Access haplotype data for all segregating sites of drones
getSegSiteHaplo
and pullSegSiteHaplo
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) 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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 5) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) # Input is a population getSegSiteHaplo(x = getQueen(colony)) queens <- getQueen(apiary, collapse = TRUE) getSegSiteHaplo(queens) # Input is a colony getSegSiteHaplo(colony, caste = "queen") getQueenSegSiteHaplo(colony) getSegSiteHaplo(colony, caste = "workers", nInd = 3) getWorkersSegSiteHaplo(colony) #Same aliases exist for all the castes! # Get haplotypes for all individuals getSegSiteHaplo(colony, caste = "all") # Get all haplotypes in a single matrix getSegSiteHaplo(colony, caste = "all", collapse = TRUE) #Input is a MultiColony - same behaviour as for the Colony! getSegSiteHaplo(apiary, caste = "queen") getQueenSegSiteHaplo(apiary) # Get the haplotypes of all individuals either by colony or in a single matrix getSegSiteHaplo(apiary, caste = "all") getSegSiteHaplo(apiary, caste = "all", collapse = TRUE)
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) 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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 5) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) # Input is a population getSegSiteHaplo(x = getQueen(colony)) queens <- getQueen(apiary, collapse = TRUE) getSegSiteHaplo(queens) # Input is a colony getSegSiteHaplo(colony, caste = "queen") getQueenSegSiteHaplo(colony) getSegSiteHaplo(colony, caste = "workers", nInd = 3) getWorkersSegSiteHaplo(colony) #Same aliases exist for all the castes! # Get haplotypes for all individuals getSegSiteHaplo(colony, caste = "all") # Get all haplotypes in a single matrix getSegSiteHaplo(colony, caste = "all", collapse = TRUE) #Input is a MultiColony - same behaviour as for the Colony! getSegSiteHaplo(apiary, caste = "queen") getQueenSegSiteHaplo(apiary) # Get the haplotypes of all individuals either by colony or in a single matrix getSegSiteHaplo(apiary, caste = "all") getSegSiteHaplo(apiary, caste = "all", collapse = TRUE)
Level 0 function that returns SNP array genotypes of individuals in a caste.
getSnpGeno( x, caste = NULL, nInd = NULL, snpChip = 1, chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getQueenSnpGeno( x, snpChip = 1, chr = NULL, collapse = FALSE, simParamBee = NULL ) getFathersSnpGeno( x, nInd = NULL, snpChip = 1, chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getVirginQueensSnpGeno( x, nInd = NULL, snpChip = 1, chr = NULL, collapse = FALSE, simParamBee = NULL ) getWorkersSnpGeno( x, nInd = NULL, snpChip = 1, chr = NULL, collapse = FALSE, simParamBee = NULL ) getDronesSnpGeno( x, nInd = NULL, snpChip = 1, chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL )
getSnpGeno( x, caste = NULL, nInd = NULL, snpChip = 1, chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getQueenSnpGeno( x, snpChip = 1, chr = NULL, collapse = FALSE, simParamBee = NULL ) getFathersSnpGeno( x, nInd = NULL, snpChip = 1, chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getVirginQueensSnpGeno( x, nInd = NULL, snpChip = 1, chr = NULL, collapse = FALSE, simParamBee = NULL ) getWorkersSnpGeno( x, nInd = NULL, snpChip = 1, chr = NULL, collapse = FALSE, simParamBee = NULL ) getDronesSnpGeno( x, nInd = NULL, snpChip = 1, chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL )
x |
|
caste |
NULL or character, NULL when |
nInd |
numeric, number of individuals to access, if |
snpChip |
numeric, indicates which SNP array genotypes to retrieve |
chr |
numeric, chromosomes to retrieve, if |
dronesHaploid |
logical, return haploid result for drones? |
collapse |
logical, if the return value should be a single matrix with genotypes of all the individuals |
simParamBee |
|
matrix with genotypes when x
is Colony-class
and
list of matrices with genotypes when x
is
MultiColony-class
, named by colony id when x
is
MultiColony-class
getQueenSnpGeno()
: Access SNP array genotype data of the queen
getFathersSnpGeno()
: Access SNP array genotype data of fathers
getVirginQueensSnpGeno()
: Access SNP array genotype data of virgin queens
getWorkersSnpGeno()
: Access SNP array genotype data of workers
getDronesSnpGeno()
: Access SNP array genotype data of drones
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) SP$addSnpChip(nSnpPerChr = 5) 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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 5) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) # Input is a population getSnpGeno(x = getQueen(colony)) queens <- getQueen(apiary, collapse = TRUE) getSnpGeno(queens) # Input is a colony getSnpGeno(colony, caste = "queen") getQueenSnpGeno(colony) getSnpGeno(colony, caste = "workers", nInd = 3) getWorkersSnpGeno(colony) # Same aliases exist for all the castes! # Get genotypes for all individuals getSnpGeno(colony, caste = "all") # Get all haplotypes in a single matrix getSnpGeno(colony, caste = "all", collapse = TRUE) # Input is a MultiColony - same behaviour as for the Colony! getSnpGeno(apiary, caste = "queen") getQueenSnpGeno(apiary) # Get the haplotypes of all individuals either by colony or in a single matrix getSnpGeno(apiary, caste = "all") getSnpGeno(apiary, caste = "all", collapse = TRUE)
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) SP$addSnpChip(nSnpPerChr = 5) 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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 5) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) # Input is a population getSnpGeno(x = getQueen(colony)) queens <- getQueen(apiary, collapse = TRUE) getSnpGeno(queens) # Input is a colony getSnpGeno(colony, caste = "queen") getQueenSnpGeno(colony) getSnpGeno(colony, caste = "workers", nInd = 3) getWorkersSnpGeno(colony) # Same aliases exist for all the castes! # Get genotypes for all individuals getSnpGeno(colony, caste = "all") # Get all haplotypes in a single matrix getSnpGeno(colony, caste = "all", collapse = TRUE) # Input is a MultiColony - same behaviour as for the Colony! getSnpGeno(apiary, caste = "queen") getQueenSnpGeno(apiary) # Get the haplotypes of all individuals either by colony or in a single matrix getSnpGeno(apiary, caste = "all") getSnpGeno(apiary, caste = "all", collapse = TRUE)
Level 0 function that returns SNP array haplotypes of individuals in a caste.
getSnpHaplo( x, caste = NULL, nInd = NULL, snpChip = 1, haplo = "all", chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getQueenSnpHaplo( x, snpChip = 1, haplo = "all", chr = NULL, collapse = FALSE, simParamBee = NULL ) getFathersSnpHaplo( x, nInd = NULL, snpChip = 1, haplo = "all", chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getVirginQueensSnpHaplo( x, nInd = NULL, snpChip = 1, haplo = "all", chr = NULL, collapse = FALSE, simParamBee = NULL ) getWorkersSnpHaplo( x, nInd = NULL, snpChip = 1, haplo = "all", chr = NULL, collapse = FALSE, simParamBee = NULL ) getDronesSnpHaplo( x, nInd = NULL, snpChip = 1, haplo = "all", chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL )
getSnpHaplo( x, caste = NULL, nInd = NULL, snpChip = 1, haplo = "all", chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getQueenSnpHaplo( x, snpChip = 1, haplo = "all", chr = NULL, collapse = FALSE, simParamBee = NULL ) getFathersSnpHaplo( x, nInd = NULL, snpChip = 1, haplo = "all", chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL ) getVirginQueensSnpHaplo( x, nInd = NULL, snpChip = 1, haplo = "all", chr = NULL, collapse = FALSE, simParamBee = NULL ) getWorkersSnpHaplo( x, nInd = NULL, snpChip = 1, haplo = "all", chr = NULL, collapse = FALSE, simParamBee = NULL ) getDronesSnpHaplo( x, nInd = NULL, snpChip = 1, haplo = "all", chr = NULL, dronesHaploid = TRUE, collapse = FALSE, simParamBee = NULL )
x |
|
caste |
NULL or character, NULL when |
nInd |
numeric, number of individuals to access, if |
snpChip |
numeric, indicates which SNP array haplotypes to retrieve |
haplo |
character, either "all" for all haplotypes or an integer for a single set of haplotypes, use a value of 1 for female haplotypes and a value of 2 for male haplotypes |
chr |
numeric, chromosomes to retrieve, if |
dronesHaploid |
logical, return haploid result for drones? |
collapse |
logical, if the return value should be a single matrix with haplotypes of all the individuals |
simParamBee |
|
matrix with haplotypes when x
is Colony-class
and list of matrices with haplotypes when x
is
MultiColony-class
, named by colony id when x
is
MultiColony-class
getQueenSnpHaplo()
: Access SNP array haplotype data of the queen
getFathersSnpHaplo()
: Access SNP array haplotype data of fathers
getVirginQueensSnpHaplo()
: Access SNP array haplotype data of virgin queens
getWorkersSnpHaplo()
: Access SNP array haplotype of workers
getDronesSnpHaplo()
: Access SNP array haplotype data of drones
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) SP$addSnpChip(nSnpPerChr = 5) 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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 5) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) # Input is a population getSnpHaplo(x = getQueen(colony)) queens <- getQueen(apiary, collapse = TRUE) getSnpHaplo(queens) # Input is a colony getSnpHaplo(colony, caste = "queen") getQueenSnpHaplo(colony) getSnpHaplo(colony, caste = "workers", nInd = 3) getWorkersSnpHaplo(colony) # Same aliases exist for all the castes! # Get haplotypes for all individuals getSnpHaplo(colony, caste = "all") # Get all haplotypes in a single matrix getSnpHaplo(colony, caste = "all", collapse = TRUE) # Input is a MultiColony - same behaviour as for the Colony! getSnpHaplo(apiary, caste = "queen") getQueenSnpHaplo(apiary) # Get the haplotypes of all individuals either by colony or in a single matrix getSnpHaplo(apiary, caste = "all") getSnpHaplo(apiary, caste = "all", collapse = TRUE)
founderGenomes <- quickHaplo(nInd = 4, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) SP$addSnpChip(nSnpPerChr = 5) 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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 5) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) # Input is a population getSnpHaplo(x = getQueen(colony)) queens <- getQueen(apiary, collapse = TRUE) getSnpHaplo(queens) # Input is a colony getSnpHaplo(colony, caste = "queen") getQueenSnpHaplo(colony) getSnpHaplo(colony, caste = "workers", nInd = 3) getWorkersSnpHaplo(colony) # Same aliases exist for all the castes! # Get haplotypes for all individuals getSnpHaplo(colony, caste = "all") # Get all haplotypes in a single matrix getSnpHaplo(colony, caste = "all", collapse = TRUE) # Input is a MultiColony - same behaviour as for the Colony! getSnpHaplo(apiary, caste = "queen") getQueenSnpHaplo(apiary) # Get the haplotypes of all individuals either by colony or in a single matrix getSnpHaplo(apiary, caste = "all") getSnpHaplo(apiary, caste = "all", collapse = TRUE)
Level 0 function that returns colony collapse status.
hasCollapsed(x)
hasCollapsed(x)
x |
logical, named by colony id when x
is MultiColony-class
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 = 6, nDrones = 3) colony <- addVirginQueens(colony, nInd = 5) hasCollapsed(colony) colony <- collapse(colony) hasCollapsed(colony) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) hasCollapsed(apiary) apiary <- collapse(apiary) hasCollapsed(apiary)
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 = 6, nDrones = 3) colony <- addVirginQueens(colony, nInd = 5) hasCollapsed(colony) colony <- collapse(colony) hasCollapsed(colony) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) hasCollapsed(apiary) apiary <- collapse(apiary) hasCollapsed(apiary)
Level 0 function that returns colony split status. This will obviously impact colony strength.
hasSplit(x)
hasSplit(x)
x |
logical, named by colony id when x
is MultiColony-class
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 = 6, nDrones = 3) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) hasSplit(colony) tmp <- split(colony) hasSplit(tmp$split) hasSplit(tmp$remnant) hasSplit(apiary) tmp2 <- split(apiary) hasSplit(tmp2$split) hasSplit(tmp2$remnant)
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 = 6, nDrones = 3) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) hasSplit(colony) tmp <- split(colony) hasSplit(tmp$split) hasSplit(tmp$remnant) hasSplit(apiary) tmp2 <- split(apiary) hasSplit(tmp2$split) hasSplit(tmp2$remnant)
Level 0 function that returns colony supersedure status.
hasSuperseded(x)
hasSuperseded(x)
x |
logical, named by colony id when x
is MultiColony-class
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 = 6, nDrones = 3) 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 = 6, nDrones = 3) hasSuperseded(colony) colony <- supersede(colony) hasSuperseded(colony) hasSuperseded(apiary) apiary <- supersede(apiary) hasSuperseded(apiary)
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 = 6, nDrones = 3) 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 = 6, nDrones = 3) hasSuperseded(colony) colony <- supersede(colony) hasSuperseded(colony) hasSuperseded(apiary) apiary <- supersede(apiary) hasSuperseded(apiary)
Level 0 function that returns colony swarmed status. This will obviously have major impact on the colony and its downstream events.
hasSwarmed(x)
hasSwarmed(x)
x |
logical, named by colony id when x
is MultiColony-class
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 = 6, nDrones = 3) 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 = 6, nDrones = 3) hasSwarmed(colony) tmp <- swarm(colony) hasSwarmed(tmp$swarm) hasSwarmed(tmp$remnant) hasSwarmed(apiary) tmp2 <- swarm(apiary) hasSwarmed(tmp2$swarm) hasSwarmed(tmp2$remnant)
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 = 6, nDrones = 3) 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 = 6, nDrones = 3) hasSwarmed(colony) tmp <- swarm(colony) hasSwarmed(tmp$swarm) hasSwarmed(tmp$remnant) hasSwarmed(apiary) tmp2 <- swarm(apiary) hasSwarmed(tmp2$swarm) hasSwarmed(tmp2$remnant)
Level 0 function that tests if individuals are members of a specific caste
isCaste(x, caste, simParamBee = NULL) isQueen(x, simParamBee = NULL) isFather(x, simParamBee = NULL) isWorker(x, simParamBee = NULL) isDrone(x, simParamBee = NULL) isVirginQueens(x, simParamBee = NULL) isVirginQueen(x, simParamBee = NULL)
isCaste(x, caste, simParamBee = NULL) isQueen(x, simParamBee = NULL) isFather(x, simParamBee = NULL) isWorker(x, simParamBee = NULL) isDrone(x, simParamBee = NULL) isVirginQueens(x, simParamBee = NULL) isVirginQueen(x, simParamBee = NULL)
x |
|
caste |
character, one of "queen", "fathers", "workers", "drones", or "virginQueens"; only single value is used |
simParamBee |
|
logical
isQueen()
: Is individual a queen
isFather()
: Is individual a father
isWorker()
: Is individual a worker
isDrone()
: Is individual a drone
isVirginQueens()
: Is individual a virgin queen
isVirginQueen()
: Is individual a virgin queen
isQueen
, isFather
,
isVirginQueen
,
isWorker
, and
isDrone
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 class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) colony <- buildUp(x = colony, nWorkers = 120, nDrones = 20) colony <- addVirginQueens(x = colony, nInd = 4) isCaste(getQueen(colony), caste = "queen") isCaste(getFathers(colony, nInd = 2), caste = "fathers") isCaste(getWorkers(colony, nInd = 2), caste = "workers") # random sample! isCaste(getDrones(colony, nInd = 2), caste = "drones") isCaste(getVirginQueens(colony, nInd = 2), caste = "virginQueens") bees <- c( getQueen(colony), getFathers(colony, nInd = 2), getWorkers(colony, nInd = 2), getDrones(colony, nInd = 2), getVirginQueens(colony, nInd = 2) ) isCaste(bees, caste = "queen") isCaste(bees, caste = "fathers") isCaste(bees, caste = "workers") isCaste(bees, caste = "drones") isCaste(bees, caste = "virginQueens") isQueen(getQueen(colony)) isQueen(getFathers(colony, nInd = 2)) isFather(getQueen(colony)) isFather(getFathers(colony, nInd = 2)) isWorker(getQueen(colony)) isWorker(getFathers(colony, nInd = 2)) isWorker(getWorkers(colony, nInd = 2)) isDrone(getQueen(colony)) isDrone(getFathers(colony, nInd = 2)) isDrone(getDrones(colony, nInd = 2)) isVirginQueen(getQueen(colony)) isVirginQueen(getFathers(colony, nInd = 2)) isVirginQueen(getVirginQueens(colony, nInd = 2))
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 class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) colony <- buildUp(x = colony, nWorkers = 120, nDrones = 20) colony <- addVirginQueens(x = colony, nInd = 4) isCaste(getQueen(colony), caste = "queen") isCaste(getFathers(colony, nInd = 2), caste = "fathers") isCaste(getWorkers(colony, nInd = 2), caste = "workers") # random sample! isCaste(getDrones(colony, nInd = 2), caste = "drones") isCaste(getVirginQueens(colony, nInd = 2), caste = "virginQueens") bees <- c( getQueen(colony), getFathers(colony, nInd = 2), getWorkers(colony, nInd = 2), getDrones(colony, nInd = 2), getVirginQueens(colony, nInd = 2) ) isCaste(bees, caste = "queen") isCaste(bees, caste = "fathers") isCaste(bees, caste = "workers") isCaste(bees, caste = "drones") isCaste(bees, caste = "virginQueens") isQueen(getQueen(colony)) isQueen(getFathers(colony, nInd = 2)) isFather(getQueen(colony)) isFather(getFathers(colony, nInd = 2)) isWorker(getQueen(colony)) isWorker(getFathers(colony, nInd = 2)) isWorker(getWorkers(colony, nInd = 2)) isDrone(getQueen(colony)) isDrone(getFathers(colony, nInd = 2)) isDrone(getDrones(colony, nInd = 2)) isVirginQueen(getQueen(colony)) isVirginQueen(getFathers(colony, nInd = 2)) isVirginQueen(getVirginQueens(colony, nInd = 2))
Level 0 function that checks if the csd locus has been
activated. See SimParamBee
for more information about the csd
locus.
isCsdActive(simParamBee = NULL)
isCsdActive(simParamBee = NULL)
simParamBee |
|
logical
founderGenomes <- quickHaplo(nInd = 3, nChr = 3, segSites = 100) SP <- SimParamBee$new(founderGenomes, csdChr = NULL) isCsdActive() SP <- SimParamBee$new(founderGenomes) isCsdActive()
founderGenomes <- quickHaplo(nInd = 3, nChr = 3, segSites = 100) SP <- SimParamBee$new(founderGenomes, csdChr = NULL) isCsdActive() SP <- SimParamBee$new(founderGenomes) isCsdActive()
Level 0 function that returns if individuals of a population are
heterozygous at the csd locus. See SimParamBee
for more
information about the csd locus.
isCsdHeterozygous(pop, simParamBee = NULL)
isCsdHeterozygous(pop, simParamBee = NULL)
pop |
|
simParamBee |
|
We could expand isCsdHeterozygous
to work also with
Colony-class
and MultiColony-class
if needed
logical
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 class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) colony <- buildUp(x = colony, nWorkers = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 4) # Use isCsdHeterozygous on a Population isCsdHeterozygous(getQueen(colony)) isCsdHeterozygous(getWorkers(colony))
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 class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) colony <- buildUp(x = colony, nWorkers = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 4) # Use isCsdHeterozygous on a Population isCsdHeterozygous(getQueen(colony)) isCsdHeterozygous(getWorkers(colony))
Level 0 function that returns drones presence status (are they present or not).
isDronesPresent(x, simParamBee = NULL)
isDronesPresent(x, simParamBee = NULL)
x |
|
simParamBee |
|
logical, named by colony id when x
is
MultiColony-class
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 = 120, nDrones = 20) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 100, nDrones = 10) isDronesPresent(colony) isDronesPresent(removeDrones(colony)) isDronesPresent(apiary) isDronesPresent(removeDrones(apiary))
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 = 120, nDrones = 20) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 100, nDrones = 10) isDronesPresent(colony) isDronesPresent(removeDrones(colony)) isDronesPresent(apiary) isDronesPresent(removeDrones(apiary))
Check whether a population, colony or a multicolony object has no individuals within.
isEmpty(x)
isEmpty(x)
x |
boolean when x
is Pop-class
or
Colony-class
, and named vector of boolean when
x
is MultiColony-class
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) isEmpty(new(Class = "Pop")) isEmpty(basePop[0]) isEmpty(basePop) emptyColony <- createColony() nonEmptyColony <- createColony(basePop[1]) isEmpty(emptyColony) isEmpty(nonEmptyColony) emptyApiary <- createMultiColony(n = 3) emptyApiary1 <- c(createColony(), createColony()) emptyApiary2 <- createMultiColony() nonEmptyApiary <- createMultiColony(basePop[2:5], n = 4) isEmpty(emptyApiary) isEmpty(emptyApiary1) isEmpty(nonEmptyApiary) isNULLColonies(emptyApiary) isNULLColonies(emptyApiary1) isNULLColonies(nonEmptyApiary) nEmptyColonies(emptyApiary) nEmptyColonies(emptyApiary1) nEmptyColonies(nonEmptyApiary) nNULLColonies(emptyApiary) nNULLColonies(emptyApiary1) nNULLColonies(nonEmptyApiary)
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) isEmpty(new(Class = "Pop")) isEmpty(basePop[0]) isEmpty(basePop) emptyColony <- createColony() nonEmptyColony <- createColony(basePop[1]) isEmpty(emptyColony) isEmpty(nonEmptyColony) emptyApiary <- createMultiColony(n = 3) emptyApiary1 <- c(createColony(), createColony()) emptyApiary2 <- createMultiColony() nonEmptyApiary <- createMultiColony(basePop[2:5], n = 4) isEmpty(emptyApiary) isEmpty(emptyApiary1) isEmpty(nonEmptyApiary) isNULLColonies(emptyApiary) isNULLColonies(emptyApiary1) isNULLColonies(nonEmptyApiary) nEmptyColonies(emptyApiary) nEmptyColonies(emptyApiary1) nEmptyColonies(nonEmptyApiary) nNULLColonies(emptyApiary) nNULLColonies(emptyApiary1) nNULLColonies(nonEmptyApiary)
Level 0 function that returns fathers presence status (are they present or not, which means the queen is mated).
isFathersPresent(x, simParamBee = NULL) areFathersPresent(x, simParamBee = NULL)
isFathersPresent(x, simParamBee = NULL) areFathersPresent(x, simParamBee = NULL)
x |
|
simParamBee |
|
logical, named by colony id when x
is
MultiColony-class
areFathersPresent()
: Are fathers present
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]) isFathersPresent(colony) apiary <- createMultiColony(basePop[3:4], n = 2) isFathersPresent(apiary) colony <- cross(colony, drones = droneGroups[[1]]) isFathersPresent(removeDrones(colony)) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) isFathersPresent(removeDrones(apiary))
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]) isFathersPresent(colony) apiary <- createMultiColony(basePop[3:4], n = 2) isFathersPresent(apiary) colony <- cross(colony, drones = droneGroups[[1]]) isFathersPresent(removeDrones(colony)) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) isFathersPresent(removeDrones(apiary))
Level 0 function that returns heterozygote status for a multilocus genotype.
isGenoHeterozygous(x)
isGenoHeterozygous(x)
x |
integer or matrix, output from |
logical # Not exporting this function, since its just a helper
Check which of the colonies in a multicolony are NULL
isNULLColonies(multicolony)
isNULLColonies(multicolony)
multicolony |
Named vector of boolean
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) emptyApiary <- createMultiColony(n = 3) emptyApiary1 <- c(createColony(), createColony()) nonEmptyApiary <- createMultiColony(basePop[2:5], n = 4) isEmpty(emptyApiary) isEmpty(emptyApiary1) isEmpty(nonEmptyApiary) isNULLColonies(emptyApiary) isNULLColonies(emptyApiary1) isNULLColonies(nonEmptyApiary) nEmptyColonies(emptyApiary) nEmptyColonies(emptyApiary1) nEmptyColonies(nonEmptyApiary) nNULLColonies(emptyApiary) nNULLColonies(emptyApiary1) nNULLColonies(nonEmptyApiary)
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) emptyApiary <- createMultiColony(n = 3) emptyApiary1 <- c(createColony(), createColony()) nonEmptyApiary <- createMultiColony(basePop[2:5], n = 4) isEmpty(emptyApiary) isEmpty(emptyApiary1) isEmpty(nonEmptyApiary) isNULLColonies(emptyApiary) isNULLColonies(emptyApiary1) isNULLColonies(nonEmptyApiary) nEmptyColonies(emptyApiary) nEmptyColonies(emptyApiary1) nEmptyColonies(nonEmptyApiary) nNULLColonies(emptyApiary) nNULLColonies(emptyApiary1) nNULLColonies(nonEmptyApiary)
Level 0 function that returns colony production status. This can be used to decided if colony production can be simulated.
isProductive(x)
isProductive(x)
x |
logical, named by colony id when x
is MultiColony-class
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]]) isProductive(colony) colony <- buildUp(x = colony, nWorkers = 6, nDrones = 3) isProductive(colony) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) isProductive(apiary) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) isProductive(apiary)
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]]) isProductive(colony) colony <- buildUp(x = colony, nWorkers = 6, nDrones = 3) isProductive(colony) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) isProductive(apiary) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) isProductive(apiary)
Level 0 function that returns queen's presence status (is she present/alive or not).
isQueenPresent(x, simParamBee = NULL)
isQueenPresent(x, simParamBee = NULL)
x |
|
simParamBee |
|
logical, named by colony id when x
is
MultiColony-class
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 = 120, nDrones = 20) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 100, nDrones = 10) isQueenPresent(colony) isQueenPresent(apiary) colony <- removeQueen(colony) isQueenPresent(colony)
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 = 120, nDrones = 20) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 100, nDrones = 10) isQueenPresent(colony) isQueenPresent(apiary) colony <- removeQueen(colony) isQueenPresent(colony)
Test if x is a SimParamBee
class object
isSimParamBee(x)
isSimParamBee(x)
x |
logical
founderGenomes <- quickHaplo(nInd = 2, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) isSimParamBee(SP)
founderGenomes <- quickHaplo(nInd = 2, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) isSimParamBee(SP)
Level 0 function that returns virgin queen(s) presence status.
isVirginQueensPresent(x, simParamBee = NULL) isVirginQueenPresent(x, simParamBee = NULL) areVirginQueensPresent(x, simParamBee = NULL)
isVirginQueensPresent(x, simParamBee = NULL) isVirginQueenPresent(x, simParamBee = NULL) areVirginQueensPresent(x, simParamBee = NULL)
x |
|
simParamBee |
|
logical, named by colony id when x
is
MultiColony-class
isVirginQueenPresent()
: Are virgin queen(s) present
areVirginQueensPresent()
: Are virgin queen(s) present
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 <- addVirginQueens(x = colony, nInd = 4) isVirginQueenPresent(colony) isVirginQueenPresent(pullVirginQueens(colony)$remnant) isVirginQueenPresent(removeQueen(colony)) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 100, nDrones = 10) isVirginQueenPresent(apiary) tmp <- swarm(x = apiary) isVirginQueenPresent(tmp$swarm) isVirginQueenPresent(tmp$remnant)
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 <- addVirginQueens(x = colony, nInd = 4) isVirginQueenPresent(colony) isVirginQueenPresent(pullVirginQueens(colony)$remnant) isVirginQueenPresent(removeQueen(colony)) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 100, nDrones = 10) isVirginQueenPresent(apiary) tmp <- swarm(x = apiary) isVirginQueenPresent(tmp$swarm) isVirginQueenPresent(tmp$remnant)
Level 0 function that returns workers presence status (are they present or not).
isWorkersPresent(x, simParamBee = NULL) areWorkersPresent(x, simParamBee = NULL) areDronesPresent(x, simParamBee = NULL)
isWorkersPresent(x, simParamBee = NULL) areWorkersPresent(x, simParamBee = NULL) areDronesPresent(x, simParamBee = NULL)
x |
|
simParamBee |
|
logical, named by colony id when x
is
MultiColony-class
areWorkersPresent()
: Are workers present
areDronesPresent()
: Are drones present
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 = 120, nDrones = 20) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 100, nDrones = 10) isWorkersPresent(colony) isWorkersPresent(removeWorkers(colony)) isWorkersPresent(apiary) isWorkersPresent(removeWorkers(apiary))
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 = 120, nDrones = 20) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 100, nDrones = 10) isWorkersPresent(colony) isWorkersPresent(removeWorkers(colony)) isWorkersPresent(apiary) isWorkersPresent(removeWorkers(apiary))
Maps caste member (individual) values to a colony value - for
phenotype, genetic, breeding, dominance, and epistasis values. This function
can be used as FUN
argument in calcColonyValue
function(s). It can also be saved in SimParamBee$colonyValueFUN
as a
default function called by calcColonyValue
function(s).
This is just an example - quite a flexible one! You can provide your
own "caste functions" that satisfy your needs within this mapping function
(see queenFUN
, workersFUN
, and dronesFUN
below)
or provide a complete replacement of this mapping function! For example,
this mapping function does not cater for indirect (social) genetic effects
where colony individuals value impacts value of other colony individuals.
Note though that you can achieve this impact also via multiple correlated
traits, such as a queen and a workers trait.
mapCasteToColonyValue( colony, value = "pheno", queenTrait = 1, queenFUN = function(x) x, workersTrait = 2, workersFUN = colSums, dronesTrait = NULL, dronesFUN = NULL, traitName = NULL, combineFUN = function(q, w, d) q + w, checkProduction = TRUE, notProductiveValue = 0, simParamBee = NULL ) mapCasteToColonyPheno(colony, simParamBee = NULL, ...) mapCasteToColonyGv(colony, simParamBee = NULL, ...) mapCasteToColonyBv(colony, simParamBee = NULL, ...) mapCasteToColonyDd(colony, simParamBee = NULL, ...) mapCasteToColonyAa(colony, simParamBee = NULL, ...)
mapCasteToColonyValue( colony, value = "pheno", queenTrait = 1, queenFUN = function(x) x, workersTrait = 2, workersFUN = colSums, dronesTrait = NULL, dronesFUN = NULL, traitName = NULL, combineFUN = function(q, w, d) q + w, checkProduction = TRUE, notProductiveValue = 0, simParamBee = NULL ) mapCasteToColonyPheno(colony, simParamBee = NULL, ...) mapCasteToColonyGv(colony, simParamBee = NULL, ...) mapCasteToColonyBv(colony, simParamBee = NULL, ...) mapCasteToColonyDd(colony, simParamBee = NULL, ...) mapCasteToColonyAa(colony, simParamBee = NULL, ...)
colony |
|
value |
character, one of |
queenTrait |
numeric (column position) or character (column name),
trait(s) that represents queen's contribution to colony value(s); if
|
queenFUN |
function, function that will be applied to queen's value |
workersTrait |
numeric (column position) or character (column name),
trait(s) that represents workers' contribution to colony value(s); if
|
workersFUN |
function, function that will be applied to workers values |
dronesTrait |
numeric (column position) or character (column name),
trait(s) that represents drones' contribution to colony value(s); if
|
dronesFUN |
function, function that will be applied to drone values |
traitName |
the name of the colony trait(s), say, honeyYield; you can pass
more than one trait name here, but make sure to match them with
|
combineFUN |
function that will combine the queen, worker, and drone
contributions - this function should be defined as |
checkProduction |
logical, does the value depend on the production
status of colony; if yes and production is |
notProductiveValue |
numeric, returned value when colony is not productive;
you can pass more than one logical value here (one per trait coming out of
|
simParamBee |
|
... |
other arguments of |
This is a utility/mapping function meant to be called by
calcColonyValue
. It only works on a single colony - use
calcColonyValue
to get Colony or MultiColony values.
numeric matrix with one value or a row of values
mapCasteToColonyPheno()
: Map caste member (individual) phenotype values to a colony phenotype value
mapCasteToColonyGv()
: Map caste member (individual) genetic values to a colony genetic value
mapCasteToColonyBv()
: Map caste member (individual) breeding values to a colony breeding value
mapCasteToColonyDd()
: Map caste member (individual) dominance values to a colony dominance value
mapCasteToColonyAa()
: Map caste member (individual) epistasis values to a colony epistasis value
SimParamBee
field colonyValueFUN
and functions
calcColonyValue
, calcColonyPheno
,
calcColonyGv
, getEvents
,
pheno
, and gv
, as well as
vignette(topic = "QuantitativeGenetics", package = "SIMplyBee")
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) # Define two traits that collectively affect colony honey yield: # 1) queen's effect on colony honey yield, say via pheromone secretion phenotype # 2) workers' effect on colony honey yield, say via foraging ability phenotype # The traits will have a negative genetic correlation of -0.5 and heritability # of 0.25 (on an individual level) nWorkers <- 10 mean <- c(10, 10 / nWorkers) varA <- c(1, 1 / nWorkers) corA <- matrix(data = c( 1.0, -0.5, -0.5, 1.0 ), nrow = 2, byrow = TRUE) varE <- c(3, 3 / nWorkers) varA / (varA + varE) SP$addTraitADE(nQtlPerChr = 100, mean = mean, var = varA, corA = corA, meanDD = 0.1, varDD = 0.2, corD = corA, relAA = 0.1, corAA = corA) SP$setVarE(varE = varE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 10) colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = drones) colony <- buildUp(colony, nWorkers = nWorkers, nDrones = 3) # Colony value mapCasteToColonyPheno(colony) mapCasteToColonyGv(colony) # To understand where the above values come from, study the contents of # mapCasteToColonyValue() and the values below: # Phenotype values getQueenPheno(colony) getWorkersPheno(colony) # Genetic values getQueenGv(colony) getWorkersGv(colony)
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) # Define two traits that collectively affect colony honey yield: # 1) queen's effect on colony honey yield, say via pheromone secretion phenotype # 2) workers' effect on colony honey yield, say via foraging ability phenotype # The traits will have a negative genetic correlation of -0.5 and heritability # of 0.25 (on an individual level) nWorkers <- 10 mean <- c(10, 10 / nWorkers) varA <- c(1, 1 / nWorkers) corA <- matrix(data = c( 1.0, -0.5, -0.5, 1.0 ), nrow = 2, byrow = TRUE) varE <- c(3, 3 / nWorkers) varA / (varA + varE) SP$addTraitADE(nQtlPerChr = 100, mean = mean, var = varA, corA = corA, meanDD = 0.1, varDD = 0.2, corD = corA, relAA = 0.1, corAA = corA) SP$setVarE(varE = varE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 10) colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = drones) colony <- buildUp(colony, nWorkers = nWorkers, nDrones = 3) # Colony value mapCasteToColonyPheno(colony) mapCasteToColonyGv(colony) # To understand where the above values come from, study the contents of # mapCasteToColonyValue() and the values below: # Phenotype values getQueenPheno(colony) getWorkersPheno(colony) # Genetic values getQueenGv(colony) getWorkersGv(colony)
Finds loci on a genetic map and return a list of positions. This function is adopted from AlphaSimR (Gaynor et al., 2021)
mapLoci(markers, genMap)
mapLoci(markers, genMap)
markers |
character, vector of marker positions as "chr_position" |
genMap |
list, genetic map |
A list with number of loci per chromosome and genetic positions of the markers
An object holding a collection of honeybee colonies. It behaves like a list.
isMultiColony(x) ## S4 method for signature 'MultiColony' show(object) ## S4 method for signature 'MultiColony' c(x, ...) ## S4 method for signature 'MultiColonyOrNULL' c(x, ...) ## S4 method for signature 'MultiColony,integerOrNumericOrLogical' x[i, j, drop] ## S4 method for signature 'MultiColony,character' x[i, j, drop] ## S4 method for signature 'MultiColony,integerOrNumericOrLogical' x[[i]] ## S4 method for signature 'MultiColony,character' x[[i]] ## S4 replacement method for signature ## 'MultiColony,integerOrNumericOrLogicalOrCharacter,ANY,MultiColony' x[i, j] <- value ## S4 replacement method for signature ## 'MultiColony,integerOrNumericOrLogicalOrCharacter,ANY,Colony' x[[i, j]] <- value
isMultiColony(x) ## S4 method for signature 'MultiColony' show(object) ## S4 method for signature 'MultiColony' c(x, ...) ## S4 method for signature 'MultiColonyOrNULL' c(x, ...) ## S4 method for signature 'MultiColony,integerOrNumericOrLogical' x[i, j, drop] ## S4 method for signature 'MultiColony,character' x[i, j, drop] ## S4 method for signature 'MultiColony,integerOrNumericOrLogical' x[[i]] ## S4 method for signature 'MultiColony,character' x[[i]] ## S4 replacement method for signature ## 'MultiColony,integerOrNumericOrLogicalOrCharacter,ANY,MultiColony' x[i, j] <- value ## S4 replacement method for signature ## 'MultiColony,integerOrNumericOrLogicalOrCharacter,ANY,Colony' x[[i, j]] <- value
x |
|
object |
|
... |
|
i |
integer, numeric, logical, or character, index or ID to select a colony (see examples) |
j |
not used |
drop |
not used |
value |
|
MultiColony-class
or Colony-class
isMultiColony()
: Test if x is a MultiColony class object
show(MultiColony)
: Show MultiColony object
c(MultiColony)
: Combine multiple Colony and MultiColony objects
c(MultiColonyOrNULL)
: Combine multiple Colony and MultiColony objects
x[i
: Extract a colony (one or more!) with an integer/numeric/logical index (position) (return MultiColony-class
)
x[i
: Extract a colony (one or more!) with a character ID (name) (return MultiColony-class
)
x[[i
: Extract a colony (just one!) with an integer/numeric/logical index (position) (return Colony-class
)
x[[i
: Extract a colony (just one!) with a character ID (name) (return Colony-class
)
`[`(x = MultiColony, i = integerOrNumericOrLogicalOrCharacter, j = ANY) <- value
: Assign colonies into MultiColony
`[[`(x = MultiColony, i = integerOrNumericOrLogicalOrCharacter, j = ANY) <- value
: Assign Colony into MultiColony
colonies
list, a collection of Colony-class
objects
founderGenomes <- quickHaplo(nInd = 10, 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) apiary <- createMultiColony(basePop[1:6], n = 6) apiary <- cross(apiary, drones = droneGroups[1:6]) apiary show(apiary) is(apiary) isMultiColony(apiary) getId(apiary) apiary[1] getId(apiary[1]) getId(apiary["2"]) getId(apiary[2]) getId(apiary[-1]) getId(apiary[5]) getId(apiary) getId(apiary[c(1, 3)]) getId(apiary[c("2", "4")]) getId(apiary[c(TRUE, FALSE, TRUE, FALSE)]) getId(apiary[c(TRUE, FALSE)]) # beware of recycling! getId(apiary[c(5, 6)]) getId(apiary[c("6", "7")]) apiary[[1]] apiary[["2"]] apiary[[3]] apiary[["4"]] try(apiary[[6]]) apiary[["7"]] getId(c(apiary[c(1, 3)], apiary[2])) getId(c(apiary[2], apiary[c(1, 3)])) getId(c(apiary[2], apiary[0])) getId(c(apiary[0], apiary[2])) getId(c(apiary[2], NULL)) getId(c(NULL, apiary[2])) apiary1 <- apiary[1:2] apiary2 <- apiary[3:4] getId(apiary1) getId(apiary2) apiary1[[1]] <- apiary2[[1]] getId(apiary1) try(apiary2[[1]] <- apiary2[[2]]) apiary1 <- apiary[1:2] apiary2 <- apiary[3:5] getId(apiary1) getId(apiary2) apiary2[1:2] <- apiary1 getId(apiary2) try(apiary2[1] <- apiary1) try(apiary2[1:3] <- apiary1) try(apiary2[1:2] <- apiary1[[1]]) apiary2 <- apiary[3:5] getId(apiary2) try(apiary2[c("4", "5")] <- apiary1) try(apiary2[c("4", "5")] <- apiary1)
founderGenomes <- quickHaplo(nInd = 10, 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) apiary <- createMultiColony(basePop[1:6], n = 6) apiary <- cross(apiary, drones = droneGroups[1:6]) apiary show(apiary) is(apiary) isMultiColony(apiary) getId(apiary) apiary[1] getId(apiary[1]) getId(apiary["2"]) getId(apiary[2]) getId(apiary[-1]) getId(apiary[5]) getId(apiary) getId(apiary[c(1, 3)]) getId(apiary[c("2", "4")]) getId(apiary[c(TRUE, FALSE, TRUE, FALSE)]) getId(apiary[c(TRUE, FALSE)]) # beware of recycling! getId(apiary[c(5, 6)]) getId(apiary[c("6", "7")]) apiary[[1]] apiary[["2"]] apiary[[3]] apiary[["4"]] try(apiary[[6]]) apiary[["7"]] getId(c(apiary[c(1, 3)], apiary[2])) getId(c(apiary[2], apiary[c(1, 3)])) getId(c(apiary[2], apiary[0])) getId(c(apiary[0], apiary[2])) getId(c(apiary[2], NULL)) getId(c(NULL, apiary[2])) apiary1 <- apiary[1:2] apiary2 <- apiary[3:4] getId(apiary1) getId(apiary2) apiary1[[1]] <- apiary2[[1]] getId(apiary1) try(apiary2[[1]] <- apiary2[[2]]) apiary1 <- apiary[1:2] apiary2 <- apiary[3:5] getId(apiary1) getId(apiary2) apiary2[1:2] <- apiary1 getId(apiary2) try(apiary2[1] <- apiary1) try(apiary2[1:3] <- apiary1) try(apiary2[1:2] <- apiary1[[1]]) apiary2 <- apiary[3:5] getId(apiary2) try(apiary2[c("4", "5")] <- apiary1) try(apiary2[c("4", "5")] <- apiary1)
Returns the number of individuals of a caste in a colony
nCaste(x, caste = "all", simParamBee = NULL) nQueens(x, simParamBee = NULL) nFathers(x, simParamBee = NULL) nWorkers(x, simParamBee = NULL) nDrones(x, simParamBee = NULL) nVirginQueens(x, simParamBee = NULL)
nCaste(x, caste = "all", simParamBee = NULL) nQueens(x, simParamBee = NULL) nFathers(x, simParamBee = NULL) nWorkers(x, simParamBee = NULL) nDrones(x, simParamBee = NULL) nVirginQueens(x, simParamBee = NULL)
x |
|
caste |
character, "queen", "fathers", "workers", "drones", "virginQueens", or "all" |
simParamBee |
|
when x
is Colony-class
return is integer for
caste != "all"
or list for caste == "all"
with nodes named
by caste; when x
is MultiColony-class
return is named
integer for caste != "all"
or named list of lists for
caste == "all"
nQueens()
: Number of queens in a colony
nFathers()
: Number of fathers in a colony
nWorkers()
: Number of workers in a colony
nDrones()
: Number of drones in a colony
nVirginQueens()
: Number of virgin queens in a colony
nQueens
, nFathers
,
nVirginQueens
, nWorkers
, and
nDrones
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 = 100, nDrones = 10) colony <- addVirginQueens(x = colony, nInd = 3) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 100, nDrones = 10) apiary <- addVirginQueens(x = apiary, nInd = 3) # Check caste members nCaste(colony, caste = "queen") nCaste(colony, caste = "fathers") nCaste(colony, caste = "virginQueens") nCaste(colony, caste = "workers") nCaste(colony, caste = "drones") nCaste(colony, caste = "all") nCaste(apiary, caste = "queen") nCaste(apiary, caste = "fathers") nCaste(apiary, caste = "virginQueens") nCaste(apiary, caste = "workers") nCaste(apiary, caste = "drones") nCaste(apiary, caste = "all") # Check number of queens nQueens(colony) nQueens(apiary) apiary <- removeQueen(apiary) nQueens(apiary) # Check number of fathers nFathers(colony) nFathers(apiary) # Check number of workers nWorkers(colony) nWorkers(apiary) # Check number of drones nDrones(colony) nDrones(apiary) # Check number of virgin queens nVirginQueens(colony) nVirginQueens(apiary)
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 = 100, nDrones = 10) colony <- addVirginQueens(x = colony, nInd = 3) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 100, nDrones = 10) apiary <- addVirginQueens(x = apiary, nInd = 3) # Check caste members nCaste(colony, caste = "queen") nCaste(colony, caste = "fathers") nCaste(colony, caste = "virginQueens") nCaste(colony, caste = "workers") nCaste(colony, caste = "drones") nCaste(colony, caste = "all") nCaste(apiary, caste = "queen") nCaste(apiary, caste = "fathers") nCaste(apiary, caste = "virginQueens") nCaste(apiary, caste = "workers") nCaste(apiary, caste = "drones") nCaste(apiary, caste = "all") # Check number of queens nQueens(colony) nQueens(apiary) apiary <- removeQueen(apiary) nQueens(apiary) # Check number of fathers nFathers(colony) nFathers(apiary) # Check number of workers nWorkers(colony) nWorkers(apiary) # Check number of drones nDrones(colony) nDrones(apiary) # Check number of virgin queens nVirginQueens(colony) nVirginQueens(apiary)
Level 0 function that returns the number of colonies in a MultiColony object.
nColonies(multicolony) nNULLColonies(multicolony) nEmptyColonies(multicolony)
nColonies(multicolony) nNULLColonies(multicolony) nEmptyColonies(multicolony)
multicolony |
integer
nNULLColonies()
: Number of NULL
colonies in a MultiColony object
nEmptyColonies()
: Number of empty colonies in a MultiColony object
nNULLColonies
and nEmptyColonies
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) emptyApiary <- createMultiColony(n = 3) emptyApiary1 <- c(createColony(), createColony()) nonEmptyApiary <- createMultiColony(basePop[2:3], n = 2) nColonies(nonEmptyApiary) nColonies(emptyApiary) isEmpty(emptyApiary) isEmpty(emptyApiary1) isEmpty(nonEmptyApiary) isNULLColonies(emptyApiary) isNULLColonies(emptyApiary1) isNULLColonies(nonEmptyApiary) nEmptyColonies(emptyApiary) nEmptyColonies(emptyApiary1) nEmptyColonies(nonEmptyApiary) nNULLColonies(emptyApiary) nNULLColonies(emptyApiary1) nNULLColonies(nonEmptyApiary)
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) emptyApiary <- createMultiColony(n = 3) emptyApiary1 <- c(createColony(), createColony()) nonEmptyApiary <- createMultiColony(basePop[2:3], n = 2) nColonies(nonEmptyApiary) nColonies(emptyApiary) isEmpty(emptyApiary) isEmpty(emptyApiary1) isEmpty(nonEmptyApiary) isNULLColonies(emptyApiary) isNULLColonies(emptyApiary1) isNULLColonies(nonEmptyApiary) nEmptyColonies(emptyApiary) nEmptyColonies(emptyApiary1) nEmptyColonies(nonEmptyApiary) nNULLColonies(emptyApiary) nNULLColonies(emptyApiary1) nNULLColonies(nonEmptyApiary)
Level 0 function that returns the number of distinct csd alleles
in input. See SimParamBee
for more information about the csd
locus.
nCsdAlleles(x, collapse = FALSE, simParamBee = NULL)
nCsdAlleles(x, collapse = FALSE, simParamBee = NULL)
x |
|
collapse |
logical, if |
simParamBee |
|
Queen has 2 distinct csd alleles, since she has to be heterozygous
to be viable. The same holds for individual virgin queens and workers, but
note that looking at csd genotypes of virgin queens or workers we are
looking at a sample of 1 csd allele from the queen and 1 csd allele from
their fathers, noting that homozygous genotypes are excluded. Therefore,
nCsdAlleles()
from virgin queens and workers is a noisy realisation
of nCsdAlleles()
from queens and fathers. For this reason, we also
report nCsdAlleles()
from queens and fathers combined (see the
queenAndFathers
list node) when x
is
Colony-class
. This last measure is then the expected number
of csd alleles in a colony as opposed to realised number of csd alleles in
a sample of virgin queens and workers. Similarly as for virgin queens and
workers, nCsdAlleles()
from drones gives a noisy realisation of
nCsdAlleles()
from queens. The amount of noise will depend on the
number of individuals, so in most cases with reasonable number of
individuals there should be minimal amount of noise.
integer representing the number of distinct csd alleles when x
is Pop-class
(or ), list of integer
when x
is Colony-class
(list nodes named by caste) and
list of a list of integer when x
is MultiColony-class
,
outer list is named by colony id when x
is
MultiColony-class
; the integer rep
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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 4) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) nCsdAlleles(getQueen(colony)) nCsdAlleles(getWorkers(colony)) nCsdAlleles(colony) nCsdAlleles(colony, collapse = TRUE) nCsdAlleles(apiary) nCsdAlleles(apiary, collapse = TRUE)
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 = 6, nDrones = 3) colony <- addVirginQueens(x = colony, nInd = 4) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 6, nDrones = 3) apiary <- addVirginQueens(x = apiary, nInd = 5) nCsdAlleles(getQueen(colony)) nCsdAlleles(getWorkers(colony)) nCsdAlleles(colony) nCsdAlleles(colony, collapse = TRUE) nCsdAlleles(apiary) nCsdAlleles(apiary, collapse = TRUE)
Sample a number of drones - used when nDrones = NULL
(see SimParamBee$nDrones
).
This is just an example. You can provide your own functions that satisfy your needs!
nDronesPoisson(x, n = 1, average = 100) nDronesTruncPoisson(x, n = 1, average = 100, lowerLimit = 0) nDronesColonyPhenotype( x, queenTrait = 1, workersTrait = NULL, checkProduction = FALSE, lowerLimit = 0, simParamBee = NULL, ... )
nDronesPoisson(x, n = 1, average = 100) nDronesTruncPoisson(x, n = 1, average = 100, lowerLimit = 0) nDronesColonyPhenotype( x, queenTrait = 1, workersTrait = NULL, checkProduction = FALSE, lowerLimit = 0, simParamBee = NULL, ... )
x |
|
n |
integer, number of samples |
average |
numeric, average number of drones |
lowerLimit |
numeric, returned numbers will be above this value |
queenTrait |
numeric (column position) or character (column name), trait
that represents queen's effect on the colony phenotype (defined in
|
workersTrait |
numeric (column position) or character (column name), trait
that represents workers's effect on the colony phenotype (defined in
|
checkProduction |
logical, does the phenotype depend on the production
status of colony; if yes and production is not |
simParamBee |
|
... |
other arguments of |
nDronesPoisson
samples from a Poisson distribution with a
given average, which can return a value 0.
nDronesTruncPoisson
samples from a zero truncated Poisson
distribution.
nDronesColonyPhenotype
returns a number (above lowerLimit
) as
a function of colony phenotype, say queen's fecundity. Colony phenotype is
provided by mapCasteToColonyPheno
. You need to set up
traits influencing the colony phenotype and their parameters (mean and
variances) via SimParamBee
(see examples).
When x
is Pop-class
, only workersTrait
is not
used, that is, only queenTrait
is used.
numeric, number of drones
nDronesTruncPoisson()
: Sample a non-zero number of drones
nDronesColonyPhenotype()
: Sample a non-zero number of drones based on
colony phenotype, say queen's fecundity
SimParamBee
field nDrones
and
vignette(topic = "QuantitativeGenetics", package = "SIMplyBee")
nDronesPoisson() nDronesPoisson() n <- nDronesPoisson(n = 1000) hist(n, breaks = seq(from = min(n), to = max(n)), xlim = c(0, 200)) table(n) nDronesTruncPoisson() nDronesTruncPoisson() n <- nDronesTruncPoisson(n = 1000) hist(n, breaks = seq(from = min(n), to = max(n)), xlim = c(0, 200)) table(n) # Example for nDronesColonyPhenotype() founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) average <- 100 h2 <- 0.1 SP$addTraitA(nQtlPerChr = 100, mean = average, var = average * h2) SP$setVarE(varE = average * (1 - h2)) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 50) droneGroups <- pullDroneGroupsFromDCA(drones, n = 2, nDrones = 15) colony1 <- createColony(x = basePop[2]) colony2 <- createColony(x = basePop[3]) colony1 <- cross(colony1, drones = droneGroups[[1]]) colony2 <- cross(colony2, drones = droneGroups[[2]]) colony1@queen@pheno colony2@queen@pheno createDrones(colony1, nInd = nDronesColonyPhenotype) createDrones(colony2, nInd = nDronesColonyPhenotype)
nDronesPoisson() nDronesPoisson() n <- nDronesPoisson(n = 1000) hist(n, breaks = seq(from = min(n), to = max(n)), xlim = c(0, 200)) table(n) nDronesTruncPoisson() nDronesTruncPoisson() n <- nDronesTruncPoisson(n = 1000) hist(n, breaks = seq(from = min(n), to = max(n)), xlim = c(0, 200)) table(n) # Example for nDronesColonyPhenotype() founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) average <- 100 h2 <- 0.1 SP$addTraitA(nQtlPerChr = 100, mean = average, var = average * h2) SP$setVarE(varE = average * (1 - h2)) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 50) droneGroups <- pullDroneGroupsFromDCA(drones, n = 2, nDrones = 15) colony1 <- createColony(x = basePop[2]) colony2 <- createColony(x = basePop[3]) colony1 <- cross(colony1, drones = droneGroups[[1]]) colony2 <- cross(colony2, drones = droneGroups[[2]]) colony1@queen@pheno colony2@queen@pheno createDrones(colony1, nInd = nDronesColonyPhenotype) createDrones(colony2, nInd = nDronesColonyPhenotype)
Sample a number of fathers - use when nFathers = NULL
(see SimParamBee$nFathers
).
This is just an example. You can provide your own functions that satisfy your needs!
nFathersPoisson(n = 1, average = 15) nFathersTruncPoisson(n = 1, average = 15, lowerLimit = 0)
nFathersPoisson(n = 1, average = 15) nFathersTruncPoisson(n = 1, average = 15, lowerLimit = 0)
n |
integer, number of samples |
average |
numeric, average number of fathers |
lowerLimit |
numeric, returned numbers will be above this value |
nFathersPoisson
samples from a Poisson distribution, which
can return a value 0 (that would mean a failed queen mating).
nFathersTruncPoisson
samples from a truncated Poisson distribution
(truncated at zero) to avoid failed matings.
numeric, number of fathers
nFathersTruncPoisson()
: Sample a non-zero number of fathers
SimParamBee
field nFathers
nFathersPoisson() nFathersPoisson() n <- nFathersPoisson(n = 1000) hist(n, breaks = seq(from = min(n), to = max(n)), xlim = c(0, 40)) table(n) nFathersTruncPoisson() nFathersTruncPoisson() n <- nFathersTruncPoisson(n = 1000) hist(n, breaks = seq(from = min(n), to = max(n)), xlim = c(0, 40)) table(n)
nFathersPoisson() nFathersPoisson() n <- nFathersPoisson(n = 1000) hist(n, breaks = seq(from = min(n), to = max(n)), xlim = c(0, 40)) table(n) nFathersTruncPoisson() nFathersTruncPoisson() n <- nFathersTruncPoisson(n = 1000) hist(n, breaks = seq(from = min(n), to = max(n)), xlim = c(0, 40)) table(n)
Sample a number of virgin queens - used when
nFathers = NULL
(see SimParamBee$nVirginQueens
).
This is just an example. You can provide your own functions that satisfy your needs!
nVirginQueensPoisson(colony, n = 1, average = 10) nVirginQueensTruncPoisson(colony, n = 1, average = 10, lowerLimit = 0) nVirginQueensColonyPhenotype( colony, queenTrait = 1, workersTrait = 2, checkProduction = FALSE, lowerLimit = 0, simParamBee = NULL, ... )
nVirginQueensPoisson(colony, n = 1, average = 10) nVirginQueensTruncPoisson(colony, n = 1, average = 10, lowerLimit = 0) nVirginQueensColonyPhenotype( colony, queenTrait = 1, workersTrait = 2, checkProduction = FALSE, lowerLimit = 0, simParamBee = NULL, ... )
colony |
|
n |
integer, number of samples |
average |
numeric, average number of virgin queens |
lowerLimit |
numeric, returned numbers will be above this value |
queenTrait |
numeric (column position) or character (column name), trait
that represents queen's effect on the colony phenotype (defined in
|
workersTrait |
numeric (column position) or character (column name), trait
that represents workers's effect on the colony phenotype (defined in
|
checkProduction |
logical, does the phenotype depend on the production
status of colony; if yes and production is not |
simParamBee |
|
... |
other arguments of |
nVirginQueensPoisson
samples from a Poisson distribution,
which can return a value 0 (that would mean a colony will fail to raise a
single virgin queen after the queen swarms or dies).
nVirginQueensTruncPoisson
samples from a truncated Poisson
distribution (truncated at zero) to avoid failure.
nVirginQueensColonyPhenotype
returns a number (above
lowerLimit
) as a function of colony phenotype, say swarming
tendency. Colony phenotype is provided by
mapCasteToColonyPheno
. You need to set up traits
influencing the colony phenotype and their parameters (mean and variances)
via SimParamBee
(see examples).
numeric, number of virgin queens
nVirginQueensTruncPoisson()
: Sample a non-zero number of virgin queens
nVirginQueensColonyPhenotype()
: Sample a non-zero number of virgin queens
based on colony's phenotype, say, swarming tendency
SimParamBee
field nVirginQueens
and
vignette(topic = "QuantitativeGenetics", package = "SIMplyBee")
nVirginQueensPoisson() nVirginQueensPoisson() n <- nVirginQueensPoisson(n = 1000) hist(n, breaks = seq(from = min(n), to = max(n)), xlim = c(0, 30)) table(n) nVirginQueensTruncPoisson() nVirginQueensTruncPoisson() n <- nVirginQueensTruncPoisson(n = 1000) hist(n, breaks = seq(from = min(n), to = max(n)), xlim = c(0, 30)) table(n) # Example for nVirginQueensColonyPhenotype() founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) # Setting trait scale such that mean is 10 split into queen and workers effects meanP <- c(5, 5 / SP$nWorkers) # setup variances such that the total phenotype variance will match the mean varA <- c(3 / 2, 3 / 2 / SP$nWorkers) corA <- matrix(data = c( 1.0, -0.5, -0.5, 1.0 ), nrow = 2, byrow = TRUE) varE <- c(7 / 2, 7 / 2 / SP$nWorkers) varA / (varA + varE) varP <- varA + varE varP[1] + varP[2] * SP$nWorkers SP$addTraitA(nQtlPerChr = 100, mean = meanP, var = varA, corA = corA) SP$setVarE(varE = varE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 50) droneGroups <- pullDroneGroupsFromDCA(drones, n = 2, nDrones = 15) colony1 <- createColony(x = basePop[2]) colony2 <- createColony(x = basePop[3]) colony1 <- cross(colony1, drones = droneGroups[[1]]) colony2 <- cross(colony2, drones = droneGroups[[2]]) colony1 <- buildUp(colony1) colony2 <- buildUp(colony2) nVirginQueensColonyPhenotype(colony1) nVirginQueensColonyPhenotype(colony2)
nVirginQueensPoisson() nVirginQueensPoisson() n <- nVirginQueensPoisson(n = 1000) hist(n, breaks = seq(from = min(n), to = max(n)), xlim = c(0, 30)) table(n) nVirginQueensTruncPoisson() nVirginQueensTruncPoisson() n <- nVirginQueensTruncPoisson(n = 1000) hist(n, breaks = seq(from = min(n), to = max(n)), xlim = c(0, 30)) table(n) # Example for nVirginQueensColonyPhenotype() founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) # Setting trait scale such that mean is 10 split into queen and workers effects meanP <- c(5, 5 / SP$nWorkers) # setup variances such that the total phenotype variance will match the mean varA <- c(3 / 2, 3 / 2 / SP$nWorkers) corA <- matrix(data = c( 1.0, -0.5, -0.5, 1.0 ), nrow = 2, byrow = TRUE) varE <- c(7 / 2, 7 / 2 / SP$nWorkers) varA / (varA + varE) varP <- varA + varE varP[1] + varP[2] * SP$nWorkers SP$addTraitA(nQtlPerChr = 100, mean = meanP, var = varA, corA = corA) SP$setVarE(varE = varE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 50) droneGroups <- pullDroneGroupsFromDCA(drones, n = 2, nDrones = 15) colony1 <- createColony(x = basePop[2]) colony2 <- createColony(x = basePop[3]) colony1 <- cross(colony1, drones = droneGroups[[1]]) colony2 <- cross(colony2, drones = droneGroups[[2]]) colony1 <- buildUp(colony1) colony2 <- buildUp(colony2) nVirginQueensColonyPhenotype(colony1) nVirginQueensColonyPhenotype(colony2)
Sample a number of workers - used when nInd = NULL
(see SimParamBee$nWorkers
).
This is just an example. You can provide your own functions that satisfy your needs!
nWorkersPoisson(colony, n = 1, average = 100) nWorkersTruncPoisson(colony, n = 1, average = 100, lowerLimit = 0) nWorkersColonyPhenotype( colony, queenTrait = 1, workersTrait = NULL, checkProduction = FALSE, lowerLimit = 0, simParamBee = NULL, ... )
nWorkersPoisson(colony, n = 1, average = 100) nWorkersTruncPoisson(colony, n = 1, average = 100, lowerLimit = 0) nWorkersColonyPhenotype( colony, queenTrait = 1, workersTrait = NULL, checkProduction = FALSE, lowerLimit = 0, simParamBee = NULL, ... )
colony |
|
n |
integer, number of samples |
average |
numeric, average number of workers |
lowerLimit |
numeric, returned numbers will be above this value |
queenTrait |
numeric (column position) or character (column name), trait
that represents queen's effect on the colony phenotype (defined in
|
workersTrait |
numeric (column position) or character (column name), trait
that represents workers's effect on the colony phenotype (defined in
|
checkProduction |
logical, does the phenotype depend on the production
status of colony; if yes and production is not |
simParamBee |
|
... |
other arguments of |
nWorkersPoisson
samples from a Poisson distribution with a
given average, which can return a value 0. nDronesTruncPoisson
samples from a zero truncated Poisson distribution.
nWorkersColonyPhenotype
returns a number (above lowerLimit
)
as a function of colony phenotype, say queen's fecundity. Colony phenotype
is provided by mapCasteToColonyPheno
. You need to set up
traits influencing the colony phenotype and their parameters (mean and
variances) via SimParamBee
(see examples).
numeric, number of workers
nWorkersTruncPoisson()
: Sample a non-zero number of workers
nWorkersColonyPhenotype()
: Sample a non-zero number of workers based on
colony phenotype, say queen's fecundity
SimParamBee
field nWorkers
and
vignette(topic = "QuantitativeGenetics", package = "SIMplyBee")
nWorkersPoisson() nWorkersPoisson() n <- nWorkersPoisson(n = 1000) hist(n, breaks = seq(from = min(n), to = max(n)), xlim = c(0, 200)) table(n) nWorkersTruncPoisson() nWorkersTruncPoisson() n <- nWorkersTruncPoisson(n = 1000) hist(n, breaks = seq(from = min(n), to = max(n)), xlim = c(0, 200)) table(n) # Example for nWorkersColonyPhenotype() founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) average <- 100 h2 <- 0.1 SP$addTraitA(nQtlPerChr = 100, mean = average, var = average * h2) SP$setVarE(varE = average * (1 - h2)) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 50) droneGroups <- pullDroneGroupsFromDCA(drones, n = 2, nDrones = 15) colony1 <- createColony(x = basePop[2]) colony2 <- createColony(x = basePop[3]) colony1 <- cross(colony1, drones = droneGroups[[1]]) colony2 <- cross(colony2, drones = droneGroups[[2]]) colony1@queen@pheno colony2@queen@pheno createWorkers(colony1, nInd = nWorkersColonyPhenotype) createWorkers(colony2, nInd = nWorkersColonyPhenotype)
nWorkersPoisson() nWorkersPoisson() n <- nWorkersPoisson(n = 1000) hist(n, breaks = seq(from = min(n), to = max(n)), xlim = c(0, 200)) table(n) nWorkersTruncPoisson() nWorkersTruncPoisson() n <- nWorkersTruncPoisson(n = 1000) hist(n, breaks = seq(from = min(n), to = max(n)), xlim = c(0, 200)) table(n) # Example for nWorkersColonyPhenotype() founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) average <- 100 h2 <- 0.1 SP$addTraitA(nQtlPerChr = 100, mean = average, var = average * h2) SP$setVarE(varE = average * (1 - h2)) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 50) droneGroups <- pullDroneGroupsFromDCA(drones, n = 2, nDrones = 15) colony1 <- createColony(x = basePop[2]) colony2 <- createColony(x = basePop[3]) colony1 <- cross(colony1, drones = droneGroups[[1]]) colony2 <- cross(colony2, drones = droneGroups[[2]]) colony1@queen@pheno colony2@queen@pheno createWorkers(colony1, nInd = nWorkersColonyPhenotype) createWorkers(colony2, nInd = nWorkersColonyPhenotype)
Level 1 function that pulls individuals from a caste in a
colony. These individuals are removed from the colony (compared to
getCaste
).
pullCastePop( x, caste, nInd = NULL, use = "rand", removeFathers = TRUE, collapse = FALSE, simParamBee = NULL ) pullQueen(x, collapse = FALSE, simParamBee = NULL) pullWorkers(x, nInd = NULL, use = "rand", collapse = FALSE, simParamBee = NULL) pullDrones( x, nInd = NULL, use = "rand", removeFathers = TRUE, collapse = FALSE, simParamBee = NULL ) pullVirginQueens( x, nInd = NULL, use = "rand", collapse = FALSE, simParamBee = NULL )
pullCastePop( x, caste, nInd = NULL, use = "rand", removeFathers = TRUE, collapse = FALSE, simParamBee = NULL ) pullQueen(x, collapse = FALSE, simParamBee = NULL) pullWorkers(x, nInd = NULL, use = "rand", collapse = FALSE, simParamBee = NULL) pullDrones( x, nInd = NULL, use = "rand", removeFathers = TRUE, collapse = FALSE, simParamBee = NULL ) pullVirginQueens( x, nInd = NULL, use = "rand", collapse = FALSE, simParamBee = NULL )
x |
|
caste |
character, "queen", "workers", "drones", or "virginQueens" |
nInd |
numeric, number of individuals to pull, if |
use |
character, all options provided by |
removeFathers |
logical, removes |
collapse |
logical, whether to return a single merged population for the pulled individuals (does not affect the remnant colonies) |
simParamBee |
|
list of Pop-class
and Colony-class
when x
is Colony-class
and list of (a list of
Pop-class
named by colony id) and
MultiColony-class
when x
is
MultiColony-class
pullQueen()
: Pull queen from a colony
pullWorkers()
: Pull workers from a colony
pullDrones()
: Pull drones from a colony
pullVirginQueens()
: Pull virgin queens from a colony
pullQueen
, pullVirginQueens
,
pullWorkers
, and pullDrones
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 = 100, nDrones = 10, exact = TRUE) colony <- addVirginQueens(x = colony, nInd = 3) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 100, nDrones = 10, exact = TRUE) apiary <- addVirginQueens(x = apiary, nInd = 3) # pullCastePop on Colony class # We can't pull the queen and leave the colony queenless pullCastePop(colony, caste = "virginQueens") pullCastePop(colony, caste = "virginQueens", nInd = 2) # Or use aliases pullVirginQueens(colony) pullVirginQueens(colony, nInd = 2) # Same aliases exist for all the castes!!! # pullCastePop on MultiColony class - same behaviour as for the Colony! pullCastePop(apiary, caste = "workers") # Or pull out unequal number of workers from colonies pullCastePop(apiary, caste = "workers", nInd = c(10, 20)) pullWorkers(apiary) nWorkers(apiary) nWorkers(pullWorkers(apiary)$remnant) # Merge all the pulled populations into a single population pullCastePop(apiary, caste = "queen", collapse = TRUE) pullCastePop(apiary, caste = "virginQueens", collapse = TRUE)
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 = 100, nDrones = 10, exact = TRUE) colony <- addVirginQueens(x = colony, nInd = 3) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) apiary <- buildUp(x = apiary, nWorkers = 100, nDrones = 10, exact = TRUE) apiary <- addVirginQueens(x = apiary, nInd = 3) # pullCastePop on Colony class # We can't pull the queen and leave the colony queenless pullCastePop(colony, caste = "virginQueens") pullCastePop(colony, caste = "virginQueens", nInd = 2) # Or use aliases pullVirginQueens(colony) pullVirginQueens(colony, nInd = 2) # Same aliases exist for all the castes!!! # pullCastePop on MultiColony class - same behaviour as for the Colony! pullCastePop(apiary, caste = "workers") # Or pull out unequal number of workers from colonies pullCastePop(apiary, caste = "workers", nInd = c(10, 20)) pullWorkers(apiary) nWorkers(apiary) nWorkers(pullWorkers(apiary)$remnant) # Merge all the pulled populations into a single population pullCastePop(apiary, caste = "queen", collapse = TRUE) pullCastePop(apiary, caste = "virginQueens", collapse = TRUE)
Level 3 function that pulls out some colonies from the MultiColony based on colony ID or random selection.
pullColonies( multicolony, ID = NULL, n = NULL, p = NULL, by = NULL, pullTop = TRUE, simParamBee = NULL )
pullColonies( multicolony, ID = NULL, n = NULL, p = NULL, by = NULL, pullTop = TRUE, simParamBee = NULL )
multicolony |
|
ID |
character or numeric, ID of a colony (one or more) to be pulled out |
n |
numeric, number of colonies to select |
p |
numeric, percentage of colonies pulled out (takes precedence
over |
by |
matrix, matrix of values to select by with names being
colony IDs (can be obtained with |
pullTop |
logical, pull highest (lowest) values if |
simParamBee |
|
list with two MultiColony-class
, the pulled
and the remnant
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) mean <- c(10, 10 / SP$nWorkers) varA <- c(1, 1 / SP$nWorkers) corA <- matrix(data = c( 1.0, -0.5, -0.5, 1.0 ), nrow = 2, byrow = TRUE) varE <- c(3, 3 / SP$nWorkers) varA / (varA + varE) SP$addTraitADE(nQtlPerChr = 100, mean = mean, var = varA, corA = corA, meanDD = 0.1, varDD = 0.2, corD = corA, relAA = 0.1, corAA = corA) SP$setVarE(varE = varE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1:4], nInd = 100) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = 10) apiary <- createMultiColony(basePop[2:5], n = 4) apiary <- cross(apiary, drones = droneGroups[1:4]) apiary <- buildUp(apiary) getId(apiary) tmp <- pullColonies(apiary, ID = c(1, 2)) getId(tmp$pulled) getId(tmp$remnant) tmp <- pullColonies(apiary, ID = c("3", "4")) getId(tmp$pulled) getId(tmp$remnant) tmp <- pullColonies(apiary, n = 2) getId(tmp$pulled) getId(tmp$remnant) tmp <- pullColonies(apiary, p = 0.75) getId(tmp$pulled) getId(tmp$remnant) # How to pull out colonies based on colony values? colonyGv <- calcColonyGv(apiary) pullColonies(apiary, n = 1, by = colonyGv)
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) mean <- c(10, 10 / SP$nWorkers) varA <- c(1, 1 / SP$nWorkers) corA <- matrix(data = c( 1.0, -0.5, -0.5, 1.0 ), nrow = 2, byrow = TRUE) varE <- c(3, 3 / SP$nWorkers) varA / (varA + varE) SP$addTraitADE(nQtlPerChr = 100, mean = mean, var = varA, corA = corA, meanDD = 0.1, varDD = 0.2, corD = corA, relAA = 0.1, corAA = corA) SP$setVarE(varE = varE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1:4], nInd = 100) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = 10) apiary <- createMultiColony(basePop[2:5], n = 4) apiary <- cross(apiary, drones = droneGroups[1:4]) apiary <- buildUp(apiary) getId(apiary) tmp <- pullColonies(apiary, ID = c(1, 2)) getId(tmp$pulled) getId(tmp$remnant) tmp <- pullColonies(apiary, ID = c("3", "4")) getId(tmp$pulled) getId(tmp$remnant) tmp <- pullColonies(apiary, n = 2) getId(tmp$pulled) getId(tmp$remnant) tmp <- pullColonies(apiary, p = 0.75) getId(tmp$pulled) getId(tmp$remnant) # How to pull out colonies based on colony values? colonyGv <- calcColonyGv(apiary) pullColonies(apiary, n = 1, by = colonyGv)
Level 1 function that pulls drone groups from a Drone Congregation Area (DCA) to use them later in mating. Within the function drones are pulled (removed) from the DCA to reflect the fact that drones die after mating, so they can't be present in the DCA anymore. Be careful what you do with the DCA object outside function to avoid drone "copies".
pullDroneGroupsFromDCA(DCA, n, nDrones = NULL, simParamBee = NULL, ...)
pullDroneGroupsFromDCA(DCA, n, nDrones = NULL, simParamBee = NULL, ...)
DCA |
|
n |
integer, number of drone groups to be created |
nDrones |
numeric of function, number of drones that a virgin queen
mates with; if |
simParamBee |
|
... |
additional arguments passed to |
list of Pop-class
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 <- addDrones(colony, nInd = 100) # Create colony DCA DCA <- createDCA(colony) pullDroneGroupsFromDCA(DCA, n = 4, nDrones = 5) pullDroneGroupsFromDCA(DCA, n = 5, nDrones = nFathersPoisson)
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 <- addDrones(colony, nInd = 100) # Create colony DCA DCA <- createDCA(colony) pullDroneGroupsFromDCA(DCA, n = 4, nDrones = 5) pullDroneGroupsFromDCA(DCA, n = 5, nDrones = nFathersPoisson)
Level 1 function that pulls individuals from a population and update the population (these individuals don't stay in a population).
pullInd(pop, nInd = NULL, use = "rand", simParamBee = NULL)
pullInd(pop, nInd = NULL, use = "rand", simParamBee = NULL)
pop |
|
nInd |
numeric, number of individuals to pull, if |
use |
character, all options provided by |
simParamBee |
|
list with a node pulled
holding Pop-class
of
pulled individuals and a node remnant)
holding Pop-class
of remaining individuals
founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 100) SP <- SimParam$new(founderGenomes) basePop <- newPop(founderGenomes) pullInd(basePop, nInd = 2) pullInd(basePop, nInd = 3) pullInd(basePop)
founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 100) SP <- SimParam$new(founderGenomes) basePop <- newPop(founderGenomes) pullInd(basePop, nInd = 2) pullInd(basePop, nInd = 3) pullInd(basePop)
Level 0 function that samples random points (x, y) within a circle via rejection sampling.
rcircle(n = 1, radius = 1, uniform = TRUE, normScale = 1/3)
rcircle(n = 1, radius = 1, uniform = TRUE, normScale = 1/3)
n |
integer, number of samples points |
radius |
numeric, radius of the sampled circle |
uniform |
logical, should sampling be uniform or according to a bi-variate spherical (uncorrelated) Gaussian distribution (see examples) |
normScale |
numeric, if |
matrix with two columns for the x and y coordinates of the points.
nubDotDev (2021) The BEST Way to Find a Random Point in a Circle https://youtu.be/4y_nmpv-9lI
Wolfram MathWorld (2023) Disk Point Picking https://mathworld.wolfram.com/DiskPointPicking.html
x <- rcircle(n = 500) lim <- range(x) plot(x, xlim = lim, ylim = lim, main = "Uniform") x <- rcircle(n = 500, uniform = FALSE) lim <- range(x) plot(x, xlim = lim, ylim = lim, main = "Gaussian")
x <- rcircle(n = 500) lim <- range(x) plot(x, xlim = lim, ylim = lim, main = "Uniform") x <- rcircle(n = 500, uniform = FALSE) lim <- range(x) plot(x, xlim = lim, ylim = lim, main = "Gaussian")
Level 0 function that reduces drone's genotype to a single haplotype, because we internally simulate them as diploid (doubled haploid). This is an internal utility function that you likely don't need to use.
reduceDroneGeno(geno, pop)
reduceDroneGeno(geno, pop)
geno |
|
pop |
matrix with genotype as one haplotype per drone instead of two - the order of individuals and the number of rows stays the same!
founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 5) SP <- SimParamBee$new(founderGenomes, csdChr = NULL) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 2) (tmp <- getSegSiteGeno(drones)) reduceDroneGeno(geno = tmp, pop = drones) (tmp <- getSegSiteGeno(c(basePop, drones))) reduceDroneGeno(geno = tmp, pop = c(basePop, drones))
founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 5) SP <- SimParamBee$new(founderGenomes, csdChr = NULL) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 2) (tmp <- getSegSiteGeno(drones)) reduceDroneGeno(geno = tmp, pop = drones) (tmp <- getSegSiteGeno(c(basePop, drones))) reduceDroneGeno(geno = tmp, pop = c(basePop, drones))
Level 0 function that returns one haplotype of drones, because we internally simulate them as diploid (doubled haploid). This is an internal utility function that you likely don't need to use.
reduceDroneHaplo(haplo, pop)
reduceDroneHaplo(haplo, pop)
haplo |
|
pop |
While this function is meant to work on male (drone) haplotypes, we
handle cases where the haplo
matrix contains male and female
haplotypes, which is why you need to provide pop
. We only reduce
haplotypes for males though.
matrix with one haplotype per drone instead of two - the order of individuals stays the same, but there will be less rows!
founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 5) SP <- SimParamBee$new(founderGenomes, csdChr = NULL) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 2) (tmp <- getSegSiteHaplo(drones, dronesHaploid = FALSE)) reduceDroneHaplo(haplo = tmp, pop = drones) (tmp <- getSegSiteHaplo(c(basePop, drones), dronesHaploid = FALSE)) reduceDroneHaplo(haplo = tmp, pop = c(basePop, drones))
founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 5) SP <- SimParamBee$new(founderGenomes, csdChr = NULL) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 2) (tmp <- getSegSiteHaplo(drones, dronesHaploid = FALSE)) reduceDroneHaplo(haplo = tmp, pop = drones) (tmp <- getSegSiteHaplo(c(basePop, drones), dronesHaploid = FALSE)) reduceDroneHaplo(haplo = tmp, pop = c(basePop, drones))
Level 2 function that removes a proportion of virgin queens of a Colony or MultiColony object
removeCastePop( x, caste = NULL, p = 1, use = "rand", addVirginQueens = FALSE, nVirginQueens = NULL, year = NULL, simParamBee = NULL ) removeQueen( x, addVirginQueens = FALSE, nVirginQueens = NULL, year = NULL, simParamBee = NULL ) removeWorkers(x, p = 1, use = "rand", simParamBee = NULL) removeDrones(x, p = 1, use = "rand", simParamBee = NULL) removeVirginQueens(x, p = 1, use = "rand", simParamBee = NULL)
removeCastePop( x, caste = NULL, p = 1, use = "rand", addVirginQueens = FALSE, nVirginQueens = NULL, year = NULL, simParamBee = NULL ) removeQueen( x, addVirginQueens = FALSE, nVirginQueens = NULL, year = NULL, simParamBee = NULL ) removeWorkers(x, p = 1, use = "rand", simParamBee = NULL) removeDrones(x, p = 1, use = "rand", simParamBee = NULL) removeVirginQueens(x, p = 1, use = "rand", simParamBee = NULL)
x |
|
caste |
character, "queen", "workers", "drones", or "virginQueens" |
p |
numeric, proportion to be removed; if input is |
use |
character, all the options provided by |
addVirginQueens |
logical, whether virgin queens should be added; only used when removing the queen from the colony |
nVirginQueens |
integer, the number of virgin queens to be created in the
colony; only used when removing the queen from the colony. If |
year |
numeric, only relevant when adding virgin queens - year of birth for virgin queens |
simParamBee |
|
Colony-class
or MultiColony-class
without virgin queens
removeQueen()
: Remove queen from a colony
removeWorkers()
: Remove workers from a colony
removeDrones()
: Remove workers from a colony
removeVirginQueens()
: Remove virgin queens from a colony
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 100) droneGroups <- pullDroneGroupsFromDCA(drones, n = 5, nDrones = nFathersPoisson) # Create and cross Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) colony <- buildUp(colony) apiary <- createMultiColony(basePop[4:5], n = 2) apiary <- cross(apiary, drones = droneGroups[3:4]) apiary <- buildUp(apiary) # Remove workers nWorkers(colony) colony <- removeCastePop(colony, caste = "workers", p = 0.3) # or alias: colony <- removeWorkers(colony, p = 0.3) # Same aliases exist for all the castes!! nWorkers(apiary) apiary <- removeCastePop(apiary, caste = "workers", p = 0.3) nWorkers(apiary) # Remove different proportions apiary <- buildUp(apiary) nWorkers(apiary) nWorkers(removeWorkers(apiary, p = c(0.1, 0.5)))
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 100) droneGroups <- pullDroneGroupsFromDCA(drones, n = 5, nDrones = nFathersPoisson) # Create and cross Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) colony <- buildUp(colony) apiary <- createMultiColony(basePop[4:5], n = 2) apiary <- cross(apiary, drones = droneGroups[3:4]) apiary <- buildUp(apiary) # Remove workers nWorkers(colony) colony <- removeCastePop(colony, caste = "workers", p = 0.3) # or alias: colony <- removeWorkers(colony, p = 0.3) # Same aliases exist for all the castes!! nWorkers(apiary) apiary <- removeCastePop(apiary, caste = "workers", p = 0.3) nWorkers(apiary) # Remove different proportions apiary <- buildUp(apiary) nWorkers(apiary) nWorkers(removeWorkers(apiary, p = c(0.1, 0.5)))
Level 3 function that removes some colonies from the MultiColony object based on their ID.
removeColonies( multicolony, ID = NULL, n = NULL, p = NULL, by = NULL, removeTop = FALSE, simParamBee = NULL )
removeColonies( multicolony, ID = NULL, n = NULL, p = NULL, by = NULL, removeTop = FALSE, simParamBee = NULL )
multicolony |
|
ID |
character or numeric, ID of a colony (one or more) to be removed |
n |
numeric, number of colonies to remove |
p |
numeric, percentage of colonies removed (takes precedence
over |
by |
matrix, matrix of values to select by with names being
colony IDs (can be obtained with |
removeTop |
logical, remove highest (lowest) values if |
simParamBee |
|
MultiColony-class
with some colonies removed
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) mean <- c(10, 10 / SP$nWorkers) varA <- c(1, 1 / SP$nWorkers) corA <- matrix(data = c( 1.0, -0.5, -0.5, 1.0 ), nrow = 2, byrow = TRUE) varE <- c(3, 3 / SP$nWorkers) varA / (varA + varE) SP$addTraitADE(nQtlPerChr = 100, mean = mean, var = varA, corA = corA, meanDD = 0.1, varDD = 0.2, corD = corA, relAA = 0.1, corAA = corA) SP$setVarE(varE = varE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1:4], nInd = 100) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = 10) apiary <- createMultiColony(basePop[2:5], n = 4) apiary <- cross(apiary, drones = droneGroups[1:4]) apiary <- buildUp(apiary) getId(apiary) getId(removeColonies(apiary, ID = 1)) getId(removeColonies(apiary, ID = c("3", "4"))) nColonies(apiary) apiary <- removeColonies(apiary, ID = "2") nColonies(apiary) # How to remove colonies based on colony values? # Obtain colony phenotype colonyPheno <- calcColonyPheno(apiary) # Remove the worst colony removeColonies(apiary, n = 1, by = colonyPheno)
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) mean <- c(10, 10 / SP$nWorkers) varA <- c(1, 1 / SP$nWorkers) corA <- matrix(data = c( 1.0, -0.5, -0.5, 1.0 ), nrow = 2, byrow = TRUE) varE <- c(3, 3 / SP$nWorkers) varA / (varA + varE) SP$addTraitADE(nQtlPerChr = 100, mean = mean, var = varA, corA = corA, meanDD = 0.1, varDD = 0.2, corD = corA, relAA = 0.1, corAA = corA) SP$setVarE(varE = varE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1:4], nInd = 100) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = 10) apiary <- createMultiColony(basePop[2:5], n = 4) apiary <- cross(apiary, drones = droneGroups[1:4]) apiary <- buildUp(apiary) getId(apiary) getId(removeColonies(apiary, ID = 1)) getId(removeColonies(apiary, ID = c("3", "4"))) nColonies(apiary) apiary <- removeColonies(apiary, ID = "2") nColonies(apiary) # How to remove colonies based on colony values? # Obtain colony phenotype colonyPheno <- calcColonyPheno(apiary) # Remove the worst colony removeColonies(apiary, n = 1, by = colonyPheno)
Level 2 function that replaces a proportion of caste individuals with new individuals from a Colony or MultiColony object. Useful after events like season change, swarming, supersedure, etc. due to the short life span honeybees.
replaceCastePop( x, caste = NULL, p = 1, use = "rand", exact = TRUE, year = NULL, simParamBee = NULL ) replaceWorkers(x, p = 1, use = "rand", exact = TRUE, simParamBee = NULL) replaceDrones(x, p = 1, use = "rand", simParamBee = NULL) replaceVirginQueens(x, p = 1, use = "rand", simParamBee = NULL)
replaceCastePop( x, caste = NULL, p = 1, use = "rand", exact = TRUE, year = NULL, simParamBee = NULL ) replaceWorkers(x, p = 1, use = "rand", exact = TRUE, simParamBee = NULL) replaceDrones(x, p = 1, use = "rand", simParamBee = NULL) replaceVirginQueens(x, p = 1, use = "rand", simParamBee = NULL)
x |
|
caste |
character, "workers", "drones", or "virginQueens" |
p |
numeric, proportion of caste individuals to be replaced with new ones;
if input is |
use |
character, all the options provided by |
exact |
logical, only relevant when adding workers - if the csd locus is turned
on and exact is |
year |
numeric, only relevant when replacing virgin queens, year of birth for virgin queens |
simParamBee |
|
Colony-class
or or MultiColony-class
with
replaced virgin queens
replaceWorkers()
: Replaces some workers in a colony
replaceDrones()
: Replaces some drones in a colony
replaceVirginQueens()
: Replaces some virgin queens in a colony
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 100) droneGroups <- pullDroneGroupsFromDCA(drones, n = 5, nDrones = nFathersPoisson) # Create and cross Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) apiary <- createMultiColony(basePop[4:5], n = 2) apiary <- cross(apiary, drones = droneGroups[3:4]) # Add individuals colony <- buildUp(colony, nWorkers = 5, nDrones = 2) apiary <- buildUp(apiary, nWorkers = 5, nDrones = 2) # Replace workers in a colony getCasteId(colony, caste = "workers") colony <- replaceCastePop(colony, caste = "workers", p = 0.5) # You can also use an alias replaceWorkers(colony, p = 0.5) # Same aliases exist for all the castes!!! getCasteId(colony, caste = "workers") getCasteId(apiary, caste="workers") apiary <- replaceWorkers(apiary, p = 0.5) getCasteId(apiary, caste="workers")
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 100) droneGroups <- pullDroneGroupsFromDCA(drones, n = 5, nDrones = nFathersPoisson) # Create and cross Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) apiary <- createMultiColony(basePop[4:5], n = 2) apiary <- cross(apiary, drones = droneGroups[3:4]) # Add individuals colony <- buildUp(colony, nWorkers = 5, nDrones = 2) apiary <- buildUp(apiary, nWorkers = 5, nDrones = 2) # Replace workers in a colony getCasteId(colony, caste = "workers") colony <- replaceCastePop(colony, caste = "workers", p = 0.5) # You can also use an alias replaceWorkers(colony, p = 0.5) # Same aliases exist for all the castes!!! getCasteId(colony, caste = "workers") getCasteId(apiary, caste="workers") apiary <- replaceWorkers(apiary, p = 0.5) getCasteId(apiary, caste="workers")
Level 2 function that re-queens a Colony or MultiColony object by adding a mated or a virgin queen, removing the previous queen, and changing the colony id to the new mated queen.
reQueen(x, queen, removeVirginQueens = TRUE, simParamBee = NULL)
reQueen(x, queen, removeVirginQueens = TRUE, simParamBee = NULL)
x |
|
queen |
|
removeVirginQueens |
logical, remove existing virgin queens, default is
|
simParamBee |
|
If the provided queen is mated, then she is saved in the queen slot of the colony. If she is not mated, then she is saved in the virgin queen slot (replacing any existing virgin queens) and once she is mated will be promoted to the queen of the colony.
Colony-class
or MultiColony-class
with new queen(s) (see details)
founderGenomes <- quickHaplo(nInd = 12, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 200) droneGroups <- pullDroneGroupsFromDCA(drones, n = 7, nDrones = nFathersPoisson) # Create and cross Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[2:3]) # Check queen and virgin queens IDs getCasteId(colony, caste = "queen") getCasteId(colony, caste = "virginQueens") getCasteId(apiary, caste = "queen") getCasteId(apiary, caste = "virginQueens") # Requeen with virgin queens virginQueens <- basePop[5:8] # Requeen a Colony class colony <- reQueen(colony, queen = virginQueens[1]) # Check queen and virgin queens IDs getCasteId(colony, caste = "queen") getCasteId(colony, caste = "virginQueens") #' # Requeen with mated queens matedQueens <- cross(x = basePop[9:12], drones = droneGroups[4:7]) colony <- reQueen(colony, queen = matedQueens[1]) # Check queen and virgin queens IDs getCasteId(colony, caste = "queen") getCasteId(colony, caste = "virginQueens") # Requeen a MultiColony class apiary <- reQueen(apiary, queen = virginQueens[2:3]) # Check queen and virgin queens IDs getCasteId(apiary, caste = "queen") getCasteId(apiary, caste = "virginQueens")
founderGenomes <- quickHaplo(nInd = 12, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 200) droneGroups <- pullDroneGroupsFromDCA(drones, n = 7, nDrones = nFathersPoisson) # Create and cross Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[2:3]) # Check queen and virgin queens IDs getCasteId(colony, caste = "queen") getCasteId(colony, caste = "virginQueens") getCasteId(apiary, caste = "queen") getCasteId(apiary, caste = "virginQueens") # Requeen with virgin queens virginQueens <- basePop[5:8] # Requeen a Colony class colony <- reQueen(colony, queen = virginQueens[1]) # Check queen and virgin queens IDs getCasteId(colony, caste = "queen") getCasteId(colony, caste = "virginQueens") #' # Requeen with mated queens matedQueens <- cross(x = basePop[9:12], drones = droneGroups[4:7]) colony <- reQueen(colony, queen = matedQueens[1]) # Check queen and virgin queens IDs getCasteId(colony, caste = "queen") getCasteId(colony, caste = "virginQueens") # Requeen a MultiColony class apiary <- reQueen(apiary, queen = virginQueens[2:3]) # Check queen and virgin queens IDs getCasteId(apiary, caste = "queen") getCasteId(apiary, caste = "virginQueens")
Level 2 function that resets the slots swarm, split, supersedure, collapsed, and production to FALSE in a Colony or MultiColony object. Useful at the end of a yearly cycle to reset the events, allowing the user to track new events in a new year.
resetEvents(x, collapse = NULL)
resetEvents(x, collapse = NULL)
x |
|
collapse |
logical, reset the collapse event (only sensible in setting
up a new colony, which the default of |
Colony-class
or MultiColony-class
with
events reset
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 100) droneGroups <- pullDroneGroupsFromDCA(drones, n = 5, nDrones = nFathersPoisson) # Create and cross Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) apiary <- createMultiColony(basePop[4:5], n = 2) apiary <- cross(apiary, drones = droneGroups[3:4]) # Build-up - this sets Productive to TRUE (colony <- buildUp(colony, nWorkers = 100)) isProductive(colony) resetEvents(colony) apiary <- buildUp(apiary, nWorkers = 100) isProductive(apiary) resetEvents(apiary) # Split - this sets Split to TRUE tmp <- split(colony) (split <- tmp$split) hasSplit(split) resetEvents(split) (remnant <- tmp$remnant) hasSplit(remnant) resetEvents(remnant) # Swarm - this sets Swarm to TRUE tmp <- swarm(colony) (swarm <- tmp$swarm) hasSwarmed(swarm) resetEvents(swarm) (remnant <- tmp$remnant) hasSwarmed(remnant) resetEvents(remnant) # Supersede - this sets Supersede to TRUE (tmp <- supersede(colony)) hasSuperseded(tmp) resetEvents(tmp) # Collapse - this sets Collapse to TRUE (tmp <- collapse(colony)) hasCollapsed(tmp) resetEvents(tmp) resetEvents(tmp, collapse = TRUE) # Same behaviour for MultiColony (example for the split) tmp <- split(apiary) (splits <- tmp$split) hasSplit(splits[[1]]) resetEvents(splits)[[1]] (remnants <- tmp$remnant) hasSplit(remnants[[1]]) resetEvents(remnants)[[1]]
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 100) droneGroups <- pullDroneGroupsFromDCA(drones, n = 5, nDrones = nFathersPoisson) # Create and cross Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) apiary <- createMultiColony(basePop[4:5], n = 2) apiary <- cross(apiary, drones = droneGroups[3:4]) # Build-up - this sets Productive to TRUE (colony <- buildUp(colony, nWorkers = 100)) isProductive(colony) resetEvents(colony) apiary <- buildUp(apiary, nWorkers = 100) isProductive(apiary) resetEvents(apiary) # Split - this sets Split to TRUE tmp <- split(colony) (split <- tmp$split) hasSplit(split) resetEvents(split) (remnant <- tmp$remnant) hasSplit(remnant) resetEvents(remnant) # Swarm - this sets Swarm to TRUE tmp <- swarm(colony) (swarm <- tmp$swarm) hasSwarmed(swarm) resetEvents(swarm) (remnant <- tmp$remnant) hasSwarmed(remnant) resetEvents(remnant) # Supersede - this sets Supersede to TRUE (tmp <- supersede(colony)) hasSuperseded(tmp) resetEvents(tmp) # Collapse - this sets Collapse to TRUE (tmp <- collapse(colony)) hasCollapsed(tmp) resetEvents(tmp) resetEvents(tmp, collapse = TRUE) # Same behaviour for MultiColony (example for the split) tmp <- split(apiary) (splits <- tmp$split) hasSplit(splits[[1]]) resetEvents(splits)[[1]] (remnants <- tmp$remnant) hasSplit(remnants[[1]]) resetEvents(remnants)[[1]]
Level 3 function that selects colonies from MultiColony object based on colony ID or random selection. Whilst user can provide all three arguments ID, p and n, there is a priority list: ID takes first priority. If no ID is provided, p takes precedence over n.
selectColonies( multicolony, ID = NULL, n = NULL, p = NULL, by = NULL, selectTop = TRUE, simParamBee = NULL )
selectColonies( multicolony, ID = NULL, n = NULL, p = NULL, by = NULL, selectTop = TRUE, simParamBee = NULL )
multicolony |
|
ID |
character or numeric, ID of a colony (one or more) to be selected |
n |
numeric, number of colonies to select |
p |
numeric, percentage of colonies selected (takes precedence
over |
by |
matrix, matrix of values to select by with names being
colony IDs (can be obtained with |
selectTop |
logical, selects highest (lowest) values if |
simParamBee |
|
MultiColony-class
with selected colonies
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) mean <- c(10, 10 / SP$nWorkers) varA <- c(1, 1 / SP$nWorkers) corA <- matrix(data = c( 1.0, -0.5, -0.5, 1.0 ), nrow = 2, byrow = TRUE) varE <- c(3, 3 / SP$nWorkers) varA / (varA + varE) SP$addTraitADE(nQtlPerChr = 100, mean = mean, var = varA, corA = corA, meanDD = 0.1, varDD = 0.2, corD = corA, relAA = 0.1, corAA = corA) SP$setVarE(varE = varE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1:4], nInd = 100) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = 10) apiary <- createMultiColony(basePop[2:5], n = 4) apiary <- cross(apiary, drones = droneGroups[1:4]) apiary <- buildUp(apiary) getId(apiary) getId(selectColonies(apiary, ID = 1)) getId(selectColonies(apiary, ID = c("3", "4"))) # ... alternative getId(apiary[1]) getId(apiary[["4"]]) # Select a random number of colonies selectColonies(apiary, n = 3) # Select a percentage of colonies selectColonies(apiary, p = 0.2) # Since selection is random, you would get a different set of colonies with # each function call getId(selectColonies(apiary, p = 0.5)) getId(selectColonies(apiary, p = 0.5)) # How to select colonies based on colony values? # Obtain colony phenotype colonyPheno <- calcColonyPheno(apiary) # Select the best colony selectColonies(apiary, n = 1, by = colonyPheno) # Select the worst 2 colonies selectColonies(apiary, n = 2, by = colonyPheno, selectTop = FALSE) # Select best colony based on queen's genetic value for trait 1 queenGv <- calcColonyGv(apiary, FUN = mapCasteToColonyGv, workersTrait = NULL) selectColonies(apiary, n = 1, by = queenGv)
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) mean <- c(10, 10 / SP$nWorkers) varA <- c(1, 1 / SP$nWorkers) corA <- matrix(data = c( 1.0, -0.5, -0.5, 1.0 ), nrow = 2, byrow = TRUE) varE <- c(3, 3 / SP$nWorkers) varA / (varA + varE) SP$addTraitADE(nQtlPerChr = 100, mean = mean, var = varA, corA = corA, meanDD = 0.1, varDD = 0.2, corD = corA, relAA = 0.1, corAA = corA) SP$setVarE(varE = varE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1:4], nInd = 100) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = 10) apiary <- createMultiColony(basePop[2:5], n = 4) apiary <- cross(apiary, drones = droneGroups[1:4]) apiary <- buildUp(apiary) getId(apiary) getId(selectColonies(apiary, ID = 1)) getId(selectColonies(apiary, ID = c("3", "4"))) # ... alternative getId(apiary[1]) getId(apiary[["4"]]) # Select a random number of colonies selectColonies(apiary, n = 3) # Select a percentage of colonies selectColonies(apiary, p = 0.2) # Since selection is random, you would get a different set of colonies with # each function call getId(selectColonies(apiary, p = 0.5)) getId(selectColonies(apiary, p = 0.5)) # How to select colonies based on colony values? # Obtain colony phenotype colonyPheno <- calcColonyPheno(apiary) # Select the best colony selectColonies(apiary, n = 1, by = colonyPheno) # Select the worst 2 colonies selectColonies(apiary, n = 2, by = colonyPheno, selectTop = FALSE) # Select best colony based on queen's genetic value for trait 1 queenGv <- calcColonyGv(apiary, FUN = mapCasteToColonyGv, workersTrait = NULL) selectColonies(apiary, n = 1, by = queenGv)
Level 2 function that to set a Colony or MultiColony object location to (x, y) coordinates.
setLocation(x, location = c(0, 0))
setLocation(x, location = c(0, 0))
x |
|
location |
numeric, list, or data.frame, x and y coordinates of colony
locations as
|
Colony-class
or MultiColony-class
with set
location
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(basePop[1], n = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 4, nDrones = 10) # Create Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) apiary <- createMultiColony(basePop[3:5]) apiary <- cross(apiary, drones = droneGroups[2:4]) getLocation(colony) getLocation(apiary) loc <- c(1, 1) colony <- setLocation(colony, location = loc) getLocation(colony) # Assuming one location (as in bringing colonies to one place!) apiary <- setLocation(apiary, location = loc) getLocation(apiary) # Assuming different locations locList <- list(c(0, 0), c(1, 1), c(2, 2)) apiary <- setLocation(apiary, location = locList) getLocation(apiary) locDF <- data.frame(x = c(0, 1, 2), y = c(0, 1, 2)) apiary <- setLocation(apiary, location = locDF) getLocation(apiary)
founderGenomes <- quickHaplo(nInd = 5, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(basePop[1], n = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 4, nDrones = 10) # Create Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) apiary <- createMultiColony(basePop[3:5]) apiary <- cross(apiary, drones = droneGroups[2:4]) getLocation(colony) getLocation(apiary) loc <- c(1, 1) colony <- setLocation(colony, location = loc) getLocation(colony) # Assuming one location (as in bringing colonies to one place!) apiary <- setLocation(apiary, location = loc) getLocation(apiary) # Assuming different locations locList <- list(c(0, 0), c(1, 1), c(2, 2)) apiary <- setLocation(apiary, location = locList) getLocation(apiary) locDF <- data.frame(x = c(0, 1, 2), y = c(0, 1, 2)) apiary <- setLocation(apiary, location = locDF) getLocation(apiary)
Set miscellaneous information in a population
setMisc(x, node = NULL, value = NULL)
setMisc(x, node = NULL, value = NULL)
x |
|
node |
character, name of the node to set within the |
value |
value to be saved into |
A NULL
in value
is ignored
Level 1 function that sets the queen's year of birth.
setQueensYearOfBirth(x, year, simParamBee = NULL)
setQueensYearOfBirth(x, year, simParamBee = NULL)
x |
|
year |
integer, the year of the birth of the queen |
simParamBee |
|
Pop-class
, Colony-class
, or
MultiColony-class
with queens having the year of birth set
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(x = colony, drones = droneGroups[[1]]) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) # Example on Colony class getQueenYearOfBirth(colony) getQueenYearOfBirth(apiary) queen1 <- getQueen(colony) queen1 <- setQueensYearOfBirth(queen1, year = 2022) getQueenYearOfBirth(queen1) colony <- setQueensYearOfBirth(colony, year = 2022) getQueenYearOfBirth(colony) apiary <- setQueensYearOfBirth(apiary, year = 2022) getQueenYearOfBirth(apiary)
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(x = colony, drones = droneGroups[[1]]) apiary <- createMultiColony(basePop[3:4], n = 2) apiary <- cross(apiary, drones = droneGroups[c(2, 3)]) # Example on Colony class getQueenYearOfBirth(colony) getQueenYearOfBirth(apiary) queen1 <- getQueen(colony) queen1 <- setQueensYearOfBirth(queen1, year = 2022) getQueenYearOfBirth(queen1) colony <- setQueensYearOfBirth(colony, year = 2022) getQueenYearOfBirth(colony) apiary <- setQueensYearOfBirth(apiary, year = 2022) getQueenYearOfBirth(apiary)
Container for global honeybee simulation parameters. Saving this
object as SP
will allow it to be accessed by SIMplyBee functions
without repeatedly (and annoyingly!) typing out
someFun(argument, simParamBee = SP)
. SimParamBee
inherits
from AlphaSimR SimParam
, so all SimParam
slots
and functions are available in addition to SimParamBee
-specific
slots and functions. Some SimParam
functions could have
upgraded behaviour as documented in line with honeybee biology.
This documentation shows details specific to SimParamBee
. We
suggest you also read all the options provided by the AlphaSimR
SimParam
. Below we show minimal usage cases for each
SimParamBee
function.
See also vignette(package = "SIMplyBee")
for descriptions of how
SIMplyBee implements the specific honeybee biology.
AlphaSimR::SimParam
-> SimParamBee
nWorkers
numeric or function, a number of workers generated in a
colony - used in createWorkers
, addWorkers
,
buildUp
.
The default value is 100, that is, queen generates 100 workers - this
is for a down-scaled simulation (for efficiency) assuming that this
represents ~60,000 workers in a full/strong colony (Seeley, 2019). This
value is set in SimParamBee$new()
to have a number to work with.
You can change this setting to your needs!
When nWorkers
is a function, it should work with internals of
other functions. Therefore, the function MUST be defined like
function(colony, arg = default) someCode
, that is, the first
argument MUST be colony
and any following arguments MUST have a
default value.
For flexibility you can add ... argument to pass on any other argument.
See nWorkersPoisson
, nWorkersTruncPoisson
,
or nWorkersColonyPhenotype
for examples.
You can provide your own functions that satisfy your needs!
nDrones
numeric or function, a number of drones generated in a
colony - used in createDrones
, addDrones
,
buildUp
.
The default value is 100, that is, queen generates 100 drones - this is
for a down-scaled simulation (for efficiency) assuming that this
represents ~1,000 drones in a full/strong colony (Seeley, 2019). This
value is set in SimParamBee$new()
to have a number to work with.
You can change this setting to your needs!
When nDrones
is a function, it should work with internals of
other functions. Therefore, the function MUST be defined like
function(x, arg = default) someCode
, that is, the first
argument MUST be x
and any following arguments MUST have a
default value.
For flexibility you can add ... argument to pass on any other argument.
See nDronesPoisson
, nDronesTruncPoisson
, or
nDronesColonyPhenotype
for examples.
You can provide your own functions that satisfy your needs!
nVirginQueens
numeric or function, a number of virgin queens
generated when a queen dies or other situations - used in
createVirginQueens
and addVirginQueens
.
The default value is 10, that is, when the queen dies, workers generate
10 new virgin queens (Seeley, 2019). This value is set in
SimParamBee$new()
to have a number to work with.
You can change this setting to your needs!
When nVirginQueens
is a function, it should work with internals
of other functions. Therefore, the function MUST be defined like
function(colony, arg = default) someCode
, that is, the first
argument MUST be colony
and any following arguments MUST have a
default value.
For flexibility you can add ... argument to pass on any other argument.
See nVirginQueensPoisson
,
nVirginQueensTruncPoisson
, or
nVirginQueensColonyPhenotype
for examples.
You can provide your own functions that satisfy your needs!
nFathers
numeric or function, a number of drones a queen mates
with - used in pullDroneGroupsFromDCA
,
cross
.
The default value is 15, that is, a virgin queen mates on average with
15 drones (Seeley, 2019). This value is set in SimParamBee$new()
to have a number to work with.
You can change this setting to your needs!
When nFathers
is a function, it should work with internals of
other functions. Therefore, the function MUST be defined like
function(arg = default) someCode
, that is, any arguments MUST
have a default value. We did not use the colony
argument here,
because nFathers
likely does not depend on the colony. Let us
know if we are wrong!
For flexibility you can add ... argument to pass on any other argument.
See nFathersPoisson
or
nFathersTruncPoisson
for examples.
You can provide your own functions that satisfy your needs!
swarmP
numeric or a function, the swarm proportion - the proportion
of workers that leave with the old queen when the colony swarms - used
in swarm
.
The default value is 0.50, that is, about a half of workers leave colony
in a swarm (Seeley, 2019). This value is set in SimParamBee$new()
to have a proportion to work with.
You can change this setting to your needs!
When swarmP
is a function, it should work with internals of
other functions. Therefore, the function MUST be defined like
function(colony, arg = default) someCode
, that is, the first
argument MUST be colony
and any following arguments MUST have a
default value.
For flexibility you can add ... argument to pass on any other argument.
See swarmPUnif
for
examples.
You can provide your own functions that satisfy your needs!
swarmRadius
numeric, radius within which to sample a location of
of the swarm - used in swarm
- see its radius
argument.
The default value is 0
, that is, swarm gets the same location as
the original colony.
You can change this setting to your needs!
splitP
numeric or a function, the split proportion - the
proportion of workers removed in a managed split - used in
split
.
The default value is 0.30, that is, about a third of workers is put into
a split colony from a strong colony (Seeley, 2019). This value is set
in SimParamBee$new()
to have a proportion to work with.
You can change this setting to your needs!
When splitP
is a function, it should work with internals of
other functions. Therefore, the function MUST be defined like
function(colony, arg = default) someCode
, that is, the first
argument MUST be colony
and any following arguments MUST have a
default value.
For flexibility you can add ... argument to pass on any other argument.
See splitPUnif
or splitPColonyStrength
for
examples.
You can provide your own functions that satisfy your needs!
downsizeP
numeric or a function, the downsize proportion - the
proportion of workers removed from the colony when downsizing, usually
in autumn - used in downsize
.
The default value is 0.85, that is, a majority of workers die before
autumn or all die but some winter workers are created (Seeley, 2019).
This value is set in SimParamBee$new()
to have a proportion to
work with.
You can change this setting to your needs!
When downsizeP
is a function, it should work with internals of
other functions. Therefore, the function MUST be defined like
function(colony, arg = default) someCode
, that is, the first
argument MUST be colony
and any following arguments MUST have a
default value.
For flexibility you can add ... argument to pass on any other argument.
See downsizePUnif
for example.
You can provide your own functions that satisfy your needs!
colonyValueFUN
function, to calculate colony values - used
in calcColonyValue
- see also calcColonyPheno
and calcColonyGv
.
This function should work with internals of others functions -
therefore the function MUST be defined like function(colony, arg
= default) someCode
, that is, the first argument MUST be
colony
and any following arguments MUST have a default value.
For flexibility you can add ... argument to pass on any other argument.
See mapCasteToColonyValue
for an example.
You can provide your own functions that satisfy your needs!
caste
character, caste information for every individual ever created
lastColonyId
integer, ID of the last Colony object
created with createColony
csdChr
integer, chromosome of the csd locus
csdPos
numeric, starting position of the csd locus on the
csdChr
chromosome (relative at the moment, but could be in base
pairs in the future)
nCsdAlleles
integer, number of possible csd alleles
nCsdSites
integer, number of segregating sites representing the csd locus
csdPosStart
integer, starting position of the csd locus
csdPosStop
integer, ending position of the csd locus
version
list, versions of AlphaSimR and SIMplyBee packages used to generate this object
AlphaSimR::SimParam$addSnpChip()
AlphaSimR::SimParam$addSnpChipByName()
AlphaSimR::SimParam$addStructuredSnpChip()
AlphaSimR::SimParam$addToPed()
AlphaSimR::SimParam$addToRec()
AlphaSimR::SimParam$addTraitA()
AlphaSimR::SimParam$addTraitAD()
AlphaSimR::SimParam$addTraitADE()
AlphaSimR::SimParam$addTraitADEG()
AlphaSimR::SimParam$addTraitADG()
AlphaSimR::SimParam$addTraitAE()
AlphaSimR::SimParam$addTraitAEG()
AlphaSimR::SimParam$addTraitAG()
AlphaSimR::SimParam$altAddTraitAD()
AlphaSimR::SimParam$ibdHaplo()
AlphaSimR::SimParam$importTrait()
AlphaSimR::SimParam$manAddTrait()
AlphaSimR::SimParam$removeTrait()
AlphaSimR::SimParam$rescaleTraits()
AlphaSimR::SimParam$resetPed()
AlphaSimR::SimParam$restrSegSites()
AlphaSimR::SimParam$setCorE()
AlphaSimR::SimParam$setFounderHap()
AlphaSimR::SimParam$setRecombRatio()
AlphaSimR::SimParam$setSexes()
AlphaSimR::SimParam$setTrackPed()
AlphaSimR::SimParam$setTrackRec()
AlphaSimR::SimParam$setVarE()
AlphaSimR::SimParam$switchFemaleMap()
AlphaSimR::SimParam$switchGenMap()
AlphaSimR::SimParam$switchMaleMap()
AlphaSimR::SimParam$switchTrait()
AlphaSimR::SimParam$updateLastId()
new()
Starts the process of building a new simulation by creating a new SimParamBee object and assigning a founder population of genomes to the this object.
SimParamBee$new( founderPop, nWorkers = 100, nDrones = 100, nVirginQueens = 10, nFathers = 15, swarmP = 0.5, swarmRadius = 0, splitP = 0.3, downsizeP = 0.85, csdChr = 3, csdPos = 0.865, nCsdAlleles = 128, colonyValueFUN = NULL )
founderPop
MapPop-class
, founder population of
genomes
nWorkers
see SimParamBee
field nWorkers
nDrones
see SimParamBee
field nDrones
nVirginQueens
see SimParamBee
field nVirginQueens
nFathers
see SimParamBee
field nFathers
swarmP
see SimParamBee
field swarmP
swarmRadius
see SimParamBee
field swarmRadius
splitP
see SimParamBee
field splitP
downsizeP
see SimParamBee
field downsizeP
csdChr
integer, chromosome that will carry the csd locus, by
default 3, but if there are less chromosomes (for a simplified
simulation), the locus is put on the last available chromosome (1 or
2); if NULL
then csd locus is ignored in the simulation
csdPos
numeric, starting position of the csd locus on the
csdChr
chromosome (relative at the moment, but could be in base
pairs in future)
nCsdAlleles
integer, number of possible csd alleles (this
determines how many segregating sites will be needed to represent the
csd locus from the underlying bi-allelic SNP; the minimum number of
bi-allelic SNP needed is log2(nCsdAlleles)
); if set to 0
then csdChr=NULL
is triggered. By default we set nCsdAlleles
to 128, which is at the upper end of the reported number of csd alleles
(Lechner et al., 2014; Zareba et al., 2017; Bovo et al., 2021).
colonyValueFUN
see SimParamBee
field colonyValueFUN
founderGenomes <- quickHaplo(nInd = 10, nChr = 3, segSites = 10) SP <- SimParamBee$new(founderGenomes, nCsdAlleles = 2) \dontshow{SP$nThreads = 1L} # We need enough segregating sites try(SP <- SimParamBee$new(founderGenomes, nCsdAlleles = 100)) \dontshow{SP$nThreads = 1L} founderGenomes <- quickHaplo(nInd = 10, nChr = 3, segSites = 100) SP <- SimParamBee$new(founderGenomes, nCsdAlleles = 100) \dontshow{SP$nThreads = 1L} # We can save the csd locus on chromosome 1 or 2, too, for quick simulations founderGenomes <- quickHaplo(nInd = 10, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes, nCsdAlleles = 100) \dontshow{SP$nThreads = 1L}
addToCaste()
Store caste information (for internal use only!)
SimParamBee$addToCaste(id, caste)
id
character, individuals whose caste will be stored
caste
character, single "Q" for queens, "W" for workers, "D" for drones, "V" for virgin queens, and "F" for fathers
founderGenomes <- quickHaplo(nInd = 2, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) \dontshow{SP$nThreads = 1L} SP$setTrackPed(isTrackPed = TRUE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 10) colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = drones) colony <- addWorkers(colony, nInd = 5) colony <- addDrones(colony, nInd = 5) colony <- addVirginQueens(colony, nInd = 2) SP$pedigree SP$caste
changeCaste()
Change caste information (for internal use only!)
SimParamBee$changeCaste(id, caste)
id
character, individuals whose caste will be changed
caste
character, single "Q" for queens, "W" for workers, "D" for drones, "V" for virgin queens, and "F" for fathers
founderGenomes <- quickHaplo(nInd = 2, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) \dontshow{SP$nThreads = 1L} SP$setTrackPed(isTrackPed = TRUE) basePop <- createVirginQueens(founderGenomes) SP$pedigree SP$caste drones <- createDrones(x = basePop[1], nInd = 10) colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = drones) SP$pedigree SP$caste
updateLastColonyId()
A function to update the colony last ID everytime we create a Colony-class with createColony. For internal use only.
SimParamBee$updateLastColonyId()
lastColonyId
integer, last colony ID assigned
clone()
The objects of this class are cloneable with this method.
SimParamBee$clone(deep = FALSE)
deep
Whether to make a deep clone.
Bovo et al. (2021) Application of Next Generation Semiconductor-Based Sequencing for the Identification of Apis mellifera Complementary Sex Determiner (csd) Alleles from Honey DNA. Insects, 12(10), 868. doi:10.3390/insects12100868
Lechner et al. (2014) Nucleotide variability at its limit? Insights into the number and evolutionary dynamics of the sex-determining specificities of the honey bee Apis mellifera Molecular Biology and Evolution, 31, 272-287. doi:10.1093/molbev/mst207
Seeley (2019) The Lives of Bees: The Untold Story of the Honey Bee in the Wild. Princeton: Princeton University Press. doi:10.1515/9780691189383
Zareba et al. (2017) Uneven distribution of complementary sex determiner (csd) alleles in Apis mellifera population. Scientific Reports, 7, 2317. doi:10.1038/s41598-017-02629-9
## ------------------------------------------------ ## Method `SimParamBee$new` ## ------------------------------------------------ founderGenomes <- quickHaplo(nInd = 10, nChr = 3, segSites = 10) SP <- SimParamBee$new(founderGenomes, nCsdAlleles = 2) # We need enough segregating sites try(SP <- SimParamBee$new(founderGenomes, nCsdAlleles = 100)) founderGenomes <- quickHaplo(nInd = 10, nChr = 3, segSites = 100) SP <- SimParamBee$new(founderGenomes, nCsdAlleles = 100) # We can save the csd locus on chromosome 1 or 2, too, for quick simulations founderGenomes <- quickHaplo(nInd = 10, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes, nCsdAlleles = 100) ## ------------------------------------------------ ## Method `SimParamBee$addToCaste` ## ------------------------------------------------ founderGenomes <- quickHaplo(nInd = 2, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) SP$setTrackPed(isTrackPed = TRUE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 10) colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = drones) colony <- addWorkers(colony, nInd = 5) colony <- addDrones(colony, nInd = 5) colony <- addVirginQueens(colony, nInd = 2) SP$pedigree SP$caste ## ------------------------------------------------ ## Method `SimParamBee$changeCaste` ## ------------------------------------------------ founderGenomes <- quickHaplo(nInd = 2, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) SP$setTrackPed(isTrackPed = TRUE) basePop <- createVirginQueens(founderGenomes) SP$pedigree SP$caste drones <- createDrones(x = basePop[1], nInd = 10) colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = drones) SP$pedigree SP$caste
## ------------------------------------------------ ## Method `SimParamBee$new` ## ------------------------------------------------ founderGenomes <- quickHaplo(nInd = 10, nChr = 3, segSites = 10) SP <- SimParamBee$new(founderGenomes, nCsdAlleles = 2) # We need enough segregating sites try(SP <- SimParamBee$new(founderGenomes, nCsdAlleles = 100)) founderGenomes <- quickHaplo(nInd = 10, nChr = 3, segSites = 100) SP <- SimParamBee$new(founderGenomes, nCsdAlleles = 100) # We can save the csd locus on chromosome 1 or 2, too, for quick simulations founderGenomes <- quickHaplo(nInd = 10, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes, nCsdAlleles = 100) ## ------------------------------------------------ ## Method `SimParamBee$addToCaste` ## ------------------------------------------------ founderGenomes <- quickHaplo(nInd = 2, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) SP$setTrackPed(isTrackPed = TRUE) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 10) colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = drones) colony <- addWorkers(colony, nInd = 5) colony <- addDrones(colony, nInd = 5) colony <- addVirginQueens(colony, nInd = 2) SP$pedigree SP$caste ## ------------------------------------------------ ## Method `SimParamBee$changeCaste` ## ------------------------------------------------ founderGenomes <- quickHaplo(nInd = 2, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) SP$setTrackPed(isTrackPed = TRUE) basePop <- createVirginQueens(founderGenomes) SP$pedigree SP$caste drones <- createDrones(x = basePop[1], nInd = 10) colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = drones) SP$pedigree SP$caste
Level 0 function that returns simulated honeybee genomes
simulateHoneyBeeGenomes( nMelN = 0L, nMelS = 0L, nCar = 0L, nLig = 0L, Ne = 170000L, ploidy = 2L, nChr = 16L, nSegSites = 100L, nBp = 225200000/16, genLen = 3.199121, mutRate = 3.4e-09, recRate = 2.3e-07, nThreads = NULL )
simulateHoneyBeeGenomes( nMelN = 0L, nMelS = 0L, nCar = 0L, nLig = 0L, Ne = 170000L, ploidy = 2L, nChr = 16L, nSegSites = 100L, nBp = 225200000/16, genLen = 3.199121, mutRate = 3.4e-09, recRate = 2.3e-07, nThreads = NULL )
nMelN |
integer, number of Apis mellifera mellifera North individuals to simulate |
nMelS |
integer, number of Apis mellifera mellifera South individuals to simulate |
nCar |
integer, number of Apis mellifera carnica individuals to simulate |
nLig |
integer, number of Apis mellifera ligustica individuals to simulate |
Ne |
integer, effective size of the simulated population. Currently set to 170,000, according to Wallberg et al., 2014. Would discourage you to change it since it is linked to the parameters of the demographic model we use for the simulation. However, there might be some edge cases when using a different Ne is necessary, but proceed with caution. |
ploidy |
integer, the ploidy of the individuals |
nChr |
integer, number of chromosomes to simulate |
nSegSites |
integer, number of segregating sites to keep per chromosome |
nBp |
integer, base pair length of chromosome |
genLen |
numeric, genetic length of chromosome in Morgans |
mutRate |
numeric, per base pair mutation rate |
recRate |
numeric, per base pair recombination rate |
nThreads |
integer, if OpenMP is available, this will allow for simulating
chromosomes in parallel. If |
Wallberg, A., Bunikis, I., Pettersson, O.V. et al. A hybrid de novo genome assembly of the honeybee, Apis mellifera, with chromosome-length scaffolds. 2019, BMC Genomics 20:275. doi:10.1186/s12864-019-5642-0
Beye M, Gattermeier I, Hasselmann M, et al. Exceptionally high levels of recombination across the honey bee genome. 2006, Genome Res 16(11):1339-1344. doi:10.1101/gr.5680406
Wallberg, A., Han, F., Wellhagen, G. et al. A worldwide survey of genome sequence variation provides insight into the evolutionary history of the honeybee Apis mellifera. 2014, Nat Genet 46:1081–1088. doi:10.1038/ng.3077
Yang S, Wang L, Huang J, Zhang X, Yuan Y, Chen JQ, Hurst LD, Tian D. Parent-progeny sequencing indicates higher mutation rates in heterozygotes. 2015, Nature 523(7561):463-7. doi:10.1038/nature14649.
Due to the computational time and resources required to run this function, we do not include an example here, but we demonstrate its use in the Honeybee biology vignette.
Level 2 function that splits a Colony or MultiColony object into two new colonies to prevent swarming (in managed situation). The remnant colony retains the queen and a proportion of the workers and all drones. The split colony gets the other part of the workers, which raise virgin queens, of which only one prevails. Location of the split is the same as for the remnant.
split(x, p = NULL, year = NULL, simParamBee = NULL, ...)
split(x, p = NULL, year = NULL, simParamBee = NULL, ...)
x |
|
p |
numeric, proportion of workers that will go to the split colony; if
|
year |
numeric, year of birth for virgin queens |
simParamBee |
|
... |
additional arguments passed to |
list with two Colony-class
or MultiColony-class
,
the split
and the remnant
(see the description what each colony holds!);
both outputs have the split even slot set do TRUE
founderGenomes <- quickHaplo(nInd = 10, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(basePop[1], n = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = 10) # Create Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) (colony <- buildUp(colony, nWorkers = 100)) apiary <- createMultiColony(basePop[3:8], n = 6) apiary <- cross(apiary, drones = droneGroups[2:7]) apiary <- buildUp(apiary, nWorkers = 100) # Split a colony tmp <- split(colony) tmp$split tmp$remnant # Split all colonies in the apiary with p = 0.5 (50% of workers in each split) tmp <- split(apiary, p = 0.5) tmp$split[[1]] tmp$remnant[[1]] # Split with different proportions nWorkers(apiary) tmp <- split(apiary, p = c(0.1, 0.2, 0.3, 0.4, 0.5, 0.6)) nWorkers(tmp$split) nWorkers(tmp$remnant) # Split only specific colonies in the apiary tmp <- pullColonies(apiary, ID = c(4, 5)) # Split only the pulled colonies (split(tmp$pulled, p = 0.5))
founderGenomes <- quickHaplo(nInd = 10, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(basePop[1], n = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = 10) # Create Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) (colony <- buildUp(colony, nWorkers = 100)) apiary <- createMultiColony(basePop[3:8], n = 6) apiary <- cross(apiary, drones = droneGroups[2:7]) apiary <- buildUp(apiary, nWorkers = 100) # Split a colony tmp <- split(colony) tmp$split tmp$remnant # Split all colonies in the apiary with p = 0.5 (50% of workers in each split) tmp <- split(apiary, p = 0.5) tmp$split[[1]] tmp$remnant[[1]] # Split with different proportions nWorkers(apiary) tmp <- split(apiary, p = c(0.1, 0.2, 0.3, 0.4, 0.5, 0.6)) nWorkers(tmp$split) nWorkers(tmp$remnant) # Split only specific colonies in the apiary tmp <- pullColonies(apiary, ID = c(4, 5)) # Split only the pulled colonies (split(tmp$pulled, p = 0.5))
Sample the split proportion - proportion of removed workers in a
managed split - used when p = NULL
- (see
SimParamBee$splitP
).
This is just an example. You can provide your own functions that satisfy your needs!
splitPUnif(colony, n = 1, min = 0.2, max = 0.4) splitPColonyStrength(colony, n = 1, nWorkersFull = 100, scale = 1)
splitPUnif(colony, n = 1, min = 0.2, max = 0.4) splitPColonyStrength(colony, n = 1, nWorkersFull = 100, scale = 1)
colony |
|
n |
integer, number of samples |
min |
numeric, lower limit for |
max |
numeric, upper limit for |
nWorkersFull |
numeric, average number of workers in a full/strong
colony for |
scale |
numeric, scaling of numbers in |
splitPUnif
samples from a uniform distribution between values
0.2 and 0.4 irrespective of colony strength.
splitPColonyStrength
samples from a beta distribution with mean
a / (a + b)
, where a = nWorkers + nWorkersFull
and b =
nWorkers
. This beta sampling mimics larger splits for strong colonies and
smaller splits for weak colonies - see examples. This is just an example -
adapt to your needs!
The nWorkersFull
default value used in this function is geared
towards a situation where we simulate ~100 workers per colony (down-scaled
simulation for efficiency). If you simulate more workers, you should change
the default accordingly.
numeric, split proportion
splitPColonyStrength()
: Sample the split proportion - the proportion of
removed workers in a managed split based on the colony strength
SimParamBee
field splitP
splitPUnif() splitPUnif() p <- splitPUnif(n = 1000) hist(p, breaks = seq(from = 0, to = 1, by = 0.01), xlim = c(0, 1)) # Example for splitPColonyStrength() founderGenomes <- quickHaplo(nInd = 2, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 15) colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = drones) colony <- addWorkers(colony, nInd = 10) nWorkers(colony) # weak colony splitPColonyStrength(colony) splitPColonyStrength(colony) colony <- addWorkers(colony, nInd = 100) nWorkers(colony) # strong colony splitPColonyStrength(colony) splitPColonyStrength(colony) # Logic behind splitPColonyStrength() nWorkersFull <- 100 nWorkers <- 0:200 splitP <- 1 - rbeta( n = length(nWorkers), shape1 = nWorkers + nWorkersFull, shape2 = nWorkers ) plot(splitP ~ nWorkers, ylim = c(0, 1)) abline(v = nWorkersFull) pKeep <- 1 - splitP plot(pKeep ~ nWorkers, ylim = c(0, 1)) abline(v = nWorkersFull)
splitPUnif() splitPUnif() p <- splitPUnif(n = 1000) hist(p, breaks = seq(from = 0, to = 1, by = 0.01), xlim = c(0, 1)) # Example for splitPColonyStrength() founderGenomes <- quickHaplo(nInd = 2, nChr = 1, segSites = 100) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(x = basePop[1], nInd = 15) colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = drones) colony <- addWorkers(colony, nInd = 10) nWorkers(colony) # weak colony splitPColonyStrength(colony) splitPColonyStrength(colony) colony <- addWorkers(colony, nInd = 100) nWorkers(colony) # strong colony splitPColonyStrength(colony) splitPColonyStrength(colony) # Logic behind splitPColonyStrength() nWorkersFull <- 100 nWorkers <- 0:200 splitP <- 1 - rbeta( n = length(nWorkers), shape1 = nWorkers + nWorkersFull, shape2 = nWorkers ) plot(splitP ~ nWorkers, ylim = c(0, 1)) abline(v = nWorkersFull) pKeep <- 1 - splitP plot(pKeep ~ nWorkers, ylim = c(0, 1)) abline(v = nWorkersFull)
Level 2 function that supersedes a Colony or MultiColony object - an event where the queen dies. The workers and drones stay unchanged, but workers raise virgin queens, of which only one prevails.
supersede(x, year = NULL, nVirginQueens = NULL, simParamBee = NULL, ...)
supersede(x, year = NULL, nVirginQueens = NULL, simParamBee = NULL, ...)
x |
|
year |
numeric, year of birth for virgin queens |
nVirginQueens |
integer, the number of virgin queens to be created in the
colony; of these one is randomly selected as the new virgin queen of the
remnant colony. If |
simParamBee |
|
... |
additional arguments passed to |
Colony-class
or MultiColony-class
with the
supersede event set to TRUE
founderGenomes <- quickHaplo(nInd = 10, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(basePop[1], n = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = 10) # Create Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) (colony <- buildUp(colony, nWorkers = 100)) apiary <- createMultiColony(basePop[3:8], n = 6) apiary <- cross(apiary, drones = droneGroups[2:7]) apiary <- buildUp(apiary, nWorkers = 100) # Supersede a colony isQueenPresent(colony) isVirginQueenPresent(colony) colony <- supersede(colony) isQueenPresent(colony) isVirginQueenPresent(colony) # Supersede all colonies in the apiary isQueenPresent(colony) isVirginQueenPresent(colony) apiary1 <- supersede(apiary) isQueenPresent(colony) isVirginQueenPresent(colony) # Sample colonies from the apiary that will supersede (sample with probability of 0.2) tmp <- pullColonies(apiary, p = 0.2) # Swarm only the pulled colonies (supersede(tmp$pulled))
founderGenomes <- quickHaplo(nInd = 10, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(basePop[1], n = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = 10) # Create Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) (colony <- buildUp(colony, nWorkers = 100)) apiary <- createMultiColony(basePop[3:8], n = 6) apiary <- cross(apiary, drones = droneGroups[2:7]) apiary <- buildUp(apiary, nWorkers = 100) # Supersede a colony isQueenPresent(colony) isVirginQueenPresent(colony) colony <- supersede(colony) isQueenPresent(colony) isVirginQueenPresent(colony) # Supersede all colonies in the apiary isQueenPresent(colony) isVirginQueenPresent(colony) apiary1 <- supersede(apiary) isQueenPresent(colony) isVirginQueenPresent(colony) # Sample colonies from the apiary that will supersede (sample with probability of 0.2) tmp <- pullColonies(apiary, p = 0.2) # Swarm only the pulled colonies (supersede(tmp$pulled))
Level 2 function that swarms a Colony or MultiColony object - an event where the queen leaves with a proportion of workers to create a new colony (the swarm). The remnant colony retains the other proportion of workers and all drones, and the workers raise virgin queens, of which only one prevails. Location of the swarm is the same as for the remnant or sampled as deviation from the remnant.
swarm( x, p = NULL, year = NULL, nVirginQueens = NULL, sampleLocation = TRUE, radius = NULL, simParamBee = NULL, ... )
swarm( x, p = NULL, year = NULL, nVirginQueens = NULL, sampleLocation = TRUE, radius = NULL, simParamBee = NULL, ... )
x |
|
p |
numeric, proportion of workers that will leave with the swarm colony;
if |
year |
numeric, year of birth for virgin queens |
nVirginQueens |
integer, the number of virgin queens to be created in the
colony; of these one is randomly selected as the new virgin queen of the
remnant colony. If |
sampleLocation |
logical, sample location of the swarm by taking
the current colony location and adding deviates to each coordinate using
|
radius |
numeric, radius of a circle within which swarm will go; if
|
simParamBee |
|
... |
additional arguments passed to |
list with two Colony-class
or MultiColony-class
,
the swarm
and the remnant
(see the description what each
colony holds!); both outputs have the swarm event set to TRUE
founderGenomes <- quickHaplo(nInd = 8, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(basePop[1], n = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = 10) # Create Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) (colony <- buildUp(colony, nWorkers = 100)) apiary <- createMultiColony(basePop[3:8], n = 6) apiary <- cross(apiary, drones = droneGroups[2:7]) apiary <- buildUp(apiary, nWorkers = 100) # Swarm a colony tmp <- swarm(colony) tmp$swarm tmp$remnant # Swarm all colonies in the apiary with p = 0.6 (60% of workers leave) tmp <- swarm(apiary, p = 0.6) nWorkers(tmp$swarm) nWorkers(tmp$remnant) # Swarm with different proportions nWorkers(apiary) tmp <- swarm(apiary, p = c(0.4, 0.6, 0.5, 0.5, 0.34, 0.56)) nWorkers(tmp$swarm) nWorkers(tmp$remnant) # Sample colonies from the apiary that will swarm (sample with probability of 0.2) tmp <- pullColonies(apiary, p = 0.2) # Swarm only the pulled colonies (swarm(tmp$pulled, p = 0.6))
founderGenomes <- quickHaplo(nInd = 8, nChr = 1, segSites = 50) SP <- SimParamBee$new(founderGenomes) basePop <- createVirginQueens(founderGenomes) drones <- createDrones(basePop[1], n = 1000) droneGroups <- pullDroneGroupsFromDCA(drones, n = 10, nDrones = 10) # Create Colony and MultiColony class colony <- createColony(x = basePop[2]) colony <- cross(colony, drones = droneGroups[[1]]) (colony <- buildUp(colony, nWorkers = 100)) apiary <- createMultiColony(basePop[3:8], n = 6) apiary <- cross(apiary, drones = droneGroups[2:7]) apiary <- buildUp(apiary, nWorkers = 100) # Swarm a colony tmp <- swarm(colony) tmp$swarm tmp$remnant # Swarm all colonies in the apiary with p = 0.6 (60% of workers leave) tmp <- swarm(apiary, p = 0.6) nWorkers(tmp$swarm) nWorkers(tmp$remnant) # Swarm with different proportions nWorkers(apiary) tmp <- swarm(apiary, p = c(0.4, 0.6, 0.5, 0.5, 0.34, 0.56)) nWorkers(tmp$swarm) nWorkers(tmp$remnant) # Sample colonies from the apiary that will swarm (sample with probability of 0.2) tmp <- pullColonies(apiary, p = 0.2) # Swarm only the pulled colonies (swarm(tmp$pulled, p = 0.6))
Sample the swarm proportion - the proportion of workers that
swarm - used when p = NULL
(see SimParamBee$swarmP
).
This is just an example. You can provide your own functions that satisfy your needs!
swarmPUnif(colony, n = 1, min = 0.4, max = 0.6)
swarmPUnif(colony, n = 1, min = 0.4, max = 0.6)
colony |
|
n |
integer, number of samples |
min |
numeric, lower limit for |
max |
numeric, upper limit for |
swarmPUnif
samples from a uniform distribution between values
0.4 and 0.6 irrespective of colony strength.
The nWorkersFull
default value used in this function is geared
towards a situation where we simulate ~100 workers per colony (down-scaled
simulation for efficiency). If you simulate more workers, you should change
the default accordingly.
numeric, swarm proportion
SimParamBee
field swarmP
swarmPUnif() swarmPUnif() p <- swarmPUnif(n = 1000) hist(p, breaks = seq(from = 0, to = 1, by = 0.01), xlim = c(0, 1))
swarmPUnif() swarmPUnif() p <- swarmPUnif(n = 1000) hist(p, breaks = seq(from = 0, to = 1, by = 0.01), xlim = c(0, 1))