Skip to content

Commit

Permalink
Merge pull request #116 from gaynorr/devel
Browse files Browse the repository at this point in the history
Committing version 1.4.2
  • Loading branch information
gaynorr authored Mar 27, 2023
2 parents 6bf1b1d + b931a32 commit 695aef0
Show file tree
Hide file tree
Showing 13 changed files with 445 additions and 162 deletions.
10 changes: 6 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: AlphaSimR
Type: Package
Title: Breeding Program Simulations
Version: 1.3.4
Date: 2022-12-8
Version: 1.4.2
Date: 2023-3-27
Authors@R: c(person("Chris", "Gaynor", email = "[email protected]",
role = c("aut", "cre"), comment = c(ORCID = "0000-0003-0558-6656")),
person("Gregor", "Gorjanc", role = "ctb",
Expand All @@ -13,7 +13,9 @@ Authors@R: c(person("Chris", "Gaynor", email = "[email protected]",
comment = c(ORCID = "0000-0001-5151-3648")),
person("David", "Wilson", role = "ctb"),
person("Thiago","Oliveira", role = "ctb",
comment = c(ORCID = "0000-0002-4555-2584")))
comment = c(ORCID = "0000-0002-4555-2584")),
person("Audrey", "Martin", role = "ctb",
comment = c(ORCID = "0000-0003-2235-0098")))
Description: The successor to the 'AlphaSim' software for breeding program
simulation [Faux et al. (2016) <doi:10.3835/plantgenome2016.02.0013>].
Used for stochastic simulations of breeding programs to the level of DNA
Expand All @@ -35,7 +37,7 @@ Depends: R (>= 4.0.0), methods, R6
Imports: Rcpp (>= 0.12.7), Rdpack
RdMacros: Rdpack
LinkingTo: Rcpp, RcppArmadillo (>= 0.7.500.0.0), BH
RoxygenNote: 7.2.2
RoxygenNote: 7.2.3
Suggests: knitr, rmarkdown, testthat
VignetteBuilder: knitr
NeedsCompilation: true
16 changes: 16 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# AlphaSimR 1.4.2

* updated MaCS citation to https site

# AlphaSimR 1.4.1

* Changed citation to use `bibentry` instead of `citEntry`

# AlphaSimR 1.4.0

*fixed a bug in IBD tracking

*add `setFounderHap` to SimParam for applying custom haplotypes to founders

*added `addSnpChipByName` to SimParam for defining SNP chips by marker names

# AlphaSimR 1.3.4

*changed C++ using `sprintf` to use `snprintf`
Expand Down
70 changes: 70 additions & 0 deletions R/Class-SimParam.R
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,18 @@ SimParam = R6Class(
}
invisible(self)
},

#' @description
#' Allows for the manual setting of founder haplotypes. This functionality
#' is not fully documented, because it is still experimental.
#'
#' @param hapMap a list of founder haplotypes
setFounderHap = function(hapMap){
private$.hap = hapMap
private$.hasHap = rep(TRUE, length(hapMap))
private$.isFounder = rep(FALSE, length(hapMap))
invisible(self)
},

#' @description
#' Randomly assigns eligible SNPs to a SNP chip
Expand Down Expand Up @@ -347,6 +359,64 @@ SimParam = R6Class(
self$snpChips[[self$nSnpChips + 1L]] = snpChip
invisible(self)
},

#' @description
#' Assigns SNPs to a SNP chip by supplying marker names. This function does
#' check against excluded SNPs and will not add the SNPs to the list of
#' excluded QTL for the purpose of avoiding overlap between SNPs and QTL.
#' Excluding these SNPs from being used as QTL can be accomplished using
#' the excludeQtl argument in SimParam's restrSegSites function.
#'
#' @param markers a vector of names for the markers
#' @param name optional name for chip
#'
#' @examples
#' #Create founder haplotypes
#' founderPop = quickHaplo(nInd=10, nChr=1, segSites=10)
#'
#' #Set simulation parameters
#' SP = SimParam$new(founderPop)
#' SP$addSnpChipByName(c("1_1","1_3"))
addSnpChipByName = function(markers, name=NULL){
genMap = private$.femaleMap

# Check that the markers are present on the map
genMapMarkerNames = unlist(lapply(genMap, names))
stopifnot(all(markers%in%genMapMarkerNames))

# Create lociPerChr and lociLoc
lociPerChr = integer(length(genMap))
lociLoc = vector("list", length(genMap))

# Loop through chromosomes
for(i in 1:length(genMap)){

# Initialize lociLoc
lociLoc[[i]] = integer()

# Find matches if they exist
take = match(names(genMap[[i]]), markers)
lociPerChr[i] = length(na.omit(take))
if(lociPerChr[i]>0L){
lociLoc[[i]] = which(!is.na(take))
}
}
lociLoc = unlist(lociLoc)

snpChip = new("LociMap",
nLoci=sum(lociPerChr),
lociPerChr=lociPerChr,
lociLoc=lociLoc)

if(is.null(name)){
snpChip@name = paste0("Chip",self$nSnpChips + 1L)
}else{
snpChip@name = name
}

self$snpChips[[self$nSnpChips + 1L]] = snpChip
invisible(self)
},

#' @description
#' Randomly selects the number of snps in structure and then
Expand Down
8 changes: 4 additions & 4 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,14 @@ getHybridGv <- function(trait, females, femaleParents, males, maleParents, nThre
.Call(`_AlphaSimR_getHybridGv`, trait, females, femaleParents, males, maleParents, nThreads)
}

