Skip to content

Commit

Permalink
Use the initial prior likelihoods to estimate the parameters of chrom…
Browse files Browse the repository at this point in the history
…atin state component
  • Loading branch information
Aleksander Jankowski committed Jul 29, 2016
1 parent b20b66f commit 05037d9
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions R/fitRomulus.R
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,14 @@ fitRomulus <- function(cuts1, cuts2, anno, priors, bins1, bins2, nbound = NA,
}
stopifnot(nrow(PriorLik) == nrow(anno))
stopifnot(ncol(PriorLik) == nbound)

PriorLogLik <- log(PriorLik)
PriorProbUnbound <- 1 / (1 + apply(PriorLik, 1, sum))
PriorProb <- cbind(PriorLik * PriorProbUnbound, PriorProbUnbound, deparse.level = 0)

# only for the first iteration
PostProb <- PriorProb
OldPostProb <- NA

Beta <- list()
for (k in 1:nbound)
Expand Down Expand Up @@ -226,15 +233,6 @@ fitRomulus <- function(cuts1, cuts2, anno, priors, bins1, bins2, nbound = NA,
extcols <- lapply(cols, function(v) v[colsel])
}

PriorLogLik <- sapply(1:nbound, function(k) extanno[, extcols[[k]], drop = F] %*% Beta[[k]])
PriorLik <- exp(PriorLogLik)
PriorProbUnbound <- 1 / (1 + apply(PriorLik, 1, sum))
PriorProb <- cbind(PriorLik * PriorProbUnbound, PriorProbUnbound, deparse.level = 0)

# only for the first iteration
PostProb <- PriorProb
OldPostProb <- NA


for (iter in 1:maxIter)
{
Expand Down

0 comments on commit 05037d9

Please sign in to comment.