From 3160b98673d792d579e0032c653d4e8d5e5bc93b Mon Sep 17 00:00:00 2001 From: janaobsteter Date: Thu, 19 Sep 2024 07:29:25 +0200 Subject: [PATCH] Changing the vignette D to now read the colony's locations from a file to prevent any queens being left unmated --- NEWS.md | 11 +++++++++++ vignettes/Colony_locations.csv | 36 ++++++++++++++++++++++++++++++++++ vignettes/D_Crossing.Rmd | 28 +++++++++++++++++--------- 3 files changed, 66 insertions(+), 9 deletions(-) create mode 100644 vignettes/Colony_locations.csv diff --git a/NEWS.md b/NEWS.md index c304462e..d72a41ac 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,17 @@ editor_options: wrap: 72 --- +# SIMplyBee version 0.4.1 + +- 2024-09-19 + +## Bug fixes + +- locations of the colonies in the D_Crossing vignettes were previously +sampled by random. This caused that on some runs some queens were left unmated, +which caused an error. We now read in the locations from a csv file. + + # SIMplyBee version 0.4.0 - 2024-08-23 diff --git a/vignettes/Colony_locations.csv b/vignettes/Colony_locations.csv new file mode 100644 index 00000000..0ac2a90d --- /dev/null +++ b/vignettes/Colony_locations.csv @@ -0,0 +1,36 @@ +ColonyID,X,Y +1,0.662431162288274,5.97033145745812 +2,0.889869211813095,0.882040306233467 +3,3.20406617225118,4.2012594475023 +4,3.37467634975274,1.85276144978548 +5,6.26877271726022,4.12336288238627 +6,1.49762073729787,0.854711175179748 +7,6.27428327657999,5.28537368571472 +8,0.377119552748809,1.26003243402567 +9,0.884600259265786,2.55843304434275 +10,4.85341262281402,4.34423864421118 +11,0.439273950460384,5.78768883580839 +12,4.85267013629791,5.24037990077726 +13,6.27814888107222,1.67684867115787 +14,5.91398658831959,2.21947012261649 +15,2.2845571049277,2.76273156562477 +16,2.15001173188715,5.30559199476844 +17,3.30277055998226,3.88408253149063 +18,1.59318554922445,3.95724726174676 +19,5.14489315015939,3.48380219722517 +20,4.89542592867685,4.87175443368121 +21,4.98504294579104,4.63186113766538 +22,1.96273450676472,2.98552319129881 +23,1.94181870616625,1.04070091389605 +24,3.71355474699821,3.98892629339701 +25,1.76640287495849,1.81689439235 +26,3.49162610986539,2.007127614613 +27,4.70110619836582,1.98065883153337 +28,2.93773502070683,2.79053982429322 +29,1.69897541097397,2.4435374157815 +30,1.54126706057672,0.265964466739025 +31,0.211675140867833,1.58970616827141 +32,4.38863010920245,4.35616019770602 +33,4.3632705003701,0.955920230806015 +34,5.94574863325625,5.50420647366442 +35,2.86914251070775,0.176914088999066 diff --git a/vignettes/D_Crossing.Rmd b/vignettes/D_Crossing.Rmd index d255c2a9..7c25f075 100644 --- a/vignettes/D_Crossing.Rmd +++ b/vignettes/D_Crossing.Rmd @@ -287,19 +287,26 @@ colonies. Although we are not sampling drones directly, you still need to provide `nDrones` argument to determine the number of sampled drone producing colonies. -For spatial mating, we need to set the location to our apiaries (all the -colonies within an beekeeper will have the same location). Here, we are setting -this locations randomly, but these could be actual coordinated of colonies -within a country. +For spatial mating, we need to set the location to our apiaries. Here, we are +reading the locations in from a file with the coordinates of all colonies, then +selecting the colonies of a specific beekeeper, creating a list of coordinate +pairs (with the `Map` function). We could also set locations randomly. ```{r} +# Read locations from a file +locations = read.csv("Colony_locations.csv") # Set location to apiaries +beekeeper1_locations <- locations[locations$ColonyID %in% getId(beekeeper1),] beekeeper1 <- setLocation(beekeeper1, - location = Map(c, runif(nColonies(beekeeper1), 0, 2*pi), runif(nColonies(beekeeper1), 0, 2*pi))) + location = Map(c, beekeeper1_locations$X, beekeeper1_locations$Y)) + +beekeeper2_locations <- locations[locations$ColonyID %in% getId(beekeeper2),] beekeeper2 <- setLocation(beekeeper2, - location = Map(c, runif(nColonies(beekeeper2), 0, 2*pi), runif(nColonies(beekeeper2), 0, 2*pi))) + location = Map(c, beekeeper2_locations$X, beekeeper2_locations$Y)) + +beekeeper3_locations <- locations[locations$ColonyID %in% getId(beekeeper3),] beekeeper3 <- setLocation(beekeeper3, - location = Map(c, runif(nColonies(beekeeper2), 0, 2*pi), runif(nColonies(beekeeper3), 0, 2*pi))) + location = Map(c, beekeeper3_locations$X, beekeeper3_locations$Y)) ``` @@ -372,10 +379,13 @@ beekeepers 1 to 3 as drone producing colonies. Let's first set the locations of the beekeepers 4 and 5 colonies. ```{r} +beekeeper4_locations <- locations[locations$ColonyID %in% getId(beekeeper4),] beekeeper4 <- setLocation(beekeeper4, - location = Map(c, runif(nColonies(beekeeper4), 0, 2*pi), runif(nColonies(beekeeper4), 0, 2*pi))) + location = Map(c, beekeeper4_locations$X, beekeeper4_locations$Y)) + +beekeeper5_locations <- locations[locations$ColonyID %in% getId(beekeeper5),] beekeeper5 <- setLocation(beekeeper5, - location = Map(c, runif(nColonies(beekeeper5), 0, 2*pi), runif(nColonies(beekeeper5), 0, 2*pi))) + location = Map(c, beekeeper5_locations$X, beekeeper5_locations$Y)) ``` Now, we will mate the colonies of beekeeper 4 in a random manner and colonies of