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,
  ...
)

Arguments

x

Pop-class or codeColony-class or MultiColony-class, the object with the virgin queens that need to be crossed. When spatial = TRUE, the argument needs to be a codeColony-class or MultiColony-class with the location set

drones

Pop-class, a population of drones (resembling a drone congregation area) available for mating. When spatial = TRUE, the user can not provide drones, but needs to provide drone producing colonies instead (see argument droneColonies)

droneColonies

MultiColony-class, drone producing colonies available for mating. When spatial = TRUE, the object needs to have the location set

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 spatial = TRUE

simParamBee

SimParamBee, global simulation parameters

Value

named list with names being virgin queens/colonies IDs with each list element holding the IDs of selected drones or drone producing colonies

Examples

founderGenomes <- quickHaplo(nInd = 1000, nChr = 1, segSites = 100)
SP <- SimParamBee$new(founderGenomes)
basePop <- createVirginQueens(founderGenomes)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found

# Create three virgin MultiColony objects with locations
virginColonies1 <- createMultiColony(basePop[1:30])
#> Error in createMultiColony(basePop[1:30]): object 'basePop' not found
virginColonies1 <- setLocation(virginColonies1,
                               location = Map(c, runif(30, 0, 2*pi),
                                                 runif(30, 0, 2*pi)))
#> Error in is(x, class2 = "Colony"): object 'virginColonies1' not found
virginColonies2 <- createMultiColony(basePop[31:60])
#> Error in createMultiColony(basePop[31:60]): object 'basePop' not found
virginColonies2 <- setLocation(virginColonies2,
                               location = Map(c, runif(30, 0, 2*pi),
                                                 runif(30, 0, 2*pi)))
#> Error in is(x, class2 = "Colony"): object 'virginColonies2' not found
virginColonies3 <- createMultiColony(basePop[61:90])
#> Error in createMultiColony(basePop[61:90]): object 'basePop' not found
virginColonies3 <- setLocation(virginColonies3,
                               location = Map(c, runif(30, 0, 2*pi),
                                                 runif(30, 0, 2*pi)))
#> Error in is(x, class2 = "Colony"): object 'virginColonies3' not found

# Create drone colonies
droneColonies <- createMultiColony(basePop[121:200])
#> Error in createMultiColony(basePop[121:200]): object 'basePop' not found
droneColonies <- setLocation(droneColonies,
                             location = Map(c, runif(80, 0, 2*pi),
                                               runif(80, 0, 2*pi)))
#> Error in is(x, class2 = "Colony"): object 'droneColonies' not found

# Create some drones to mate initial drone colonies with
DCA <- createDrones(basePop[201:300], nInd = 20)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
# Cross initial virgin drone colonies to the DCA with a random cross plan
randomCrossPlan <- createCrossPlan(x = droneColonies,
                                   drones = DCA,
                                   nDrones = nFathersPoisson,
                                   spatial = FALSE)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
droneColonies <- cross(droneColonies,
                       drones = DCA,
                       nDrones = nFathersPoisson,
                       crossPlan = randomCrossPlan)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found

# Plot the colonies in space
virginLocations <- as.data.frame(getLocation(c(virginColonies1, virginColonies2, virginColonies3),
                                             collapse= TRUE))
#> Error in is(x, class2 = "Colony"): object 'virginColonies1' not found
virginLocations$Type <- "Virgin"
#> Error in virginLocations$Type <- "Virgin": object 'virginLocations' not found
droneLocations <- as.data.frame(getLocation(droneColonies, collapse= TRUE))
#> Error in is(x, class2 = "Colony"): object 'droneColonies' not found
droneLocations$Type <- "Drone"
#> Error in droneLocations$Type <- "Drone": object 'droneLocations' not found
locations <- rbind(virginLocations, droneLocations)
#> Error in rbind(virginLocations, droneLocations): object 'virginLocations' not found

plot(x = locations$V1, y = locations$V2, col = c("red", "blue")[as.numeric(as.factor(locations$Type))])
#> Error in plot(x = locations$V1, y = locations$V2, col = c("red", "blue")[as.numeric(as.factor(locations$Type))]): object 'locations' not found

# 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)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found

# Plot the crossing for the first colony in the crossPlan
virginLocations1 <- as.data.frame(getLocation(virginColonies1, collapse= TRUE))
#> Error in is(x, class2 = "Colony"): object 'virginColonies1' not found
virginLocations1$Type <- "Virgin"
#> Error in virginLocations1$Type <- "Virgin": object 'virginLocations1' not found
droneLocations <- as.data.frame(getLocation(droneColonies, collapse= TRUE))
#> Error in is(x, class2 = "Colony"): object 'droneColonies' not found
droneLocations$Type <- "Drone"
#> Error in droneLocations$Type <- "Drone": object 'droneLocations' not found
locations1 <- rbind(virginLocations1, droneLocations)
#> Error in rbind(virginLocations1, droneLocations): object 'virginLocations1' not found

# 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")))
#> Error in 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"))): object 'locations1' not found

colonies1 <- cross(x = virginColonies1,
                   crossPlan = crossPlanSpatial,
                   droneColonies = droneColonies,
                   nDrones = nFathersPoisson)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
nFathers(colonies1)
#> Error in is(x, class2 = "Pop"): object 'colonies1' not found

# 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")
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found

# 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)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found