[Adephylo-commits] r190 - in pkg: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue May 14 16:12:05 CEST 2013


Author: jombart
Date: 2013-05-14 16:12:05 +0200 (Tue, 14 May 2013)
New Revision: 190

Modified:
   pkg/ChangeLog
   pkg/DESCRIPTION
   pkg/R/bullseye.R
   pkg/man/adephylo.package.Rd
   pkg/man/dibas.Rd
   pkg/man/table.phylo4d.Rd
Log:
preparing new release - 1.1-4

Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog	2013-05-14 11:48:33 UTC (rev 189)
+++ pkg/ChangeLog	2013-05-14 14:12:05 UTC (rev 190)
@@ -1,3 +1,15 @@
+			CHANGES IN ADEPHYLO VERSION 1.1-4
+
+
+NEW FEATURES
+
+	o added the function bullseye to plot fan-like phylogenies and
+	associated traits.
+
+	o added new methods for dibas.
+
+
+
 			CHANGES IN ADEPHYLO VERSION 1.1-3
 
 

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2013-05-14 11:48:33 UTC (rev 189)
+++ pkg/DESCRIPTION	2013-05-14 14:12:05 UTC (rev 190)
@@ -1,6 +1,6 @@
 Package: adephylo
-Version: 1.1-3
-Date: 2012/10/30
+Version: 1.1-4
+Date: 2013/05/15
 Title: adephylo: exploratory analyses for the phylogenetic comparative method.
 Author: Thibaut Jombart <t.jombart at imperial.ac.uk>, Stephane Dray <stephane.dray at univ-lyon1.fr>
 Maintainer: Thibaut Jombart <t.jombart at imperial.ac.uk>
@@ -9,4 +9,4 @@
 Description: Multivariate tools to analyze comparative data, i.e. a phylogeny and some traits measured for each taxa.
 License: GPL (>=2)
 LazyLoad: yes
-Collate: utils.R partition.R table.phylo4d.R distances.R proximities.R orthobasis.R ppca.R orthogram.R abouheif.R moran.R dibas.R zzz.R
+Collate: utils.R partition.R table.phylo4d.R distances.R proximities.R orthobasis.R ppca.R orthogram.R abouheif.R moran.R dibas.R bullseye.R zzz.R

Modified: pkg/R/bullseye.R
===================================================================
--- pkg/R/bullseye.R	2013-05-14 11:48:33 UTC (rev 189)
+++ pkg/R/bullseye.R	2013-05-14 14:12:05 UTC (rev 190)
@@ -9,37 +9,49 @@
 ############
 ## bullseye
 ############
