Skip to content

Commit

Permalink
small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
KlausVigo committed Nov 22, 2024
1 parent 7e27429 commit 751a8c3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export(read.nexus.partitions)
export(read.nexus.splits)
export(read.phyDat)
export(readDist)
export(relabel)
export(removeAmbiguousSites)
export(removeTrivialSplits)
export(removeUndeterminedSites)
Expand Down
8 changes: 4 additions & 4 deletions R/ancestral.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ ancestral.pml <- function(object, type = "marginal", return = "prob", ...) {
#' @rdname ancestral.pml
#' @export
anc_pml <- function(object, type = "marginal", ...) {
ancestral.pml(object, type=type, return="ancestral")
call <- c(object$call, match.call())
res <- ancestral.pml(object, type=type, return="ancestral")
res$call <- call
res
}





fitchCoding2ambiguous <- function(x, type = "DNA") {
y <- c(1L, 2L, 4L, 8L, 8L, 3L, 5L, 9L, 6L, 10L, 12L, 7L, 11L, 13L,
14L, 15L, 15L, 15L)
Expand Down
14 changes: 8 additions & 6 deletions R/phylo.R
Original file line number Diff line number Diff line change
Expand Up @@ -2511,7 +2511,7 @@ optim.pml <- function(object, optNni = FALSE, optBf = FALSE, optQ = FALSE,
eig = eig, bf = bf, inv=inv,
rate=rate, ll.0 = ll.0, INV = INV, llMix = llMix,
wMix=wMix, ASC=ASC,
control=list(eps=1e-08, maxit=3, trace=trace-1,
control=list(eps=1e-08, maxit=3, trace=0,
tau=tau))
fbs[[i]] <- tree2
} else if(rearrangement == "multi2di"){
Expand All @@ -2532,33 +2532,35 @@ optim.pml <- function(object, optNni = FALSE, optBf = FALSE, optQ = FALSE,
inv=inv, rate=rate, ll.0=ll.0, llMix = llMix, wMix=wMix,
ASC=ASC,
control = pml.control(epsilon = 1e-08, maxit = 10,
trace = trace-1L, tau = tau))
trace = 0, tau = tau))
ll2 <- res[[2]]
tree2 <- res[[1]]
swap <- 1
# ll2 <- pml.fit(tree2, data, bf, shape = shape, k = k, Q = Q,
# levels = attr(data, "levels"), inv = inv, rate = rate,
# g = g, w = w, eig = eig, INV = INV, ll.0 = ll.0,
# llMix = llMix, wMix = wMix, site = FALSE, Mkv=Mkv)
res <- opt_nni(tree2, data, rooted=optRooted, iter_max=25, trace=trace,
res <- opt_nni(tree2, data, rooted=optRooted, iter_max=25, trace=0,
ll=ll2, w = w, g = g, eig = eig, bf = bf, inv=inv,
rate=rate, ll.0 = ll.0, INV = INV, llMix = llMix,
wMix=wMix, ASC=ASC, RELL=RELL,
control=list(eps=1e-08, maxit=3, trace=trace-1, tau=tau))
control=list(eps=1e-08, maxit=3, trace=0, tau=tau))
if (res$logLik > (ll + epsR)) {
tree <- res$tree
ll <- res$logLik
kmax <- 1
}
else kmax <- kmax + 1
if(!is.null(RELL)) RELL <- res$RELL
if (trace > 0) cat("Ratchet iteration ", i, ", best pscore so far:", ll,
"\n")
if (trace > 0) cat("\rRatchet iteration ", i, ", best pscore so far:", ll) # "\n")
if ( (kmax >= maxR) && (i >= minit)) break()
}
optNni <- TRUE
perturbation <- FALSE
rounds <- 1

# cat("\rIteration: ", i, ". Best parsimony score so far: ", mp, sep="")
if (trace >= 0)cat("\n")
}
if ( perturbation==FALSE &&
((abs((ll1 - ll) / ll) < control$eps) || rounds > control$maxit)){
Expand Down
2 changes: 2 additions & 0 deletions R/treeManipulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,8 @@ mrca2 <- function(phy, full = FALSE) {
}


#' @rdname phangorn-internal
#' @export
relabel <- function(y, ref) {
label <- y$tip.label
if (identical(label, ref)) return(y)
Expand Down
5 changes: 4 additions & 1 deletion man/phangorn-internal.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 751a8c3

Please sign in to comment.