Skip to content

Commit

Permalink
fix notes
Browse files Browse the repository at this point in the history
  • Loading branch information
KlausVigo committed Aug 27, 2024
1 parent 6ab3adc commit 3b440d0
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 10 deletions.
10 changes: 8 additions & 2 deletions R/ancestral.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
## returned.
#' @author Klaus Schliep \email{klaus.schliep@@gmail.com}
#' @seealso \code{\link{pml}}, \code{\link{parsimony}}, \code{\link[ape]{ace}},
#' \code{\link{plotAnc}}, \code{\link{ltg2amb}}, \code{\link{latag2n}},
#' \code{\link{plotAnc}}, \code{\link{ltg2amb}}, \code{\link[ape]{latag2n}},
#' \code{\link{gap_as_state}}, \code{\link[ape]{root}},
#' \code{\link[ape]{makeNodeLabel}}
#' @references Felsenstein, J. (2004). \emph{Inferring Phylogenies}. Sinauer
Expand Down Expand Up @@ -107,6 +107,9 @@ ancestral.pml <- function(object, type = "marginal", ...) {
tree$node.label <- node_label
tmp <- length(data)

joint <- TRUE
if(length(w) > 1 || object$inv > 0) joint <- FALSE

eig <- object$eig

bf <- object$bf
Expand Down Expand Up @@ -165,12 +168,15 @@ ancestral.pml <- function(object, type = "marginal", ...) {
result2[[k]][ind] <- data[[1]][ind]
}
}
result3 <- NULL
if(joint) result3 <- joint_pml(object)
attrib$names <- node_label
attributes(result2) <- attrib
attributes(result) <- attrib
result <- list2df_ancestral(result, result2)
result2 <- compress.phyDat(result2)
erg <- list(tree=tree, data=data, prob=result, state=result2)
erg <- list(tree=tree, data=data, prob=result, state=result2,
joint_state = result3)
class(erg) <- "ancestral"
erg
}
Expand Down
7 changes: 4 additions & 3 deletions R/draw_CI.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ edge_length_matrix <- function(tree, trees, rooted=TRUE){
##' add_edge_length(bs)
##' plot(tree_compat)
##' add_boxplot(tree_compat, bs, boxwex=.7)
##' @seealso \code{\link{node.depth.edgelength}}, \code{\link{consensus}},
##' \code{\link{maxCladeCred}}, \code{\link{add_boxplot}}
##' @seealso \code{\link[ape::node.depth]{node.depth.edgelength}},
##' \code{\link[ape]{consensus}}, \code{\link{maxCladeCred}},
##' \code{\link{add_boxplot}}
##' @keywords aplot
##' @export
add_edge_length <- function(tree, trees, fun=\(x)median(na.omit(x)),
Expand Down Expand Up @@ -109,7 +110,7 @@ add_edge_length <- function(tree, trees, fun=\(x)median(na.omit(x)),
##' add_ci(tree, trees)
##' plot(tree, direction="downwards")
##' add_boxplot(tree, trees, boxwex=.7)
##' @seealso \code{\link{plot.phylo}}, \code{\link{plotBS}},
##' @seealso \code{\link[ape]{plot.phylo}}, \code{\link{plotBS}},
##' \code{\link{add_edge_length}}, \code{\link{maxCladeCred}}
##' @keywords aplot
##' @rdname add_ci
Expand Down
27 changes: 26 additions & 1 deletion R/phyDat_conversion.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#' @author Klaus Schliep \email{klaus.schliep@@gmail.com}
#' @seealso [DNAbin()], [as.DNAbin()],
#' \code{\link{baseFreq}}, \code{\link{glance.phyDat}},
#' \code{\link{read.dna}}, \code{\link{read.nexus.data}}
#' \code{\link[ape]{read.dna}}, \code{\link[ape]{read.nexus.data}}
#' and the chapter 1 in the \code{vignette("phangorn-specials",
#' package="phangorn")} and the example of \code{\link{pmlMix}} for the use of
#' \code{allSitePattern}
Expand Down Expand Up @@ -158,6 +158,31 @@ as.phyDat.DNAStringSet <- function(x, ...){
}


# @rdname phyDat
#' @export
as.StringSet <- function (x, ...){
if (inherits(x, "StringSet")) return(x)
UseMethod("as.StringSet")
}



#' @rdname as.phyDat
#' @export
as.StringSet.phyDat <- function(x, ...){
if (requireNamespace("Biostrings")){
z <- as.character(x)
type <- attr(x, "type")
seq <- switch(type,
DNA = tolower(apply(z, 1, paste, collapse="")),
AA = toupper(apply(z, 1, paste, collapse="")))
if(type=="DNA") return(Biostrings::DNAStringSet(seq))
if(type=="AA") return(Biostrings::AAStringSet(seq))
}
return(NULL)
}


# @rdname phyDat
#' @export
as.MultipleAlignment <- function (x, ...){
Expand Down
2 changes: 1 addition & 1 deletion R/splits.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#' two splits are incompatible.
#' @note The internal representation is likely to change.
#' @author Klaus Schliep \email{klaus.schliep@@gmail.com}
#' @seealso \code{\link{prop.part}}, \code{\link{lento}},
#' @seealso \code{\link[ape]{prop.part}}, \code{\link{lento}},
#' \code{\link{as.networx}}, \code{\link{distanceHadamard}},
#' \code{\link{read.nexus.splits}}
#' @keywords cluster
Expand Down
2 changes: 1 addition & 1 deletion R/treeManipulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ addOneTree <- function(tree, subtree, i, node) {
#' @param edge.length optional numeric vector with edge length
#' @return an object of class phylo
#' @author Klaus Schliep \email{klaus.schliep@@gmail.com}
#' @seealso \code{\link{bind.tree}}
#' @seealso \code{\link[ape]{bind.tree}}
#' @keywords cluster
#' @examples
#' tree <- rcoal(10)
Expand Down
2 changes: 1 addition & 1 deletion man/ancestral.pml.Rd

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

5 changes: 4 additions & 1 deletion man/as.phyDat.Rd

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

0 comments on commit 3b440d0

Please sign in to comment.