[Picante-commits] r240 - in pkg: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Oct 9 14:10:48 CEST 2012
Author: skembel
Date: 2012-10-09 14:10:48 +0200 (Tue, 09 Oct 2012)
New Revision: 240
Removed:
pkg/R/pic3.R
pkg/man/pic3.Rd
Modified:
pkg/R/traitgram.R
pkg/man/traitgram.Rd
Log:
Modify traitgram to remove pic3 function and dependencies on ape's C code
Deleted: pkg/R/pic3.R
===================================================================
--- pkg/R/pic3.R 2012-10-02 00:33:03 UTC (rev 239)
+++ pkg/R/pic3.R 2012-10-09 12:10:48 UTC (rev 240)
@@ -1,47 +0,0 @@
-## pic3 is a minor modification of the pic function from the ape
-## library that returns the nodal values at each node of the
-## tree in a third column, along with the contrasts and the
-## variance of the contrasts.
-
-pic3 = function (x, phy, scaled = TRUE, var.contrasts = TRUE)
-{
- if (class(phy) != "phylo")
- stop("object 'phy' is not of class \"phylo\"")
- if (is.null(phy$edge.length))
- stop("your tree has no branch lengths: you may consider setting them equal to one, or using the function `compute.brlen'.")
- nb.tip <- length(phy$tip.label)
- nb.node <- phy$Nnode
- if (nb.node != nb.tip - 1)
- stop("'phy' is not rooted and fully dichotomous")
- if (length(x) != nb.tip)
- stop("length of phenotypic and of phylogenetic data do not match")
- if (any(is.na(x)))
- stop("the present method cannot (yet) be used directly with missing data: you may consider removing the species with missing data from your tree with the function `drop.tip'.")
- phy <- reorder(phy, "pruningwise")
- phenotype <- numeric(nb.tip + nb.node)
- if (is.null(names(x))) {
- phenotype[1:nb.tip] <- x
- } else {
- if (all(names(x) %in% phy$tip.label))
- phenotype[1:nb.tip] <- x[phy$tip.label]
- else {
- phenotype[1:nb.tip] <- x
- warning("the names of argument \"x\" and the names of the tip labels did not match: the former were ignored in the analysis.")
- }
- }
- contr <- var.con <- numeric(nb.node)
- ans <- .C("pic", as.integer(nb.tip), as.integer(nb.node),
- as.integer(phy$edge[, 1]), as.integer(phy$edge[, 2]),
- as.double(phy$edge.length), as.double(phenotype), as.double(contr),
- as.double(var.con), as.integer(var.contrasts), as.integer(scaled),
- PACKAGE = "ape")
- contr <- ans[[7]]
- if (var.contrasts) {
- contr <- cbind(contr, ans[[8]])
- contr <- cbind(contr, ans[[6]][-(1:nb.tip)])
- dimnames(contr) <- list(1:nb.node + nb.tip, c("contrasts",
- "variance","node.vals"))
- }
- else names(contr) <- 1:nb.node + nb.tip
- return(contr)
-}
\ No newline at end of file
Modified: pkg/R/traitgram.R
===================================================================
--- pkg/R/traitgram.R 2012-10-02 00:33:03 UTC (rev 239)
+++ pkg/R/traitgram.R 2012-10-09 12:10:48 UTC (rev 240)
@@ -1,18 +1,17 @@
+## draws a phylogeny with tips and nodes positioned
+## by trait value, and brownian ancestral value
+## node height by branch lengths
traitgram = function(
- ## draws a phylogeny with tips and nodes positioned
- ## by trait value, and brownian ancestral value
- ## node height by branch lengths
-
- x,phy,
+ x, phy,
xaxt='s',
underscore = FALSE,
show.names = TRUE,
show.xaxis.values = TRUE,
- method = c('ace','pic'),
+ method = c('ML','pic'),
...)
-
{
- require(ape)
+
+ method <- match.arg(method)
Ntaxa = length(phy$tip.label)
Ntot = Ntaxa + phy$Nnode
phy = node.age(phy)
@@ -36,8 +35,9 @@
lmar = 0.2
if (xaxt=='s') if (show.xaxis.values) lmar = 1 else lmar = 0.5
- if (method[1]=='ace') xanc = ace(xx,phy)$ace
- else xanc = pic3(xx,phy)[,3]
+ xanc <- ace(xx, phy, method=method)$ace
+ #if (method[1]=='ace') xanc = ace(xx,phy)$ace
+ # else xanc = pic3(xx,phy)[,3]
xall = c(xx,xanc)
a0 = ages[phy$edge[,1]]
Deleted: pkg/man/pic3.Rd
===================================================================
--- pkg/man/pic3.Rd 2012-10-02 00:33:03 UTC (rev 239)
+++ pkg/man/pic3.Rd 2012-10-09 12:10:48 UTC (rev 240)
@@ -1,38 +0,0 @@
-\name{pic3}
-\alias{pic3}
-
-\title{ Independent contrasts }
-\description{
- Modification of pic function from ape to return internal node values as well as contrasts and variance of contrasts.
-}
-\usage{
-pic3(x, phy, scaled = TRUE, var.contrasts = TRUE)
-}
-
-\arguments{
- \item{x}{ Trait vector (same order as phy\$tip.label) }
- \item{phy}{ phylo object }
- \item{scaled}{ TRUE = standardize contrasts by branch lengths }
- \item{var.contrasts}{ TRUE = return variance of contrasts }
-}
-\value{
- Matrix with three columns:
- \item{row.names }{node numbers}
- \item{contrasts }{independent contrast value}
- \item{variance }{variance of contrasts (sum of subtending branch lengths)}
- \item{node.vals }{values calculated at internal nodes by contrast algorithm}
-}
-\references{
-Felsenstein J (1985) Phylogenies and the comparative method. American Naturalist 125: 1-15.
-
-Garland T, Jr, Harvey PH & Ives AR (1992) Procedures for the analysis of comparative data using phylogenetically independent contrasts. Systematic Biology 41: 18-32.
- }
-\author{ Original pic function by Emmanuel Paradis <Emmanuel.Paradis at mpl.ird.fr> modified to return node.vals by David Ackerly <dackerly at berkeley.edu> }
-\seealso{ \code{\link[ape]{pic}} }
-\section{Warning }{ Assumes that trait data are sorted in the same order as phylo\$tip.label }
-\examples{
-randtree <- rcoal(20)
-randtraits <- rTraitCont(randtree)
-pic3(randtraits,randtree)
-}
-\keyword{univar}
\ No newline at end of file
Modified: pkg/man/traitgram.Rd
===================================================================
--- pkg/man/traitgram.Rd 2012-10-02 00:33:03 UTC (rev 239)
+++ pkg/man/traitgram.Rd 2012-10-09 12:10:48 UTC (rev 240)
@@ -7,7 +7,7 @@
}
\usage{
traitgram(x, phy, xaxt = 's', underscore = FALSE, show.names = TRUE,
- show.xaxis.values = TRUE, method = c('ace','pic'), ...)
+ show.xaxis.values = TRUE, method = c('ML','pic'), ...)
}
\arguments{
More information about the Picante-commits
mailing list