-
Notifications
You must be signed in to change notification settings - Fork 6
Description
In multicolony setting "getSegSiteGeno" function generates a list instead of raw genotype data
Example
Create a founder genome
founderGenomes <- quickHaplo(nInd = 20, nChr = 3, segSites = 100)
Initialise SP
SP <- SimParamBee$new(founderGenomes,
nWorkers = 50,
nDrones = 10,
csdChr = 3,
nCsdAlleles = 32)
baseQueens <- createVirginQueens(founderGenomes)
apiary <- createMultiColony(x = baseQueens[1:20])
DCA <- createDrones(baseQueens[5:10],nInd = 50)
fun <- nFathersPoisson
droneGroups <- pullDroneGroupsFromDCA(DCA, n = 20,nDrones = fun)
apiary <- cross(apiary, drones = droneGroups)
apiary <- buildUp(apiary)
Below I have temporary addressed the issue and it works
start.time <- Sys.time()
library(parallel)
nColony <- nColonies(apiary)
process_colony <- function(colony_data) {
segSiteGeno <- getSegSiteGeno(colony_data, caste = "workers")
pooledGeno <- getPooledGeno(segSiteGeno,
type = "mean",
sex = getCasteSex(colony_data, caste = "workers"))
return(pooledGeno)
}
genoW <- lapply(seq_len(nColony), function(colony) {
process_colony(apiary@colonies[[colony]])
})
pooledGenoW <- do.call(rbind, genoW)
Another option
genoW <- vector("list", length = nColony)
nColony <- colonies(age_0)
for (colony in 1:nColony) {
pooledGenoW <- getPooledGeno(getSnpGeno(age_0, snpChip = 1, caste = "workers",collapse = T),type = "mean",
sex = getCasteSex(age_0@colonies[[colony]], caste = "workers"))
genoW[[colony]] <- pooledGenoW
}
pooledGenoW <- do.call(rbind, genoW)
end.time <- Sys.time()
time.taken <- end.time - start.time
time.taken