From noreply at r-forge.r-project.org Wed May 29 22:28:40 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 29 May 2013 22:28:40 +0200 (CEST) Subject: [Picante-commits] r242 - in pkg: . R inst/doc man Message-ID: <20130529202840.278E5184A68@r-forge.r-project.org> Author: skembel Date: 2013-05-29 22:28:39 +0200 (Wed, 29 May 2013) New Revision: 242 Added: pkg/R/phyEstimate.R pkg/man/phyEstimate.Rd Modified: pkg/ pkg/DESCRIPTION pkg/R/randomizeSample.R pkg/inst/doc/picante-intro.Rnw pkg/man/comdist.Rd pkg/man/comdistnt.Rd pkg/man/comm.phylo.cor.Rd pkg/man/comm.phylo.qr.Rd pkg/man/cor.table.Rd pkg/man/data.checking.Rd pkg/man/expected.pd.Rd pkg/man/matrix2sample.Rd pkg/man/mntd.Rd pkg/man/mpd.Rd pkg/man/multiPhylosignal.Rd pkg/man/pd.Rd pkg/man/phylosignal.Rd pkg/man/phylosor.Rd pkg/man/phylosor.rnd.Rd pkg/man/picante-package.Rd pkg/man/pruning.Rd pkg/man/randomizeSample.Rd pkg/man/raoD.Rd pkg/man/sample2matrix.Rd pkg/man/ses.mntd.Rd pkg/man/ses.mpd.Rd pkg/man/ses.pd.Rd pkg/man/species.dist.Rd pkg/man/unifrac.Rd pkg/man/utility.Rd pkg/man/writesample.Rd pkg/man/writetraits.Rd Log: Adding phyEstimate functions, updating maintainer email address for 1.6-0 Property changes on: pkg ___________________________________________________________________ Added: svn:ignore + .Rproj.user .Rhistory .RData Modified: pkg/DESCRIPTION =================================================================== --- pkg/DESCRIPTION 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/DESCRIPTION 2013-05-29 20:28:39 UTC (rev 242) @@ -1,10 +1,10 @@ Package: picante Type: Package Title: R tools for integrating phylogenies and ecology -Version: 1.5-2 -Date: 2012-10-9 -Author: Steven W. Kembel , David D. Ackerly , Simon P. Blomberg , Will K. Cornwell , Peter D. Cowan , Matthew R. Helmus , Helene Morlon , Campbell O. Webb -Maintainer: Steven W. Kembel +Version: 1.6-0 +Date: 2013-5-29 +Author: Steven W. Kembel , David D. Ackerly , Simon P. Blomberg , Will K. Cornwell , Peter D. Cowan , Matthew R. Helmus , Helene Morlon , Campbell O. Webb +Maintainer: Steven W. Kembel Depends: ape, vegan, nlme Suggests: brglm, circular, corpcor, quantreg, plotrix Description: Phylocom integration, community analyses, null-models, traits and evolution in R Added: pkg/R/phyEstimate.R =================================================================== --- pkg/R/phyEstimate.R (rev 0) +++ pkg/R/phyEstimate.R 2013-05-29 20:28:39 UTC (rev 242) @@ -0,0 +1,122 @@ +#phyEstimate.R +#use phylogeny to predict trait values for new species +phyEstimate <- function(phy, trait, method="pic", ...) { + + #trait should be a data.frame or vector with (row)names matching phylogeny + if (is.vector(trait)) { + trait <- data.frame(trait) + } + + trait.orig <- trait + + #given a tree with a novel species on it + sppObs <- row.names(trait) + #(novel spp. are in tree but have no trait value) + sppUnobs <- phy$tip.label[!(phy$tip.label %in% sppObs)] + + res <- as.data.frame(matrix(nrow=length(sppUnobs), ncol=2, dimnames=list(sppUnobs, c("estimate","se")))) + + for (i in sppUnobs) { + + #for each novel species, prune all but measured + that species + tree <- drop.tip(phy, subset(sppUnobs, sppUnobs != i)) + + #root the tree at the novel species (leave root as trichotomy) + tree <- root(tree, i, resolve.root=FALSE) + + #record branch length leading to novel species in rerooted tree + edge <- Nnode(tree) - 1 + which(tree$tip.label==i) + bl <- tree$edge.length[edge] + + #prune novel species and match new pruned tree <-> trait data + tree <- drop.tip(tree, i) + trait <- trait.orig[tree$tip.label,] + + #use PIC framework to estimate trait value at root node + error + est <- ace(trait, tree, method=method, ...) + val <- est$ace[1] + cimax <- est$CI95[1,2] + se <- abs(cimax-val)/1.96 + + se.adj <- sqrt(bl)+se + + res[i,] <- data.frame(estimate=val, se=se.adj) + + } + + return(res) + +} + + +# for discrete traits +phyEstimateDisc <- function(phy, trait, best.state=TRUE, cutoff=0.5, ...) { + + #trait should be a data.frame or vector with names matching phylogeny + if (is.vector(trait)|is.factor(trait)) { + trait <- data.frame(trait) + } + + trait[,1] <- factor(trait[,1]) + trait.orig <- trait + + #given a tree with a novel taxa on it (taxa with no trait value) + sppObs <- row.names(trait) + sppUnobs <- phy$tip.label[!(phy$tip.label %in% sppObs)] + trtlevels <- levels(trait[,1]) + res <- as.data.frame(matrix(nrow=length(sppUnobs), ncol=length(trtlevels), dimnames=list(sppUnobs, trtlevels))) + + #estimate support for different states for each novel taxon + for (i in sppUnobs) { + + #for each novel species, prune all but measured + that species + tree <- drop.tip(phy, subset(sppUnobs, sppUnobs != i)) + + #root the tree at the novel species (leave root as trichotomy) + tree <- root(tree, i, resolve.root=FALSE) + + #record branch length leading to novel species in rerooted tree + edge <- Nnode(tree) - 1 + which(tree$tip.label==i) + bl <- tree$edge.length[edge] + + #prune novel species and match new pruned tree <-> trait data + tree <- drop.tip(tree, i) + trait <- trait.orig[tree$tip.label,] + + #calculate value at root node and impute to novel species + est <- ace(trait, tree, type="discrete", ...) + val <- est$lik.anc[1,] + + res[i,] <- val + + } + + #estimate the best-supported state for each taxon + if (best.state) { + beststate <- as.data.frame(matrix(nrow=dim(res)[1], ncol=2)) + colnames(beststate) <- c("estimated.state","estimated.state.support") + rownames(beststate) <- rownames(res) + + for (i in 1:dim(res)[1]) { + #if >=cutoff % taxa have same label assign a consensus taxon to node + best <- -sort(-(res[i,]))[1] + if (best >= cutoff) { + beststate[i,1] <- names(best) + beststate[i,2] <- best + } + else + { + beststate[i,1] <- NA + beststate[i,2] <- NA + } + } + } + + #return the output + if (best.state) { + return(cbind(as.matrix(res),beststate)) + } else { + return(as.matrix(res)) + } + +} Modified: pkg/R/randomizeSample.R =================================================================== --- pkg/R/randomizeSample.R 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/R/randomizeSample.R 2013-05-29 20:28:39 UTC (rev 242) @@ -1,7 +1,3 @@ -.First.lib <- function(lib,pkg) { - library.dynam("picante",pkg,lib) -} - `randomizeMatrix` <- function(samp, null.model=c("frequency","richness","independentswap","trialswap"), iterations=1000) Modified: pkg/inst/doc/picante-intro.Rnw =================================================================== --- pkg/inst/doc/picante-intro.Rnw 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/inst/doc/picante-intro.Rnw 2013-05-29 20:28:39 UTC (rev 242) @@ -8,7 +8,7 @@ \usepackage{url} \title{An introduction to the picante package} -\author{Steven Kembel (skembel at uoregon.edu)} +\author{Steven Kembel (steve.kembel at gmail.com)} \date{April 2010} \begin{document} Modified: pkg/man/comdist.Rd =================================================================== --- pkg/man/comdist.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/comdist.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -21,7 +21,7 @@ This function calculates a measure of phylogenetic beta diversity: the expected phylogenetic distance separating two individuals or taxa drawn randomly from different communities. } \references{ C.O. Webb, D.D. Ackerly, and S.W. Kembel. 2008. Phylocom: software for the analysis of phylogenetic community structure and trait evolution. Bioinformatics 18:2098-2100. } -\author{ Steven Kembel } +\author{ Steven Kembel } \seealso{ \code{\link{mpd}}, \code{\link{ses.mpd}} } \examples{ data(phylocom) Modified: pkg/man/comdistnt.Rd =================================================================== --- pkg/man/comdistnt.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/comdistnt.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -24,7 +24,7 @@ This function calculates a measure of phylogenetic beta diversity: the average phylogenetic distance to the most similar taxon or individual in the other community for taxa or individuals in two communities. } \references{ C.O. Webb, D.D. Ackerly, and S.W. Kembel. 2008. Phylocom: software for the analysis of phylogenetic community structure and trait evolution. Bioinformatics 18:2098-2100. } -\author{ Steven Kembel } +\author{ Steven Kembel } \seealso{ \code{\link{mntd}}, \code{\link{ses.mntd}} } \examples{ data(phylocom) Modified: pkg/man/comm.phylo.cor.Rd =================================================================== --- pkg/man/comm.phylo.cor.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/comm.phylo.cor.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -39,7 +39,7 @@ } } \references{ Cavender-Bares J., D.A. Ackerly, D. Baum and F.A. Bazzaz. 2004. Phylogenetic overdispersion in Floridian oak communities, American Naturalist, 163(6):823-843. } -\author{ Steven Kembel } +\author{ Steven Kembel } \seealso{ \code{\link{randomizeMatrix}} } \examples{ data(phylocom) Modified: pkg/man/comm.phylo.qr.Rd =================================================================== --- pkg/man/comm.phylo.qr.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/comm.phylo.qr.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -47,7 +47,7 @@ Cavender-Bares J., D.A. Ackerly, D. Baum and F.A. Bazzaz. 2004. Phylogenetic overdispersion in Floridian oak communities, American Naturalist, 163(6):823-843. Slingsby, J. A. and G. A. Verboom. 2006. Phylogenetic relatedness limits coexistence at fine spatial scales: evidence from the schoenoid sedges (Cyperaceae: Schoeneae) of the Cape Floristic Region, South Africa. The American Naturalist 168:14-27. } -\author{ Steven Kembel } +\author{ Steven Kembel } \seealso{ \code{\link{randomizeMatrix}} } \examples{ data(phylocom) Modified: pkg/man/cor.table.Rd =================================================================== --- pkg/man/cor.table.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/cor.table.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -23,5 +23,5 @@ \references{ Garland, T., Jr., P. H. Harvey, and A. R. Ives. 1992. Procedures for the analysis of comparative data using phylogenetically independent contrasts. Systematic Biology 41:18-32. } -\author{ Steven Kembel } +\author{ Steven Kembel } \keyword{univar} Modified: pkg/man/data.checking.Rd =================================================================== --- pkg/man/data.checking.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/data.checking.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -38,7 +38,7 @@ These utility functions are used by several functions that assume taxa labels in phylogeny and data match, including \code{\link{Kcalc}}, \code{\link{phylosignal}}, and \code{\link{raoD}}. } -\author{ Steven Kembel } +\author{ Steven Kembel } \seealso{\code{\link{prune.missing}}, \code{\link{prune.sample}}} \examples{ data(phylocom) Modified: pkg/man/expected.pd.Rd =================================================================== --- pkg/man/expected.pd.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/expected.pd.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -29,7 +29,7 @@ \references{ O'Dwyer, Kembel, and Green. 2012. Phylogenetic diversity theory sheds light on the structure of microbial communities. } -\author{ Steven Kembel and James O'Dwyer } +\author{ Steven Kembel and James O'Dwyer } \seealso{ \code{\link{pd}} } Modified: pkg/man/matrix2sample.Rd =================================================================== --- pkg/man/matrix2sample.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/matrix2sample.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -17,7 +17,7 @@ Phylocom database-format community sample } \references{ Webb, C.O., Ackerly, D.D., and Kembel, S.W. 2008. Phylocom: software for the analysis of phylogenetic community structure and trait evolution. Version 4.0.1. \url{http://www.phylodiversity.net/phylocom/}.} -\author{ Steven Kembel and Cam Webb } +\author{ Steven Kembel and Cam Webb } \examples{ data(phylocom) matrix2sample(phylocom$sample) Modified: pkg/man/mntd.Rd =================================================================== --- pkg/man/mntd.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/mntd.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -21,7 +21,7 @@ This metric has also been referred to as MNND (mean nearest neighbour distance), and the function was named \code{mnnd} in picante versions < 0.7. } \references{ Webb, C., D. Ackerly, M. McPeek, and M. Donoghue. 2002. Phylogenies and community ecology. Annual Review of Ecology and Systematics 33:475-505. } -\author{ Steven Kembel } +\author{ Steven Kembel } \seealso{ \code{\link{ses.mntd}} } \examples{ data(phylocom) Modified: pkg/man/mpd.Rd =================================================================== --- pkg/man/mpd.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/mpd.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -18,7 +18,7 @@ Vector of MPD values for each community } \references{ Webb, C., D. Ackerly, M. McPeek, and M. Donoghue. 2002. Phylogenies and community ecology. Annual Review of Ecology and Systematics 33:475-505. } -\author{ Steven Kembel } +\author{ Steven Kembel } \seealso{ \code{\link{ses.mpd}}} \examples{ data(phylocom) Modified: pkg/man/multiPhylosignal.Rd =================================================================== --- pkg/man/multiPhylosignal.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/multiPhylosignal.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -16,5 +16,5 @@ \value{ Returns a data frame with phylogenetic signal results for each trait } -\author{ Steven Kembel } +\author{ Steven Kembel } \keyword{univar} Modified: pkg/man/pd.Rd =================================================================== --- pkg/man/pd.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/pd.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -33,7 +33,7 @@ \code{prunedTree <- prune.sample(sample,tree)} } \references{ Faith D.P. (1992) Conservation evaluation and phylogenetic diversity. Biological Conservation, 61, 1-10. } -\author{ Matthew Helmus \email{mrhelmus at gmail.com}, Jonathan Davies \email{davies at nceas.ucsb.edu}, Steven Kembel \email{skembel at uoregon.edu}} +\author{ Matthew Helmus \email{mrhelmus at gmail.com}, Jonathan Davies \email{davies at nceas.ucsb.edu}, Steven Kembel \email{steve.kembel at gmail.com}} \seealso{ \code{\link{psr}}, \code{\link{ses.pd}} } \examples{ data(phylocom) Added: pkg/man/phyEstimate.Rd =================================================================== --- pkg/man/phyEstimate.Rd (rev 0) +++ pkg/man/phyEstimate.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -0,0 +1,56 @@ +\name{phyEstimate} +\alias{phyEstimate} +\alias{phyEstimateDisc} + +\title{ Phylogenetic estimation of traits for unobserved taxa } +\description{ + Uses phylogenetic ancestral state reconstruction to estimate trait values for unobserved taxa. +} +\usage{ +phyEstimate(phy, trait, method="pic", ...) +phyEstimateDisc(phy, trait, best.state=TRUE, cutoff=0.5, ...) +} + +\arguments{ + \item{phy }{ phylo object } + \item{trait }{ vector or data.frame containing trait values } + \item{method }{ ancestral state estimation method used by \code{ace} (default="pic")} + \item{best.state }{ estimate best-supported trait state for discrete variables? (default=TRUE)} + \item{cutoff }{ support cutoff required to declare a best.state } + \item{...}{ Additional arguments passed to \code{ace} } +} +\value{ + phyEstimate produces a data frame with columns: + \item{est}{ Estimated trait value } + \item{se}{ Standard error of estimated trait value } + phyEstimateDisc produces a data frame with columns: + \item{states 1..N}{ A column with statistical support is produced for each discrete trait state } + \item{estimated.state}{ If best.state=TRUE, a column with the state with the highest support } + \item{estimated.state.support}{ Statistical support for the state with the highest support } +} + +\details{ +These functions use phylogenetic ancestral state estimation to infer trait values for novel taxa on a phylogenetic tree, for continuous (\code{phyEstimate}) and discrete (\code{phyEstimateDisc}) traits. + +The required input is a phylogenetic tree object plus a vector or data.frame containing estimated trait values for a subset of the taxa in the phylogenetic tree. Trait values for taxa that are present in the tree but not the trait data will be estimated using ancestral state estimation (Garland and Ives 2000). Briefly, for each taxon present in the tree but not the trait data, the phylogeny is rerooted at the most recent common ancestor of the novel taxon and the rest of the phylogeny, and the trait value of the novel taxon is estimated from the reconstructed trait value at the root of the rerooted phylogeny. + +For \code{phyEstimateDisc}, the state with the highest support will be reported if argument \code{best.state=TRUE}. If the best-supported state's support is less than the specified \code{cutoff}, no best state is reported and a \code{NA} value will be returned. +} + +\references{ +T. Garland Jr., and A.R. Ives. 2000. Using the past to predict the present: confidence intervals for regression equations in phylogenetic comparative methods. American Naturalist 155:346364. + +S.W. Kembel, M. Wu, J.A. Eisen, and J.L. Green. 2012. Incorporating 16S gene copy number information improves estimates of microbial diversity and abundance. PLoS Computational Biology 8(10):e1002743. + +} +\author{ Steven Kembel } + +\examples{ +#generate random phylogeny +randtree <- rcoal(50) +#simulate trait evolution for a subset of taxa on phylogeny +randtraits <- sample(rTraitCont(randtree, sigma=10, root.value=100), 40) +#estimate trait values for "missing" taxa using PIC method +phyEstimate(randtree, randtraits, method="pic") +} +\keyword{univar} \ No newline at end of file Modified: pkg/man/phylosignal.Rd =================================================================== --- pkg/man/phylosignal.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/phylosignal.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -27,7 +27,7 @@ Blomberg, S. P., and T. Garland, Jr. 2002. Tempo and mode in evolution: phylogenetic inertia, adaptation and comparative methods. Journal of Evolutionary Biology 15:899-910. Blomberg, S. P., T. Garland, Jr., and A. R. Ives. 2003. Testing for phylogenetic signal in comparative data: behavioral traits are more labile. Evolution 57:717-745. } -\author{ Steven Kembel } +\author{ Steven Kembel } \seealso{ \code{\link{Kcalc}} } \examples{ randtree <- rcoal(20) Modified: pkg/man/phylosor.Rd =================================================================== --- pkg/man/phylosor.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/phylosor.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -13,7 +13,7 @@ } \value{A distance object of the PhyloSor index of similarity between communities, the fraction of PD (branch-length) shared between two samples} \references{Bryant, J.B., Lamanna, C., Morlon, H., Kerkhoff, A.J., Enquist, B.J., Green, J.L. 2008. Microbes on mountainsides: Contrasting elevational patterns of bacterial and plant diversity. Proceedings of the National Academy of Sciences 105 Supplement 1: 11505-11511} -\author{ Helene Morlon and Steven Kembel } +\author{ Helene Morlon and Steven Kembel } \seealso{\code{\link{phylosor.rnd}}, \code{\link{pd}}} \note{ The root of the supplied tree is included in calculations of PhyloSor. The supplied tree must be rooted. Single-species samples will be assigned a PD value equal to the distance from the root to the present. Modified: pkg/man/phylosor.rnd.Rd =================================================================== --- pkg/man/phylosor.rnd.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/phylosor.rnd.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -35,7 +35,7 @@ } } \references{Bryant, J.B., Lamanna, C., Morlon, H., Kerkhoff, A.J., Enquist, B.J., Green, J.L. 2008. Microbes on mountainsides: Contrasting elevational patterns of bacterial and plant diversity. Proceedings of the National Academy of Sciences 105 Supplement 1: 11505-11511} -\author{ Helene Morlon and Steven Kembel } +\author{ Helene Morlon and Steven Kembel } \seealso{ \code{\link{phylosor}}, \code{\link{randomizeMatrix}} } \examples{ data(phylocom) Modified: pkg/man/picante-package.Rd =================================================================== --- pkg/man/picante-package.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/picante-package.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -12,13 +12,13 @@ \tabular{ll}{ Package: \tab picante\cr Type: \tab Package\cr -Version: \tab 1.5-2\cr -Date: \tab 2012-10-9\cr +Version: \tab 1.6-0\cr +Date: \tab 2013-5-29\cr License: \tab GPL-2\cr } } \author{ -Author: Steven W. Kembel , David D. Ackerly , Simon P. Blomberg , Will K. Cornwell , Peter D. Cowan , Matthew R. Helmus , Helene Morlon , Campbell O. Webb -Maintainer: Steven W. Kembel +Author: Steven W. Kembel , David D. Ackerly , Simon P. Blomberg , Will K. Cornwell , Peter D. Cowan , Matthew R. Helmus , Helene Morlon , Campbell O. Webb +Maintainer: Steven W. Kembel } \keyword{package} Modified: pkg/man/pruning.Rd =================================================================== --- pkg/man/pruning.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/pruning.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -19,5 +19,5 @@ \value{ Returns a pruned phylo object } -\author{ Steven Kembel } +\author{ Steven Kembel } \keyword{manip} Modified: pkg/man/randomizeSample.Rd =================================================================== --- pkg/man/randomizeSample.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/randomizeSample.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -32,7 +32,7 @@ Miklos I. & Podani J. 2004. Randomization of presence-absence matrices: Comments and new algorithms. Ecology 85: 86-92. } -\author{ Steven Kembel } +\author{ Steven Kembel } \examples{ data(phylocom) randomizeMatrix(phylocom$sample, null.model="richness")} Modified: pkg/man/raoD.Rd =================================================================== --- pkg/man/raoD.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/raoD.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -56,7 +56,7 @@ Webb, C.O., Ackerly, D.D., and Kembel, S.W. 2008. Phylocom: software for the analysis of phylogenetic community structure and trait evolution. Version 4.0.1. \url{http://www.phylodiversity.net/phylocom/}. } \seealso{ \code{\link{mpd}}, \code{\link{comdist}} } -\author{ Steven Kembel } +\author{ Steven Kembel } \examples{ data(phylocom) raoD(phylocom$sample) Modified: pkg/man/sample2matrix.Rd =================================================================== --- pkg/man/sample2matrix.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/sample2matrix.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -20,5 +20,5 @@ } \references{ Webb, C.O., Ackerly, D.D., and Kembel, S.W. 2008. Phylocom: software for the analysis of phylogenetic community structure and trait evolution. Version 4.0.1. \url{http://www.phylodiversity.net/phylocom/}.} -\author{ Steven Kembel and Cam Webb } +\author{ Steven Kembel and Cam Webb } \keyword{IO} Modified: pkg/man/ses.mntd.Rd =================================================================== --- pkg/man/ses.mntd.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/ses.mntd.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -46,7 +46,7 @@ } } \references{ Webb, C.O., Ackerly, D.D., and Kembel, S.W. 2008. Phylocom: software for the analysis of phylogenetic community structure and trait evolution. Version 4.0.1. \url{http://www.phylodiversity.net/phylocom/}. } -\author{ Steven Kembel } +\author{ Steven Kembel } \seealso{ \code{\link{mntd}}, \code{\link{randomizeMatrix}} } \examples{ data(phylocom) Modified: pkg/man/ses.mpd.Rd =================================================================== --- pkg/man/ses.mpd.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/ses.mpd.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -45,7 +45,7 @@ } \references{ Webb, C.O., Ackerly, D.D., and Kembel, S.W. 2008. Phylocom: software for the analysis of phylogenetic community structure and trait evolution. Version 4.0.1. \url{http://www.phylodiversity.net/phylocom/}. } -\author{ Steven Kembel } +\author{ Steven Kembel } \seealso{ \code{\link{mpd}}, \code{\link{randomizeMatrix}} } \examples{ data(phylocom) Modified: pkg/man/ses.pd.Rd =================================================================== --- pkg/man/ses.pd.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/ses.pd.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -47,7 +47,7 @@ \references{ Webb, C.O., Ackerly, D.D., and Kembel, S.W. 2008. Phylocom: software for the analysis of phylogenetic community structure and trait evolution. Version 4.0.1. \url{http://www.phylodiversity.net/phylocom/}. Proches, S., Wilson, J.R.U. and Cowling, R.M. 2006. How much evolutionary history in a 10 x 10m plot? Proceedings of Royal Society of London B, Biological Sciences 273:1143-1148.} -\author{ Steven Kembel } +\author{ Steven Kembel } \seealso{ \code{\link{pd}}, \code{\link{randomizeMatrix}} } \examples{ data(phylocom) Modified: pkg/man/species.dist.Rd =================================================================== --- pkg/man/species.dist.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/species.dist.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -27,7 +27,7 @@ \item{doij}{ DOij index of co-occurrence } } } -\author{ Steven Kembel } +\author{ Steven Kembel } \references{ Hardy, O.J. 2008. Testing the spatial phylogenetic structure of local communities: statistical performances of different null models and test statistics on a locally neutral community. Journal of Ecology 96:914-926. } Modified: pkg/man/unifrac.Rd =================================================================== --- pkg/man/unifrac.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/unifrac.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -15,7 +15,7 @@ \references{ Lozupone, C., Hamady, M., and Knight, R. 2006. UniFrac - an online tool for comparing microbial community diversity in a phylogenetic context. BMC Bioinformatics 7:371. } -\author{ Steven Kembel } +\author{ Steven Kembel } \seealso{\code{\link{pd}}} \note{ The supplied tree must be rooted. Single-species samples will be assigned a PD value equal to the distance from the root to the present. Modified: pkg/man/utility.Rd =================================================================== --- pkg/man/utility.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/utility.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -47,5 +47,5 @@ Various utility functions for manipulating trees, data, etc. } -\author{ Steven Kembel , Peter Cowan , David Ackerly } +\author{ Steven Kembel , Peter Cowan , David Ackerly } \keyword{manip} Modified: pkg/man/writesample.Rd =================================================================== --- pkg/man/writesample.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/writesample.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -14,5 +14,5 @@ \item{filename}{ Filename path } } \references{ Webb, C.O., Ackerly, D.D., and Kembel, S.W. 2008. Phylocom: software for the analysis of phylogenetic community structure and trait evolution. Version 4.0.1. \url{http://www.phylodiversity.net/phylocom/}. } -\author{ Steven Kembel and Cam Webb } +\author{ Steven Kembel and Cam Webb } \keyword{file} Modified: pkg/man/writetraits.Rd =================================================================== --- pkg/man/writetraits.Rd 2012-10-09 13:12:23 UTC (rev 241) +++ pkg/man/writetraits.Rd 2013-05-29 20:28:39 UTC (rev 242) @@ -17,5 +17,5 @@ } \references{ Webb, C.O., Ackerly, D.D., and Kembel, S.W. 2008. Phylocom: software for the analysis of phylogenetic community structure and trait evolution. Version 4.0.1. \url{http://www.phylodiversity.net/phylocom/}. } -\author{ David Ackerly and Steven Kembel } +\author{ David Ackerly and Steven Kembel } \keyword{file} From noreply at r-forge.r-project.org Wed May 29 22:33:11 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 29 May 2013 22:33:11 +0200 (CEST) Subject: [Picante-commits] r243 - / www Message-ID: <20130529203311.92A93184A68@r-forge.r-project.org> Author: skembel Date: 2013-05-29 22:33:11 +0200 (Wed, 29 May 2013) New Revision: 243 Modified: / www/index.php Log: Modify webpage for 1.6-0 release Property changes on: ___________________________________________________________________ Added: svn:ignore + .Rproj.user .Rhistory .RData Modified: www/index.php =================================================================== --- www/index.php 2013-05-29 20:28:39 UTC (rev 242) +++ www/index.php 2013-05-29 20:33:11 UTC (rev 243) @@ -40,29 +40,19 @@

