Improved function behavior on empty matrices
This commit is contained in:
parent
8323d54c01
commit
37822b2ec8
1 changed files with 5 additions and 3 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
#' @param SUMCOUNTS sumcounts
|
#' @param SUMCOUNTS sumcounts
|
||||||
#' @export
|
#' @export
|
||||||
computeAllFreqs2 <- function (noalle, COUNTS = matrix(NA, 0, 0),
|
computeAllFreqs2 <- function (noalle, COUNTS = matrix(NA, 0, 0),
|
||||||
SUMCOUNTS = sum(COUNTS)) {
|
SUMCOUNTS = NA) {
|
||||||
|
|
||||||
max_noalle <- size(COUNTS, 1)
|
max_noalle <- size(COUNTS, 1)
|
||||||
nloci <- size(COUNTS,2)
|
nloci <- size(COUNTS,2)
|
||||||
|
|
@ -17,8 +17,10 @@ computeAllFreqs2 <- function (noalle, COUNTS = matrix(NA, 0, 0),
|
||||||
sumCounts <- repmat(sumCounts, c(max_noalle, 1, 1))
|
sumCounts <- repmat(sumCounts, c(max_noalle, 1, 1))
|
||||||
|
|
||||||
prioriAlleelit <- zeros(max_noalle, nloci)
|
prioriAlleelit <- zeros(max_noalle, nloci)
|
||||||
for (j in 1:nloci) {
|
if (nloci > 0) {
|
||||||
prioriAlleelit[1:noalle[j], j] <- 1 / noalle[j]
|
for (j in 1:nloci) {
|
||||||
|
prioriAlleelit[1:noalle[j], j] <- 1 / noalle[j]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
prioriAlleelit <- repmat(prioriAlleelit, c(1, 1, npops))
|
prioriAlleelit <- repmat(prioriAlleelit, c(1, 1, npops))
|
||||||
counts <- COUNTS + prioriAlleelit
|
counts <- COUNTS + prioriAlleelit
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue