[Phylobase-commits] r622 - in pkg: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Sep 8 18:15:11 CEST 2009
Author: regetz
Date: 2009-09-08 18:15:07 +0200 (Tue, 08 Sep 2009)
New Revision: 622
Modified:
pkg/NAMESPACE
pkg/R/methods-phylo4.R
pkg/R/phylo4.R
pkg/man/treewalk.Rd
Log:
added new edgeId method and exported via NAMESPACE; no documentation yet
Modified: pkg/NAMESPACE
===================================================================
--- pkg/NAMESPACE 2009-09-04 21:54:25 UTC (rev 621)
+++ pkg/NAMESPACE 2009-09-08 16:15:07 UTC (rev 622)
@@ -25,7 +25,7 @@
exportMethods(nTips, nNodes, nEdges)
# edge methods
-exportMethods(edges, hasEdgeLength, edgeLength, "edgeLength<-",
+exportMethods(edges, edgeId, hasEdgeLength, edgeLength, "edgeLength<-",
sumEdgeLength, edgeOrder)
# root methods
Modified: pkg/R/methods-phylo4.R
===================================================================
--- pkg/R/methods-phylo4.R 2009-09-04 21:54:25 UTC (rev 621)
+++ pkg/R/methods-phylo4.R 2009-09-08 16:15:07 UTC (rev 622)
@@ -137,6 +137,25 @@
x at order
})
+# return edge IDs (or a subset thereof) in edge matrix order
+setMethod("edgeId", "phylo4", function(x, type=c("all", "tip",
+ "internal", "root")) {
+ type <- match.arg(type)
+ edge <- edges(x)
+ if (type=="tip") {
+ isTip <- !(edge[, 2] %in% edge[, 1])
+ edge <- edge[isTip, , drop=FALSE]
+ } else if (type=="internal") {
+ isInt <- (edge[, 2] %in% edge[, 1])
+ edge <- edge[isInt, , drop=FALSE]
+ } else if (type=="root") {
+ isRoot <- is.na(edge[, 1])
+ edge <- edge[isRoot, , drop=FALSE]
+ } # else just use complete edge matrix if type is "all"
+ id <- paste(edge[, 1], edge[, 2], sep="-")
+ return(id)
+})
+
setMethod("hasEdgeLength","phylo4", function(x) {
!all(is.na(x at edge.length))
})
Modified: pkg/R/phylo4.R
===================================================================
--- pkg/R/phylo4.R 2009-09-04 21:54:25 UTC (rev 621)
+++ pkg/R/phylo4.R 2009-09-08 16:15:07 UTC (rev 622)
@@ -35,6 +35,12 @@
standardGeneric("edgeOrder")
})
+## edgeId
+setGeneric("edgeId", function(x, type=c("all", "tip", "internal",
+ "root")) {
+ standardGeneric("edgeId")
+})
+
## hasEdgeLength
setGeneric("hasEdgeLength", function(x) {
standardGeneric("hasEdgeLength")
Modified: pkg/man/treewalk.Rd
===================================================================
--- pkg/man/treewalk.Rd 2009-09-04 21:54:25 UTC (rev 621)
+++ pkg/man/treewalk.Rd 2009-09-08 16:15:07 UTC (rev 622)
@@ -12,6 +12,8 @@
\alias{sumEdgeLength,phylo4-method}
\alias{nodeId}
\alias{nodeId,phylo4-method}
+\alias{edgeId}
+\alias{edgeId,phylo4-method}
\title{tree traversal and utility functions}
\description{
Functions for describing relationships among
More information about the Phylobase-commits
mailing list