[Phylobase-commits] r834 - in pkg: . R inst/nexusfiles inst/unitTests tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Nov 12 15:27:16 CET 2012


Author: bbolker
Date: 2012-11-12 15:27:16 +0100 (Mon, 12 Nov 2012)
New Revision: 834

Modified:
   pkg/DESCRIPTION
   pkg/NAMESPACE
   pkg/R/methods-oldclasses.R
   pkg/R/setAs-Methods.R
   pkg/R/zzz.R
   pkg/inst/nexusfiles/multiLines.Rdata
   pkg/inst/unitTests/runit.class-phylo4.R
   pkg/inst/unitTests/runit.class-phylo4d.R
   pkg/inst/unitTests/runit.readNCL.R
   pkg/inst/unitTests/runit.setAs-Methods.R
   pkg/inst/unitTests/runit.treestruc.R
   pkg/tests/roundtrip.R
Log:


fixed small issues in testing
  (order should be "unknown" in readNexus, readNCL; should be "preorder" in phylo -> phylo4 conversion when phylo object has 'cladewise')

add ade4 to imports, remove explicit require(ade4)
 (had to remove commented version entirely?)
remove .onLoad require(methods)

various replacements of read.tree by ape::read.tree (avoid explicitly attaching ape, to avoid edges() conflicts)



Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2012-01-11 17:00:24 UTC (rev 833)
+++ pkg/DESCRIPTION	2012-11-12 14:27:16 UTC (rev 834)
@@ -1,14 +1,48 @@
 Package: phylobase
 Type: Package
 Title: Base package for phylogenetic structures and comparative data
-Version: 0.6.3
-Date: 2011-03-24
-Depends: methods, grid, ape(>= 2.1), Rcpp (>= 0.9)
+Version: 0.6.4
+Date: 2012-11-09
+Depends:
+    methods,
+    grid,
+    ape(>= 2.1),
+    Rcpp (>= 0.9)
+Imports: ade4
 LinkingTo: Rcpp
