diff --git a/DESCRIPTION b/DESCRIPTION index bb491891..38324bb4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -8,6 +8,8 @@ Authors@R: c( person("Justin", "Silverman", email = "jsilve24@gmail.com", rol = "ctb", comment = "geom_balance"), person("Casey", "Dunn", email = "casey_dunn@brown.edu", rol = "ctb", comment = "NHX") + person("Bradley", "Jones", email = "brj1@sfu.ca", rol = "ctb", + comment = "get.tree method for data.frame") ) Maintainer: Guangchuang Yu Description: 'ggtree' extends the 'ggplot2' plotting system which implemented the grammar of graphics. diff --git a/R/method-get-tree.R b/R/method-get-tree.R index fcd64eec..8028b29d 100644 --- a/R/method-get-tree.R +++ b/R/method-get-tree.R @@ -70,9 +70,9 @@ setMethod("get.tree", signature(object="phylo"), ##' @exportMethod get.tree setMethod("get.tree", signature(object="data.frame"), function(object, ...) { - edge <- object[, c("parent", "node")] - edge <- edge[edge[,1] != 0 & edge[,1] != edge[,2], ] - edge.length <- object[, "branch.length"] + i <- which(edge[,1] != 0 & edge[,1] != edge[,2]) + edge <- edge[i, ] + edge.length <- object[i, "branch.length"] tip.label <- object[object[, "isTip"], "label"] phylo <- list(edge = edge, edge.length = edge.length,