[Adephylo-commits] r100 - in pkg: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Dec 14 16:52:39 CET 2008


Author: jombart
Date: 2008-12-14 16:52:39 +0100 (Sun, 14 Dec 2008)
New Revision: 100

Modified:
   pkg/R/abouheif.R
   pkg/R/ppca.R
   pkg/man/abouheif.Rd
   pkg/man/carni70.Rd
   pkg/man/lizards.Rd
   pkg/man/maples.Rd
   pkg/man/miscUtils.Rd
   pkg/man/mjrochet.Rd
   pkg/man/orthobasis.Rd
   pkg/man/ungulates.Rd
Log:
Corrected all the docs, and added some improvements.


Modified: pkg/R/abouheif.R
===================================================================
--- pkg/R/abouheif.R	2008-12-13 18:08:12 UTC (rev 99)
+++ pkg/R/abouheif.R	2008-12-14 15:52:39 UTC (rev 100)
@@ -7,12 +7,12 @@
     alter <- match.arg(alter)
     method <- match.arg(method)
 
-    ## handles W
+    ## handle W
     if(!is.null(W)){ # W is provided
-        if (any(W<0)) stop ("term <0 found in 'W'")
+        if (any(W<0)) stop ("negative terms found in 'W'")
         if (nrow(W) != ncol(W)) stop ("'W' is not squared")
         W <- as.matrix(W)
-    } else { # otherwise computed from x, a phylo4d object
+    } else { # otherwise computed W from x, a phylo4d object
         if(!inherits(x, "phylo4d")) stop("if W is not provided, x has to be a phylo4d object")
         if (is.character(chk <- check_phylo4(x))) stop("bad phylo4d object: ",chk)
         if (is.character(chk <- check_data(x))) stop("bad phylo4d object: ",chk)
@@ -31,8 +31,10 @@
     }
 
     ## main computations
+    x <- data.frame(x)
     test.names <- names(x)
-    x <- data.matrix(x)
+    x <- data.matrix(x) # convert all variables to numeric type
+
     if (nrow(x) != nobs) stop ("non convenient dimension")
     nvar <- ncol(x)
     res <- .C("gearymoran",

Modified: pkg/R/ppca.R
===================================================================
--- pkg/R/ppca.R	2008-12-13 18:08:12 UTC (rev 99)
+++ pkg/R/ppca.R	2008-12-14 15:52:39 UTC (rev 100)
@@ -163,6 +163,8 @@
     }
     args <- c(obj,args)
     do.call(s.phylo4d, args)
+
+    return(invisible(match.call()))
 } # end scatter.ppca
 
 
@@ -368,7 +370,7 @@
 
     ## some checks
     if (!inherits(x, "ppca")) stop("Use only with 'ppca' objects.")
-    if(axes>ncol(x$li) | axes<0) stop("wrong axes required.")
+    if(any(axes>ncol(x$li) | axes<0)) stop("wrong axes required.")
 
     ## par / layout
     opar <- par(no.readonly = TRUE)
@@ -387,6 +389,8 @@
     col <- rep("white", r)
 
     keptAxes <- c( (1:r)[1:x$nfposi], (r:1)[1:x$nfnega]) # kept axes
+    if(x$nfposi==0) keptAxes <- keptAxes[-1]
+    if(x$nfnega==0) keptAxes <- keptAxes[-length(keptAxes)]
     col[keptAxes] <- "grey"
 
     repAxes <- gsub("PC","",colnames(x$li)[axes]) # represented axes
@@ -450,7 +454,7 @@
         scatterOk <- !inherits(temp,"try-error")
     }
 
-    return(match.call())
+    return(invisible(match.call()))
 
 } # end plot.phylo
 

Modified: pkg/man/abouheif.Rd
===================================================================
--- pkg/man/abouheif.Rd	2008-12-13 18:08:12 UTC (rev 99)
+++ pkg/man/abouheif.Rd	2008-12-14 15:52:39 UTC (rev 100)
@@ -83,5 +83,4 @@
 plot(abouheif.moran(x, method="nNodes") )
 }
 }
