[Phylobase-commits] r801 - in tags: . phylobase-0.6 phylobase-0.6/R phylobase-0.6/inst/doc phylobase-0.6/inst/nexusfiles phylobase-0.6/man phylobase-0.6/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jul 15 11:12:00 CEST 2010
Author: francois
Date: 2010-07-15 11:11:59 +0200 (Thu, 15 Jul 2010)
New Revision: 801
Added:
tags/phylobase-0.6/
tags/phylobase-0.6/DESCRIPTION
tags/phylobase-0.6/NAMESPACE
tags/phylobase-0.6/NEWS
tags/phylobase-0.6/R/readNCL.R
tags/phylobase-0.6/R/readNexus.R
tags/phylobase-0.6/R/setAs-Methods.R
tags/phylobase-0.6/R/treePlot.R
tags/phylobase-0.6/inst/doc/developer.pdf
tags/phylobase-0.6/inst/doc/phylobase.pdf
tags/phylobase-0.6/inst/nexusfiles/treeWithPolyExcludedData.nex
tags/phylobase-0.6/man/readNexus.Rd
tags/phylobase-0.6/man/subset-methods.Rd
tags/phylobase-0.6/src/GetNCL.cpp
Removed:
tags/phylobase-0.6/DESCRIPTION
tags/phylobase-0.6/NAMESPACE
tags/phylobase-0.6/NEWS
tags/phylobase-0.6/R/readNexus.R
tags/phylobase-0.6/R/setAs-Methods.R
tags/phylobase-0.6/R/treePlot.R
tags/phylobase-0.6/inst/doc/developer.pdf
tags/phylobase-0.6/inst/doc/phylobase.pdf
tags/phylobase-0.6/inst/nexusfiles/treeWithPolyExcludedData.nex
tags/phylobase-0.6/man/read.nexustreestring.Rd
tags/phylobase-0.6/man/readNexus.Rd
tags/phylobase-0.6/man/subset-methods.Rd
tags/phylobase-0.6/src/NCLInterface.cpp
tags/phylobase-0.6/src/NCLInterface.h
tags/phylobase-0.6/src/ReadWithNCL.cpp
Log:
tagging version 0.6
Deleted: tags/phylobase-0.6/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION 2010-04-25 20:37:55 UTC (rev 795)
+++ tags/phylobase-0.6/DESCRIPTION 2010-07-15 09:11:59 UTC (rev 801)
@@ -1,13 +0,0 @@
-Package: phylobase
-Type: Package
-Title: Base package for phylogenetic structures and comparative data
-Version: 0.5.11
-Date: 2010-04-12
-Depends: methods, grid, ape(>= 2.1), Rcpp (>= 0.7.4)
-Suggests: ade4, MASS
-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 ufl.edu>
-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 readNexus.R tbind.R zzz.R
-URL: http://phylobase.R-forge.R-project.org
Copied: tags/phylobase-0.6/DESCRIPTION (from rev 799, pkg/DESCRIPTION)
===================================================================
--- tags/phylobase-0.6/DESCRIPTION (rev 0)
+++ tags/phylobase-0.6/DESCRIPTION 2010-07-15 09:11:59 UTC (rev 801)
@@ -0,0 +1,13 @@
+Package: phylobase
+Type: Package
+Title: Base package for phylogenetic structures and comparative data
+Version: 0.6.0
+Date: 2010-07-15
+Depends: methods, grid, ape(>= 2.1), Rcpp (>= 0.8.3)
+Suggests: ade4, MASS
+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 ufl.edu>
+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 readNexus.R readNCL.R tbind.R zzz.R
+URL: http://phylobase.R-forge.R-project.org
Deleted: tags/phylobase-0.6/NAMESPACE
===================================================================
--- pkg/NAMESPACE 2010-04-25 20:37:55 UTC (rev 795)
+++ tags/phylobase-0.6/NAMESPACE 2010-07-15 09:11:59 UTC (rev 801)
@@ -1,108 +0,0 @@
-#----------------------------------------------------------------------
-
-useDynLib(phylobase)
-
-#----------------------------------------------------------------------
-
-import(methods)
-importFrom(graphics, plot)
-importFrom(stats, reorder)
-importFrom(utils, head, tail)
-
-#----------------------------------------------------------------------
-
-exportClasses(phylo4, phylo4d, multiPhylo4, multiPhylo4d)
-
-#----------------------------------------------------------------------
-
-# utility methods
-exportMethods(print, head, tail, reorder, plot, summary)
-
-# tree constructor methods
-exportMethods(phylo4, phylo4d)
-
-# counting methods
-exportMethods(nTips, nNodes, nEdges)
-
-# edge methods
-exportMethods(edges, edgeId, hasEdgeLength, edgeLength, "edgeLength<-",
- sumEdgeLength, edgeOrder)
-
-# root methods
-exportMethods(isRooted, rootNode, "rootNode<-")
-#export(rootEdge) # no methods defined yet?
-
-# node methods
-exportMethods(nodeId, nodeType)
-
-# tree data methods
-exportMethods(tdata, "tdata<-", tipData, "tipData<-", nodeData,
- "nodeData<-", hasTipData, hasNodeData, addData, nData)
-
-# subset methods
-exportMethods(subset, prune, "[")
-
-# pdata methods
-exportMethods("[<-", "[[", "[[<-")
-
-# label methods
-exportMethods(labels, "labels<-", nodeLabels, "nodeLabels<-",
- tipLabels, "tipLabels<-", edgeLabels, "edgeLabels<-",
- hasNodeLabels, hasEdgeLabels, hasDuplicatedLabels)
-
-#----------------------------------------------------------------------
-
-# tree structure functions
-export(hasPoly, hasSingle, hasRetic)
-
-# treewalk functions
-export(getNode, ancestor, children, descendants, siblings, ancestors,
- MRCA, shortestPath, getEdge)
-
-# Nexus functions
-export(readNexus, read.nexustreestring)
-
-# pdata functions
-export(pdata, check_pdata)
-
-# plotting functions
-export(treePlot, plotOneTree, tip.data.plot)
-export(phyloXXYY, phylobubbles)
-
-# misc functions
-export(extractTree, tbind)
-export(checkPhylo4, checkTree, checkPhylo4Data, formatData)
-export(as_phylo4vcov)
-export(printphylo4)
-
-#----------------------------------------------------------------------
-
-# misc objects
-export(phylo4_orderings)
-
-## options
-export(phylobase.options)
-
-## commented out in source code, probably should be omitted here
-#export(phyloStripchart)
-#export(internEdges, terminEdges, isPoly)
-
-## presumably these should remain hidden
-##export(.createLabels, .createEdge, .phylo4Data, orderIndex, .genlab,
-## .chnumsort, .phylo4ToDataFrame, .bubLegendGrob)
-## hidden: drawDetails.bubLegend)
-
-## recently removed:
-## tree.plot
-## segs
-## checkData
-## attachData
-## orderIndex
-
-#----------------------------------------------------------------------
-## For reference, quick & dirty UNIX-y commandline statements to pull
-## out methods and functions from package code; use in pkg/R/ dir:
-# grep "^ *setMethod" *.R | sed 's/setMethod(//' | sed 's/.*:["]\([^,]*\)["].*/\1/' | sort | uniq
-# grep "^ *setReplaceMethod" *.R | sed 's/setReplaceMethod(//' | sed 's/.*:["]\([^,]*\)["].*/\1/' | sort | uniq
-# grep "^[^ ].*<- *function *(" *.R | sed 's/.*R://'
-
Copied: tags/phylobase-0.6/NAMESPACE (from rev 798, pkg/NAMESPACE)
===================================================================
--- tags/phylobase-0.6/NAMESPACE (rev 0)
+++ tags/phylobase-0.6/NAMESPACE 2010-07-15 09:11:59 UTC (rev 801)
@@ -0,0 +1,109 @@
+#----------------------------------------------------------------------
+
+useDynLib(phylobase)
+
+#----------------------------------------------------------------------
+
+import(methods)
+importFrom(graphics, plot)
+importFrom(stats, reorder)
+importFrom(utils, head, tail)
+
+#----------------------------------------------------------------------
+
+exportClasses(phylo4, phylo4d, multiPhylo4, multiPhylo4d)
+
+#----------------------------------------------------------------------
+
+# utility methods
+exportMethods(print, head, tail, reorder, plot, summary)
+
+# tree constructor methods
+exportMethods(phylo4, phylo4d)
+
+# counting methods
+exportMethods(nTips, nNodes, nEdges)
+
+# edge methods
+exportMethods(edges, edgeId, hasEdgeLength, edgeLength, "edgeLength<-",
+ sumEdgeLength, edgeOrder)
+
+# root methods
+exportMethods(isRooted, rootNode, "rootNode<-")
+#export(rootEdge) # no methods defined yet?
+
+# node methods
+exportMethods(nodeId, nodeType)
+
+# tree data methods
+exportMethods(tdata, "tdata<-", tipData, "tipData<-", nodeData,
+ "nodeData<-", hasTipData, hasNodeData, addData, nData)
+
+# subset methods
+exportMethods(subset, prune, "[")
+
+# pdata methods
+exportMethods("[<-", "[[", "[[<-")
+
+# label methods
+exportMethods(labels, "labels<-", nodeLabels, "nodeLabels<-",
+ tipLabels, "tipLabels<-", edgeLabels, "edgeLabels<-",
+ hasNodeLabels, hasEdgeLabels, hasDuplicatedLabels)
+
+#----------------------------------------------------------------------
+
+# tree structure functions
+export(hasPoly, hasSingle, hasRetic)
+
+# treewalk functions
+export(getNode, ancestor, children, descendants, siblings, ancestors,
+ MRCA, shortestPath, getEdge)
+
+# Nexus functions
+export(readNexus)
+export(readNCL)
+
+# pdata functions
+export(pdata, check_pdata)
+
+# plotting functions
+export(treePlot, plotOneTree, tip.data.plot)
+export(phyloXXYY, phylobubbles)
+
+# misc functions
+export(extractTree, tbind)
+export(checkPhylo4, checkTree, checkPhylo4Data, formatData)
+export(as_phylo4vcov)
+export(printphylo4)
+
+#----------------------------------------------------------------------
+
+# misc objects
+export(phylo4_orderings)
+
+## options
+export(phylobase.options)
+
+## commented out in source code, probably should be omitted here
+#export(phyloStripchart)
+#export(internEdges, terminEdges, isPoly)
+
+## presumably these should remain hidden
+##export(.createLabels, .createEdge, .phylo4Data, orderIndex, .genlab,
+## .chnumsort, .phylo4ToDataFrame, .bubLegendGrob)
+## hidden: drawDetails.bubLegend)
+
+## recently removed:
+## tree.plot
+## segs
+## checkData
+## attachData
+## orderIndex
+
+#----------------------------------------------------------------------
+## For reference, quick & dirty UNIX-y commandline statements to pull
+## out methods and functions from package code; use in pkg/R/ dir:
+# grep "^ *setMethod" *.R | sed 's/setMethod(//' | sed 's/.*:["]\([^,]*\)["].*/\1/' | sort | uniq
+# grep "^ *setReplaceMethod" *.R | sed 's/setReplaceMethod(//' | sed 's/.*:["]\([^,]*\)["].*/\1/' | sort | uniq
+# grep "^[^ ].*<- *function *(" *.R | sed 's/.*R://'
+
Deleted: tags/phylobase-0.6/NEWS
===================================================================
--- pkg/NEWS 2010-04-25 20:37:55 UTC (rev 795)
+++ tags/phylobase-0.6/NEWS 2010-07-15 09:11:59 UTC (rev 801)
@@ -1,147 +0,0 @@
- *************************************************
- * *
- * 0.5 SERIES NEWS *
- * *
- *************************************************
-
- CHANGES IN phylobase VERSION 0.5
-
-MAJOR CHANGES
-
- * A var-cov matrix tree class, phylo4vcov, and methods for converting to
- and from other classes now exists.
-
- * Replaced separate the tip.label and node.label slots with a unified
- label slot in the phylo4 class definition.
-
- * Replaced separate the tip.data and node.data into a single data slot in
- the phylo4d class definition.
-
- * The phylo4 class grew a annotate slot.
-
- * The phylo4d class grew a metadata slot.
-
- * Added an order slot to the phylo4 class definition and updated as()
- methods to assign the proper order (if possible) when converting
- between ape and phylobase tree formats.
-
- * The Nnode slot was removed from the phylo4 class definition.
-
- * An explicit root edge has been added to the edge matrix with 0 as the
- ancestor and nTips(phy) + 1 as the rood node.
-
- * The edgeLabels() and edgeLength() accessors now return vectors with
- named elements in the same order as rows of the edge matrix, even when
- some/all values are missing.
-
- * The labels() accessor and nodeID() methods now always return labels in
- ascending order of node ID
-
- * Many function and argument names and defaults have been changed to make
- them more consistent most functions follow the getNode() pattern.
-
- * The plotting functions have been replaced (see below).
-
- * Now, data are matched against node numbers instead of node labels.
-
- * Tip and internal node labels have now internal names that are character
- strings of the node number they correspond to. Thus it is possible to
- store labels in any order and assignment of labels more robust.
-
- * We now use the RUnit package (not required for normal use) for adding
- unit tests. Adding unit tests to inst/unitTests/ is now preferred over
- the tests/ directory.
-
- * Numerous changes to pruning and tree subsetting code. It is
- considerably more robust and no longer relies on calls to APE.
-
-NEW FEATURES
-
- * Added a function nodeType() for identifying whether a node is root,
- tip or internal.
-
- * Changed nodeNumbers to nodeId() and extended it abilities.
-
- * Added method reorder() for converting edge matrices into preorder or
- postorder.
-
- * Added the edgeOrder accessor to get the order of a phylobase object.
-
- * Added a package help file accessible from ?phylobase.
-
- * Added labels()<- for assigning labels.
-
- * Added edgeLength()<- for assigning edgeLengths.
-
- * Added a phylo4() method for importing APE phylo objects.
-
- * Added a hasTipData() method.
-
- * Added a edgeId() method.
-
- * Created the addData() method for adding data to phylo4 objects.
-
- * Added tipData and nodeData getter/setter methods
-
- * If all node.labels are numerical values, they are automatically
- converted as data. Useful when importing consensus tree from MrBayes.
-
- * It is now possible to print tree objects in edge order using the
- edgeOrder argument in printphylo4().
-
- * reorder(), descendants(), ancestors(), and portions of the plotting code
- have been recoded in C to improve performance.
-
- * Added a developer vignette to document and guide development of the
- phylobase package.
-
- * The previous plotting functions, based on base graphics, have been
- replaced with function based on the grid graphics device.
-
- * A S4 generic plot() function, calling treePlot() has been added it
- dispatches a plotting function based on object class and arguments.
-
- * Plots using grid based code can be inserted at the tree tips using the
- tip.plot.fun argument in plot()
-
- * The getNode() method has been enhanced to allow matching against
- specific node types, and if the requested node is missing, all nodes of
- specified type are returned.
-
- * Changed getEdge() to allow no node argument, which returns all edges
- appropriate for the given type.
-
-CHANGES
-
- * Node labels are, if not supplied, a vector of NA.
-
- * printphylo() is now deprecated, print() and summary() now alsow work on
- empty objects.
-
- * phylo4() is now and S4 generic with signature "matrix".
-
- * phylobase now uses a NAMESPACE file.
-
- * Legacy plotting code (0.4) can be found in the SVN repo tags directory.
-
- * The tdata default "type" argument changed to 'all'.
-
- * Row names now stored internally as numeric, not character.
-
-BUG FIXES
-
- * Far too many to document. See the SVN log for details.
-
-KNOWN ISSUES
-
- * Unrooted trees are not supported by all functions, e.g. plot() and
- reorder().
-
- * Factors are not supported by the default plotting method.
-
- * The Nexus Class Library is build for the system default ARCH which may
- or may not be the architecture that R and the rest of the package is
- built with. If this occurs the package will fail to load.
-
- * Unique labels are required for internal nodes, this behavior will be
- changed in the future.
Copied: tags/phylobase-0.6/NEWS (from rev 799, pkg/NEWS)
===================================================================
--- tags/phylobase-0.6/NEWS (rev 0)
+++ tags/phylobase-0.6/NEWS 2010-07-15 09:11:59 UTC (rev 801)
@@ -0,0 +1,206 @@
+ *************************************************
+ * *
+ * 0.6 SERIES NEWS *
+ * *
+ *************************************************
+
+ CHANGES IN phylobase VERSION 0.6
+
+MAJOR CHANGES
+
+ * Updated to the Nexus Class Library (NCL) 2.1.12.
+
+ * Changed the way NCL is built during the installation process.
+
+ * Complete rewrite of the function readNexus which brings many new
+ functionalities.
+
+ * Nodes labels do not have to be unique.
+
+
+NEW FEATURES
+
+ * In readNexus, the option return.labels gives the state labels of the
+ characters.
+
+ * It is now possible to import several types of data blocks in a single
+ NEXUS file with readNexus.
+
+ * The function phylobase.options() provides global options to control the
+ behavior of the phylo4/phylo4d validator.
+
+ * The new method hasDuplicatedLabels() indicates whether any node labels
+ are duplicated.
+
+ * The new method nData() returns the number of datasets associated with
+ a tree.
+
+ * The column that contains the labels can now be specified by its name in
+ the function formatData()
+
+CHANGES
+
+ * The function getNode() has been modified to allow node matching in the
+ case of non-unique labels.
+
+ * Many new unit tests.
+
+BUG FIXES
+
+ * Far too many to document. See the SVN log for details.
+
+KNOWN ISSUES
+
+ * Unrooted trees are not supported by all functions, e.g. plot() and
+ reorder().
+
+ * Factors are not supported by the default plotting method.
+
+
+ *************************************************
+ * *
+ * 0.5 SERIES NEWS *
+ * *
+ *************************************************
+
+ CHANGES IN phylobase VERSION 0.5
+
+MAJOR CHANGES
+
+ * A var-cov matrix tree class, phylo4vcov, and methods for converting to
+ and from other classes now exists.
+
+ * Replaced separate the tip.label and node.label slots with a unified
+ label slot in the phylo4 class definition.
+
+ * Replaced separate the tip.data and node.data into a single data slot in
+ the phylo4d class definition.
+
+ * The phylo4 class grew a annotate slot.
+
+ * The phylo4d class grew a metadata slot.
+
+ * Added an order slot to the phylo4 class definition and updated as()
+ methods to assign the proper order (if possible) when converting
+ between ape and phylobase tree formats.
+
+ * The Nnode slot was removed from the phylo4 class definition.
+
+ * An explicit root edge has been added to the edge matrix with 0 as the
+ ancestor and nTips(phy) + 1 as the rood node.
+
+ * The edgeLabels() and edgeLength() accessors now return vectors with
+ named elements in the same order as rows of the edge matrix, even when
+ some/all values are missing.
+
+ * The labels() accessor and nodeID() methods now always return labels in
+ ascending order of node ID
+
+ * Many function and argument names and defaults have been changed to make
+ them more consistent most functions follow the getNode() pattern.
+
+ * The plotting functions have been replaced (see below).
+
+ * Now, data are matched against node numbers instead of node labels.
+
+ * Tip and internal node labels have now internal names that are character
+ strings of the node number they correspond to. Thus it is possible to
+ store labels in any order and assignment of labels more robust.
+
+ * We now use the RUnit package (not required for normal use) for adding
+ unit tests. Adding unit tests to inst/unitTests/ is now preferred over
+ the tests/ directory.
+
+ * Numerous changes to pruning and tree subsetting code. It is
+ considerably more robust and no longer relies on calls to APE.
+
+NEW FEATURES
+
+ * Added a function nodeType() for identifying whether a node is root,
+ tip or internal.
+
+ * Changed nodeNumbers to nodeId() and extended it abilities.
+
+ * Added method reorder() for converting edge matrices into preorder or
+ postorder.
+
+ * Added the edgeOrder accessor to get the order of a phylobase object.
+
+ * Added a package help file accessible from ?phylobase.
+
+ * Added labels()<- for assigning labels.
+
+ * Added edgeLength()<- for assigning edgeLengths.
+
+ * Added a phylo4() method for importing APE phylo objects.
+
+ * Added a hasTipData() method.
+
+ * Added a edgeId() method.
+
+ * Created the addData() method for adding data to phylo4 objects.
+
+ * Added tipData and nodeData getter/setter methods
+
+ * If all node.labels are numerical values, they are automatically
+ converted as data. Useful when importing consensus tree from MrBayes.
+
+ * It is now possible to print tree objects in edge order using the
+ edgeOrder argument in printphylo4().
+
+ * reorder(), descendants(), ancestors(), and portions of the plotting code
+ have been recoded in C to improve performance.
+
+ * Added a developer vignette to document and guide development of the
+ phylobase package.
+
+ * The previous plotting functions, based on base graphics, have been
+ replaced with function based on the grid graphics device.
+
+ * A S4 generic plot() function, calling treePlot() has been added it
+ dispatches a plotting function based on object class and arguments.
+
+ * Plots using grid based code can be inserted at the tree tips using the
+ tip.plot.fun argument in plot()
+
+ * The getNode() method has been enhanced to allow matching against
+ specific node types, and if the requested node is missing, all nodes of
+ specified type are returned.
+
+ * Changed getEdge() to allow no node argument, which returns all edges
+ appropriate for the given type.
+
+CHANGES
+
+ * Node labels are, if not supplied, a vector of NA.
+
+ * printphylo() is now deprecated, print() and summary() now alsow work on
+ empty objects.
+
+ * phylo4() is now and S4 generic with signature "matrix".
+
+ * phylobase now uses a NAMESPACE file.
+
+ * Legacy plotting code (0.4) can be found in the SVN repo tags directory.
+
+ * The tdata default "type" argument changed to 'all'.
+
+ * Row names now stored internally as numeric, not character.
+
+BUG FIXES
+
+ * Far too many to document. See the SVN log for details.
+
+KNOWN ISSUES
+
+ * Unrooted trees are not supported by all functions, e.g. plot() and
+ reorder().
+
+ * Factors are not supported by the default plotting method.
+
+ * The Nexus Class Library is build for the system default ARCH which may
+ or may not be the architecture that R and the rest of the package is
+ built with. If this occurs the package will fail to load.
+
+ * Unique labels are required for internal nodes, this behavior will be
+ changed in the future.
Copied: tags/phylobase-0.6/R/readNCL.R (from rev 798, pkg/R/readNCL.R)
===================================================================
--- tags/phylobase-0.6/R/readNCL.R (rev 0)
+++ tags/phylobase-0.6/R/readNCL.R 2010-07-15 09:11:59 UTC (rev 801)
@@ -0,0 +1,179 @@
+readNCL <- function(file, simplify=FALSE, type=c("all", "tree", "data"),
+ char.all=FALSE, polymorphic.convert=TRUE,
+ levels.uniform=TRUE, quiet=TRUE,
+ check.node.labels=c("keep", "drop", "asdata"),
+ return.labels=TRUE, ...) {
+
+
+ type <- match.arg(type)
+ check.node.labels <- match.arg(check.node.labels)
+
+
+
+ if (type == "all" || type == "data") {
+ returnData <- TRUE
+ }
+ else {
+ returnData <- FALSE
+ }
+ if (type == "all" || type == "tree") {
+ returnTrees <- TRUE
+ }
+ else {
+ returnTrees <- FALSE
+ }
+
+ fileName <- list(fileName=file)
+ parameters <- c(char.all, polymorphic.convert, levels.uniform, returnTrees, returnData)
+
+ ## GetNCL returns a list containing:
+ ## $taxaNames: names of the taxa (from taxa block, implied or declared)
+ ## $treeNames: the names of the trees
+ ## $trees: a vector of (untranslated) Newick strings
+ ## $dataTypes: data type for each character block of the nexus file (length = number of chr blocks)
+ ## $nbCharacters: number of characters in each block (length = number of chr blocks)
+ ## $charLabels: the labels for the characters, i.e. the headers of the data frame to be returned
+ ## (length = number of chr blocks * sum of number of characters in each block)
+ ## $nbStates: the number of states of each character (equals 0 for non-standard types, length = number
+ ## of characters)
+ ## $stateLabels: the labels for the states of the characters, i.e. the levels of the factors to be returned
+ ## $dataChr: string that contains the data to be returned
+ ncl <- .Call("GetNCL", fileName, parameters, PACKAGE="phylobase")
+
+ if (!quiet) print(ncl)
+
+ ## Disclaimer
+ if (!length(grep("\\{", ncl$dataChr)) && return.labels && !polymorphic.convert) {
+ stop("At this stage, it's not possible to use the combination: ",
+ "return.labels=TRUE and polymorphic.convert=FALSE for datasets ",
+ "that contain polymorphic characters.")
+ }
+
+ if (returnData && length(ncl$dataChr)) {
+ tipData <- vector("list", length(ncl$dataChr))
+ for (iBlock in 1:length(ncl$dataTypes)) {
+ chrCounter <- ifelse(iBlock == 1, 0, sum(ncl$nbCharacters[1:(iBlock-1)]))
+ if (ncl$dataTypes[iBlock] == "Continuous") {
+ for (iChar in 1:ncl$nbCharacters[iBlock]) {
+ i <- chrCounter + iChar
+ tipData[[i]] <- eval(parse(text=ncl$dataChr[i]))
+ names(tipData)[i] <- ncl$charLabels[i]
+ }
+ }
+ else {
+
+ if (ncl$dataTypes[iBlock] == "Standard") {
+ iForBlock <- integer(0)
+ for (iChar in 1:ncl$nbCharacters[iBlock]) {
+ i <- chrCounter + iChar
+ iForBlock <- c(iForBlock, i)
+ lblCounterMin <- ifelse(i == 1, 1, sum(ncl$nbStates[1:(i-1)]) + 1)
+ lblCounter <- seq(lblCounterMin, length.out=ncl$nbStates[i])
+ tipData[[i]] <- eval(parse(text=ncl$dataChr[i]))
+ names(tipData)[i] <- ncl$charLabels[i]
+ tipData[[i]] <- as.factor(tipData[[i]])
+ if (return.labels) {
+ levels(tipData[[i]]) <- ncl$stateLabels[lblCounter]
+ }
+ }
+ if (levels.uniform) {
+ allLevels <- character(0)
+ for (j in iForBlock) {
+ allLevels <- union(allLevels, levels(tipData[[j]]))
+ }
+ for (j in iForBlock) {
+ levels(tipData[[j]]) <- allLevels
+ }
+ }
+ }
+ else {
+ warning("This datatype is not currently supported by phylobase")
+ next
+ ## FIXME: different datatypes in a same file isn't going to work
+ }
+ }
+ }
+ tipData <- data.frame(tipData)
+ if (length(ncl$taxaNames) == nrow(tipData)) {
+ rownames(tipData) <- ncl$taxaNames
+ }
+ else stop("phylobase doesn't deal with multiple taxa block at this time.")
+ }
+ else {
+ tipData <- NULL
+ }
+
+ if (returnTrees && length(ncl$trees) > 0) {
+ listTrees <- vector("list", length(ncl$trees))
+ for (i in 1:length(ncl$trees)) {
+ if (length(grep(":", ncl$trees[i]))) {
+ listTrees[[i]] <- tree.build(ncl$trees[i])
+ }
+ else {
+ listTrees[[i]] <- clado.build(ncl$trees[i])
+ }
+ }
+ listTrees <- lapply(listTrees, function(tr) {
+ if (length(ncl$taxaNames) == nTips(tr)) {
+ tr$tip.label <- ncl$taxaNames[as.numeric(tr$tip.label)]
+ }
+ else stop("phylobase doesn't deal with multiple taxa block at this time.")
+ if (is.null(tr$node.label)) {
+ if (check.node.labels == "asdata") {
+ warning("Could not use value \"asdata\" for ",
+ "check.node.labels because there are no ",
+ "labels associated with the tree")
+ check.node.labels <- "drop"
+ }
+ tr <- phylo4(tr, check.node.labels=check.node.labels, ...)
+ }
+ else {
+ tr <- phylo4d(tr, check.node.labels=check.node.labels, ...)
+ }
+ })
+ if (length(listTrees) == 1 || simplify)
+ listTrees <- listTrees[[1]]
+ }
+ else {
+ listTrees <- NULL
+ }
+
+ ###
+ switch(type,
+ "data" = {
+ if (is.null(tipData)) {
+ toRet <- NULL
+ }
+ else {
+ toRet <- tipData
+ }
+ },
+ "tree" = {
+ if (is.null(listTrees)) {
+ toRet <- NULL
+ }
+ else {
+ toRet <- listTrees
+ }
+ },
+ "all" = {
+ if (is.null(tipData) && is.null(listTrees)) {
+ toRet <- NULL
+ }
+ else if (is.null(tipData)) {
+ toRet <- listTrees
+ }
+ else if (is.null(listTrees)) {
+ toRet <- tipData
+ }
+ else {
+ if (length(listTrees) > 1) {
+ toRet <- lapply(listTrees, function(tr)
+ addData(tr, tip.data=tipData, ...))
+ }
+ else toRet <- addData(listTrees, tip.data=tipData, ...)
+ }
+ })
+ toRet
+}
+
Deleted: tags/phylobase-0.6/R/readNexus.R
===================================================================
--- pkg/R/readNexus.R 2010-04-25 20:37:55 UTC (rev 795)
+++ tags/phylobase-0.6/R/readNexus.R 2010-07-15 09:11:59 UTC (rev 801)
@@ -1,355 +0,0 @@
-readNexus <- function (file, simplify=FALSE, type=c("all", "tree", "data"),
- char.all=FALSE, polymorphic.convert=TRUE,
- levels.uniform=TRUE, quiet=TRUE,
- check.node.labels=c("keep", "drop", "asdata"),
- return.labels=TRUE, ...) {
-
- ## file = input nexus file
- ## simplify = if TRUE only keeps the first tree, if several trees are found in
- ## the Nexus file
- ## type = specify whether to return trees+data as phylo4d object ("all") if
- ## both are found, returning a data.frame or phylo4 object if only one
- ## is found, "tree": return a phylo4 object only, regardless of
- ## whether there are data, "data": return a data.frame (no tree), even
- ## if a tree is present
- ## char.all = if TRUE, includes even excluded chars in the nexus file
- ## polymorphic.convert = if TRUE, convert polymorphic characters to missing
- ## characters
- ## levels.uniform = if TRUE, categorical data are loaded with the same levels,
- ## even if one character is missing a state
- ## return.labels = if TRUE, returns the names of the states instead of the
- ## the internal codes
- ## quiet = if TRUE, returns the object without printing tree strings (printing
- ## makes readNexus very slow in the cases of very big trees)
- ## check.node.labels = how to deal with node labels, to be passed to phylo4d
- ## constructor
-
- type <- match.arg(type)
- check.node.labels <- match.arg(check.node.labels)
-
- output <- c("Failure")
- if (type == "all" || type == "data") {
- params <- list(filename=file, allchar=char.all,
- polymorphictomissing=polymorphic.convert,
- levelsall=levels.uniform,
- returnlabels=return.labels)
-
- ## Check that params is properly formatted.
- if(!is.list(params) || length(params) == 0) {
- stop("The params parameter must be a non-empty list")
- }
- incharsstring <- .Call("ReadCharsWithNCL", params,
- PACKAGE="phylobase")
- if (length(incharsstring) > 0) {
- incharsstring <- unlist(strsplit(incharsstring$charstring, "\\|"))
- incharsstring <- incharsstring[nzchar(incharsstring)]
-
- if (!quiet) print(incharsstring) # display character string if quiet is FALSE
-
- iDtType <- seq(from=1, to=length(incharsstring), by=2)
- iCharStrg <- seq(from=2, to=length(incharsstring), by=2)
-
- datatype <- incharsstring[iDtType]
- charString <- incharsstring[iCharStrg]
-
- tipdata <- list()
- for (i in 1:length(charString)) {
- if (datatype[i] == "Standard") {
- ## Remove empty labels for factors
- charString[i] <- gsub("\\\"\\\"", "", charString[i])
- charString[i] <- gsub(",+)", ")", charString[i])
-
- ## For now, we can't deal with polymorphic characters and their labels
- if (length(grep("\\{", charString[i])) > 0 &&
- return.labels) {
- stop("At this stage, it's not possible to use the combination: ",
- "return.labels=TRUE for datasets that contain polymorphic ",
- "characters.")
- }
-
- ## Convert the string to data frame
- tipdata[[i]] <- eval(parse(text=charString[i]))
-
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/phylobase -r 801
More information about the Phylobase-commits
mailing list