Level 1 function that crosses (mates) a virgin queen to a group of drones. The virgin queen(s) could be within a population (Pop-class), in a colony (Colony-class), or multi-colony (MultiColony-class). This function does not create any progeny, it only stores the mated drones (fathers) so we can later create progeny as needed. When input is a (Colony-class) or (MultiColony-class), one virgin queens is selected at random, mated, and promoted to the queen of the colony. Other virgin queens are destroyed. Mated drones (fathers) are stored for producing progeny at a later stage. For a better understanding of crossing and the functions have a look at the "Crossing" vignette.

cross(
  x,
  crossPlan = NULL,
  drones = NULL,
  droneColonies = NULL,
  nDrones = NULL,
  spatial = FALSE,
  radius = NULL,
  checkCross = "error",
  simParamBee = NULL,
  ...
)

Arguments

x

Pop-class or codeColony-class or MultiColony-class, one or more virgin queens / colonies to be mated;

crossPlan,

named list with names being virgin queen or colony IDs with each list element holding the IDs of either selected drones or selected drone producing colonies, OR a string "create" if you want the cross plan to be created internally. The function can create a random (spatial = FALSE) or spatial (spatial = TRUE) cross plan internally. Also see createCrossPlan.

drones

a Pop-class or a list of Pop-class, group(s) of drones that will be mated with virgin queen(s). See pullDroneGroupsFromDCA) to create a list of drone "packages". A single Pop-class is only allowed when mating a single virgin queen or colony, or when mating according to a cross plan that includes drones' IDs. When creating a spatial cross plan internally, males can not be provided through the drones argument as a Pop-class, but should be provided through the droneColonies argument as or MultiColony-class

droneColonies

MultiColony-class with all available drone producing colonies. Provided when drones is not provided (NULL). When providing drone producing colonies, the cross function uses a cross plan, that can either be provided by the user through (crossPlan) argument or created internally (when crossPlan is "create")

nDrones

numeric of function, the number of drones to sample to mate with each virgin queen when using a cross plan

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 around the virgin colony in which to sample mating partners, only needed when spatial = TRUE

checkCross

character, throw a warning (when checkCross = "warning"),

simParamBee

SimParamBee, global simulation parameters

Value

Pop-class with mated queen(s). The misc slot of the queens contains additional information about the number of workers, drones, and homozygous brood produced, and the expected percentage of csd homozygous brood.

Details

This function changes caste for the mated drones to fathers, and mated virgin queens to queens. See examples. This means that you can not use these individuals in matings any more!

If the supplied drone population is empty (has 0 individuals), which can happen in edge cases or when nFathersPoisson is used instead of nFathersTruncPoisson, or when performing spatially-aware mating and no drone producing colonies are found in the vicinity, then mating of a virgin queen will fail and she will stay virgin. This can happen for just a few of many virgin queens, which can be annoying to track down, but you can use isQueen or isVirginQueen to find such virgin queens. You can use checkCross to alert you about this situation.

See also

Colony-class on how we store the fathers along the queen. For more examples for mating with either externally or internally created cross plan, please see createCrossPlan

For crossing virgin queens according to a cross plan, see createCrossPlan. For crossing virgin queens on a mating stations, see createMatingStationDCA

Examples

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

drones <- createDrones(x = basePop[1], nInd = 1000)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
droneGroups <- pullDroneGroupsFromDCA(drones, n = 20, nDrones = nFathersPoisson)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found

# If input is a Pop class of virgin queen(s)
virginQueen <- basePop[2]
#> Error in eval(expr, envir, enclos): object 'basePop' not found
isQueen(virginQueen)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
(matedQueen <- cross(
  x = virginQueen,
  drones = droneGroups[1]
))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found

isQueen(virginQueen)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
isQueen(matedQueen)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
nFathers(matedQueen)
#> Error in is(x, class2 = "Pop"): object 'matedQueen' not found
isDrone(getFathers(matedQueen))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
isFather(getFathers(matedQueen))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found

virginQueens <- basePop[4:5]
#> Error in eval(expr, envir, enclos): object 'basePop' not found
matedQueens <- cross(
  x = virginQueens,
  drones = droneGroups[c(3, 4)]
)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found