-\keyword{spatial}
-\keyword{ts}
+

Modified: pkg/man/carni70.Rd
===================================================================
--- pkg/man/carni70.Rd	2008-12-13 18:08:12 UTC (rev 99)
+++ pkg/man/carni70.Rd	2008-12-14 15:52:39 UTC (rev 100)
@@ -30,11 +30,14 @@
 par(mar=rep(.1,4))
 s.phylo4d(x,cex.lab=.5, show.n=FALSE, ratio=.5)
 
-## transform size in log
+## transform size in log and test for a phylogenetic signal
 size <- log(carni70$tab)[,1]
 names(size) <- row.names(carni70$tab)
-tdata(x) <- cbind.data.frame(sizeLog=size, tdata(x))
-s.phylo4d(x,cex.lab=.5, show.n=FALSE, ratio=.5)
+orthogram(size, tre)
 
+## transform range and test for a phylogenetic signal
+yrange <- scalewt(carni70$tab)[,2]
+names(yrange) <- row.names(carni70$tab)
+orthogram(yrange, tre)
 }
 \keyword{datasets}

Modified: pkg/man/lizards.Rd
===================================================================
--- pkg/man/lizards.Rd	2008-12-13 18:08:12 UTC (rev 99)
+++ pkg/man/lizards.Rd	2008-12-14 15:52:39 UTC (rev 100)
@@ -33,7 +33,6 @@
 }
 \examples{
 data(lizards)
-traits <- data.frame(log(lizards$traits))
 
 ## see data
 data(lizards)
@@ -43,12 +42,24 @@
 
 ## compute and plot principal components
 if(require(ade4)){
-liz.pca1 <- dudi.pca(traits, scannf=FALSE, nf=2) # PCA of traits
+liz.pca1 <- dudi.pca(traits, cent=TRUE, scale=TRUE, scannf=FALSE, nf=2) # PCA of traits
 myPC <- phylo4d(liz.tr, liz.pca1$li) # store PC in a phylo4d object
 varlab <- paste("Principal \ncomponent", 1:2) # make labels for PCs
 s.phylo4d(myPC, ratio=.8, var.lab=varlab) # plot the PCs
 add.scatter.eig(liz.pca1$eig,2,1,2,posi="topleft", inset=c(0,.15))
 title("Phylogeny and the principal components")
+
+## compute a pPCA ##
+## remove size effect
+temp <- lapply(liz.pca1$tab, function(e) residuals(lm(e~-1+liz.pca1$li[,1])) )
+temp <- data.frame(temp)
+row.names(temp) <- liz at tip.label
+
+## build corresponding phylo4d object
+liz.noSize <- phylo4d(liz.tr, temp)
+ppca1 <- ppca(liz.noSize, method="Abouheif", scale=FALSE, scannf=FALSE)
+plot(ppca1)
+
 }
 }
 \keyword{datasets}

Modified: pkg/man/maples.Rd
===================================================================
--- pkg/man/maples.Rd	2008-12-13 18:08:12 UTC (rev 99)
+++ pkg/man/maples.Rd	2008-12-14 15:52:39 UTC (rev 100)
@@ -45,6 +45,6 @@
 ## use ape's PIC (phylogenetic independent contrasts)
 pic.bif <- pic(bif, tre)
 pic.dom <- pic(dom, tre)
-cor.test(pic.bif, pic.dom) # correlation no longer significant
+cor.test(pic.bif, pic.dom) # correlation is no longer significant
 }
 \keyword{datasets}

Modified: pkg/man/miscUtils.Rd
===================================================================
--- pkg/man/miscUtils.Rd	2008-12-13 18:08:12 UTC (rev 99)
+++ pkg/man/miscUtils.Rd	2008-12-14 15:52:39 UTC (rev 100)
@@ -6,7 +6,7 @@
   functions. Regular users can use them as well, but no validity checks
   are performed for the arguments: speed is here favored over safety.
   Most of these functions handle trees inheriting \linkS4class{phylo4}
-  class .\cr
+  class.\cr
 
   \code{.tipToRoot} finds the set of nodes between a tip and the root of
   a tree.\cr
