Fixed syntax
This commit is contained in:
parent
bdf512fca7
commit
c0d36e2c30
3 changed files with 16 additions and 7 deletions
|
|
@ -6,7 +6,7 @@ computeDiffInCounts <- function(rows, max_noalle, nloci, data) {
|
||||||
diffInCounts <- zeros(max_noalle, nloci)
|
diffInCounts <- zeros(max_noalle, nloci)
|
||||||
for (i in rows) {
|
for (i in rows) {
|
||||||
row <- data[i, ]
|
row <- data[i, ]
|
||||||
notEmpty <- find(row>=0)
|
notEmpty <- as.matrix(find(row>=0))
|
||||||
|
|
||||||
if (length(notEmpty) > 0) {
|
if (length(notEmpty) > 0) {
|
||||||
diffInCounts[row(notEmpty) + (notEmpty - 1) * max_noalle] <-
|
diffInCounts[row(notEmpty) + (notEmpty - 1) * max_noalle] <-
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,26 @@
|
||||||
computePopulationLogml <- function(pops, adjprior, priorTerm) {
|
computePopulationLogml <- function(pops, adjprior, priorTerm = 0) {
|
||||||
# Palauttaa length(pops)*1 taulukon, jossa on laskettu korikohtaiset
|
# Palauttaa length(pops)*1 taulukon, jossa on laskettu korikohtaiset
|
||||||
|
|
||||||
|
# ======================================================== #
|
||||||
|
# Limiting COUNTS size #
|
||||||
|
# ======================================================== #
|
||||||
|
COUNTS <- COUNTS[seq_len(nrow(adjprior)), seq_len(ncol(adjprior)), pops, drop=FALSE]
|
||||||
|
|
||||||
x <- size(COUNTS, 1)
|
x <- size(COUNTS, 1)
|
||||||
y <- size(COUNTS, 2)
|
y <- size(COUNTS, 2)
|
||||||
z <- length(pops)
|
z <- length(pops)
|
||||||
|
|
||||||
popLogml <- squeeze(
|
# ======================================================== #
|
||||||
|
# Computation #
|
||||||
|
# ======================================================== #
|
||||||
|
term1 <- squeeze(
|
||||||
# FIXME: assumes COUNTS has 3 dims. Where does this come from?
|
# FIXME: assumes COUNTS has 3 dims. Where does this come from?
|
||||||
sum(
|
sum(
|
||||||
sum(
|
sum(
|
||||||
reshape(
|
reshape(
|
||||||
lgamma(
|
lgamma(
|
||||||
repmat(adjprior, c(1, 1, length(pops))) +
|
repmat(adjprior, c(1, 1, length(pops))) +
|
||||||
COUNTS[, , pops]
|
COUNTS[seq_len(nrow(adjprior)), seq_len(ncol(adjprior)), pops, drop=FALSE]
|
||||||
),
|
),
|
||||||
c(x, y, z)
|
c(x, y, z)
|
||||||
),
|
),
|
||||||
|
|
@ -20,6 +28,7 @@ computePopulationLogml <- function(pops, adjprior, priorTerm) {
|
||||||
),
|
),
|
||||||
2
|
2
|
||||||
)
|
)
|
||||||
) - sum(lgamma(1 + SUMCOUNTS[pops, ]), 2) - priorTerm
|
)
|
||||||
|
popLogml <- term1 - sum(lgamma(1 + SUMCOUNTS[pops, ]), 2) - priorTerm
|
||||||
return(popLogml)
|
return(popLogml)
|
||||||
}
|
}
|
||||||
|
|
@ -137,11 +137,11 @@ indMix <- function(c, npops, dispText) {
|
||||||
round <- roundTypes[n]
|
round <- roundTypes[n]
|
||||||
kivaluku <- 0
|
kivaluku <- 0
|
||||||
|
|
||||||
if (kokeiltu(round) == 1) { #Askelta kokeiltu viime muutoksen j<>lkeen
|
if (kokeiltu[round] == 1) { #Askelta kokeiltu viime muutoksen j<>lkeen
|
||||||
|
|
||||||
} else if (round == 0 | round == 1) { #Yksil<69>n siirt<72>minen toiseen populaatioon.
|
} else if (round == 0 | round == 1) { #Yksil<69>n siirt<72>minen toiseen populaatioon.
|
||||||
inds <- 1:ninds
|
inds <- 1:ninds
|
||||||
aputaulu <- c(t(inds), rand(ninds, 1))
|
aputaulu <- cbind(inds, rand(ninds, 1))
|
||||||
aputaulu <- sortrows(aputaulu, 2)
|
aputaulu <- sortrows(aputaulu, 2)
|
||||||
inds <- t(aputaulu[, 1])
|
inds <- t(aputaulu[, 1])
|
||||||
muutosNyt <- 0
|
muutosNyt <- 0
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue