Skip to content

Commit

Permalink
leave arguments of pratchet the same
Browse files Browse the repository at this point in the history
  • Loading branch information
KlausVigo committed Feb 19, 2019
1 parent c17898e commit 05db2a8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
49 changes: 26 additions & 23 deletions R/parsimony.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ sankoff.quartet <- function(dat, cost, p, l, weight) {
#' @param all return all equally good trees or just one of them.
#' @param perturbation whether to use "ratchet", "random_addition" or
#' "stochastic" (nni) for shuffling the tree.
#' @param return return only best tree(s) or trees from each run.

#' @param ... Further arguments passed to or from other methods (e.g.
#' model="sankoff" and cost matrix).
#' @return \code{parsimony} returns the maximum parsimony score (pscore).
Expand Down Expand Up @@ -491,20 +491,23 @@ optim.parsimony <- function(tree, data, method = "fitch", cost = NULL,
}


## @param return return only best tree(s) or trees from each run.

#' @rdname parsimony
#' @export
# perturbation="ratchet", "stochastic"
pratchet <- function(data, start = NULL, method = "fitch", maxit = 1000,
minit = 10, k = 10, trace = 1, all = FALSE,
rearrangements = "SPR", perturbation = "ratchet",
return="single", ...) {
rearrangements = "SPR", perturbation = "ratchet", ...) {
search_history <- c(FALSE, FALSE)
if (return=="single") all <- FALSE
if(return=="best") all <- TRUE
if(return=="all" | return=="history"){
all <- TRUE
search_history <- c(TRUE, TRUE)
}
# search_history <- c(FALSE, FALSE)
# return="single",
# if (return=="single") all <- FALSE
# if(return=="best") all <- TRUE
# if(return=="all" | return=="history"){
# all <- TRUE
# search_history <- c(TRUE, TRUE)
#}
# c("single", "best", "all", "history") needs better names

eps <- 1e-08
Expand Down Expand Up @@ -559,20 +562,20 @@ pratchet <- function(data, start = NULL, method = "fitch", maxit = 1000,
if (!all) result <- tree
else class(result) <- "multiPhylo"
if (length(result) == 1) result <- result[[1]]
if(return=="all"){
all <- FALSE
class(search_trees) <- "multiPhylo"
search_trees <- .compressTipLabel(search_trees)
result <- search_trees
}
if (return=="history"){
class(start_trees) <- "multiPhylo"
class(search_trees) <- "multiPhylo"
start_trees <- .compressTipLabel(start_trees)
search_trees <- .compressTipLabel(search_trees)
result <- list(best = result,
start_trees = start_trees, search_trees = search_trees)
}
# if(return=="all"){
# all <- FALSE
# class(search_trees) <- "multiPhylo"
# search_trees <- .compressTipLabel(search_trees)
# result <- search_trees
# }
# if (return=="history"){
# class(start_trees) <- "multiPhylo"
# class(search_trees) <- "multiPhylo"
# start_trees <- .compressTipLabel(start_trees)
# search_trees <- .compressTipLabel(search_trees)
# result <- list(best = result,
# start_trees = start_trees, search_trees = search_trees)
# }
return(result)
})
kmax <- 1
Expand Down
5 changes: 1 addition & 4 deletions man/parsimony.Rd

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

0 comments on commit 05db2a8

Please sign in to comment.