X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=R%2FplotPhyloCoor.R;h=654288b645423241cbdd080b811a8227bb50e4b7;hb=c488b74490ee3d9d200de0e471881f002a18fe4f;hp=8ede4df55bf89aaa871b4b6eca72011658347761;hpb=d9c8f411a20ef829c9c332aacc5e245b11162d93;p=ape.git diff --git a/R/plotPhyloCoor.R b/R/plotPhyloCoor.R index 8ede4df..654288b 100644 --- a/R/plotPhyloCoor.R +++ b/R/plotPhyloCoor.R @@ -1,15 +1,15 @@ -## plotPhyloCoor.R (2008-04-30) +## plotPhyloCoor.R (2013-03-30) ## Coordinates of a Tree Plot -## Copyright 2008 Damien de Vienne +## Copyright 2008 Damien de Vienne, 2013 Klaus Schliep ## This file is part of the R-package `ape'. ## See the file ../COPYING for licensing issues. plotPhyloCoor <- function (x, type = "phylogram", use.edge.length = TRUE, node.pos = NULL, - direction = "rightwards", ...) + direction = "rightwards", tip.order = NULL, ...) { Ntip <- length(x$tip.label) if (Ntip == 1) @@ -22,17 +22,21 @@ plotPhyloCoor <- phyloORclado <- type %in% c("phylogram", "cladogram") horizontal <- direction %in% c("rightwards", "leftwards") if (phyloORclado) { - if (!is.null(attr(x, "order"))) - if (attr(x, "order") == "pruningwise") - x <- reorder(x) + ## changed by KS: yy <- numeric(Ntip + Nnode) - TIPS <- x$edge[x$edge[, 2] <= Ntip, 2] - yy[TIPS] <- 1:Ntip - + if (!is.null(tip.order)) { + yy[tip.order] <- 1:length(tip.order) + } else { + x <- reorder(x) + TIPS <- x$edge[x$edge[, 2] <= Ntip, 2] + yy[TIPS] <- 1:Ntip + } } xe <- x$edge - x <- reorder(x, order = "pruningwise") + ## first reorder the tree in cladewise order to avoid cophyloplot() hanging: + ## x <- reorder(reorder(x), order = "pruningwise") ... maybe not needed anymore (EP) + x <- reorder(x, order = "postorder") ereorder <- match(x$edge[, 2], xe[, 2]) if (phyloORclado) {