[Phylobase-commits] r337 - in pkg: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Dec 19 21:05:44 CET 2008


Author: bbolker
Date: 2008-12-19 21:05:44 +0100 (Fri, 19 Dec 2008)
New Revision: 337

Modified:
   pkg/R/checkdata.R
   pkg/R/class-phylo4.R
   pkg/man/phylo4-class.Rd
   pkg/man/phylo4.Rd
Log:

 added @order slot



Modified: pkg/R/checkdata.R
===================================================================
--- pkg/R/checkdata.R	2008-12-19 20:04:31 UTC (rev 336)
+++ pkg/R/checkdata.R	2008-12-19 20:05:44 UTC (rev 337)
@@ -53,6 +53,11 @@
       Emat <- matrix(0,nrow=max(E),ncol=max(E))
       Emat[E] <- 1
     }
+    if (!object at order %in% phylo4_orderings) {
+      stop("unknown order: allowed values are ",
+           paste(phylo4_orderings,collapse=","))
+    }
+
     ## all done with fatal errors.  Now construct a list
     ##  of warnings and paste them together
     msg <- character(0)

Modified: pkg/R/class-phylo4.R
===================================================================
--- pkg/R/class-phylo4.R	2008-12-19 20:04:31 UTC (rev 336)
+++ pkg/R/class-phylo4.R	2008-12-19 20:05:44 UTC (rev 337)
@@ -4,7 +4,8 @@
                         Nnode = "integer",
                         node.label = "character",
                         tip.label = "character",
-                        edge.label = "character"),
+                        edge.label = "character",
+                        order = "character"),
          prototype = list(
                         edge = matrix(nrow = 0, ncol = 2,
                             dimname = list(NULL, c("ancestor", "descendant"))),
@@ -12,7 +13,8 @@
                         Nnode = as.integer(0),
                         tip.label = character(0),
                         node.label = character(0),
-                        edge.label = character(0)
+                        edge.label = character(0),
+                        order = "unknown"
                        ),
          validity = check_phylo4)
 
@@ -20,8 +22,10 @@
 ## phylo4 constructor
 #####################
 
-phylo4 <- function(edge, edge.length = NULL, tip.label = NULL, node.label = NULL, edge.label = NULL, ...){
+phylo4_orderings <- c("unknown","preorder","postorder")
 
+phylo4 <- function(edge, edge.length = NULL, tip.label = NULL, node.label = NULL, edge.label = NULL, order="unknown", ...){
+
     ## edge
     mode(edge) <- "integer"
     #if(any(is.na(edge))) stop("NA are not allowed in edge matrix")
@@ -64,7 +68,6 @@
     ##        edge.label <- paste("E", edge[, 2], sep = "")
     } else if (length(edge.label) != nrow(edge))
       stop("the edge labels are not consistent with the number of edges")
-      
     ## fill in the result
     res <- new("phylo4")
     res at edge <- edge
@@ -73,6 +76,7 @@
     res at tip.label <- tip.label
     res at node.label <- node.label
     res at edge.label <- edge.label
+    res at order <- order
 
     ## check_phylo4 will return a character string if object is
     ##  bad, otherwise TRUE

Modified: pkg/man/phylo4-class.Rd
===================================================================
--- pkg/man/phylo4-class.Rd	2008-12-19 20:04:31 UTC (rev 336)
+++ pkg/man/phylo4-class.Rd	2008-12-19 20:05:44 UTC (rev 337)
@@ -1,5 +1,6 @@
 \name{phylo4-class}
 \docType{class}
+\alias{phylo4_orderings}
 \alias{phylo-class}
 \alias{phylo4-class}
 \alias{$,phylo4-method}
@@ -17,22 +18,25 @@
   }
 \section{Slots}{
   \describe{
-    \item{\code{edge}:}{Matrix of edges}
-    \item{\code{edge.length}:}{Numeric vector of edge lengths}
-    \item{\code{Nnode}:}{Integer: number of nodes}
-    \item{\code{tip.label}:}{Character vector of tip labels}
-    \item{\code{root.edge}:}{Integer: root edge (NA if none)}
-    }
-}
+    \item{\code{edge}:}{matrix of edges}
+    \item{\code{edge.length}:}{numeric vector of edge lengths}
+    \item{\code{Nnode}:}{integer: number of nodes}
+    \item{\code{tip.label}:}{character vector of tip labels}
+    \item{\code{root.edge}:}{integer: root edge (NA if none)}
+    \item{\code{order}:}{character: tree ordering (allowable values are
+      listed in \code{phylo4_ordering}, currently "unknown", "reorder"
+      (="pruningwise" in \code{ape}), "postorder" (="cladewise" in \code{ape}))}
+  }
+  }
 \section{Methods}{
   \describe{
     \item{\$}{\code{signature(x = "phylo4")}: extract a slot}
     \item{print}{\code{signature(x = "phylo4")}: print method}
     \item{show}{\code{signature(object = "phylo4")}: show method }
     \item{summary}{\code{signature(object = "phylo4")}: summary method}
-    \item{names}{\code{signature(x = "phylo4")}: gives the slots names}
+    \item{names}{\code{signature(x = "phylo4")}: gives the slot names}
+  }
 }