News

    -
  • A manuscript describing Picante has been published in Bioinformatics.
  • -
  • Picante 1.5 has been released +
  • Picante 1.6 has been released
      -
    • The phylogenetic generalized linear mixed models of Ives and Helmus (2011) are now included in function pglmm
    • -
    • The functions pic.circular and pic3 have been deprecated.
    • -
    • Code for rapid estimation of expected phylogenetic diversity and the edge abundance distribution (O'Dwyer et al. 2012) is now included in functions expected.pd and ead. +
    • Added methods for phylogenetic estimation of trait values for unobserved taxa (Kembel et al. 2012 PLOS Comp Biol).
  • -
  • Lots of changes and new features since version 1.0 -
      -
    • Calculate Rao's quadratic entropy (alpha and beta diversity taking phylogenetic distinctiveness into account)
    • -
    • Added more phylobeta diversity measures (UniFrac, Rao's quadratic entropy)
    • -
    • Changed name of randomizeSample to randomizeMatrix for consistency with other functions
    • -
    • Added automatic checks to ensure taxa labels in phylogeny and other data sets match
    -
  • -

Current features

  • Community phylogenetic and trait diversity
    • Faith's PD (phylogenetic diversity), standardized effect size of PD, expected PD of subsets of a phylogenetic tree.
    • +
    • Rapid estimation of PD (O'Dwyer et al. 2012)
    • Webb's NRI/NTI and related measures of standardized effect size of community phylogenetic structure.
    • Mean pairwise distance and mean distance to nearest taxon among co-occurring species (can be used with any interspecific distance measure). Distances can be calculated based on presence or abundance in samples.
    • Rao's quadratic entropy, a measure of diversity within and among communities optionally taking phylogenetic distinctiveness into account.
    • @@ -73,7 +63,7 @@
    • Numerous phylogenetic beta diversity measures (PCD, phylosor, UniFrac, betaMPD, betaMNTD, Rao's quadratic entropy).
  • Phylogenetic signal (Blomberg et al.'s K statistic and P-value based on randomization test)
  • -
  • Independent contrasts for traits with circular distributions
  • +
  • Estimtion of trait values for unobserved taxa (Kembel et al. 2012 PLOS Comp Biol)
  • Null models for community and phylogeny randomization
    • Shuffle taxa labels across tips of phylogeny
    • @@ -110,6 +100,7 @@

      Release history

        +
      • Version 1.6: Add phylogenetic trait estimation for unobserved taxa (Kembel et al. 2012).
      • Version 1.5: Add expected.pd and ead functions to estimate expected phylogenetic diversity and edge abundance distribution (O'Dwyer et al. 2012).
      • Version 1.4: Add pglmm methods from Ives & Helmus (2011). Correct typos in vignette and documentation. Remove pic.circular function until further testing can be performed.
      • Version 1.3: Add function pcd. Fix single-community error in pse.
      • From noreply at r-forge.r-project.org Fri May 31 20:48:08 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 31 May 2013 20:48:08 +0200 (CEST) Subject: [Picante-commits] r244 - pkg/R pkg/man www Message-ID: <20130531184808.1E8EA1856C0@r-forge.r-project.org> Author: skembel Date: 2013-05-31 20:48:07 +0200 (Fri, 31 May 2013) New Revision: 244 Modified: pkg/R/expected.pd.R pkg/man/color.plot.phylo.Rd pkg/man/comm.phylo.qr.Rd pkg/man/evol.distinct.Rd pkg/man/expected.pd.Rd pkg/man/pblm.Rd pkg/man/pglmm.Rd pkg/man/phylostruct.Rd pkg/man/randomizeSample.Rd pkg/man/ses.mntd.Rd pkg/man/sppregs.Rd www/index.php Log: Fix typos in website, add variance.pd function, fix documentation to pass r-devel check for long lines Modified: pkg/R/expected.pd.R =================================================================== --- pkg/R/expected.pd.R 2013-05-29 20:33:11 UTC (rev 243) +++ pkg/R/expected.pd.R 2013-05-31 18:48:07 UTC (rev 244) @@ -31,28 +31,138 @@ return(byclass) } +#expected variance of PD +variance.pd <- function(phy, upper.bound=TRUE) { + Nedges <- length(phy$edge.length) + if (upper.bound) { + ead <- .edge.children.var.ub(phy) + epd <- .binomial.pd(ead,Ntip(phy)) + varpd <- .var.pd.ub(ead,Ntip(phy)) + } else { + ead <- .edge.children.var.ub(phy) + eadvar <- .edge.children.var(phy) + epd <- .binomial.pd(ead,Ntip(phy)) + varpd <- .var.pd(eadvar,Ntip(phy)) + } + return(data.frame(expected.pd=epd, variance.pd=varpd)) +} + +# binomial PD +.binomial.pd <-function(ead,Ntip){ + epd=vector(mode="numeric",length=Ntip) + for(n in 1:Ntip){ + epd[n]<-sum(ead$byclass$edge.length*(1-dbinom(0,ead$byclass$num.children,n/Ntip))) + } + return(epd) +} + +#expected variance in pd from R(k),R(k,l) +.var.pd <- function(test, Ntip) { + varpd=vector(mode="numeric",length=Ntip) + for(n in 1:Ntip) { + varpd[n]=sum(test$byclass.sq$sum.sq.edge.length*((1-n/Ntip)^test$byclass.sq$num.children)*(1-(1-n/Ntip)^test$byclass.sq$num.children))+2*sum(test$byclass.prod$sum.prods.edge.length*((1-n/Ntip)^test$byclass.prod$num.children)*(1-(1-n/Ntip)^test$byclass.prod$num.desc.children)) + } + return(varpd) +} + +# upper bound on variance in PD---quicker by far than var.pd +.var.pd.ub<-function(test,Ntip) { + varpd <- vector(mode="numeric",length=Ntip) + for(n in 1:Ntip) { + varpd[n]=sum((test$byclass.sq$sum.sq.edge.length+2*test$byclass.prod$edge.length.times.subclade)*((1-n/Ntip)^test$byclass.sq$num.children)*(1-(1-n/Ntip)^test$byclass.sq$num.children)) + } + return(varpd) +} + +# edge children variance +.edge.children.var <- function(phy) { + Nedges <- length(phy$edge.length) + edgelen <- vector(mode = "numeric", length=Nedges) + children <- vector(mode = "numeric", length=Nedges) + rawdata<-data.frame() + for (i in 1:Nedges) { + edgelen[i] <- phy$edge.length[i] + descnode <- phy$edge[i,2] + if (descnode <= Ntip(phy)) { + children[i] <- 1 + } + else + { + desc.phy<-.extract.clade.noreord(phy, descnode) + children[i] <- Ntip(desc.phy) + desc.Nedges <- length(desc.phy$edge.length) + desc.edgelen <- vector(mode = "numeric", length=desc.Nedges) + desc.children <- vector(mode = "numeric", length=desc.Nedges) + for (j in 1:desc.Nedges) { + desc.edgelen[j] <- desc.phy$edge.length[j] + desc.descnode <- desc.phy$edge[j,2] + if (desc.descnode <= Ntip(desc.phy)) { + desc.children[j] <- 1 + } + else + { + desc.children[j] <- Ntip(.extract.clade.noreord(desc.phy, desc.descnode)) + } + } + rawdata <- rbind(rawdata,data.frame(num.children=matrix(children[i],nrow=length(desc.children), ncol=1), num.desc.children=desc.children, prod.edge.length=edgelen[i]*desc.edgelen)) + } + } + byclass.prod <- aggregate(rawdata$prod.edge.length, by=list(num.children=rawdata$num.children,num.desc.children=rawdata$num.desc.children), sum) + rawdata2<- data.frame(num.children=children, node.edge.length=edgelen) + byclass.sq <- aggregate(rawdata2$node.edge.length^2, by=list(num.children=rawdata2$num.children), sum) + colnames(byclass.prod)[3] <- "sum.prods.edge.length" + colnames(byclass.sq)[2] <- "sum.sq.edge.length" + return(list(rawdata=rawdata, byclass.prod=byclass.prod,byclass.sq=byclass.sq)) +} + +# calculate components needed for upper bound on variance +.edge.children.var.ub <- function(phy) { + phy <- reorder(phy) + Nedges <- length(phy$edge.length) + edgelen <- vector(mode = "numeric", length=Nedges) + children <- vector(mode = "numeric", length=Nedges) + product<-vector(mode = "numeric", length=Nedges) + for (i in 1:Nedges) { + edgelen[i] <- phy$edge.length[i] + descnode <- phy$edge[i,2] + if (descnode <= Ntip(phy)) { + children[i] <- 1 + } + else + { + desc.tree<-.extract.clade.noreord(phy, descnode) + children[i] <- Ntip(desc.tree) + product[i]<-edgelen[i]*(sum(desc.tree$edge.length)) + } + } + rawdata <- data.frame(num.children=children, edge.length=edgelen,product=product) + byclass <- aggregate(rawdata$edge.length, by=list(num.children=rawdata$num.children), sum) + byclass.sq <- aggregate(rawdata$edge.length^2, by=list(num.children=rawdata$num.children), sum) + byclass.prod<- aggregate(rawdata$product, by=list(num.children=rawdata$num.children), sum) + colnames(byclass)[2] <- "edge.length" + colnames(byclass.sq)[2] <- "sum.sq.edge.length" + colnames(byclass.prod)[2] <- "edge.length.times.subclade" + return(list(rawdata=rawdata, byclass=byclass,byclass.sq=byclass.sq,byclass.prod=byclass.prod)) +} + # utility function - modified from ape's extract.clade function -.extract.clade.noreord <- function (phy, node, root.edge = 0, interactive = FALSE) +.extract.clade.noreord <- function (phy, node, root.edge = 0) { Ntip <- length(phy$tip.label) ROOT <- Ntip + 1 Nedge <- dim(phy$edge)[1] wbl <- !is.null(phy$edge.length) - if (interactive) - node <- identify(phy)$nodes - else { - if (length(node) > 1) { - node <- node[1] - warning("only the first value of 'node' has been considered") - } - if (is.character(node)) { - if (is.null(phy$node.label)) - stop("the tree has no node labels") - node <- which(phy$node.label %in% node) + Ntip - } - if (node <= Ntip) - stop("node number must be greater than the number of tips") - } + if (length(node) > 1) { + node <- node[1] + warning("only the first value of 'node' has been considered") + } + if (is.character(node)) { + if (is.null(phy$node.label)) + stop("the tree has no node labels") + node <- which(phy$node.label %in% node) + Ntip + } + if (node <= Ntip) + stop("node number must be greater than the number of tips") if (node == ROOT) return(phy) # phy <- reorder(phy) Modified: pkg/man/color.plot.phylo.Rd =================================================================== --- pkg/man/color.plot.phylo.Rd 2013-05-29 20:33:11 UTC (rev 243) +++ pkg/man/color.plot.phylo.Rd 2013-05-31 18:48:07 UTC (rev 244) @@ -7,7 +7,8 @@ color.plot.phylo(phylo, df, trait, taxa.names, num.breaks = ifelse(is.factor(df[,trait]), length(levels(df[,trait])), 12), - col.names = rainbow(ifelse(length(num.breaks) > 1, length(num.breaks) - 1, num.breaks)), + col.names = rainbow(ifelse(length(num.breaks) > 1, + length(num.breaks) - 1, num.breaks)), cut.labs = NULL, leg.title = NULL, main = trait, Modified: pkg/man/comm.phylo.qr.Rd =================================================================== --- pkg/man/comm.phylo.qr.Rd 2013-05-29 20:33:11 UTC (rev 243) +++ pkg/man/comm.phylo.qr.Rd 2013-05-31 18:48:07 UTC (rev 244) @@ -51,5 +51,6 @@ \seealso{ \code{\link{randomizeMatrix}} } \examples{ data(phylocom) -comm.phylo.qr(phylocom$sample, phylocom$phylo, metric="cij", null.model="sample.taxa.labels", runs=99)} +comm.phylo.qr(phylocom$sample, phylocom$phylo, metric="cij", + null.model="sample.taxa.labels", runs=99)} \keyword{univar} Modified: pkg/man/evol.distinct.Rd =================================================================== --- pkg/man/evol.distinct.Rd 2013-05-29 20:33:11 UTC (rev 243) +++ pkg/man/evol.distinct.Rd 2013-05-31 18:48:07 UTC (rev 244) @@ -10,7 +10,8 @@ Calculates evolutionary distinctiveness measures for a suite of species by: a) equal splits (Redding and Mooers 2006) b) fair proportions (Isaac et al., 2007). Returns a datafram with species identifiers and species scores. } \usage{ -evol.distinct(tree, type = c("equal.splits", "fair.proportion"), scale = FALSE, use.branch.lengths = TRUE) +evol.distinct(tree, type = c("equal.splits", "fair.proportion"), + scale = FALSE, use.branch.lengths = TRUE) } %- maybe also 'usage' for other objects documented here. \arguments{ Modified: pkg/man/expected.pd.Rd =================================================================== --- pkg/man/expected.pd.Rd 2013-05-29 20:33:11 UTC (rev 243) +++ pkg/man/expected.pd.Rd 2013-05-31 18:48:07 UTC (rev 244) @@ -1,40 +1,53 @@ \name{expected.pd} \alias{expected.pd} +\alias{variance.pd} \alias{ead} -\title{ Expected PD and Edge Abundance Distribution of a phylogeny } +\title{ Expected PD, PD Variance, and Edge Abundance Distribution of a phylogeny } -\description{ Calculates the expected phylogenetic diversity (Faith's PD) under binomial sampling with a fixed probability of each tip being sampled, and the Edge-length Abundance Distribution of a phylogeny. } +\description{ Calculates the expected phylogenetic diversity (Faith's PD) and variance of PD under binomial sampling with a fixed probability of each tip being sampled, and the Edge-length Abundance Distribution of a phylogeny. } \usage{ expected.pd(phy) +variance.pd(phy, upper.bound=TRUE) ead(phy) } \arguments{ \item{phy}{ phylo object } + \item{upper.bound}{ Calculate upper bound of PD variance? (default = TRUE) } } \value{ \item{n}{ Expected Number of tips sampled } \item{expected.pd}{ Expected PD for a given n } + \item{variance.pd}{ Variance of PD for a given n } \item{num.children}{ Number of tips descended from an edge } \item{edge.length}{ Total phylogenetic edge length for a given number of tips descended from an edge } } \details{The function \code{expected.pd} calculates the expected phylogenetic diversity (Faith's PD - total branch length) for all subsets of a phylogeny, based on an analytic solution for expected PD. +The function \code{variance.pd} additionally calculates the variance of expected PD for all subsets of a phylogeny, based on an analytic solution for expected PD. If argument upper.bound=TRUE, a fast solution for the upper bound of the variance is returned. Otherwise, the exact solution for the variance is returned. Note that the exact solution is much slower than the upper bound solution. + The function \code{ead} calculates the edge abundance distribution (EAD), the length of edges with different numbers of descendant tips. } -\references{ O'Dwyer, Kembel, and Green. 2012. Phylogenetic diversity theory sheds light on the structure of microbial communities. } +\references{ J.P. O'Dwyer, S.W. Kembel, and J.L. Green. 2012. Phylogenetic Diversity Theory Sheds Light on the Structure of Microbial Communities. PLoS Comput Biol 8(12): e1002832. } \author{ Steven Kembel and James O'Dwyer } \seealso{ \code{\link{pd}} } \examples{ -randtree <- rcoal(100) -plot(expected.pd(randtree), xlab="Number of tips", ylab="Expected PD", type="l") +randtree <- rcoal(300) +randtree.pd.ub <- variance.pd(randtree, upper.bound=TRUE) +randtree.pd.exact <- variance.pd(randtree, upper.bound=FALSE) +plot(expected.pd(randtree), xlab="Number of tips", ylab="Phylogenetic diversity (PD)", type="l", log="xy") +lines(randtree.pd.exact$expected.pd+1.96*sqrt(randtree.pd.exact$variance.pd), lty=2) +lines(randtree.pd.exact$expected.pd-1.96*sqrt(randtree.pd.exact$variance.pd), lty=2) +lines(randtree.pd.ub$expected.pd+1.96*sqrt(randtree.pd.ub$variance.pd), lty=3) +lines(randtree.pd.ub$expected.pd-1.96*sqrt(randtree.pd.ub$variance.pd), lty=3) +legend("bottomright", lty=c(1,2,3), legend=c("Expected PD","95 percent CI (exact)","95 percent CI (upper bound)")) } \keyword{univar} Modified: pkg/man/pblm.Rd =================================================================== --- pkg/man/pblm.Rd 2013-05-29 20:33:11 UTC (rev 243) +++ pkg/man/pblm.Rd 2013-05-31 18:48:07 UTC (rev 244) @@ -1,109 +1,110 @@ -\name{pblm} -\alias{pblm} -\alias{pblmpredict} -\title{ Phylogenetic Bipartite Linear Model } -\description{ - Fits a linear model to the association strengths of a bipartite data set with or without phylogenetic correlation among the interacting species -} -\usage{ -pblm(assocs,tree1=NULL,tree2=NULL,covars1=NULL,covars2=NULL,bootstrap=FALSE,nreps=10,maxit=10000,pstart=c(.5,.5)) -pblmpredict(x,tree1.w.novel=NULL,tree2.w.novel=NULL,predict.originals=FALSE) - -} - -\arguments{ - \item{assocs}{ A matrix of association strengths among two sets of interacting species } - \item{tree1}{ A phylo tree object or a phylogenetic covariance matrix for the rows of \code{assocs} } - \item{tree2}{ A phylo tree object or a phylogenetic covariance matrix for the columns of \code{assocs}} - \item{covars1}{ A matrix of covariates (e.g., traits) for the row species of \code{assocs} } - \item{covars2}{ A matrix of covariates (e.g., traits) for the column species of \code{assocs} } - \item{bootstrap}{ logical, bootstrap confidence intervals of the parameter estimates } - \item{nreps}{ Number of bootstrap replicated data sets to estimate parameter CIs } - \item{maxit}{ as in \code{\link{optim}} } - \item{pstart}{ starting values of the two phylogenetic signal strength parameters passed to \code{\link{optim}} } - \item{x}{ object of class \code{pblm} } - \item{tree1.w.novel}{ A phylo tree object or a phylogenetic covariance matrix which corresponds to \code{tree1} of \code{x} with species to predict associations } - \item{tree2.w.novel}{ A phylo tree object or a phylogenetic covariance matrix which corresponds to \code{tree2} of \code{x} with species to predict associations } - \item{predict.originals}{ if \code{TRUE} then the associations of each original species in the two phylogenies is predicted } -} - -\details{ - Fit a linear model with covariates using estimated generalized least squares to the association strengths between two sets of interacting species. - Associations can be either binary or continuous. If phylogenies of the two sets of interacting species are supplied, - two \emph{phyogenetic signal strength} parameters (\emph{d1} and \emph{d2}), one for each species set, based on an Ornstein-Uhlenbeck model of - evolution with stabilizing selection are estimated. Values of \emph{d=1} indicate no stabilizing selection and correspond to the Brownian motion model of - evolution; \emph{01} corresponds - to disruptive selection where phylogenetic signal is amplified. Confidence intervals for these and the other parameters can be estimated with - bootstrapping. - \cr - \cr - The function \code{pblmpredict} predicts the associations of novel species following the methods given in appendix B of Ives and Godfray (2006). - } - -\value{ - \item{MSE}{ total, full (each \emph{d} estimated), star (\emph{d=0}), and base (\emph{d=1}) mean squared errors } - \item{signal.strength}{ two estimates of phylogenetic signal strength } - \item{coefficients}{ estimated intercept and covariate coefficients with approximate 95 percent CIs for the three model types (full, star, base) } - \item{CI.boot}{ 95 percent CIs for all parameters } - \item{variates}{ matrix of model variates (can be used for plotting) } - \item{residuals}{ matrix of residuals from the three models (full, star and base) } - \item{predicted}{ predicted associations } - \item{bootvalues}{ matrix of parameters estimated from the \code{nreps} bootstrap replicated data sets used to calculate CIs } - \item{phylocovs}{ phylogenetic covariance matricies scaled by the estimated \code{d1} and \code{d2} } - \item{cors.1}{ correlations among predicted and observed associations for species of \code{tree1}, \code{NA} if \code{predict.originals=FALSE} } - \item{cors.2}{ correlations among predicted and observed associations for species of \code{tree2}, \code{NA} if \code{predict.originals=FALSE} } - \item{pred.novels1}{ predicted associations for the novel speices of \code{tree1} } - \item{pred.novels2}{ predicted associations for the novel speices of \code{tree2} } -} - - - -\note{Covariates that apply to both species sets (e.g., sampling site) should be supplied in the covariate matrix of the set with the most species. -\cr -\cr -Bootstrapping CIs is slow due to the function \code{\link{optim}} used to estimate the model parameters. See appendix A in Ives and Godfray (2006) -for a discussion about this boostrapping procedure -\cr -\cr -If \code{pblmpredict=TRUE} the function does not first remove each species in turn when predicting the associations of the original species as -is done in Ives and Godfray (2006).} - -\references{Ives A.R. & Godfray H.C. (2006) Phylogenetic analysis of trophic associations. The American Naturalist, 168, E1-E14 \cr -\cr -Blomberg S.P., Garland T.J. & Ives A.R. (2003) Testing for phylogenetic signal in comparative data: Behavioral traits are more labile. Evolution, 57, 717-745 -} - -\author{ Matthew Helmus \email{mrhelmus at gmail.com} } -\examples{ -\dontrun{ -#load example data from Ives & Godfray (2006) -data(IvesGodfray) - -#net attack rate of parasitoid on host eq.4 in Ives and Godfray -A<-(-1*log(1-IvesGodfray$interactions[,-28]/t(IvesGodfray$interactions[28]))) - -# Make tips of the phylogenetic trees contemporaneous by extending tips -p<-dim(IvesGodfray$host)[1] -q<-dim(IvesGodfray$parasitoid)[1] -host.cov.scaled<-IvesGodfray$host -para.cov.scaled<-IvesGodfray$parasitoid -for (i in 1:p) -{ - host.cov.scaled[i,i]<-max(host.cov.scaled) -} -for (i in 1:q) -{ - para.cov.scaled[i,i]<-max(para.cov.scaled) -} - -# scale covariance matrices (this reduces numerical problems caused by -# determinants going to infinity or zero) - host.cov.scaled<-host.cov.scaled/(det(as.matrix(host.cov.scaled))^(1/p)) - para.cov.scaled<-para.cov.scaled/(det(as.matrix(para.cov.scaled))^(1/q)) - -pblm.A <- pblm(sqrt(A),tree1=host.cov.scaled,tree2=para.cov.scaled) -pblm.A$signal.strength #compare to Ives and Godfray (2006) Table 1 Line 1 -pblm.A$MSE -} -} +\name{pblm} +\alias{pblm} +\alias{pblmpredict} +\title{ Phylogenetic Bipartite Linear Model } +\description{ + Fits a linear model to the association strengths of a bipartite data set with or without phylogenetic correlation among the interacting species +} +\usage{ +pblm(assocs, tree1=NULL, tree2=NULL, covars1=NULL, covars2=NULL, bootstrap=FALSE, + nreps=10, maxit=10000, pstart=c(.5,.5)) +pblmpredict(x, tree1.w.novel=NULL, tree2.w.novel=NULL, predict.originals=FALSE) + +} + +\arguments{ + \item{assocs}{ A matrix of association strengths among two sets of interacting species } + \item{tree1}{ A phylo tree object or a phylogenetic covariance matrix for the rows of \code{assocs} } + \item{tree2}{ A phylo tree object or a phylogenetic covariance matrix for the columns of \code{assocs}} + \item{covars1}{ A matrix of covariates (e.g., traits) for the row species of \code{assocs} } + \item{covars2}{ A matrix of covariates (e.g., traits) for the column species of \code{assocs} } + \item{bootstrap}{ logical, bootstrap confidence intervals of the parameter estimates } + \item{nreps}{ Number of bootstrap replicated data sets to estimate parameter CIs } + \item{maxit}{ as in \code{\link{optim}} } + \item{pstart}{ starting values of the two phylogenetic signal strength parameters passed to \code{\link{optim}} } + \item{x}{ object of class \code{pblm} } + \item{tree1.w.novel}{ A phylo tree object or a phylogenetic covariance matrix which corresponds to \code{tree1} of \code{x} with species to predict associations } + \item{tree2.w.novel}{ A phylo tree object or a phylogenetic covariance matrix which corresponds to \code{tree2} of \code{x} with species to predict associations } + \item{predict.originals}{ if \code{TRUE} then the associations of each original species in the two phylogenies is predicted } +} + +\details{ + Fit a linear model with covariates using estimated generalized least squares to the association strengths between two sets of interacting species. + Associations can be either binary or continuous. If phylogenies of the two sets of interacting species are supplied, + two \emph{phyogenetic signal strength} parameters (\emph{d1} and \emph{d2}), one for each species set, based on an Ornstein-Uhlenbeck model of + evolution with stabilizing selection are estimated. Values of \emph{d=1} indicate no stabilizing selection and correspond to the Brownian motion model of + evolution; \emph{01} corresponds + to disruptive selection where phylogenetic signal is amplified. Confidence intervals for these and the other parameters can be estimated with + bootstrapping. + \cr + \cr + The function \code{pblmpredict} predicts the associations of novel species following the methods given in appendix B of Ives and Godfray (2006). + } + +\value{ + \item{MSE}{ total, full (each \emph{d} estimated), star (\emph{d=0}), and base (\emph{d=1}) mean squared errors } + \item{signal.strength}{ two estimates of phylogenetic signal strength } + \item{coefficients}{ estimated intercept and covariate coefficients with approximate 95 percent CIs for the three model types (full, star, base) } + \item{CI.boot}{ 95 percent CIs for all parameters } + \item{variates}{ matrix of model variates (can be used for plotting) } + \item{residuals}{ matrix of residuals from the three models (full, star and base) } + \item{predicted}{ predicted associations } + \item{bootvalues}{ matrix of parameters estimated from the \code{nreps} bootstrap replicated data sets used to calculate CIs } + \item{phylocovs}{ phylogenetic covariance matricies scaled by the estimated \code{d1} and \code{d2} } + \item{cors.1}{ correlations among predicted and observed associations for species of \code{tree1}, \code{NA} if \code{predict.originals=FALSE} } + \item{cors.2}{ correlations among predicted and observed associations for species of \code{tree2}, \code{NA} if \code{predict.originals=FALSE} } + \item{pred.novels1}{ predicted associations for the novel speices of \code{tree1} } + \item{pred.novels2}{ predicted associations for the novel speices of \code{tree2} } +} + + + +\note{Covariates that apply to both species sets (e.g., sampling site) should be supplied in the covariate matrix of the set with the most species. +\cr +\cr +Bootstrapping CIs is slow due to the function \code{\link{optim}} used to estimate the model parameters. See appendix A in Ives and Godfray (2006) +for a discussion about this boostrapping procedure +\cr +\cr +If \code{pblmpredict=TRUE} the function does not first remove each species in turn when predicting the associations of the original species as +is done in Ives and Godfray (2006).} + +\references{Ives A.R. & Godfray H.C. (2006) Phylogenetic analysis of trophic associations. The American Naturalist, 168, E1-E14 \cr +\cr +Blomberg S.P., Garland T.J. & Ives A.R. (2003) Testing for phylogenetic signal in comparative data: Behavioral traits are more labile. Evolution, 57, 717-745 +} + +\author{ Matthew Helmus \email{mrhelmus at gmail.com} } +\examples{ +\dontrun{ +#load example data from Ives & Godfray (2006) +data(IvesGodfray) + +#net attack rate of parasitoid on host eq.4 in Ives and Godfray +A<-(-1*log(1-IvesGodfray$interactions[,-28]/t(IvesGodfray$interactions[28]))) + +# Make tips of the phylogenetic trees contemporaneous by extending tips +p<-dim(IvesGodfray$host)[1] +q<-dim(IvesGodfray$parasitoid)[1] +host.cov.scaled<-IvesGodfray$host +para.cov.scaled<-IvesGodfray$parasitoid +for (i in 1:p) +{ + host.cov.scaled[i,i]<-max(host.cov.scaled) +} +for (i in 1:q) +{ + para.cov.scaled[i,i]<-max(para.cov.scaled) +} + +# scale covariance matrices (this reduces numerical problems caused by +# determinants going to infinity or zero) + host.cov.scaled<-host.cov.scaled/(det(as.matrix(host.cov.scaled))^(1/p)) + para.cov.scaled<-para.cov.scaled/(det(as.matrix(para.cov.scaled))^(1/q)) + +pblm.A <- pblm(sqrt(A),tree1=host.cov.scaled,tree2=para.cov.scaled) +pblm.A$signal.strength #compare to Ives and Godfray (2006) Table 1 Line 1 +pblm.A$MSE +} +} \keyword{univar} \ No newline at end of file Modified: pkg/man/pglmm.Rd =================================================================== --- pkg/man/pglmm.Rd 2013-05-29 20:33:11 UTC (rev 243) +++ pkg/man/pglmm.Rd 2013-05-31 18:48:07 UTC (rev 244) @@ -87,10 +87,15 @@ dat<-pglmm.data(modelflag=modelflag,sim.dat=sim.dat) str(dat) -#A low number of iterations, maxit = 25 is probably good for most data sets, but exitcountermax may need to be increased depending on matrix sizes +#A low number of iterations, maxit = 25 is probably good for most data sets, +# but exitcountermax may need to be increased depending on matrix sizes out<-pglmm.fit(dat=dat,maxit=25,exitcountermax=30) +# The first row gives the estimate of phylogenetic signal, +# and the second an estimate of how strongly species +# richness varies across communities. This later parameter +# is likely biologically uninformative for most research questions. str(out) -out$s # The first row gives the estimate of phylogenetic signal and the second an estimate of how strongly species richness varies across communities. This later parameter is likely biologically uninformative for most research questions. +out$s } } Modified: pkg/man/phylostruct.Rd =================================================================== --- pkg/man/phylostruct.Rd 2013-05-29 20:33:11 UTC (rev 243) +++ pkg/man/phylostruct.Rd 2013-05-31 18:48:07 UTC (rev 244) @@ -1,47 +1,48 @@ -\name{phylostruct} -\alias{phylostruct} -\title{ Permutations to Test for Phylogenetic Signal in Community Composition } -\description{ Randomize sample/community data matrices to create null distributions of given metrics -} -\usage{ -phylostruct(samp, tree, env=NULL, metric=c("psv","psr","pse","psc","sppregs"), null.model=c("frequency", - "richness","independentswap","trialswap"), runs=100, it=1000, alpha=0.05, fam="binomial") -} -\arguments{ - \item{samp}{ community data matrix, species as columns, communities as rows } - \item{tree}{ phylo tree object or a phylogenetic covariance matrix } - \item{env}{ environmental data matrix } - \item{metric}{ if \code{metric="psv"}, \code{"psr"}, \code{"pse"}, or \code{"psc"} compares the observed mean of the respective metric to a null distribution at a given alpha; if \code{metric="sppregs"} compares the three correlations produced by \code{\link{sppregs}} to null distributions } - \item{null.model}{ permutation procedure used to create the null distribution, see \code{\link{randomizeMatrix}}} - \item{runs}{ the number of permutations to create the distribution, a rule of thumb is (number of communities)/alpha } - \item{it}{ the number of swaps for the independent and trial-swap null models, see \code{\link{randomizeMatrix}} } - \item{alpha}{ probability value to compare the observed mean/correlations to a null distribution } - \item{fam}{ as in \code{\link{sppregs}} } -} - -\details{The function creates null distributions for the \code{\link{psd}} set of metrics and for the correlations of \code{\link{sppregs}} from observed community data sets.} - -\value{ -\item{metric}{ metric used } -\item{null.model}{ permutation used } -\item{runs}{ number of permutations } -\item{it}{ number of swaps if applicable } -\item{obs}{ observed mean value of a particular metric or the three observed correlations from \code{\link{sppregs}} } -\item{mean.null}{ mean(s) of the null distribution(s) } -\item{quantiles.null}{ quantiles of the null distribution(s) to compare to \code{obs}; determined by \code{alpha}} -\item{phylo.structure}{ if \code{obs} less than (alpha/2), \code{phylo.structure="underdispersed"}; if \code{obs} greater than (1-alpha/2), \code{phylo.structure="overdispersed"}; otherwise \code{phylo.structure="random"} and NULL if \code{metric="sppregs"}} -\item{nulls}{ null values of the distribution(s)} -} - -\references{ Helmus M.R., Bland T.J., Williams C.K. & Ives A.R. (2007a) Phylogenetic measures of biodiversity. American Naturalist, 169, E68-E83 -\cr -\cr -Helmus M.R., Savage K., Diebel M.W., Maxted J.T. & Ives A.R. (2007b) Separating the determinants of phylogenetic community structure. Ecology Letters, 10, 917-925 -\cr -\cr -Gotelli N.J. (2000) Null model analysis of species co-occurrence patterns. Ecology, 81, 2606-2621} - -\author{ Matthew Helmus \email{mrhelmus at gmail.com} } -\seealso{ \code{\link{psd}} ,\code{\link{sppregs}}, \code{\link{randomizeMatrix}} } - +\name{phylostruct} +\alias{phylostruct} +\title{ Permutations to Test for Phylogenetic Signal in Community Composition } +\description{ Randomize sample/community data matrices to create null distributions of given metrics +} +\usage{ +phylostruct(samp, tree, env=NULL, metric=c("psv","psr","pse","psc","sppregs"), + null.model=c("frequency", "richness","independentswap","trialswap"), + runs=100, it=1000, alpha=0.05, fam="binomial") +} +\arguments{ + \item{samp}{ community data matrix, species as columns, communities as rows } + \item{tree}{ phylo tree object or a phylogenetic covariance matrix } + \item{env}{ environmental data matrix } + \item{metric}{ if \code{metric="psv"}, \code{"psr"}, \code{"pse"}, or \code{"psc"} compares the observed mean of the respective metric to a null distribution at a given alpha; if \code{metric="sppregs"} compares the three correlations produced by \code{\link{sppregs}} to null distributions } + \item{null.model}{ permutation procedure used to create the null distribution, see \code{\link{randomizeMatrix}}} + \item{runs}{ the number of permutations to create the distribution, a rule of thumb is (number of communities)/alpha } + \item{it}{ the number of swaps for the independent and trial-swap null models, see \code{\link{randomizeMatrix}} } + \item{alpha}{ probability value to compare the observed mean/correlations to a null distribution } + \item{fam}{ as in \code{\link{sppregs}} } +} + +\details{The function creates null distributions for the \code{\link{psd}} set of metrics and for the correlations of \code{\link{sppregs}} from observed community data sets.} + +\value{ +\item{metric}{ metric used } +\item{null.model}{ permutation used } +\item{runs}{ number of permutations } +\item{it}{ number of swaps if applicable } +\item{obs}{ observed mean value of a particular metric or the three observed correlations from \code{\link{sppregs}} } +\item{mean.null}{ mean(s) of the null distribution(s) } +\item{quantiles.null}{ quantiles of the null distribution(s) to compare to \code{obs}; determined by \code{alpha}} +\item{phylo.structure}{ if \code{obs} less than (alpha/2), \code{phylo.structure="underdispersed"}; if \code{obs} greater than (1-alpha/2), \code{phylo.structure="overdispersed"}; otherwise \code{phylo.structure="random"} and NULL if \code{metric="sppregs"}} +\item{nulls}{ null values of the distribution(s)} +} + +\references{ Helmus M.R., Bland T.J., Williams C.K. & Ives A.R. (2007a) Phylogenetic measures of biodiversity. American Naturalist, 169, E68-E83 +\cr +\cr +Helmus M.R., Savage K., Diebel M.W., Maxted J.T. & Ives A.R. (2007b) Separating the determinants of phylogenetic community structure. Ecology Letters, 10, 917-925 +\cr +\cr +Gotelli N.J. (2000) Null model analysis of species co-occurrence patterns. Ecology, 81, 2606-2621} + +\author{ Matthew Helmus \email{mrhelmus at gmail.com} } +\seealso{ \code{\link{psd}} ,\code{\link{sppregs}}, \code{\link{randomizeMatrix}} } + \keyword{univar} \ No newline at end of file Modified: pkg/man/randomizeSample.Rd =================================================================== --- pkg/man/randomizeSample.Rd 2013-05-29 20:33:11 UTC (rev 243) +++ pkg/man/randomizeSample.Rd 2013-05-31 18:48:07 UTC (rev 244) @@ -6,7 +6,8 @@ Various null models for randomizing community data matrices } \usage{ -randomizeMatrix(samp, null.model = c("frequency", "richness", "independentswap", "trialswap"),iterations = 1000) +randomizeMatrix(samp, null.model = c("frequency", "richness", + "independentswap", "trialswap"), iterations = 1000) } \arguments{ Modified: pkg/man/ses.mntd.Rd =================================================================== --- pkg/man/ses.mntd.Rd 2013-05-29 20:33:11 UTC (rev 243) +++ pkg/man/ses.mntd.Rd 2013-05-31 18:48:07 UTC (rev 244) @@ -7,7 +7,8 @@ Standardized effect size of mean nearest taxon distances in communities. When used with a phylogenetic distance matrix, equivalent to -1 times the Nearest Taxon Index (NTI). } \usage{ -ses.mntd(samp, dis, null.model = c("taxa.labels", "richness", "frequency", "sample.pool", "phylogeny.pool", "independentswap", "trialswap"), +ses.mntd(samp, dis, null.model = c("taxa.labels", "richness", "frequency", + "sample.pool", "phylogeny.pool", "independentswap", "trialswap"), abundance.weighted=FALSE, runs = 999, iterations = 1000) } Modified: pkg/man/sppregs.Rd =================================================================== --- pkg/man/sppregs.Rd 2013-05-29 20:33:11 UTC (rev 243) +++ pkg/man/sppregs.Rd 2013-05-31 18:48:07 UTC (rev 244) @@ -1,57 +1,58 @@ -\name{sppregs} -\alias{sppregs} [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/picante -r 244 From noreply at r-forge.r-project.org Fri May 31 21:21:13 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 31 May 2013 21:21:13 +0200 (CEST) Subject: [Picante-commits] r245 - pkg/man Message-ID: <20130531192113.B7D91185264@r-forge.r-project.org> Author: skembel Date: 2013-05-31 21:21:13 +0200 (Fri, 31 May 2013) New Revision: 245 Modified: pkg/man/expected.pd.Rd Log: Further shortening of documentation lines to pass r-devel check cleanly Modified: pkg/man/expected.pd.Rd =================================================================== --- pkg/man/expected.pd.Rd 2013-05-31 18:48:07 UTC (rev 244) +++ pkg/man/expected.pd.Rd 2013-05-31 19:21:13 UTC (rev 245) @@ -43,11 +43,13 @@ randtree <- rcoal(300) randtree.pd.ub <- variance.pd(randtree, upper.bound=TRUE) randtree.pd.exact <- variance.pd(randtree, upper.bound=FALSE) -plot(expected.pd(randtree), xlab="Number of tips", ylab="Phylogenetic diversity (PD)", type="l", log="xy") +plot(expected.pd(randtree), xlab="Number of tips", + ylab="Phylogenetic diversity (PD)", type="l", log="xy") lines(randtree.pd.exact$expected.pd+1.96*sqrt(randtree.pd.exact$variance.pd), lty=2) lines(randtree.pd.exact$expected.pd-1.96*sqrt(randtree.pd.exact$variance.pd), lty=2) lines(randtree.pd.ub$expected.pd+1.96*sqrt(randtree.pd.ub$variance.pd), lty=3) lines(randtree.pd.ub$expected.pd-1.96*sqrt(randtree.pd.ub$variance.pd), lty=3) -legend("bottomright", lty=c(1,2,3), legend=c("Expected PD","95 percent CI (exact)","95 percent CI (upper bound)")) +legend("bottomright", lty=c(1,2,3), legend=c("Expected PD", + "95 percent CI (exact)","95 percent CI (upper bound)")) } \keyword{univar}