Skip to content

Commit

Permalink
Merge pull request #237 from KlausVigo/main
Browse files Browse the repository at this point in the history
remove phangorn dependency and add upgma
  • Loading branch information
zkamvar authored Feb 12, 2021
2 parents 83715cd + 1fc32e7 commit 3500679
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 9 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ Imports:
utils,
vegan,
ggplot2,
phangorn,
ape (>= 3.1-1),
igraph (>= 1.0.0),
methods,
Expand Down
6 changes: 4 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export(rrmlg)
export(samp.ia)
export(shufflepop)
export(test_replen)
export(upgma)
export(visible)
export(win.ia)
exportClasses(MLG)
Expand All @@ -123,6 +124,8 @@ importFrom(ade4,is.euclid)
importFrom(ade4,lingoes)
importFrom(ade4,quasieuclid)
importFrom(ape,add.scale.bar)
importFrom(ape,as.phylo)
importFrom(ape,as.phylo.hclust)
importFrom(ape,axisPhylo)
importFrom(ape,boot.phylo)
importFrom(ape,is.ultrametric)
Expand Down Expand Up @@ -172,8 +175,6 @@ importFrom(igraph,print.igraph)
importFrom(magrittr,"%>%")
importFrom(pegas,as.loci)
importFrom(pegas,loci2genind)
importFrom(phangorn,midpoint)
importFrom(phangorn,upgma)
importFrom(polysat,Genotypes)
importFrom(polysat,Missing)
importFrom(polysat,Ploidies)
Expand All @@ -185,6 +186,7 @@ importFrom(stats,as.formula)
importFrom(stats,dbinom)
importFrom(stats,df)
importFrom(stats,dist)
importFrom(stats,hclust)
importFrom(stats,median)
importFrom(stats,printCoefmat)
importFrom(stats,quantile)
Expand Down
5 changes: 2 additions & 3 deletions R/bruvo.r
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ bruvo.between <- function(query, ref, replen = 1, add = TRUE, loss = TRUE, by_lo
#' desired.
#'
#' @param tree any function that can generate a tree from a distance matrix.
#' Default is \code{\link[phangorn]{upgma}}.
#' Default is \code{\link{upgma}}.
#'
#' @param showtree \code{logical} if \code{TRUE}, a tree will be plotted with
#' nodelabels.
Expand Down Expand Up @@ -331,7 +331,7 @@ bruvo.between <- function(query, ref, replen = 1, add = TRUE, loss = TRUE, by_lo
#' replacement, recalculate the tree, and tally up the bootstrap support
#' (measured in percent success). While this function can take any tree
#' function, it has native support for two algorithms: \code{\link[ape]{nj}}
#' and \code{\link[phangorn]{upgma}}. If you want to use any other functions,
#' and \code{\link{upgma}}. If you want to use any other functions,
#' you must load the package before you use them (see examples).
#'
#' @note \strong{Please refer to the documentation for bruvo.dist for details on
Expand Down Expand Up @@ -383,7 +383,6 @@ bruvo.between <- function(query, ref, replen = 1, add = TRUE, loss = TRUE, by_lo
#' }
#'
#==============================================================================#
#' @importFrom phangorn upgma midpoint
#' @importFrom ape nodelabels nj boot.phylo plot.phylo axisPhylo ladderize
#' @importFrom ape add.scale.bar nodelabels tiplabels is.ultrametric
# / \
Expand Down
22 changes: 22 additions & 0 deletions R/upgma.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#' UPGMA
#'
#' UPGMA clustering. Just a wrapper function around \code{\link[stats]{hclust}}.
#'
#' @param d A distance matrix.
#' @return A phylogenetic tree of class \code{phylo}.
#' @author Klaus Schliep \email{klaus.schliep@@gmail.com}
#' @seealso \code{\link{hclust}}, \code{\link{as.phylo}}
#' @importFrom ape as.phylo.hclust as.phylo
#' @importFrom stats hclust as.dist
#' @keywords cluster
#' @examples
#'
#' library(ape)
#' data(woodmouse)
#' dm <- dist.dna(woodmouse)
#' tree <- upgma(dm)
#' plot(tree)
#'
#' @rdname upgma
#' @export
"upgma" <- function(d) as.phylo(hclust(as.dist(d), method = "average"))
4 changes: 2 additions & 2 deletions man/bruvo.boot.Rd

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

33 changes: 33 additions & 0 deletions man/upgma.Rd

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

1 change: 0 additions & 1 deletion vignettes/mlg.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ them as different. If we calculate the pairwise euclidean distances between
samples, we see that "new", "mut" and, "C" are very similar to each other:

```{r, fig.width = 5, fig.height = 5}
library("phangorn")
library("ape")
raw_dist <- function(x){
dist(genind2df(x, usepop = FALSE))
Expand Down

0 comments on commit 3500679

Please sign in to comment.