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,
...
)
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
SimParamBee
, global simulation parameters
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] 99
nDronesPoisson()
#> [1] 98
n <- nDronesPoisson(n = 1000)
hist(n, breaks = seq(from = min(n), to = max(n)), xlim = c(0, 200))
table(n)
#> n
#> 71 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
#> 1 1 1 1 3 3 4 4 8 5 7 11 8 10 19 20 21 19 31 35
#> 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
#> 24 19 39 37 37 37 44 40 34 33 33 32 39 32 28 40 28 25 26 25
#> 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 138
#> 20 13 22 18 9 9 10 11 7 1 3 3 1 1 2 1 1 1 1 2
nDronesTruncPoisson()
#> [1] 105
nDronesTruncPoisson()
#> [1] 94
n <- nDronesTruncPoisson(n = 1000)
hist(n, breaks = seq(from = min(n), to = max(n)), xlim = c(0, 200))
table(n)
#> n
#> 70 73 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
#> 1 1 1 1 1 4 5 2 8 6 4 12 9 14 14 23 26 21 26 29
#> 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
#> 24 41 36 35 37 41 41 43 47 31 43 30 36 36 31 27 18 31 23 20
#> 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 131
#> 21 14 16 19 13 10 5 7 1 3 1 4 1 2 2 1 1
# Example for nDronesColonyPhenotype()
founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 100)
SP <- SimParamBee$new(founderGenomes)
SP$nThreads = 1L
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