[Adephylo-commits] r37 - in pkg: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Nov 26 15:04:46 CET 2008


Author: jombart
Date: 2008-11-26 15:04:46 +0100 (Wed, 26 Nov 2008)
New Revision: 37

Added:
   pkg/man/listDD.Rd
Removed:
   pkg/man/listNodes.Rd
Modified:
   pkg/R/partition.R
   pkg/R/utils.R
Log:
Some rearrangements of code. Renamed listNodes to listDD, moved it to utils.R


Modified: pkg/R/partition.R
===================================================================
--- pkg/R/partition.R	2008-11-26 14:00:06 UTC (rev 36)
+++ pkg/R/partition.R	2008-11-26 14:04:46 UTC (rev 37)
@@ -33,32 +33,6 @@
 
 
 
-############
-# listNodes
-############
-listNodes <- function(x){
-    if(!require(phylobase)) stop("phylobase package is not installed")
-
-    ## conversion from phylo, phylo4 and phylo4d
-    x <- as(x, "phylo4")
-
-    ## check phylo4 object
-    if (is.character(checkval <- check_phylo4(x))) stop(checkval)
-
-    ## computations
-    nodIdx <- nTips(x)+1
-    nodIdx <- nodIdx:(nodIdx+nNodes(x)-1)
-    res <- lapply(nodIdx, function(i) children(x, i))
-
-    if(hasNodeLabels(x)) {names(res) <- nodeLabels(x)}
-
-    return(res)
-} # end listNodes
-
-
-
-
-
 ###########
 # treePart
 ###########

Modified: pkg/R/utils.R
===================================================================
--- pkg/R/utils.R	2008-11-26 14:00:06 UTC (rev 36)
+++ pkg/R/utils.R	2008-11-26 14:04:46 UTC (rev 37)
@@ -151,3 +151,30 @@
 ## heavier tree
 # x <- as(rtree(1000), "phylo4")
 # system.time(sp.tips(x,1,1:1000))
+
+
+
+
+
+############
+# listDD
+############
+listDD <- function(x){
+    if(!require(phylobase)) stop("phylobase package is not installed")
+
+    ## conversion from phylo, phylo4 and phylo4d
+    x <- as(x, "phylo4")
+
+    ## check phylo4 object
+    if (is.character(checkval <- check_phylo4(x))) stop(checkval)
+
+    ## computations
+    nodIdx <- nTips(x)+1
+    nodIdx <- nodIdx:(nodIdx+nNodes(x)-1)
+    res <- lapply(nodIdx, function(i) children(x, i))
+
+    if(hasNodeLabels(x)) {names(res) <- nodeLabels(x)}
+
+    return(res)
+} # end listDD
+

Added: pkg/man/listDD.Rd
===================================================================
--- pkg/man/listDD.Rd	                        (rev 0)
+++ pkg/man/listDD.Rd	2008-11-26 14:04:46 UTC (rev 37)
@@ -0,0 +1,34 @@
+\name{listDD}
+\alias{listDD}
+\title{List direct descendants for all nodes of a tree}
+\description{
+  The function \code{listDD} lists the direct descendants from each node
+  of a tree. The tree can be of class \code{\link[pkg:ape]{phylo}},
+  \linkS4class{phylo4} or \linkS4class{phylo4d}.
+}
+\usage{
+listDD(x)
+}
+\arguments{
+  \item{x}{A tree of  class \code{\link[pkg:ape]{phylo}},
+    \linkS4class{phylo4} or \linkS4class{phylo4d}.}
+}
+\value{
+  A list whose components are vectors of named nodes (or tips) for a
+  given internal node.
+}
+\author{ Thibaut Jombart \email{jombart at biomserv.univ-lyon1.fr} }
+\seealso{\code{\link{listTips}} which lists the tips descending from
+  each node. \cr
+  
+  \code{\link{treePart}} which defines partitions of tips
+  according to the tree topology.}
+\examples{
+if(require(ape) & require(phylobase)){
+## make a tree
+x <- as(rtree(20),"phylo4")
+plot(x,show.node=TRUE)
+listDD(x)
+}
+}
+\keyword{manip}

Deleted: pkg/man/listNodes.Rd
===================================================================
--- pkg/man/listNodes.Rd	2008-11-26 14:00:06 UTC (rev 36)
+++ pkg/man/listNodes.Rd	2008-11-26 14:04:46 UTC (rev 37)
@@ -1,34 +0,0 @@
-\name{listNodes}
-\alias{listNodes}
-\title{List direct descendants for all nodes of a tree}
-\description{
-  The function \code{listNodes} lists the direct descendants from each node
-  of a tree. The tree can be of class \code{\link[pkg:ape]{phylo}},
-  \linkS4class{phylo4} or \linkS4class{phylo4d}.
-}
-\usage{
-listNodes(x)
-}
-\arguments{
-  \item{x}{A tree of  class \code{\link[pkg:ape]{phylo}},
-    \linkS4class{phylo4} or \linkS4class{phylo4d}.}
-}
-\value{
-  A list whose components are vectors of named nodes (or tips) for a
-  given internal node.
-}
-\author{ Thibaut Jombart \email{jombart at biomserv.univ-lyon1.fr} }
-\seealso{\code{\link{listTips}} which lists the tips descending from
-  each node. \cr
-  
-  \code{\link{treePart}} which defines partitions of tips
-  according to the tree topology.}
-\examples{
-if(require(ape) & require(phylobase)){
-## make a tree
-x <- as(rtree(20),"phylo4")
-plot(x,show.node=TRUE)
-listNodes(x)
-}
-}
-\keyword{manip}



More information about the Adephylo-commits mailing list