Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to cross() to reduce chance of random warning #576

Merged
merged 6 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
^_pkgdown\.yml
^SIMplyBee\.Rproj
^docs
^vignettes/*F2*
^vignettes/*R
^vignettes/*RData
^vignettes/*pdf
Expand All @@ -16,3 +15,5 @@
^vignettes/SIMplyBee\_logo\_small\.png
^.*\.Rproj$
^\.Rproj\.user$
^doc$
^Meta$
35 changes: 18 additions & 17 deletions vignettes/A_Honeybee_biology.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@ honeybee genomes that represent the founder population. You can quickly generate
random genomes using AlphaSimR's `quickHaplo()`. These founder genomes are
rapidly simulated by sampling chromosomes as series of 0s and 1s, and do not
include any species-specific demographic history. This is equivalent to all loci
having allele frequency 0.5 and being in linkage equilibrium. We use this approach
only for demonstrations and testing.
having allele frequency 0.5 and being in linkage equilibrium. We use this
approach only for demonstrations and testing.

Alternatively, you can more accurately simulate honeybee genomes with
SIMplyBee's `simulateHoneyBeeGenomes()`. This function simulates the honeybee
genome using coalescent simulation of whole chromosomes using MaCS (Chen et al., 2009)
for three subspecies: *A. m. ligustica*, *A. m. carnica*, and *A. m. mellifera*
according to the demographic model described by Wallberg et al. (2014).
genome using coalescent simulation of whole chromosomes using MaCS (Chen et al.,
2009) for three subspecies: *A. m. ligustica*, *A. m. carnica*, and *A. m.
mellifera* according to the demographic model described by Wallberg et al.
(2014).

As a demonstration, we will use `quickHaplo()` and simulate genomes of two
founding individuals. In this example, the genomes will be represented by only
Expand All @@ -71,12 +72,12 @@ simulation here.
founderGenomes <- quickHaplo(nInd = 2, nChr = 3, segSites = 100)
```

As mentioned, the `simulateHoneyBeeGenomes()` generates more realistic chromosome
samples, but also requires much more time. Hence, when you use `simulateHoneyBeeGenomes()`,
we suggest you save the output to an RData file that you then load in your
environment and work with it. See the function documentation using
`help(simulateHoneyBeeGenomes)` to learn all the parameters involved in the
function.
As mentioned, the `simulateHoneyBeeGenomes()` generates more realistic
chromosome samples, but also requires much more time. Hence, when you use
`simulateHoneyBeeGenomes()`, we suggest you save the output to an RData file
that you then load in your environment and work with it. See the function
documentation using `help(simulateHoneyBeeGenomes)` to learn all the parameters
involved in the function.

Now we are ready to setup global simulation parameters using `SimParamBee`.
`SimParamBee` builds upon AlphaSimR's `SimParam`, which includes genome and
Expand Down Expand Up @@ -199,7 +200,7 @@ Let's now mate our virgin queen, so that she is promoted to a queen and can
start laying eggs of her own workers and drones.

```{r cross colony}
colony <- cross(colony, drones = baseDrones)
colony <- cross(colony, drones = baseDrones, checkCross = "warning")
colony
```

Expand All @@ -222,7 +223,7 @@ buildUp(colony)
All the functions in SIMplyBee return objects, hence we need to save them as an
object, otherwise they are lost.

```{r}
```{r buildup and save}
colony <- buildUp(colony)
colony
```
Expand Down Expand Up @@ -292,13 +293,13 @@ look at `pull*()` functions. These functions return a list of objects: `pulled`
being the pulled individuals (`Pop` object), and `remnant` being the remaining
colony without the pulled individuals.

```{r}
```{r remnant}
tmp <- pullWorkers(colony, n = 10)
colony <- tmp$remnant
colony
```

```{r}
```{r pulled workers}
pulledWorkers <- tmp$pulled
pulledWorkers
```
Expand Down Expand Up @@ -341,7 +342,7 @@ corresponding `pHomBrood()` and `nHombrood()` functions that can be applied
either on the queen (`Pop` class) or colony (`Colony` class) directly. You can
obtain the entire `misc` slot with the `getMisc()` function.

```{r}
```{r misc}
getMisc(getQueen(colony))
```

Expand Down Expand Up @@ -371,7 +372,7 @@ current colony and mate her with her brothers. Oh, dear.
```{r inbred colony}
inbredColony <- createColony(x = createVirginQueens(x = colony, nInd = 1))
fathers <- selectInd(drones, nInd = SP$nFathers, use = "rand")
inbredColony <- cross(inbredColony, drones = fathers)
inbredColony <- cross(inbredColony, drones = fathers, checkCross = "warning")
getCsdAlleles(inbredColony)
getCsdAlleles(inbredColony, unique = TRUE)
```
Expand Down
4 changes: 2 additions & 2 deletions vignettes/B_Multiple_colonies.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ of drones as we have colonies in our `MultiColony`.
# Pull 10 groups of drones from the DCA
droneGroups <- pullDroneGroupsFromDCA(DCA, n = 10, nDrones = nFathersPoisson)
# Cross all virgin queens in the apiary to the selected drones
apiary1 <- cross(apiary1, drones = droneGroups)
apiary1 <- cross(apiary1, drones = droneGroups, checkCross = "warning")
# Check whether the queens are present (and hence mated)
isQueenPresent(apiary1)
```
Expand Down Expand Up @@ -215,7 +215,7 @@ droneGroups <- pullDroneGroupsFromDCA(DCA,
n = nColonies(apiary2),
nDrones = nFathersPoisson)
# Cross virgin queens in apiary2 to selected drones
apiary2 <- cross(apiary2, drones = droneGroups)
apiary2 <- cross(apiary2, drones = droneGroups, checkCross = "warning")
```

To learn more about the `nFathersPoisson()` function and other similar
Expand Down
4 changes: 2 additions & 2 deletions vignettes/C_Colony_events.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ fatherGroups <- pullDroneGroupsFromDCA(drones, n = 30, nDrones = 10)
# Create Colony and MultiColony class, cross them and build them up
colony <- createColony(x = basePop[11])
colony <- cross(colony, drones = fatherGroups[[1]])
colony <- cross(colony, drones = fatherGroups[[1]], checkCross = "warning")
colony <- buildUp(colony, nWorkers = 100, nDrones = 20)
apiary <- createMultiColony(basePop[12:17])
apiary <- cross(apiary, drones = fatherGroups[2:7])
apiary <- cross(apiary, drones = fatherGroups[2:7], checkCross = "warning")
apiary <- buildUp(apiary, nWorkers = 100, nDrones = 20, exact = TRUE)
```

Expand Down
23 changes: 14 additions & 9 deletions vignettes/D_Crossing.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ to 100 drones!
# Samples some drone for mating from the DCA
drones <- selectInd(DCA, nInd = 10, use = "rand")
# Mate the virgin queen with the drones
queen1 <- cross(x = virginQueen1, drones = drones)
queen1 <- cross(x = virginQueen1, drones = drones, checkCross = "warning")
# Check the number of fathers for the queen
nFathers(queen1)
```
Expand Down Expand Up @@ -207,13 +207,13 @@ Now, we can cross our virgin queens to drone groups.

```{r}
# Pop-class with multiple queens
queens1 <- cross(x = virginQueens1, drones = droneGroups[1:3])
queens1 <- cross(x = virginQueens1, drones = droneGroups[1:3], checkCross = "warning")
nFathers(queens1)
```

```{r}
# MultiColony-class
beekeeper1 <- cross(x = beekeeper1, drones = droneGroups[4:9])
beekeeper1 <- cross(x = beekeeper1, drones = droneGroups[4:9], checkCross = "warning")
nFathers(beekeeper1)
```

Expand Down Expand Up @@ -275,7 +275,7 @@ we can cross the colonies of each beekeeper by providing the `crossPlan1` to the

```{r}
# Cross the colonies of the beekeeper 2
beekeeper2 <- cross(x = beekeeper2, drones = DCA, crossPlan = crossPlan1)
beekeeper2 <- cross(x = beekeeper2, drones = DCA, crossPlan = crossPlan1, checkCross = "warning")
nFathers(beekeeper2)
```

Expand Down Expand Up @@ -343,7 +343,8 @@ unmated. Once we have the spatial cross plan, we can mate our colonies.
beekeeper3 <- cross(x = beekeeper3,
crossPlan = crossPlan2,
droneColonies = c(beekeeper1, beekeeper2),
nDrones = 13)
nDrones = 13,
checkCross = "warning")
# Inspect the number of fathers
nFathers(beekeeper3)
```
Expand Down Expand Up @@ -387,15 +388,17 @@ beekeeper4 <- cross(x = beekeeper4,
droneColonies = c(beekeeper1, beekeeper2, beekeeper3),
crossPlan = "create",
spatial = FALSE,
nDrones = 12)
nDrones = 12,
checkCross = "warning")
nFathers(beekeeper4)

beekeeper5 <- cross(x = beekeeper5,
droneColonies = c(beekeeper1, beekeeper2, beekeeper3),
crossPlan = "create",
spatial = TRUE,
radius = 3,
nDrones = 12)
nDrones = 12,
checkCross = "warning")
nFathers(beekeeper5)
```

Expand Down Expand Up @@ -440,7 +443,8 @@ beekeeper6 <- cross(beekeeper6,
drones = matingStationDCA,
spatial = FALSE,
crossPlan = "create",
nDrones = 15)
nDrones = 15,
checkCross = "warning")
nFathers(beekeeper6)
```

Expand Down Expand Up @@ -471,6 +475,7 @@ crossPlanBeekeeper7 <- c(

beekeeper7 <- cross(x = beekeeper7,
crossPlan = crossPlanBeekeeper7,
drones = c(singleDrone, DCA, matingStationDCA))
drones = c(singleDrone, DCA, matingStationDCA),
checkCross = "warning")
nFathers(beekeeper7)
```
2 changes: 1 addition & 1 deletion vignettes/E_Genomics.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ baseQueens <- createVirginQueens(founderGenomes)
baseDrones <- createDrones(x = baseQueens[1], nInd = 15)
colony <- createColony(x = baseQueens[2])
colony <- cross(colony, drones = baseDrones)
colony <- cross(colony, drones = baseDrones, checkCross = "warning")
colony <- buildUp(colony)
```

Expand Down
4 changes: 2 additions & 2 deletions vignettes/F2_Variance_calculations.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ head(basePop@gv)
head(basePop@pheno)
drones <- createDrones(x = basePop[1:5], nInd = 3)
colony <- createColony(x = basePop[6])
colony <- cross(x = colony, drones = drones)
colony <- cross(x = colony, drones = drones, checkCross = "warning")
colony <- addWorkers(x = colony, nInd = 50)
colony <- buildUp(colony)
apiary <- createMultiColony(basePop[7:20])
drones <- createDrones(basePop[1:5], nInd = 100)
droneGroups <- pullDroneGroupsFromDCA(drones, n = nColonies(apiary), nDrones = 15)
apiary <- cross(x = apiary, drones = droneGroups)
apiary <- cross(x = apiary, drones = droneGroups, checkCross = "warning")
apiary <- buildUp(apiary)
colonyGv <- calcColonyGv(apiary)
colonyPheno <- calcColonyPheno(apiary)
Expand Down
8 changes: 4 additions & 4 deletions vignettes/F_Quantitative_Genetics.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ it, and adding some workers.

```{r create_colony}
colony <- createColony(x = basePop[6])
colony <- cross(x = colony, drones = drones)
colony <- cross(x = colony, drones = drones, checkCross = "warning")
colony <- addWorkers(x = colony, nInd = 50)
colony
```
Expand Down Expand Up @@ -365,7 +365,7 @@ apiary.
apiary <- createMultiColony(basePop[7:20])
drones <- createDrones(basePop[1:5], nInd = 100)
droneGroups <- pullDroneGroupsFromDCA(drones, n = nColonies(apiary), nDrones = 15)
apiary <- cross(x = apiary, drones = droneGroups)
apiary <- cross(x = apiary, drones = droneGroups, checkCross = "warning")
apiary <- buildUp(apiary)
```

Expand Down Expand Up @@ -460,7 +460,7 @@ basePop <- createVirginQueens(founderGenomes)
drones <- createDrones(x = basePop[1:5], nInd = 100)
apiary <- createMultiColony(basePop[6:20])
droneGroups <- pullDroneGroupsFromDCA(drones, nColonies(apiary), nDrones = 15)
apiary <- cross(x = apiary, drones = droneGroups)
apiary <- cross(x = apiary, drones = droneGroups, checkCross = "warning")
apiary <- buildUp(apiary)
apiary
```
Expand Down Expand Up @@ -588,7 +588,7 @@ basePop <- createVirginQueens(founderGenomes)
drones <- createDrones(x = basePop[1:5], nInd = 100)
apiary <- createMultiColony(basePop[6:20])
droneGroups <- pullDroneGroupsFromDCA(drones, nColonies(apiary), nDrones = 15)
apiary <- cross(x = apiary, drones = droneGroups)
apiary <- cross(x = apiary, drones = droneGroups, checkCross = "warning")
```

Let's explore queen's genetic and phenotypic values for fecundity and honey
Expand Down
2 changes: 1 addition & 1 deletion vignettes/G_Sampling_functions.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ DCA to mate with each of the 10 virgin queens.

```{r}
droneGroups <- pullDroneGroupsFromDCA(DCA = DCA, n = 10, nDrones = nFathersPoisson)
apiary <- cross(apiary, drones = droneGroups)
apiary <- cross(apiary, drones = droneGroups, checkCross = "warning")
```

And inspect the number of fathers in each of the colony and their mean.
Expand Down
4 changes: 2 additions & 2 deletions vignettes/Z_FAQ.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ baseDrones <- createDrones(baseVirginQueen[1])
# A colony
colony <- createColony(baseVirginQueen[2])
colony <- cross(x = colony, crossPlan = "create", drones = baseDrones)
colony <- cross(x = colony, crossPlan = "create", drones = baseDrones, checkCross = "warning")
colony <- addDrones(colony, nInd = 100)
colony
# Crossing one of the remaining virgin queens with drones from the
DCA <- createDCA(colony, nInd = 50)
DCA
queen <- cross(x = baseVirginQueen[3], crossPlan = "create", drones = DCA)
queen <- cross(x = baseVirginQueen[3], crossPlan = "create", drones = DCA, checkCross = "warning")
queen
getFathers(queen)
Expand Down
Binary file removed vignettes/founderpop-2.png
Binary file not shown.
Binary file modified vignettes/founderpop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.