-bullseye <- function(phy, traits=NULL, type="fan", col.tips.by=NULL, col.pal=seasun,
-                     n.circ=6, bg.circ=transp("royalblue",.1), circ.unit=NULL,
-                     legend=TRUE, posi.leg="bottomleft", leg.title="",
-                     ...){
+bullseye <- function(phy, traits=NULL, col.tips.by=NULL, col.pal=seasun,
+                     circ.n=6, circ.bg=transp("royalblue",.1), circ.unit=NULL,
+                     legend=TRUE, leg.posi="bottomleft", leg.title="", leg.bg="white",
+                     traits.inset=1.1, traits.space=0.05, traits.pch=19, traits.cex=1,
+                     alpha=1, axis=TRUE, ...){
     ## CHECKS ##
     if(inherits(phy, c("phylo4","phylo4d"))) phy <- as(phy, "phylo")
     if(!is.list(col.pal)) col.pal <- c(col.pal)
+    leg.info <- NULL
 
     ## REORDER DATA BY TIP LABEL ##
-    ## traits
+    ## make sure traits is a data.frame
+    if(!is.null(traits)) traits <- as.data.frame(traits)
     if(!is.null(traits) && !is.null(row.names(traits))){
-        traits <- traits[phy$tip.label,,drop=FALSE]
+        if(!all(phy$tip.label %in% row.names(traits))){
+            warning("tip labels and names of the traits matrix do not match")
+        } else {
+            traits <- traits[phy$tip.label,,drop=FALSE]
+        }
     }
+
     ## col.tips.by
     if(!is.null(col.tips.by) && !is.null(names(col.tips.by))){
         col.tips.by <- col.tips.by[phy$tip.label]
     }
 
+    ## recycle col.pal
+    pal.length <- 0
+    if(!is.null(traits)) pal.length <- pal.length + ncol(traits)
+    if(!is.null(col.tips.by)) pal.length <- pal.length + 1
+    col.pal <- rep(col.pal, length=pal.length)
 
+
     ## PLOT THE PHYLOGENY
     ## handle color info
-    leg.txt <- NULL
     if(!is.null(col.tips.by)){
         tip.col.info <- any2col(col.tips.by, col.pal=col.pal[[1]])
-        plot(phy, type="fan", tip.col=tip.col.info$col, ...)
-        leg.col <- tip.col.info$leg.col
-        leg.txt <- tip.col.info$leg.txt
+        plot(phy, type="fan", tip.col=transp(tip.col.info$col,alpha), ...)
     } else{
         plot(phy, type="fan", ...)
     }
 
+
     ## HANDLE THE 'BULLSEYE' ##
     ## window setting
     oxpd <- par("xpd")
@@ -49,26 +61,72 @@
     ## annot info
     if(is.null(circ.unit)){
         annot.max <- 0.5*diff(par("usr")[1:2])
-        annot.dist <- seq(from=0, to=annot.max, length=n.circ)
+        annot.dist <- seq(from=0, to=annot.max, length=circ.n)
     } else {
-        annot.dist <- seq(from=0, by=circ.unit, length=n.circ)
+        annot.dist <- seq(from=0, by=circ.unit, length=circ.n)
         annot.max <- max(annot.dist)
     }
-    
+
     ## trace the disks
-    symbols(rep(0,n.circ), rep(0,n.circ), circ=annot.dist, inches=FALSE,
-        bg=bg.circ, fg=NA, add=TRUE)
+    symbols(rep(0,circ.n), rep(0,circ.n), circles=annot.dist, inches=FALSE,
+        bg=circ.bg, fg=NA, add=TRUE)
 
     ## axis annotation
-    segments(-annot.dist[2],0,-annot.dist[3],0)
-    text(-mean(annot.dist[2:3]),-annot.dist[2]/5,
-         label=format(annot.dist[2], scientific=TRUE, digits=3),cex=.7)
+    if(axis){
+        segments(-annot.dist[2],0,-annot.dist[3],0)
+        text(-mean(annot.dist[2:3]),-annot.dist[2]/5,
+             label=format(annot.dist[2], scientific=TRUE, digits=3),cex=.7)
+    }
 
+
+    ## PLOT TRAITS ##
+    if(!is.null(traits)){
+        ## recycle pch and cex
+        traits.pch <- rep(traits.pch, length=ncol(traits))
+        traits.cex <- rep(traits.cex, length=ncol(traits))
+
+        ## get tips coordinates
+        tips.x <- get("last_plot.phylo", envir = .PlotPhyloEnv)$xx[1:length(phy$tip.label)]
+        tips.y <- get("last_plot.phylo", envir = .PlotPhyloEnv)$yy[1:length(phy$tip.label)]
+
+        ## use furthest tip from the root to define new base coords
+        vec.length <- sqrt(tips.x^2 + tips.y^2)
+
+        x.base <- (tips.x/vec.length) * max(vec.length) * traits.inset
+        y.base <- (tips.y/vec.length) * max(vec.length) * traits.inset
+
+        ## plot traits
+        for(i in 1:ncol(traits)){
+            col.info <- any2col(traits[,i], col.pal=col.pal[[i]])
+            temp.x <- x.base * (traits.inset + i*traits.space)
+            temp.y <- y.base * (traits.inset + i*traits.space)
+            points(temp.x, temp.y, pch=traits.pch[i], col=transp(col.info$col,alpha), cex=traits.cex[i])
+
+            ## save info for legend if needed
+            if(is.null(col.tips.by) && i==1){
+                leg.info <- list(col=transp(col.info$leg.col,alpha), txt=col.info$leg.txt)
+            }
+        }
+    }
+
+
+    ## ADD LEGEND ##
     ## legend info
-    if(!is.null(legend) && !is.null(leg.txt)){
-        legend(x=posi.leg, legend=leg.txt, fill=leg.col, title=leg.title)
+    if(!is.null(legend)){
+        ## legend for tip colors
+        if(!is.null(col.tips.by)){
+            leg.col <- transp(tip.col.info$leg.col,alpha)
+            leg.txt <- tip.col.info$leg.txt
+            leg.info <- list(col=transp(tip.col.info$leg.col,alpha), txt=tip.col.info$leg.txt)
+        }
+
+        ## plot legend
+        if(!is.null(leg.info) && legend){
+            leg.info$posi <- leg.posi
+            legend(x=leg.info$posi, legend=leg.info$txt, fill=leg.info$col, title=leg.title, bg=leg.bg)
+            return(invisible(leg.info))
+        }
     }
 
-    leg.info <- list(posi=posi.leg, col=leg.col, txt=leg.txt)
-    return(invisible(leg.info))
+    return(invisible())
 } # end bullseye

Modified: pkg/man/adephylo.package.Rd
===================================================================
--- pkg/man/adephylo.package.Rd	2013-05-14 11:48:33 UTC (rev 189)
+++ pkg/man/adephylo.package.Rd	2013-05-14 14:12:05 UTC (rev 190)
@@ -109,6 +109,10 @@
    representing traits onto the tips of a phylogeny. Several traits can
    be plotted in a single graphic.\cr
 
+   - \code{\link{bullseye}}: an alternative to
+     \code{\link{table.phylo4d}} based on fan-like representation, better
+     for large trees.\cr
+
    - \code{\link{scatter.ppca}}, \code{\link{screeplot.ppca}},
    \code{\link{plot.ppca}}: several plots associated to a phylogenetic
    principal component analysis (see \code{\link{ppca}}).\cr
@@ -130,8 +134,8 @@
   \tabular{ll}{
     Package: \tab adephylo\cr
     Type: \tab Package\cr
-    Version: \tab 1.1-3\cr
-    Date: \tab 2012-10-30 \cr
+    Version: \tab 1.1-4\cr
+    Date: \tab 2013-05-15 \cr
     License: \tab GPL (>=2)
   }  
 }

Modified: pkg/man/dibas.Rd
===================================================================
--- pkg/man/dibas.Rd	2013-05-14 11:48:33 UTC (rev 189)
+++ pkg/man/dibas.Rd	2013-05-14 14:12:05 UTC (rev 190)
@@ -4,6 +4,7 @@
 \alias{dibas.matrix}
 \alias{dibas.dist}
 \alias{dibas.phylo}
+\alias{dibas.vector}
 \alias{simDatGroups}
 \title{DIstance-Based Assignment}
 \description{
@@ -12,12 +13,16 @@
 }
 \usage{
 \method{dibas}{phylo}(x, grp, method = c("default", "leaveOneOut"),
-      metric = c("Abouheif", "nNodes", "patristic", "sumDD"), \ldots)
+      fromRoot=FALSE, metric = c("Abouheif", "nNodes", "patristic","sumDD"),
+      n.items=NULL, \ldots)
 
 \method{dibas}{matrix}(x, grp, method = c("default", "leaveOneOut"), \ldots)
 
 \method{dibas}{dist}(x, grp, method = c("default", "leaveOneOut"), \ldots)
 
+\method{dibas}{vector}(x, grp, method=c("default","leaveOneOut"),
+      n.items=NULL, \ldots)
+
 }
 \arguments{
   \item{x}{a \code{phylo} object, or a symmetric matrix of pairwise distances
@@ -33,6 +38,12 @@
     \code{\link{distTips}} for more information. Note that patristic
     distances should be avoided in presence of one or more highly
     diverse group because of the 'hand fan' syndrome (see example).}
+  \item{fromRoot}{a logical indicating if distances from the root,
+    rather than between groups, should be used.}
+  \item{n.items}{a vector of integers of the same length as x, stating
+    how many times each items in 'x' should be repeated; used to take
+    into account differences in abundances of the different items
+    (e.g. sequences in multiple copies).}
   \item{\dots}{further arguments passed to other methods. Can be used to
     provide arguments to \code{\link{table.phylo4d}} in \code{plot} method.}
 }

