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,
...
)
Pop-class
or Colony-class
integer, number of samples
numeric, average number of drones
numeric, returned numbers will be above this value
numeric (column position) or character (column name), trait
that represents queen's effect on the colony phenotype (defined in
SimParamBee
- see examples); if 0
then this effect is 0
numeric (column position) or character (column name), trait
that represents workers's effect on the colony phenotype (defined in
SimParamBee
- see examples); if 0
then this effect is 0
logical, does the phenotype depend on the production
status of colony; if yes and production is not TRUE
, the result is
above lowerLimit
other arguments of mapCasteToColonyPheno
numeric, number of drones
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.
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()
#> [1] 97
nDronesPoisson()
#> [1] 93
n <- nDronesPoisson(n = 1000)
hist(n, breaks = seq(from = min(n), to = max(n)), xlim = c(0, 200))
table(n)
#> n
#> 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
#> 1 3 1 4 3 6 7 2 4 11 11 9 12 14 16 18 27 23 21 37
#> 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
#> 28 37 32 34 39 39 39 35 42 34 27 38 44 43 28 45 17 30 20 15
#> 113 114 115 116 117 118 119 120 121 122 123 124 125 127 130 132
#> 14 11 19 9 9 9 4 4 2 9 6 2 1 3 1 1
nDronesTruncPoisson()
#> [1] 96
nDronesTruncPoisson()
#> [1] 96
n <- nDronesTruncPoisson(n = 1000)
hist(n, breaks = seq(from = min(n), to = max(n)), xlim = c(0, 200))
table(n)
#> n
#> 73 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
#> 1 8 4 5 2 6 7 10 8 12 12 13 19 22 36 19 25 29 44 28
#> 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
#> 32 33 36 39 34 33 38 42 45 39 23 29 27 33 31 24 18 16 23 17
#> 115 116 117 118 119 121 122 123 124 125 126 127 128 131 132 135
#> 18 13 6 6 8 5 6 4 3 2 1 2 1 1 1 1
# 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)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
drones <- createDrones(x = basePop[1], nInd = 50)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
droneGroups <- pullDroneGroupsFromDCA(drones, n = 2, nDrones = 15)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
colony1 <- createColony(x = basePop[2])
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
colony2 <- createColony(x = basePop[3])
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
colony1 <- cross(colony1, drones = droneGroups[[1]])
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
colony2 <- cross(colony2, drones = droneGroups[[2]])
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
colony1@queen@pheno
#> Error in eval(expr, envir, enclos): object 'colony1' not found
colony2@queen@pheno
#> Error in eval(expr, envir, enclos): object 'colony2' not found
createDrones(colony1, nInd = nDronesColonyPhenotype)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
createDrones(colony2, nInd = nDronesColonyPhenotype)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found