Adjusted behavior to benchmark
This commit is contained in:
parent
c9c9b7cb26
commit
f6768c67bc
3 changed files with 22 additions and 8 deletions
|
|
@ -5,23 +5,27 @@
|
|||
#' @param COUNTS COUNTS
|
||||
#' @export
|
||||
|
||||
simulateAllFreqs <- function(noalle, COUNTS = matrix(0)) {
|
||||
simulateAllFreqs <- function(noalle, COUNTS = matrix(NA, 0, 0)) {
|
||||
max_noalle <- size(COUNTS, 1)
|
||||
nloci <- size(COUNTS, 2)
|
||||
npops <- size(COUNTS, 3)
|
||||
|
||||
prioriAlleelit <- zeros(max_noalle, nloci)
|
||||
for (j in 1:nloci) {
|
||||
prioriAlleelit[1:noalle[j], j] <- 1 / noalle[j]
|
||||
if (nloci > 0) {
|
||||
for (j in 1:nloci) {
|
||||
prioriAlleelit[1:noalle[j], j] <- 1 / noalle[j]
|
||||
}
|
||||
}
|
||||
prioriAlleelit <- repmat(prioriAlleelit, matrix(c(1, 1, npops), ncol = 1))
|
||||
prioriAlleelit <- repmat(prioriAlleelit, matrix(c(1, 1, npops), 1))
|
||||
counts <- COUNTS + prioriAlleelit
|
||||
allfreqs <- zeros(size(counts))
|
||||
|
||||
for (i in 1:npops) {
|
||||
for (j in 1:nloci) {
|
||||
simuloidut <- randdir(counts[1:noalle[j], j, i] , noalle[j])
|
||||
allfreqs[1:noalle[j], j, i] <- simuloidut
|
||||
if (nloci > 0) {
|
||||
for (j in 1:nloci) {
|
||||
simuloidut <- randdir(counts[1:noalle[j], j, i] , noalle[j])
|
||||
allfreqs[1:noalle[j], j, i] <- simuloidut
|
||||
}
|
||||
}
|
||||
}
|
||||
return(allfreqs)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
\alias{simulateAllFreqs}
|
||||
\title{Simulate All Frequencies}
|
||||
\usage{
|
||||
simulateAllFreqs(noalle, COUNTS = matrix(0))
|
||||
simulateAllFreqs(noalle, COUNTS = matrix())
|
||||
}
|
||||
\arguments{
|
||||
\item{noalle}{noalle}
|
||||
|
|
|
|||
|
|
@ -212,3 +212,13 @@ test_that("simulateIndividuals works like on Matlab", {
|
|||
expected = 6
|
||||
)
|
||||
})
|
||||
|
||||
test_that("simulateAllFreqs works as expected", {
|
||||
empty_mt <- matrix(NA, 0, 0)
|
||||
expect_equivalent(suppressWarnings(simulateAllFreqs(3)), empty_mt)
|
||||
expect_equivalent(suppressWarnings(simulateAllFreqs(3:5)), empty_mt)
|
||||
expect_equivalent(
|
||||
object = suppressWarnings(simulateAllFreqs(matrix(1:4, 2))),
|
||||
expected = empty_mt
|
||||
)
|
||||
})
|
||||
Loading…
Add table
Reference in a new issue