[Adephylo-commits] r109 - in pkg: R inst/doc man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Dec 15 19:45:57 CET 2008
Author: jombart
Date: 2008-12-15 19:45:56 +0100 (Mon, 15 Dec 2008)
New Revision: 109
Modified:
pkg/R/partition.R
pkg/R/table.phylo4d.R
pkg/inst/doc/adephylo.Rnw
pkg/man/table.phylo4d.Rd
pkg/man/treePart.Rd
Log:
Still some work to do. Added a repVar argument to table.phylo4d.
Modified: pkg/R/partition.R
===================================================================
--- pkg/R/partition.R 2008-12-15 18:18:09 UTC (rev 108)
+++ pkg/R/partition.R 2008-12-15 18:45:56 UTC (rev 109)
@@ -36,7 +36,7 @@
###########
# treePart
###########
-treePart <- function(x, result=c("basis", "orthobasis")){
+treePart <- function(x, result=c("dummy", "orthobasis")){
if(!require(phylobase)) stop("phylobase package is not installed")
## conversion from phylo, phylo4 and phylo4d
@@ -66,7 +66,7 @@
row.names(res) <- x at tip.label
res <- res[,-1]
- if(result=="basis"){
+ if(result=="dummy"){
return(res) # res is a data.frame of dummy vectors
}
Modified: pkg/R/table.phylo4d.R
===================================================================
--- pkg/R/table.phylo4d.R 2008-12-15 18:18:09 UTC (rev 108)
+++ pkg/R/table.phylo4d.R 2008-12-15 18:45:56 UTC (rev 109)
@@ -2,7 +2,7 @@
## table.phylo4d
#############
table.phylo4d <- function(x, treetype=c("phylogram","cladogram"), symbol=c("circles", "squares"),
- center=TRUE, scale=TRUE, legend=TRUE, grid=TRUE, box=TRUE,
+ repVar=1:ncol(x$tip.data), center=TRUE, scale=TRUE, legend=TRUE, grid=TRUE, box=TRUE,
show.tip.label=TRUE, show.node.label=TRUE, show.var.label=TRUE,
ratio.tree=1/3, font=3,
tip.label=x at tip.label, var.label=colnames(x at tip.data),
@@ -40,6 +40,7 @@
#### data handling
## retrieve data
dat <- tdata(x, which="tip")
+ dat <- dat[, repVar]
clas <- lapply(dat,class)
isNum <- sapply(clas, function(e) e %in% c("integer","numeric"))
## keep only numeric data
Modified: pkg/inst/doc/adephylo.Rnw
===================================================================
--- pkg/inst/doc/adephylo.Rnw 2008-12-15 18:18:09 UTC (rev 108)
+++ pkg/inst/doc/adephylo.Rnw 2008-12-15 18:45:56 UTC (rev 109)
@@ -403,6 +403,60 @@
+
+% % % % % % % % % % %
+\subsubsection{Phylogenetic decomposition of trait variation}
+% % % % % % % % % % %
+The phylogenetic decomposition of the variation of a trait proposed by Ollier
+et al. (2005, see references in \code{?orthogram}) is implemented by
+the function \code{orthogram}.
+This function replaces the former, deprecated version from \code{ade4}.
+\\
+
+The idea behind the method is to model different levels of variation
+on a phylogeny.
+Basically, these levels can be obtained from dummy vectors indicating
+which tip descends from a given node.
+A partition of tips can then be obtained for each node.
+This job is achieved by the function \code{treePart}.
+Here is an example using a small simulated tree:
+<<treePart,fig=TRUE>>=
+x <- rcoal(5)
+plot(x, show.node=TRUE)
+nodelabels(paste("N",1:4,sep=""))
+treePart(x)
+@
+
+\noindent The obtained partition can also be plotted:
+<<fig=TRUE>>=
+temp <- phylo4d(x, treePart(x))
+table.phylo4d(temp, cent=FALSE, scale=FALSE)
+@
+
+\noindent What we would like to do is assess where the variation of a trait is localized on
+the phylogeny; to do so, be could use these dummy vectors as
+regressors and see how variation is distributed among these vectors.
+However, these dummy vectors cannot be used as regressors because they
+are linearly dependent.
+The orthogram circumvents this issue by transforming and selecting
+dummy vectors into a new set of variables that are orthonormal.
+The obtained orthonormal basis can be used to decompose variation of
+the trait.
+Even if not necessary to get an orthogram, this basis can be obtained
+from \code{treePart}:
+<<>>=
+args(treePart)
+temp <- phylo4d(x, treePart(x, result="orthobasis") )
+table.phylo4d(temp)
+@
+
+\noindent And here is the orthonormal basis for our dataset of ungulates:
+<<fig=TRUE>>=
+temp <- phylo4d(myTree, treePart(myTree, result="orthobasis") )
+table.phylo4d(temp, repVar=1:10)
+@
+
+
%%%%%%%%%%%%%%%%%%%%%
\subsection{Modelling phylogenetic signal}
%%%%%%%%%%%%%%%%%%%%%
Modified: pkg/man/table.phylo4d.Rd
===================================================================
--- pkg/man/table.phylo4d.Rd 2008-12-15 18:18:09 UTC (rev 108)
+++ pkg/man/table.phylo4d.Rd 2008-12-15 18:45:56 UTC (rev 109)
@@ -15,7 +15,7 @@
}
\usage{
table.phylo4d(x, treetype=c("phylogram","cladogram"), symbol=c("circles", "squares"),
- center=TRUE, scale=TRUE, legend=TRUE, grid=TRUE, box=TRUE,
+ repVar=1:ncol(x$tip.data), center=TRUE, scale=TRUE, legend=TRUE, grid=TRUE, box=TRUE,
show.tip.label=TRUE, show.node.label=TRUE, show.var.label=TRUE,
ratio.tree=1/3, font=3,
tip.label=x at tip.label, var.label=colnames(x at tip.data),
@@ -25,6 +25,7 @@
\item{x}{a \linkS4class{phylo4d} object}
\item{treetype}{the type of tree to be plotted ("phylogram" or "cladogram")}
\item{symbol}{the type of symbol used to represent data ("circles" or "squares")}
+ \item{repVar}{the numerical index of variables to be plotted}
\item{center}{a logical stating whether variables should be centred
(TRUE, default) or not (FALSE)}
\item{scale}{a logical stating whether variables should be scaled
Modified: pkg/man/treePart.Rd
===================================================================
--- pkg/man/treePart.Rd 2008-12-15 18:18:09 UTC (rev 108)
+++ pkg/man/treePart.Rd 2008-12-15 18:45:56 UTC (rev 109)
@@ -13,16 +13,16 @@
the orthogram (Ollier \emph{et al.} 2006).
}
\usage{
-treePart(x, result=c("basis", "orthobasis"))
+treePart(x, result=c("dummy", "orthobasis"))
}
\arguments{
\item{x}{a tree of class \code{\link[pkg:ape]{phylo}},
\linkS4class{phylo4} or \linkS4class{phylo4d}.}
\item{result}{a character string specifying the type of result: either
- a basis of dummy vectors (\code{basis}), or an orthobasis derived from these dummy vectors (\code{orthobasis}).}
+ a basis of dummy vectors (\code{dummy}), or an orthobasis derived from these dummy vectors (\code{orthobasis}).}
}
\value{
- A matrix of dummy vectors (in columns) having one value for each
+ A matrix of numeric vectors (in columns) having one value for each
tip (rows).
}
\author{ Thibaut Jombart \email{jombart at biomserv.univ-lyon1.fr} }
More information about the Adephylo-commits
mailing list