Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c018375
Merge pull request #583 from HighlanderLab/devel
janaobsteter Aug 29, 2024
01a56ee
Merge pull request #587 from HighlanderLab/devel
janaobsteter Sep 19, 2024
d1939bf
Parallelising functions, keeping both options
janaobsteter Apr 8, 2025
004065f
Parallelisation
janaobsteter Apr 9, 2025
d0c561c
Adding export to cross_parallel
janaobsteter Apr 9, 2025
da5b0de
renaming to enable switching from parallel (p) to non-parallel (np)
janaobsteter Apr 11, 2025
377f499
renaming to enable switching from parallel (p) to non-parallel (np)
janaobsteter Apr 11, 2025
24a3ea0
Merge branch 'Parallelisation' into Parallelisation
janaobsteter Apr 11, 2025
647aa3f
Merge pull request #599 from janaobsteter/Parallelisation
janaobsteter Apr 11, 2025
04d4d0d
Adding correct NAMESPACE
janaobsteter Apr 11, 2025
24453c7
Correcting namesapce
janaobsteter Apr 11, 2025
5c668a3
Correcting L2
janaobsteter Apr 11, 2025
6403cd0
Correcting L2
janaobsteter Apr 11, 2025
d7dc74f
Merge pull request #600 from janaobsteter/Parallelisation
janaobsteter Apr 11, 2025
7176b74
Correcting L2
janaobsteter Apr 11, 2025
fabda90
Merge pull request #601 from janaobsteter/Parallelisation
janaobsteter Apr 11, 2025
842d98d
Changing removeQueen to not include nTHreads
janaobsteter Apr 14, 2025
cdeacf8
Merge pull request #602 from janaobsteter/Parallelisation
janaobsteter Apr 14, 2025
aa2fc6b
Removing non-parallel versions
janaobsteter Apr 15, 2025
c3574aa
Merge pull request #603 from janaobsteter/Parallelisation
janaobsteter Apr 15, 2025
b501b19
Addding nThreads
janaobsteter Apr 15, 2025
2ba4ae8
Merge pull request #604 from janaobsteter/Parallelisation
janaobsteter Apr 15, 2025
997449f
Solving nThreads inconsistencies
janaobsteter Apr 15, 2025
eacb499
Merge pull request #605 from janaobsteter/Parallelisation
janaobsteter Apr 15, 2025
510b7ca
Setting nThreads = 1 before creating individuals
janaobsteter Apr 22, 2025
851d007
Merge pull request #606 from janaobsteter/Parallelisation
janaobsteter Apr 22, 2025
1830879
Removing print statements
janaobsteter Apr 22, 2025
79641ff
Merge pull request #607 from janaobsteter/Parallelisation
janaobsteter Apr 22, 2025
f35401a
Solving the issue of spatial mating in cross
janaobsteter Apr 25, 2025
cfe9d38
Addded collecting recHist and fixed isCsdHeterozygous
janaobsteter May 28, 2025
e863ff9
Merge pull request #610 from janaobsteter/Parallelisation
janaobsteter May 28, 2025
4f69148
Minor edits for my OCD
gregorgorjanc May 28, 2025
8b0a130
Adding docs
janaobsteter May 28, 2025
108b651
Merge branch 'Parallelisation' of https://github.com/janaobsteter/SIM…
janaobsteter May 28, 2025
d6b0637
Merge pull request #612 from janaobsteter/Parallelisation
janaobsteter May 28, 2025
691017b
Polishing code
gregorgorjanc May 28, 2025
42be86b
Adding docs and correcting the cross
janaobsteter May 29, 2025
322e1fa
Merge conflicts
janaobsteter May 29, 2025
5968402
Amending previous push
janaobsteter May 29, 2025
ffd4106
Merge pull request #613 from janaobsteter/Parallelisation
janaobsteter May 29, 2025
e566f55
Rd files update
gregorgorjanc May 29, 2025
e3cf5d6
Add imports
gregorgorjanc May 29, 2025
a069ddd
.gitignore change
gregorgorjanc May 29, 2025
cafc142
Removing nThreads, renaming updateLastBeeId
janaobsteter May 30, 2025
ca6e717
Merge branch 'Parallelisation' into Parallelisation
janaobsteter May 30, 2025
220fb1f
Merge pull request #619 from janaobsteter/Parallelisation
janaobsteter May 30, 2025
1e8c706
Fixing errors to make tests and examples run (devtoools::check) (#620)
janaobsteter Nov 20, 2025
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

# Output files from R CMD build
/*.tar.gz
src/*.o
src/*.so

# Output files from R CMD check
/*.Rcheck/
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ URL: https://github.com/HighlanderLab/SIMplyBee
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Imports: methods, R6, stats, utils, extraDistr (>= 1.9.1), RANN, Rcpp (>= 0.12.7)
Imports: methods, R6, stats, utils, extraDistr (>= 1.9.1), RANN, Rcpp (>= 0.12.7), foreach, doParallel
Depends: R (>= 3.3.0), AlphaSimR (>= 1.5.3)
LinkingTo: Rcpp, RcppArmadillo (>= 0.7.500.0.0), BH
RoxygenNote: 7.3.2
Expand Down
5 changes: 4 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

export(SimParamBee)
export(addCastePop)
export(addCastePop_internal)
export(addDrones)
export(addVirginQueens)
export(addWorkers)
Expand Down Expand Up @@ -75,7 +76,6 @@ export(getPooledGeno)
export(getQtlGeno)
export(getQtlHaplo)
export(getQueen)
export(getQueenAge)
export(getQueenCsdAlleles)
export(getQueenCsdGeno)
export(getQueenGv)
Expand Down Expand Up @@ -206,7 +206,10 @@ exportClasses(MultiColony)
import(AlphaSimR)
import(Rcpp)
importFrom(R6,R6Class)
importFrom(doParallel,registerDoParallel)
importFrom(extraDistr,rtpois)
importFrom(foreach,"%dopar%")
importFrom(foreach,foreach)
importFrom(methods,"slot<-")
importFrom(methods,classLabel)
importFrom(methods,is)
Expand Down
14 changes: 14 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ which caused an error. We now read in the locations from a csv file.

- Added new C++ function isHeterozygous() to speed up the SIMplyBee function isCsdHeterozygous()

- parallelised all the major functions (so they run on simParamBee$nThreads cores)

- swarm/split/supersede do no longer store the year of the queen

- colonies with high inbreeding that do not produce a viable virgin queens in
max(10, SP$nVirginQueens) attempts are
removed in swarm/supersede

- split no longer creates virgin queens in the split colonies but returns colonies with workers
and meta data, but no virgin
queens

- createMultiColony() no longer creates an empty apiary, but it adds empty colonies with IDs

## Bug fixes

- Bug fix - get\*Haplo() functions were returning diploid drones when
Expand Down
107 changes: 103 additions & 4 deletions R/Class-SimParamBee.R
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,112 @@ SimParamBee <- R6Class(
invisible(self)
},

#' @description For internal use only.
#'
#' @param nNewInd Number of newly created individuals
#' @param id the name of each individual
#' @param mother vector of mother iids
#' @param father vector of father iids
#' @param isDH indicator for DH lines
addToBeePed = function(nNewInd,id,mother,father,isDH) {
stopifnot(nNewInd>0)
if(length(isDH)==1) isDH = rep(isDH,nNewInd)
mother = as.integer(mother)
father = as.integer(father)
isDH = as.integer(isDH)
stopifnot(length(mother)==nNewInd,
length(father)==nNewInd,
length(isDH)==nNewInd)
tmp = cbind(mother,father,isDH)
rownames(tmp) = id
private$.pedigree = rbind(private$.pedigree,tmp)
private$.lastId = private$.lastId + as.integer(nNewInd)
invisible(self)
},


#' @description For internal use only.
#'
#' @param nNewInd Number of newly created individuals
#' @param id the name of each individual
#' @param mother vector of mother iids
#' @param father vector of father iids
#' @param isDH indicator for DH lines
#' @param hist new recombination history
#' @param ploidy ploidy level
addToBeeRec = function(nNewInd,id,mother,father,isDH,
hist,ploidy){
stopifnot(nNewInd>0)
if(length(isDH)==1) isDH = rep(isDH,nNewInd)
mother = as.integer(mother)
father = as.integer(father)
isDH = as.integer(isDH)
stopifnot(length(mother)==nNewInd,
length(father)==nNewInd,
length(isDH)==nNewInd)
tmp = cbind(mother,father,isDH)
rownames(tmp) = id
if(is.null(hist)){
newRecHist = vector("list",nNewInd)
tmpLastHaplo = private$.lastHaplo
if(all(isDH==1L)){
for(i in seq_len(nNewInd)){
tmpLastHaplo = tmpLastHaplo + 1L
newRecHist[[i]] = rep(tmpLastHaplo, ploidy)
}
}else{
for(i in seq_len(nNewInd)){
newRecHist[[i]] = (tmpLastHaplo+1L):(tmpLastHaplo+ploidy)
tmpLastHaplo = tmpLastHaplo + ploidy
}
}
private$.hasHap = c(private$.hasHap, rep(FALSE, nNewInd))
private$.isFounder = c(private$.isFounder, rep(TRUE, nNewInd))
#names(newRecHist) = id
private$.recHist = c(private$.recHist, newRecHist)
private$.lastHaplo = tmpLastHaplo
}else{
# Add hist to recombination history
private$.hasHap = c(private$.hasHap, rep(FALSE, nNewInd))
private$.isFounder = c(private$.isFounder, rep(FALSE, nNewInd))
#names(hist) = id
private$.recHist = c(private$.recHist, hist)
}
private$.pedigree = rbind(private$.pedigree, tmp)
private$.lastId = private$.lastId + as.integer(nNewInd)

invisible(self)
},

#' @description A function to update the caste
#' For internal use only.
#'
#' @param caste vector, named vector of castes to be added
updateCaste = function(caste) {
private$.caste = c(private$.caste, caste)
invisible(self)
},

#' @description A function to update the last
#' ID everytime we create an individual
#' For internal use in SIMplyBee only.
#'
#' @param lastId integer, last colony ID assigned
#' @param n integer, how many individuals to add
updateLastBeeId = function(n = 1L) {
private$.lastId = private$.lastId + as.integer(n)
invisible(self)
},

#' @description A function to update the colony last
#' ID everytime we create a Colony-class with createColony.
#' For internal use only.
#'
#' @param lastColonyId integer, last colony ID assigned
updateLastColonyId = function() {
private$.lastColonyId = private$.lastColonyId + 1L
#' @param n integer, how many colonies to add
updateLastColonyId = function(n = 1) {
n = as.integer(n)
private$.lastColonyId = private$.lastColonyId + n
invisible(self)
}
),
Expand Down Expand Up @@ -459,7 +558,7 @@ SimParamBee <- R6Class(
#' created
caste = function(value) {
if (missing(value)) {
x = private$.caste
x = private$.caste
} else {
stop("`$caste` is read only", call. = FALSE)
}
Expand All @@ -469,7 +568,7 @@ SimParamBee <- R6Class(
#' created with \code{\link[SIMplyBee]{createColony}}
lastColonyId = function(value) {
if (missing(value)) {
private$.lastColonyId
private$.lastColonyId
} else {
stop("`$lastColonyId` is read only", call. = FALSE)
}
Expand Down
Loading