-}
 \usage{
     \S4method{print}{phylo4}(x,printlen,\dots)
     \S4method{summary}{phylo4}(x,quiet=FALSE,\dots)
@@ -55,11 +59,11 @@
     - \code{var.el}: variance of edge lengths (estimate for population) \cr
     - \code{sumry.el}: summary (i.e. range and quartiles) of the edge
     lengths \cr
-    - \code{degree}: (optionnal) degree (i.e. number of descendents) of
+    - \code{degree}: (optional) degree (i.e. number of descendants) of
     each node; displayed only when there are polytomies \cr
-    - \code{polytomy}: (optionnal) type of polytomy for each node:
-    'node', 'terminal' (all descendents are tips) or internal (at least
-    one descendent is an internal node); displayed only when there are
+    - \code{polytomy}: (optional) type of polytomy for each node:
+    'node', 'terminal' (all descendants are tips) or internal (at least
+    one descendant is an internal node); displayed only when there are
     polytomies \cr
 
    The \code{names} method returns a vector of characters corresponding
@@ -77,7 +81,7 @@
   sumryP1 = summary(P1)
   sumryP1
 
-  ## summary of a polytomic tree
+  ## summary of a polytomous tree
   E <- matrix(c(8,9,10,10,9,9,8,11,11,11,9,10,1,2,3,4,11,5,6,7),ncol=2)
   P2 <- phylo4(E)
   plot(P2,show.node=TRUE)

Modified: pkg/man/phylo4.Rd
===================================================================
--- pkg/man/phylo4.Rd	2008-12-19 20:04:31 UTC (rev 336)
+++ pkg/man/phylo4.Rd	2008-12-19 20:05:44 UTC (rev 337)
@@ -5,7 +5,8 @@
   The \code{phylo4} function creates a phylogenetic tree object for use in phylobase methods. Phylobase contains functions for input of phylogenetic trees and data, manipulation of these objects including pruning and subsetting, and plotting. The phylobase package also contains translation functions to forms used in other comparative phylogenetic method packages.
 }
 \usage{
-phylo4(edge, edge.length = NULL, tip.label = NULL, node.label = NULL, edge.label = NULL, root.edge = NULL, ...)
+phylo4(edge, edge.length = NULL, tip.label = NULL, node.label = NULL,
+edge.label = NULL, root.edge = NULL, order="unknown", ...)
 }
 \arguments{
   \item{edge}{A numeric, two-column matrix with as many rows as branches in the phylogeny.}
@@ -13,8 +14,11 @@
   \item{tip.label}{A character vector of species names (names of "tip" nodes). (Optional)}
   \item{node.label}{A character vector of internal node names. (Optional)}
   \item{edge.label}{A character vector of edge (branch) names. (Optional)}
-  \item{root.edge}{Edge (branch) length from the most basal node to it's ancestor. (Optional)}
-  \item{...}{Any additional arguments. (Optional)}
+  \item{root.edge}{Edge (branch) length from the most basal node to it's
+    ancestor. (Optional)}
+  \item{order}{character: tree ordering (allowable values are
+      listed in \code{phylo4_ordering}, currently "unknown", "reorder"
+      (="pruningwise" in \code{ape}), "postorder" (="cladewise" in \code{ape}))}
 }
 \details{
   The minimum information necessary to create a phylobase tree object is a valid edge matrix. The edge matrix describes the topology of the phylogeny. Each row describes a branch of the phylogeny, with the (descendant) node number in column 2 and it's ancestor's node number in column 1. These numbers are used internally and must be unique for each node.



More information about the Phylobase-commits mailing list