getFounderIbd <- function(founder, nChr) {
.Call(`_AlphaSimR_getFounderIbd`, founder, nChr)
}

getNonFounderIbd <- function(recHist, mother, father) {
.Call(`_AlphaSimR_getNonFounderIbd`, recHist, mother, father)
}

getFounderIbd <- function(founder, nChr) {
.Call(`_AlphaSimR_getFounderIbd`, founder, nChr)
}

createIbdMat <- function(ibd, chr, nLoci, ploidy, nThreads) {
.Call(`_AlphaSimR_createIbdMat`, ibd, chr, nLoci, ploidy, nThreads)
}
Expand Down
11 changes: 3 additions & 8 deletions inst/CITATION
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
citHeader("To cite AlphaSimR in publications use:

Gaynor, R. Chris, Gregor Gorjanc, and John M. Hickey. 2021. AlphaSimR: an R package for breeding program simulations. G3 Gene|Genomes|Genetics 11(2):jkaa017. https://doi.org/10.1093/g3journal/jkaa017.")

citEntry(
entry = "Article",
bibentry(
bibtype = "Article",
title = "AlphaSimR: an R package for breeding program simulations",
author = "R Chris Gaynor, Gregor Gorjanc, John M Hickey",
journal = "G3 Gene|Genomes|Genetics",
year = "2021",
volume = "11",
number = "jkaa07",
issue = "2",
url = "https://doi.org/10.1093/g3journal/jkaa017",
textVersion = ""
url = "https://doi.org/10.1093/g3journal/jkaa017"
)
2 changes: 1 addition & 1 deletion inst/REFERENCES.bib
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ @article{MaCS
volume = {19},
pages = {136-142},
year = {2009},
URL ={http://genome.cshlp.org/content/19/1/136}
URL ={https://genome.cshlp.org/content/19/1/136}
}

@article{AlphaSim,
Expand Down
1 change: 1 addition & 0 deletions man/AlphaSimR-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions man/SimParam.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,18 +563,6 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}
// getFounderIbd
arma::field< arma::field< arma::field< arma::Mat<int> > > > getFounderIbd(const arma::field<arma::ivec>& founder, arma::uword nChr);
RcppExport SEXP _AlphaSimR_getFounderIbd(SEXP founderSEXP, SEXP nChrSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const arma::field<arma::ivec>& >::type founder(founderSEXP);
Rcpp::traits::input_parameter< arma::uword >::type nChr(nChrSEXP);
rcpp_result_gen = Rcpp::wrap(getFounderIbd(founder, nChr));
return rcpp_result_gen;
END_RCPP
}
// getNonFounderIbd
arma::field< arma::field< arma::Mat<int> > > getNonFounderIbd(const arma::field<arma::field<arma::Mat<int> > >& recHist, const arma::field<arma::field<arma::Mat<int> > >& mother, const arma::field<arma::field<arma::Mat<int> > >& father);
RcppExport SEXP _AlphaSimR_getNonFounderIbd(SEXP recHistSEXP, SEXP motherSEXP, SEXP fatherSEXP) {
Expand All @@ -588,6 +576,18 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}
// getFounderIbd
arma::field< arma::field< arma::field< arma::Mat<int> > > > getFounderIbd(const arma::field<arma::ivec>& founder, arma::uword nChr);
RcppExport SEXP _AlphaSimR_getFounderIbd(SEXP founderSEXP, SEXP nChrSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const arma::field<arma::ivec>& >::type founder(founderSEXP);
Rcpp::traits::input_parameter< arma::uword >::type nChr(nChrSEXP);
rcpp_result_gen = Rcpp::wrap(getFounderIbd(founder, nChr));
return rcpp_result_gen;
END_RCPP
}
// createIbdMat
arma::Mat<int> createIbdMat(arma::field<arma::field<arma::field<arma::Mat<int> > > >& ibd, arma::uvec chr, arma::uvec nLoci, arma::uword ploidy, arma::uword nThreads);
RcppExport SEXP _AlphaSimR_createIbdMat(SEXP ibdSEXP, SEXP chrSEXP, SEXP nLociSEXP, SEXP ploidySEXP, SEXP nThreadsSEXP) {
Expand Down Expand Up @@ -839,8 +839,8 @@ static const R_CallMethodDef CallEntries[] = {
{"_AlphaSimR_calcChrFreq", (DL_FUNC) &_AlphaSimR_calcChrFreq, 1},
{"_AlphaSimR_getGv", (DL_FUNC) &_AlphaSimR_getGv, 3},
{"_AlphaSimR_getHybridGv", (DL_FUNC) &_AlphaSimR_getHybridGv, 6},
{"_AlphaSimR_getFounderIbd", (DL_FUNC) &_AlphaSimR_getFounderIbd, 2},
{"_AlphaSimR_getNonFounderIbd", (DL_FUNC) &_AlphaSimR_getNonFounderIbd, 3},
{"_AlphaSimR_getFounderIbd", (DL_FUNC) &_AlphaSimR_getFounderIbd, 2},
{"_AlphaSimR_createIbdMat", (DL_FUNC) &_AlphaSimR_createIbdMat, 5},
{"_AlphaSimR_cross", (DL_FUNC) &_AlphaSimR_cross, 15},
{"_AlphaSimR_createDH2", (DL_FUNC) &_AlphaSimR_createDH2, 7},
Expand Down
Loading

0 comments on commit 695aef0

Please sign in to comment.