isQueen(matedQueens)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
nFathers(matedQueens)
#> Error in is(x, class2 = "Pop"): object 'matedQueens' not found
getFathers(matedQueens)
#> Error in is(x, class2 = "Pop"): object 'matedQueens' not found

# Inbred mated queen (mated with her own sons)
matedQueen2 <- cross(
  x = basePop[1],
  drones = droneGroups[5]
)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
# Check the expected csd homozygosity
pHomBrood(matedQueen2)
#> Error in is(x, class2 = "Pop"): object 'matedQueen2' not found

# If input is a Colony or MultiColony class
# Create Colony and MultiColony class
colony <- createColony(basePop[6])
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
isVirginQueen(getVirginQueens(colony))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
apiary <- createMultiColony(basePop[7:8])
#> Error in createMultiColony(basePop[7:8]): object 'basePop' not found
all(isVirginQueen(mergePops(getVirginQueens(apiary))))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found

# Cross
colony <- cross(colony, drones = droneGroups[[6]])
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
isQueenPresent(colony)
#> Error in is(x, class2 = "Colony"): object 'colony' not found
apiary <- cross(apiary, drones = droneGroups[c(7, 8)])
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
all(isQueenPresent(apiary))
#> Error in is(x, class2 = "Colony"): object 'apiary' not found
nFathers(apiary)
#> Error in is(x, class2 = "Pop"): object 'apiary' not found

# Try mating with drones that were already used for mating
colony <- createColony(basePop[9])
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
try((matedColony <- cross(x = colony, drones = droneGroups[[1]])))
#> Error in get(x = "SP", envir = .GlobalEnv) : object 'SP' not found
# Create new drones and mate the colony with them
drones <- createDrones(x = basePop[1], nInd = 15)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
all(isDrone(drones))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
any(isFather(drones))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
(matedColony <- cross(x = colony, drones = drones))
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
isQueenPresent(matedColony)
#> Error in is(x, class2 = "Colony"): object 'matedColony' not found

# Mate with drone producing colonies and a given cross plan
droneColonies <- createMultiColony(basePop[10:15])
#> Error in createMultiColony(basePop[10:15]): object 'basePop' not found
droneColonies <- cross(droneColonies, drones = droneGroups[10:15])
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
nFathers(droneColonies)
#> Error in is(x, class2 = "Pop"): object 'droneColonies' not found
apiary2 <- createMultiColony(basePop[16:20])
#> Error in createMultiColony(basePop[16:20]): object 'basePop' not found
apiary3 <- createMultiColony(basePop[21:25])
#> Error in createMultiColony(basePop[21:25]): object 'basePop' not found
apiary4 <- createMultiColony(basePop[26:30])
#> Error in createMultiColony(basePop[26:30]): object 'basePop' not found

# Create a random cross plan
randomCrossPlan <- createCrossPlan(x = apiary2,
                                   droneColonies = droneColonies,
                                   nDrones = nFathersPoisson,
                                   spatial = FALSE)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
apiary2 <- cross(x = apiary2,
                 droneColonies = droneColonies,
                 crossPlan = randomCrossPlan,
                 nDrones = 15)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
nFathers(apiary2)
#> Error in is(x, class2 = "Pop"): object 'apiary2' not found

# Mate colonies according to a cross plan that is created internally within the cross function
apiary3 <- cross(x = apiary3,
                 droneColonies = droneColonies,
                 crossPlan = "create",
                 nDrones = 15)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
nFathers(apiary3)
#> Error in is(x, class2 = "Pop"): object 'apiary3' not found

# Mate colonies according to a cross plan that is created internally within the cross function
# For this, all the colonies have to have a set location
droneColonies <- setLocation(droneColonies,
                             location = Map(c, runif(6, 0, 2*pi), runif(6, 0, 2*pi)))
#> Error in is(x, class2 = "Colony"): object 'droneColonies' not found
apiary4 <- setLocation(apiary4,
                       location = Map(c, runif(5, 0, 2*pi), runif(5, 0, 2*pi)))
#> Error in is(x, class2 = "Colony"): object 'apiary4' not found

apiary4 <- cross(x = apiary4,
                 droneColonies = droneColonies,
                 crossPlan = "create",
                 nDrones = nFathersPoisson,
                 spatial = TRUE,
                 checkCross = "warning",
                 radius = 3)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
nFathers(apiary4)
#> Error in is(x, class2 = "Pop"): object 'apiary4' not found