Modified: pkg/man/table.phylo4d.Rd
===================================================================
--- pkg/man/table.phylo4d.Rd	2013-05-14 11:48:33 UTC (rev 189)
+++ pkg/man/table.phylo4d.Rd	2013-05-14 14:12:05 UTC (rev 190)
@@ -12,6 +12,8 @@
   from the \code{ape} package. Hence, many of the arguments of
   \code{\link[ape]{plot.phylo}} can be passed to \code{table.phylo4d},
   through the \dots argument, but their names must be complete.
+
+  For large trees, consider using \code{\link{bullseye}}.
 }
 \usage{
 table.phylo4d(x, treetype=c("phylogram","cladogram"), symbol=c("circles", "squares","colors"),
@@ -62,8 +64,11 @@
  \item{\dots}{further arguments to be passed to plot methods from
   \code{ape}. See \code{\link[ape]{plot.phylo}}.}
 }
-\seealso{The \linkS4class{phylo4d} class for storing \code{phylogeny+data}.\cr
+\seealso{The \linkS4class{phylo4d} class for storing
+  \code{phylogeny+data}.\cr
 
+  For large trees, consider using \code{\link{bullseye}}.
+
   \code{\link[ape]{plot.phylo}} from the \code{ape} package.\cr
 
   An alternative (deprecated) representation is available from



More information about the Adephylo-commits mailing list