From dd6a471eb1c239c03a082a67573603a20e5256ad Mon Sep 17 00:00:00 2001 From: paradis Date: Tue, 8 Jul 2008 04:03:24 +0000 Subject: [PATCH] various corrections git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@40 6e262413-ae40-0410-9e79-b911bd7a66b7 --- Changes | 6 +++++- R/{plot.cophylo.R => cophyloplot.R} | 18 +++++++++--------- R/makeLabel.R | 4 ++-- R/read.nexus.R | 4 ++-- man/bind.tree.Rd | 2 +- man/consensus.Rd | 2 +- man/{plot.cophylo.Rd => cophyloplot.Rd} | 19 ++++++++++--------- man/makeLabel.Rd | 5 +++++ 8 files changed, 35 insertions(+), 25 deletions(-) rename R/{plot.cophylo.R => cophyloplot.R} (93%) rename man/{plot.cophylo.Rd => cophyloplot.Rd} (87%) diff --git a/Changes b/Changes index c831e78..86d0131 100644 --- a/Changes +++ b/Changes @@ -24,7 +24,11 @@ BUG FIXES o collapsed.singles() did not propagate the 'Nnode' and 'node.labels' elements (thanks to Elizabeth Purdom for the fix). - o read.nexus failed to remove correctly the comments within trees. + o read.nexus() failed to remove correctly the comments within + trees. + + o read.nexus() failed to read a file with a single tree and no + translation of tip labels. OTHER CHANGES diff --git a/R/plot.cophylo.R b/R/cophyloplot.R similarity index 93% rename from R/plot.cophylo.R rename to R/cophyloplot.R index 6625473..3bb3702 100644 --- a/R/plot.cophylo.R +++ b/R/cophyloplot.R @@ -1,4 +1,4 @@ -## plot.cophylo.R (2008-04-14) +## cophyloplot.R (2008-07-08) ## Plots two phylogenetic trees face to ## face with the links between the tips @@ -8,7 +8,7 @@ ## This file is part of the R-package `ape'. ## See the file ../COPYING for licensing issues. -plot.cophylo <- +cophyloplot <- function (x, y, assoc = NULL, use.edge.length = FALSE, space = 0, length.line = 1, gap = 2, type = "phylogram", rotate = FALSE, col = "red", show.tip.label = TRUE, @@ -21,7 +21,7 @@ plot.cophylo <- if (rotate == TRUE) { cat("\n Click on a node to rotate (right click to exit)\n\n") repeat { - res <- plot.cophylo2(x, y, assoc = assoc, use.edge.length = use.edge.length, + res <- plotCophylo2(x, y, assoc = assoc, use.edge.length = use.edge.length, space = space, length.line = length.line, gap = gap, type = type, return = TRUE, col = col, show.tip.label = show.tip.label, font = font) @@ -34,20 +34,20 @@ plot.cophylo <- if (click > length(res$a[, 1]) + res$N.tip.y) y <- rotate(y, click - length(res$a[, 1])) } - plot.cophylo2(x, y, assoc = assoc, use.edge.length = use.edge.length, + plotCophylo2(x, y, assoc = assoc, use.edge.length = use.edge.length, space = space, length.line = length.line, gap = gap, type = type, return = TRUE, col = col, show.tip.label = show.tip.label, font = font) } on.exit(print("done")) } - else plot.cophylo2(x, y, assoc = assoc, use.edge.length = use.edge.length, + else plotCophylo2(x, y, assoc = assoc, use.edge.length = use.edge.length, space = space, length.line = length.line, gap = gap, type = type, return = FALSE, col = col, show.tip.label = show.tip.label, font = font) } -plot.cophylo2 <- +plotCophylo2 <- function (x, y, assoc = assoc, use.edge.length = use.edge.length, space = space, length.line = length.line, gap = gap, type = type, return = return, col = col, @@ -66,10 +66,10 @@ plot.cophylo2 <- N.tip.y <- Ntip(y) res$N.tip.x <- N.tip.x res$N.tip.y <- N.tip.y - a <- plot.phylo.coor(x, use.edge.length = use.edge.length, + a <- plotPhyloCoor(x, use.edge.length = use.edge.length, type = type) res$a <- a - b <- plot.phylo.coor(y, use.edge.length = use.edge.length, + b <- plotPhyloCoor(y, use.edge.length = use.edge.length, direction = "leftwards", type = type) ###for the two trees to have the extreme leaves at the same ordinate. @@ -151,7 +151,7 @@ plot.cophylo2 <- decx[i] <- strwidth(x$tip.label[lsa[x$tip.label == assoc[i, 1]]]) decy[i] <- strwidth(y$tip.label[lsb[y$tip.label == - assoc[i, 1]]]) + assoc[i, 2]]]) } else { decx[i] <- decy[i] <- 0 } diff --git a/R/makeLabel.R b/R/makeLabel.R index 9d38dc1..e51b654 100644 --- a/R/makeLabel.R +++ b/R/makeLabel.R @@ -52,12 +52,12 @@ makeLabel.phylo <- function(x, tips = TRUE, nodes = TRUE, ...) makeLabel.multiPhylo <- function(x, tips = TRUE, nodes = TRUE, ...) { - y <- attr("TipLabel", x) + y <- attr(x, "TipLabel") if (is.null(y)) { for (i in 1:length(x)) x[[i]] <- makeLabel.phylo(x[[i]], tips = tips, nodes = nodes, ...) } else { - attr("TipLabel", x) <- makeLabel.character(y, ...) + attr(x, "TipLabel") <- makeLabel.character(y, ...) } x } diff --git a/R/read.nexus.R b/R/read.nexus.R index 05acfcd..5438456 100644 --- a/R/read.nexus.R +++ b/R/read.nexus.R @@ -1,4 +1,4 @@ -## read.nexus.R (2008-06-24) +## read.nexus.R (2008-07-04) ## Read Tree File in Nexus Format @@ -208,7 +208,7 @@ read.nexus <- function(file, tree.names = NULL) } if (Ntree == 1) { trees <- trees[[1]] - trees$tip.label <- TRANS[, 2] + if (translation) trees$tip.label <- TRANS[, 2] } else { if (!is.null(tree.names)) names(trees) <- tree.names if (translation) attr(trees, "TipLabel") <- TRANS[, 2] diff --git a/man/bind.tree.Rd b/man/bind.tree.Rd index 6617d17..ccc5714 100644 --- a/man/bind.tree.Rd +++ b/man/bind.tree.Rd @@ -7,7 +7,7 @@ bind.tree(x, y, where = "root", position = 0) \arguments{ \item{x}{an object of class \code{"phylo"}.} \item{y}{an object of class \code{"phylo"}.} - \item{where}{an) integer giving the number of the node or tip of the + \item{where}{an integer giving the number of the node or tip of the tree \code{x} where the tree \code{y} is binded (\code{"root"} is a short-cut for the root).} \item{position}{a numeric value giving the position from the tip or diff --git a/man/consensus.Rd b/man/consensus.Rd index c99dd36..f63b551 100644 --- a/man/consensus.Rd +++ b/man/consensus.Rd @@ -2,7 +2,7 @@ \alias{consensus} \title{Concensus Trees} \usage{ -consensus(..., p = 1, check.labels = FALSE) +consensus(..., p = 1, check.labels = TRUE) } \arguments{ \item{...}{either (i) a single object of class \code{"phylo"}, (ii) a diff --git a/man/plot.cophylo.Rd b/man/cophyloplot.Rd similarity index 87% rename from man/plot.cophylo.Rd rename to man/cophyloplot.Rd index 64e140d..431cbb5 100644 --- a/man/plot.cophylo.Rd +++ b/man/cophyloplot.Rd @@ -1,13 +1,13 @@ -\name{plot.cophylo} -\alias{plot.cophylo} -\title{Plots two phylogenetic trees face to face with the links between the tips.} +\name{cophyloplot} +\alias{cophyloplot} +\title{Plots two phylogenetic trees face to face with links between the tips.} \description{ This function plots two trees face to face with the links if specified. It is possible to rotate the branches of each tree around the nodes by clicking. } \usage{ -plot.cophylo(x, y, assoc=NULL, use.edge.length=FALSE,space=0, -length.line=1, gap=2, type="phylogram", rotate=FALSE, col="red", -show.tip.label=TRUE, font=3, \dots) +cophyloplot(x, y, assoc=NULL, use.edge.length=FALSE,space=0, + length.line=1, gap=2, type="phylogram", rotate=FALSE, + col="red", show.tip.label=TRUE, font=3, \dots) } \arguments{ @@ -49,10 +49,11 @@ association<-matrix(ncol=2, nrow=40) association[,1]<-association[,2]<-tree2$tip.label #plot -plot.cophylo(tree1, tree2, assoc=association, length.line=4, space=28, gap=3) +cophyloplot(tree1, tree2, assoc=association, length.line=4, space=28, gap=3) #plot with rotations -plot.cophylo(tree1, tree2, assoc=association, length.line=4, space=28, gap=3, rotate=TRUE) - +\dontrun{ +cophyloplot(tree1, tree2, assoc=association, length.line=4, space=28, gap=3, rotate=TRUE) +} } \keyword{hplot} diff --git a/man/makeLabel.Rd b/man/makeLabel.Rd index 5c56dbc..b48718b 100644 --- a/man/makeLabel.Rd +++ b/man/makeLabel.Rd @@ -1,5 +1,9 @@ \name{makeLabel} \alias{makeLabel} +\alias{makeLabel.character} +\alias{makeLabel.phylo} +\alias{makeLabel.multiPhylo} +\alias{makeLabel.DNAbin} \title{Label Management} \usage{ makeLabel(x, ...) @@ -66,3 +70,4 @@ x <- rep("aaaaa", 2) makeLabel(x, len = 3) # made unique and of length 3 makeLabel(x, len = 3, make.unique = FALSE) } +\keyword{manip} -- 2.39.5