Improved function behavior on empty matrices

This commit is contained in:
Waldir Leoncio 2020-02-25 14:28:39 +01:00
parent 8323d54c01
commit 37822b2ec8

View file

@ -6,7 +6,7 @@
#' @param SUMCOUNTS sumcounts
#' @export
computeAllFreqs2 <- function (noalle, COUNTS = matrix(NA, 0, 0),
SUMCOUNTS = sum(COUNTS)) {
SUMCOUNTS = NA) {
max_noalle <- size(COUNTS, 1)
nloci <- size(COUNTS,2)
@ -17,8 +17,10 @@ computeAllFreqs2 <- function (noalle, COUNTS = matrix(NA, 0, 0),
sumCounts <- repmat(sumCounts, c(max_noalle, 1, 1))
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, c(1, 1, npops))
counts <- COUNTS + prioriAlleelit