-Suggests: adephylo, MASS, RUnit
-Author: R Hackathon et al. (alphabetically: Ben Bolker, Marguerite Butler, Peter Cowan,  Damien de Vienne, Dirk Eddelbuettel, Mark Holder, Thibaut Jombart, Steve Kembel, Francois Michonneau, David Orme, Brian O'Meara, Emmanuel Paradis, Jim Regetz, Derrick Zwickl)
-Maintainer:  Ben Bolker <bolker at mcmaster.ca>
-Description: Provides a base S4 class for comparative methods, incorporating one or more trees and trait data
+Suggests:
+    MASS,
+    RUnit
+Author: R Hackathon et al. (alphabetically: Ben Bolker, Marguerite Butler,
+    Peter Cowan, Damien de Vienne, Dirk Eddelbuettel, Mark Holder, Thibaut
+    Jombart, Steve Kembel, Francois Michonneau, David Orme, Brian O'Meara,
+    Emmanuel Paradis, Jim Regetz, Derrick Zwickl)
+Maintainer: Ben Bolker <bolker at mcmaster.ca>
+Description: Provides a base S4 class for comparative methods, incorporating
+    one or more trees and trait data
 License: GPL (>= 2)
-Collate: phylo4.R checkdata.R formatData.R class-multiphylo4.R class-oldclasses.R class-phylo4.R class-phylo4d.R  class-phylomats.R methods-multiphylo4.R methods-oldclasses.R methods-phylo4.R methods-phylo4d.R setAs-Methods.R pdata.R subset.R phylobase.options.R prune.R treePlot.R treestruc.R treewalk.R readNCL.R tbind.R zzz.R
+Collate:
+    'phylo4.R'
+    'checkdata.R'
+    'formatData.R'
+    'class-multiphylo4.R'
+    'class-oldclasses.R'
+    'class-phylo4.R'
+    'class-phylo4d.R'
+    'class-phylomats.R'
+    'methods-multiphylo4.R'
+    'methods-oldclasses.R'
+    'methods-phylo4.R'
+    'methods-phylo4d.R'
+    'setAs-Methods.R'
+    'pdata.R'
+    'subset.R'
+    'phylobase.options.R'
+    'prune.R'
+    'treePlot.R'
+    'treestruc.R'
+    'treewalk.R'
+    'readNCL.R'
+    'tbind.R'
+    'zzz.R'
 URL: http://phylobase.R-forge.R-project.org

Modified: pkg/NAMESPACE
===================================================================
--- pkg/NAMESPACE	2012-01-11 17:00:24 UTC (rev 833)
+++ pkg/NAMESPACE	2012-11-12 14:27:16 UTC (rev 834)
@@ -1,4 +1,4 @@
-#----------------------------------------------------------------------
+# ----------------------------------------------------------------------
 
 useDynLib(phylobase)
 
@@ -88,6 +88,7 @@
 ## options
 export(phylobase.options)
 
+importFrom(ade4,newick2phylog)
 ## commented out in source code, probably should be omitted here
 #export(phyloStripchart)
 #export(internEdges, terminEdges, isPoly)

Modified: pkg/R/methods-oldclasses.R
===================================================================
--- pkg/R/methods-oldclasses.R	2012-01-11 17:00:24 UTC (rev 833)
+++ pkg/R/methods-oldclasses.R	2012-11-12 14:27:16 UTC (rev 834)
@@ -1,4 +1,4 @@
 setMethod("reorder", signature(x = "phylo"), function(x, order = 'cladewise') {
-    x <- reorder.phylo(x,  order)
+    x <- ape::reorder.phylo(x,  order)
     x
 })

Modified: pkg/R/setAs-Methods.R
===================================================================
--- pkg/R/setAs-Methods.R	2012-01-11 17:00:24 UTC (rev 833)
+++ pkg/R/setAs-Methods.R	2012-11-12 14:27:16 UTC (rev 834)
@@ -1,9 +1,18 @@
 #######################################################
 ## Importing from ape
 setAs("phylo", "phylo4", function(from, to) {
-    ## fixme SWK kludgy fix may not work well with unrooted trees
-    ## TODO should we also attempt to get order information?
-    if (is.rooted(from)) {
+  ## fixme SWK kludgy fix may not work well with unrooted trees
+  ## TODO should we also attempt to get order information?
+  ## BMB horrible kludge to avoid requiring ape explicitly
+  ape_is.rooted <- function(phy) {
+     if (!is.null(phy$root.edge)) 
+        TRUE
+    else if (tabulate(phy$edge[, 1])[length(phy$tip.label) + 
+        1] > 2) 
+        FALSE
+    else TRUE
+   }
+    if (ape_is.rooted(from)) {
         tip.idx <- 1:nTips(from)
         if (nTips(from) < nrow(from$edge)) {
             int.idx <- (nTips(from)+1):dim(from$edge)[1]
@@ -172,12 +181,10 @@
 #######################################################
 ## Exporting to ade4
 setAs("phylo4", "phylog", function(from, to) {
-    if (!require(ade4))
-        stop("the ade4 package is required")
     x <- as(from, "phylo")
     xstring <- write.tree(x, file = "")
     warning("ade4::phylog objects are deprecated, please use the adephylo package instead")
-    newick2phylog(xstring)
+    ade4::newick2phylog(xstring)
 })
 
 #######################################################

Modified: pkg/R/zzz.R
===================================================================
--- pkg/R/zzz.R	2012-01-11 17:00:24 UTC (rev 833)
+++ pkg/R/zzz.R	2012-11-12 14:27:16 UTC (rev 834)
@@ -12,10 +12,11 @@
          allow.duplicated.labels = "warn")
 
 # use this with a namespace
-.onLoad <- function(lib, pkg) {
-    require(ape)
-    require(methods)
-}
+## 12 Nov 2012 obsolete?
+## .onLoad <- function(lib, pkg) {
+##     ## require(ape)
+##     require(methods)
+## }
 
 .onAttach <- function(library, pkg)
 {

Modified: pkg/inst/nexusfiles/multiLines.Rdata
===================================================================
(Binary files differ)

Modified: pkg/inst/unitTests/runit.class-phylo4.R
===================================================================
--- pkg/inst/unitTests/runit.class-phylo4.R	2012-01-11 17:00:24 UTC (rev 833)
+++ pkg/inst/unitTests/runit.class-phylo4.R	2012-11-12 14:27:16 UTC (rev 834)
@@ -41,7 +41,7 @@
 # tested more thoroughly in runit.setAs-methods.R; focus here is on
 # annote and check.node.labels arguments
 test.phylo4.phylo <- function() {
-    tr <- read.tree(text="(((t1:0.2,(t2:0.1,t3:0.1):0.15):0.5,t4:0.7):0.2,t5:1):0.4;")
+  tr <- ape::read.tree(text="(((t1:0.2,(t2:0.1,t3:0.1):0.15):0.5,t4:0.7):0.2,t5:1):0.4;")
 
 
     ##

Modified: pkg/inst/unitTests/runit.class-phylo4d.R
===================================================================
--- pkg/inst/unitTests/runit.class-phylo4d.R	2012-01-11 17:00:24 UTC (rev 833)
+++ pkg/inst/unitTests/runit.class-phylo4d.R	2012-11-12 14:27:16 UTC (rev 834)
@@ -3,8 +3,9 @@
 #
 
 # create ape::phylo version of a simple tree for testing
+## require(ape)  ## messes badly with edges()!
 nwk <- "((t1:0.1,t2:0.2)n7:0.7,(t3:0.3,(t4:0.4,t5:0.5)n9:0.9)n8:0.8)n6:0.6;"
-tr <- read.tree(text=nwk)
+tr <- ape::read.tree(text=nwk)
 
 # create analogous phylo4 object with a full complement of valid slots
 ancestor <- as.integer(c(6,7,7,6,8,0,8,9,9))

Modified: pkg/inst/unitTests/runit.readNCL.R
===================================================================
--- pkg/inst/unitTests/runit.readNCL.R	2012-01-11 17:00:24 UTC (rev 833)
+++ pkg/inst/unitTests/runit.readNCL.R	2012-11-12 14:27:16 UTC (rev 834)
@@ -123,6 +123,14 @@
     ## match it
     load(mlFile)
     checkIdentical(multiLines[[1]], ml1)
+    ## FAILS: why?
+    ## BMB 9 Nov 2012
+    ## for (i in slotNames(ml1)) {
+    ##   cat(i,"\n")
+    ##   checkIdentical(slot(ml1,i),slot(multiLines[[1]],i))
+    ##   fails on 'order': "preorder" (ml1) vs "unknown" (multiLines[[1]])?
+    ##   "unknown" seems correct to me, so modifying original file
+    ## }
     checkIdentical(multiLines[[2]], ml1)
     rm(ml1)
 

Modified: pkg/inst/unitTests/runit.setAs-Methods.R
===================================================================
--- pkg/inst/unitTests/runit.setAs-Methods.R	2012-01-11 17:00:24 UTC (rev 833)
+++ pkg/inst/unitTests/runit.setAs-Methods.R	2012-11-12 14:27:16 UTC (rev 834)
@@ -4,7 +4,7 @@
 
 # create ape::phylo version of a simple tree for testing
 nwk <- "((t1:0.1,t2:0.2)n7:0.7,(t3:0.3,(t4:0.4,t5:0.5)n9:0.9)n8:0.8)n6:0.6;"
-tr <- read.tree(text=nwk)
+tr <- ape::read.tree(text=nwk)
 
 # create analogous phylo4 object with a full complement of valid slots
 ancestor <- as.integer(c(6,7,7,6,8,0,8,9,9))
@@ -38,7 +38,7 @@
     checkIdentical(tr$node.label, unname(nodeLabels(as.phy)))
     # TODO: ape keeps the root edge length in $root.edge
     #checkIdentical(tr$edge.length, unname(edgeLength(as.phy)))
-    checkIdentical("unknown", edgeOrder(as.phy))
+    checkIdentical("preorder", edgeOrder(as.phy))
 
     # test preservation of order attribute
     as.phy <- as(reorder(tr, "cladewise"), "phylo4")
@@ -47,7 +47,7 @@
     checkIdentical("pruningwise", edgeOrder(as.phy))
 
     # test phylo import when only 2 tips
-    tr2 <- ape::drop.tip(tr, 3:Ntip(tr))
+    tr2 <- ape::drop.tip(tr, 3:ape::Ntip(tr))
     checkEquals(nTips(as(tr2, "phylo4")), 2)
     checkEquals(nNodes(as(tr2, "phylo4")), 1)
 
@@ -153,7 +153,7 @@
     checkTrue(is.data.frame(as(phy, "data.frame")))
 
     # unrooted tree
-    tru <- unroot(tr)
+    tru <- ape::unroot(tr)
     phyu <- as(tru, "phylo4")
     # should probably check that this coercion results in something
     # *correct*, not just that it produces a data.frame

Modified: pkg/inst/unitTests/runit.treestruc.R
===================================================================
--- pkg/inst/unitTests/runit.treestruc.R	2012-01-11 17:00:24 UTC (rev 833)
+++ pkg/inst/unitTests/runit.treestruc.R	2012-11-12 14:27:16 UTC (rev 834)
@@ -4,6 +4,7 @@
  
 test.hasPoly <- function() {
     # construct simple polytomy
+    require(ape)
     owls <- read.tree(text =
         "((Strix_aluco:4.2,Asio_otus:4.2):3.1,Athene_noctua:7.3);")
     owls$edge <- matrix(c(4,4,4,1,2,3), ncol=2)

Modified: pkg/tests/roundtrip.R
===================================================================
--- pkg/tests/roundtrip.R	2012-01-11 17:00:24 UTC (rev 833)
+++ pkg/tests/roundtrip.R	2012-11-12 14:27:16 UTC (rev 834)
@@ -24,7 +24,7 @@
           max(abs(t4$edge.length-t0$edge.length))<1e-10)
 
 ## UNROOTED
-t6 <- unroot(t0)
+t6 <- ape::unroot(t0)
 ## hack around ape conversion issues:
 ##  unroot() converts integer to double
 storage.mode(t6$edge) <- "integer"



More information about the Phylobase-commits mailing list