[Mattice-commits] r221 - in pkg: . man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Sep 2 23:00:58 CEST 2009
Author: andrew_hipp
Date: 2009-09-02 23:00:57 +0200 (Wed, 02 Sep 2009)
New Revision: 221
Added:
pkg/man/regimeMaker.Rd
pkg/man/regimeMatrix.Rd
Modified:
pkg/NAMESPACE
Log:
adding regimeMaker and regimeMatrix to the NAMESPACE and to the documentation files
Modified: pkg/NAMESPACE
===================================================================
--- pkg/NAMESPACE 2009-09-02 15:51:57 UTC (rev 220)
+++ pkg/NAMESPACE 2009-09-02 21:00:57 UTC (rev 221)
@@ -4,7 +4,7 @@
export(isMonophyletic, nodeDescendents, mrcaOUCH)
export(multiModel)
export(ouSim, ouSim.hansenBatch, ouSim.hansenSummary, ouSim.browntree, ouSim.hansentree, ouSim.ouchtree, ouSim.phylo)
-export(regimeVectors, paintBranches)
+export(regimeVectors, regimeMaker, regimeMatrix, paintBranches)
export(runBatchHansen)
S3method(summary, hansenBatch)
Added: pkg/man/regimeMaker.Rd
===================================================================
--- pkg/man/regimeMaker.Rd (rev 0)
+++ pkg/man/regimeMaker.Rd 2009-09-02 21:00:57 UTC (rev 221)
@@ -0,0 +1,103 @@
+\name{regimeMaker}
+\Rdversion{1.1}
+\alias{regimeMaker}
+\title{
+ 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. ~~
+}
+\usage{
+regimeMaker(ouchTrees, regMatrix, nodeMembers)
+}
+%- maybe also 'usage' for other objects documented here.
+\arguments{
+ \item{ouchTrees}{
+%% ~~Describe \code{ouchTrees} here~~
+}
+ \item{regMatrix}{
+%% ~~Describe \code{regMatrix} here~~
+}
+ \item{nodeMembers}{
+%% ~~Describe \code{nodeMembers} here~~
+}
+}
+\details{
+%% ~~ If necessary, more details than the description above ~~
+}
+\value{
+%% ~Describe the value returned
+%% If it is a LIST, use
+%% \item{comp1 }{Description of 'comp1'}
+%% \item{comp2 }{Description of 'comp2'}
+%% ...
+}
+\references{
+%% ~put references to the literature/web site here ~
+}
+\author{
+%% ~~who you are~~
+}
+\note{
+%% ~~further notes~~
+}
+
+%% ~Make other sections like Warning with \section{Warning }{....} ~
+
+\seealso{
+%% ~~objects to See Also as \code{\link{help}}, ~~~
+}
+\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)
+ }
+}
+% Add one or more standard keywords, see file 'KEYWORDS' in the
+% R documentation directory.
+\keyword{ ~kwd1 }
+\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line
Added: pkg/man/regimeMatrix.Rd
===================================================================
--- pkg/man/regimeMatrix.Rd (rev 0)
+++ pkg/man/regimeMatrix.Rd 2009-09-02 21:00:57 UTC (rev 221)
@@ -0,0 +1,81 @@
+\name{regimeMatrix}
+\Rdversion{1.1}
+\alias{regimeMatrix}
+\title{
+%% ~~function to do ... ~~
+}
+\description{
+ \code{regimeMatrix} is a recursive function that returns 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.
+}
+\usage{
+regimeMatrix(n, maxNodes)
+}
+%- maybe also 'usage' for other objects documented here.
+\arguments{
+ \item{n}{
+%% ~~Describe \code{n} here~~
+}
+ \item{maxNodes}{
+%% ~~Describe \code{maxNodes} here~~
+}
+}
+\details{
+ Typically, this function is called by \code{regimeVectors},
+ but it may be useful to
+ }
+\value{
+%% ~Describe the value returned
+%% If it is a LIST, use
+%% \item{comp1 }{Description of 'comp1'}
+%% \item{comp2 }{Description of 'comp2'}
+%% ...
+}
+\references{
+%% ~put references to the literature/web site here ~
+}
+\author{
+%% ~~who you are~~
+}
+\note{
+%% ~~further notes~~
+}
+
+%% ~Make other sections like Warning with \section{Warning }{....} ~
+
+\seealso{
+%% ~~objects to See Also as \code{\link{help}}, ~~~
+}
+\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 (n, maxNodes)
+{
+ if (n == 1)
+ return(matrix(1:0, nrow = 2, ncol = 1))
+ outmat <- matrix(NA, nrow = 0, ncol = n)
+ for (i in 1:(n - 1)) {
+ temp <- c(rep(0, (i - 1)), 1)
+ remainder <- n - i
+ if (maxNodes > 1 && remainder > 0) {
+ nextMat <- regimeMatrix(remainder, maxNodes - 1)
+ temp <- cbind(matrix(temp, dim(nextMat)[1], length(temp),
+ byrow = TRUE), nextMat)
+ }
+ else temp[(i + 1):n] <- rep(0, length((i + 1):n))
+ outmat <- rbind(outmat, temp)
+ }
+ outmat <- rbind(outmat, c(rep(0, n - 1), 1))
+ outmat <- rbind(outmat, rep(0, n))
+ dimnames(outmat) = list(seq(dim(outmat)[1]), seq(dim(outmat)[2]))
+ return(outmat)
+ }
+}
+% Add one or more standard keywords, see file 'KEYWORDS' in the
+% R documentation directory.
+\keyword{ ~kwd1 }
+\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line
More information about the Mattice-commits
mailing list