[Mattice-commits] r222 - in pkg: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Sep 4 21:24:09 CEST 2009
Author: andrew_hipp
Date: 2009-09-04 21:24:09 +0200 (Fri, 04 Sep 2009)
New Revision: 222
Modified:
pkg/R/batchHansen.R
pkg/man/carex.Rd
pkg/man/regimeMaker.Rd
pkg/man/regimeMatrix.Rd
Log:
updating documentation files; also commens in runBatchHansen
Modified: pkg/R/batchHansen.R
===================================================================
--- pkg/R/batchHansen.R 2009-09-02 21:00:57 UTC (rev 221)
+++ pkg/R/batchHansen.R 2009-09-04 19:24:09 UTC (rev 222)
@@ -18,7 +18,7 @@
# "brown" = whether to analyse the data under a Brownian motion model
# "..." = additional arguments to pass along to hansen
function(ouchTrees, characterStates, cladeMembersList, filePrefix = NULL, di = NULL, nodeNames = NULL, maxNodes = length(cladeMembersList), regimeTitles = NULL, brown = FALSE, ...) {
- ## do all the objects in ouchTrees inherit ouchtree?
+ ## check whether all objects in ouchTrees inherit ouchtree?
if(is(ouchTrees,'ouchtree')) ouchTrees <- list(ouchTrees)
treeCheck <- unlist(lapply(ouchTrees, function(x) is(x,'ouchtree')))
if(FALSE %in% treeCheck)
Modified: pkg/man/carex.Rd
===================================================================
--- pkg/man/carex.Rd 2009-09-02 21:00:57 UTC (rev 221)
+++ pkg/man/carex.Rd 2009-09-04 19:24:09 UTC (rev 222)
@@ -47,7 +47,6 @@
}
\examples{
- library(maticce)
data(carex)
# tree comes in in phylo format, but we need an ouchtree object
trees <- lapply(carex$ovales.bayesTrees[1:10], ape2ouch)
Modified: pkg/man/regimeMaker.Rd
===================================================================
--- pkg/man/regimeMaker.Rd 2009-09-02 21:00:57 UTC (rev 221)
+++ pkg/man/regimeMaker.Rd 2009-09-04 19:24:09 UTC (rev 222)
@@ -5,7 +5,7 @@
Returns ouch-style regimes defined by a matrix, with each row specifying which nodes permit character transitions
}
\description{
-%% ~~ A concise (1-5 lines) description of what the function does. ~~
+ This function utilizes a matrix of the format returned by \code{regimeMatrix}
}
\usage{
regimeMaker(ouchTrees, regMatrix, nodeMembers)
@@ -45,57 +45,16 @@
%% ~Make other sections like Warning with \section{Warning }{....} ~
\seealso{
-%% ~~objects to See Also as \code{\link{help}}, ~~~
+ \code{\link{regimeMatrix}}, \code{\link{paintBranches}}
}
\examples{
-##---- Should be DIRECTLY executable !! ----
-##-- ==> Define data, use random,
-##-- or do help(data=index) for the standard data sets.
-
-## The function is currently defined as
-function (ouchTrees, regMatrix, nodeMembers)
-{
- numTrees <- length(ouchTrees)
- numNodes <- length(nodeMembers)
- if (numNodes != dim(regMatrix)[2])
- stop("Number of nodes (columns) in regMatrix must equal number of items in nodeMembers list")
- nodeMatrix <- matrix(NA, nrow = numTrees, ncol = numNodes,
- dimnames = list(seq(numTrees), dimnames(regMatrix)[[2]]))
- changeNodes <- list(numTrees)
- regList <- list(numTrees)
- regMatrices <- list(numTrees)
- for (i in seq(numNodes)) nodeMatrix[, i] <- unlist(lapply(ouchTrees,
- isMonophyletic, taxa = nodeMembers[[i]]))
- for (i in seq(numTrees)) {
- tree <- ouchTrees[[i]]
- regMatrices[[i]] <- regMatrix * as.numeric(matrix(nodeMatrix[i,
- ], dim(regMatrix)[1], dim(regMatrix)[2], byrow = TRUE))
- regMatrices[[i]][1:(dim(regMatrices[[i]])[1] - 1), ][which(apply(regMatrices[[i]][1:(dim(regMatrices[[i]])[1] -
- 1), ], 1, sum) == 0), ] <- rep(NA, numNodes)
- regMatrices[[i]][duplicated(apply(regMatrices[[i]], 1,
- as.decimal)), ] <- rep(NA, numNodes)
- dimnames(regMatrices[[i]]) <- list(seq(dim(regMatrices[[i]])[1]),
- dimnames(regMatrices[[i]])[[2]])
- numTreeRegs <- dim(regMatrices[[i]])[1]
- treeRegs <- list(numTreeRegs)
- nodesVector <- unlist(lapply(nodeMembers, mrcaOUCH, tree = ouchTrees[[i]]))
- for (j in seq(numTreeRegs)) {
- if (any(is.na(regMatrices[[i]][j, ])))
- treeRegs[[j]] <- NA
- else {
- treeRegs[[j]] <- as.factor(paintBranches(c("1",
- nodesVector[as.logical(regMatrices[[i]][j,
- ])]), tree))
- names(treeRegs[[j]]) <- tree at nodes
- }
- }
- regList[[i]] <- treeRegs
- }
- regMatrices$overall <- regMatrix
- outdata <- list(regList = regList, nodeMatrix = nodeMatrix,
- regMatrix = regMatrices)
- return(outdata)
- }
+ data(carex)
+ # tree comes in in phylo format, but we need an ouchtree object
+ trees <- lapply(carex$ovales.bayesTrees[1:10], ape2ouch)
+ # if we are interested in comparing the single-change models that allow changes only at nodes 1, 2, 4, 5, and 8, as well as the no-change model, we could do:
+ mat <- regimeMatrix(n = 8, maxNodes = 1)[c(1,2,4,5,8,9), ] # the 9th row is the no-change model
+ regs <- regimeMaker(trees, mat, carex$ovales.nodes)
+
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
Modified: pkg/man/regimeMatrix.Rd
===================================================================
--- pkg/man/regimeMatrix.Rd 2009-09-02 21:00:57 UTC (rev 221)
+++ pkg/man/regimeMatrix.Rd 2009-09-04 19:24:09 UTC (rev 222)
@@ -12,40 +12,34 @@
\usage{
regimeMatrix(n, maxNodes)
}
-%- maybe also 'usage' for other objects documented here.
\arguments{
\item{n}{
-%% ~~Describe \code{n} here~~
+ An integer between 1 and \code{maxNodes}
}
\item{maxNodes}{
-%% ~~Describe \code{maxNodes} here~~
+ An integer between 1 and n; at \code{n} = \code{maxNodes}, \code{regimeMatrix} will return a matrix of 2^\code{n} rows.
}
}
\details{
Typically, this function is called by \code{regimeVectors},
- but it may be useful to
+ but it may be useful to call this function if you are interested in definining a
}
\value{
-%% ~Describe the value returned
-%% If it is a LIST, use
-%% \item{comp1 }{Description of 'comp1'}
-%% \item{comp2 }{Description of 'comp2'}
-%% ...
-}
+ A matrix of n columns by k rows, where n is a number
+ of items and k is the number of all possible permutations of those items, up to a maximum number of items
+ defined by \code{maxNodes}, and including a row with zero items
+ }
\references{
%% ~put references to the literature/web site here ~
}
\author{
-%% ~~who you are~~
+ Andrew Hipp \email{ahipp at mortonarb.org}
}
\note{
%% ~~further notes~~
}
-
-%% ~Make other sections like Warning with \section{Warning }{....} ~
-
\seealso{
-%% ~~objects to See Also as \code{\link{help}}, ~~~
+ \code{\link{regimeMaker}}, \code{\link{paintBranches}}
}
\examples{
##---- Should be DIRECTLY executable !! ----
More information about the Mattice-commits
mailing list