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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Sep 14 08:40:09 CEST 2009


Author: regetz
Date: 2009-09-14 08:40:09 +0200 (Mon, 14 Sep 2009)
New Revision: 650

Modified:
   pkg/R/subset.R
   pkg/man/subset-methods.Rd
Log:
in subset, relaxed overly strict error checking added in r647; now mrca
argument once again works with internal nodes as well as tips


Modified: pkg/R/subset.R
===================================================================
--- pkg/R/subset.R	2009-09-14 05:28:28 UTC (rev 649)
+++ pkg/R/subset.R	2009-09-14 06:40:09 UTC (rev 650)
@@ -32,14 +32,14 @@
         unknown <- tips.exclude[!is.valid.tip]
     } else if (!is.null(mrca)) {
         nodes <- getNode(x, mrca, missing="OK")
-        is.valid.tip <- nodes %in% all.tips
-        if (sum(is.valid.tip)<2) {
-            stop("mrca must include at least two valid tips")
+        is.valid.node <- nodes %in% nodeId(x, "all")
+        mnode <- MRCA(x, nodes[is.valid.node])
+        if (length(mnode)!=1) {
+            stop("mrca must include at least one valid node")
         }
-        mnode <- MRCA(x, nodes[is.valid.tip])
         kept <- descendants(x, mnode)
         dropped <- setdiff(all.tips, kept)
-        unknown <- mrca[!is.valid.tip]
+        unknown <- mrca[!is.valid.node]
     } else if (!is.null(node.subtree)) {
         node <- getNode(x, node.subtree, missing="OK")
         if (length(node)!=1 || !(node %in% nodeId(x, "internal"))) {
@@ -54,7 +54,7 @@
         unknown <- numeric(0)
     }
     if (length(unknown)>0) {
-        warning("unknown tips ignored: ", paste(unknown, 
+        warning("invalid nodes ignored: ", paste(unknown, 
             collapse=", "))
     }
     if (length(kept)<2) {

Modified: pkg/man/subset-methods.Rd
===================================================================
--- pkg/man/subset-methods.Rd	2009-09-14 05:28:28 UTC (rev 649)
+++ pkg/man/subset-methods.Rd	2009-09-14 06:40:09 UTC (rev 650)
@@ -40,7 +40,7 @@
   \item{x}{an object of class \code{"phylo4"} or \code{"phylo4d"}}
   \item{tips.include}{A vector of tips to include in the subset tree}
   \item{tips.exclude}{A vector of tips to exclude from the subset tree}
-  \item{mrca}{A vector of tips for determining the most recent common
+  \item{mrca}{A vector of nodes for determining the most recent common
     ancestor, which is then used as the root of the subset tree}
   \item{node.subtree}{A single internal node specifying the root of the
     subset tree}
@@ -57,8 +57,10 @@
   \code{tips.exclude}, \code{mrca}, or \code{node.subtree}).  Each of
   these arguments can be either character or numeric.  In the first case,
   they are treated as node labels; in the second case, they are treated
-  as node numbers.  For the first three arguments, any supplied tips not
+  as node numbers.  For the first two arguments, any supplied tips not
   found in the tree (\code{tipLabels(x)}) will be ignored, with a
+  warning.  Similarly, for the \code{mrca} argument, any supplied tips
+  or internal nodes not found in the tree will be ignored, with a
   warning.  For the \code{node.subtree} argument, failure to provide a
   single, valid internal node will result in an error.
 



More information about the Phylobase-commits mailing list