@@ -19,7 +19,7 @@
   \item{x}{A valid tree of  class \linkS4class{phylo4}.}
   \item{tip}{An integer identifying a tip by its numbers.}
   \item{root}{An integer identifying the root of the tree by its
-    numbers.}
+    number.}
   \item{include.root}{a logical stating whether the root must be
     included as a node of the path from tip to root (TRUE), or not
     (FALSE, default).}

Modified: pkg/man/mjrochet.Rd
===================================================================
--- pkg/man/mjrochet.Rd	2008-12-13 18:08:12 UTC (rev 99)
+++ pkg/man/mjrochet.Rd	2008-12-14 15:52:39 UTC (rev 100)
@@ -50,5 +50,11 @@
 
 ## see data
 s.phylo4d(mjr,cex.lab=.5,show.node=FALSE,symb="square")
+
+## perform Abouheif's test for each trait
+mjr.tests <- abouheif.moran(mjr, nrep=499)
+mjr.tests
+plot(mjr.tests)
+
 }
 \keyword{datasets}

Modified: pkg/man/orthobasis.Rd
===================================================================
--- pkg/man/orthobasis.Rd	2008-12-13 18:08:12 UTC (rev 99)
+++ pkg/man/orthobasis.Rd	2008-12-14 15:52:39 UTC (rev 100)
@@ -49,8 +49,13 @@
   only uniform weights
 }
 \author{ Thibaut Jombart \email{jombart at biomserv.univ-lyon1.fr} }
-\seealso{\code{\link{proxTips}} which computes phylogenetic proximities
-  between tips.
+\seealso{
+  - \code{\link{proxTips}} which computes phylogenetic proximities
+  between tips.\cr
+
+  - \code{\link{treePart}} which can compute an orthobasis based on
+    the topology of a phylogeny.\cr
+
 }
 \examples{
 if(require(ape) & require(ade4)){
@@ -64,6 +69,23 @@
 ## plot the 10 first vectors
 obj <- phylo4d(x, as.data.frame(ME[,1:10]))
 s.phylo4d(obj, cex.sym=.7, cex.lab=.7)
+
+
+## removing phylogenetic autocorrelation in a model ##
+example(ungulates)
+lm1
+resid1 <- residuals(lm1)
+orthogram(resid1, tre) # residuals are autocorrelated
+
+## compute Moran's eigenvectors (ME)
+myME <- me.phylo(tre, method="Abou")
+lm2 <- lm(neonatw ~ myME[,1] + afbw) # use for ME as covariable
+resid2 <- residuals(lm2)
+orthogram(resid2, tre) # there is no longer phylogenetic autocorrelation 
+
+## see the difference
+s.phylo4d(phylo4d(tre, cbind.data.frame(resid1, resid2)))
+
 }
 }
 \keyword{manip}

Modified: pkg/man/ungulates.Rd
===================================================================
--- pkg/man/ungulates.Rd	2008-12-13 18:08:12 UTC (rev 99)
+++ pkg/man/ungulates.Rd	2008-12-14 15:52:39 UTC (rev 100)
@@ -41,14 +41,12 @@
 names(afbw) <- tre$tip.label
 names(neonatw) <- tre$tip.label
 plot(afbw, neonatw) # relationship between traits
-abline(lm(neonatw~afbw))
+lm1 <- lm(neonatw~afbw)
+abline(lm1)
 x <- phylo4d(tre, cbind.data.frame(afbw, neonatw)) # traits on the phylogeny
 
+## test phylogenetic inertia in residuals
 
-## orthogram(ung.x,ung.phy$Bscores,nrep=9999)
-## ung.z <- residuals(lm(ung.y~ung.x))
-## names(ung.z) <- names(ung.phy$leaves)
-## dotchart.phylog(ung.phy,ung.z,cle=1.5,cno=1.5,cdot=1,ceti=0.75)
-## orthogram(ung.z,ung.phy$Bscores,nrep=9999)
+orthogram(residuals(lm1), x)
 }
 \keyword{datasets}



More information about the Adephylo-commits mailing list