From b8edb1c8ab0f04e49abe26c540a6a558b7be0ea3 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Sat, 16 Dec 2023 10:06:14 -0500 Subject: [PATCH 01/51] fixes & improvements to fitgammaMk --- R/fitgammaMk.R | 51 +++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/R/fitgammaMk.R b/R/fitgammaMk.R index 4633bfbb..d43953e1 100644 --- a/R/fitgammaMk.R +++ b/R/fitgammaMk.R @@ -4,13 +4,15 @@ plot.fitgammaMk<-function(x,...){ if(hasArg(digits)) digits<-list(...)$digits else digits<-3 + if(hasArg(colors)) colors<-list(...)$colors + else colors<-c("yellow","red") if(is.null(x$marginal)){ stop("missing marginal likelihoods.") } else { r<-qgamma(seq(1/(2*x$nrates),1,by=1/x$nrates),x$alpha,x$alpha) r<-r/mean(r) Rates<-log(apply(x$marginal,1,function(x,y) sum(x*y),y=r)) - cols<-setNames(colorRampPalette(c("yellow","red"))(101), + cols<-setNames(colorRampPalette(colors)(101), 0:100) args<-list(...) if(is.null(args$type)) args$type<-"phylogram" @@ -44,20 +46,21 @@ plot.fitgammaMk<-function(x,...){ pp<-get("last_plot.phylo",envir=.PlotPhyloEnv) h<-max(nodeHeights(x$tree)) LWD<-diff(par()$usr[1:2])/dev.size("px")[1] - lines(x=rep(-0.25*h+LWD*15/2,2),y=c(2,Ntip(x$tree)-1)) + Nt<-Ntip(x$tree) + lines(x=rep(-0.25*h+LWD*15/2,2),y=c(1+1/40*Nt,Nt-1/40*Nt)) nticks<-10 - Y<-cbind(seq(2,Ntip(x$tree)-1,length.out=nticks), - seq(2,Ntip(x$tree)-1,length.out=nticks)) + Y<-cbind(seq(1+1/40*Nt,Nt-1/40*Nt,length.out=nticks), + seq(1+1/40*Nt,Nt-1/40*Nt,length.out=nticks)) X<-cbind(rep(-0.25*h+LWD*15/2,nticks), rep(-0.25*h+LWD*15/2+0.02*h,nticks)) for(i in 1:nrow(Y)) lines(X[i,],Y[i,]) - add.color.bar(Ntip(x$tree)-3,cols, + add.color.bar(Nt-2/40*Nt-1,cols, title="relative rate", lims=NULL,digits=3, direction="upwards", subtitle="",lwd=15, x=-0.25*h, - y=2,prompt=FALSE) + y=1+1/40*Nt,prompt=FALSE) ticks<-exp(seq(min(Rates),max(Rates),length.out=10)) text(x=X[,2],y=Y[,2],signif(ticks,digits),pos=4,cex=0.7) invisible(exp(Rates)) @@ -75,6 +78,8 @@ logLik.fitgammaMk<-function(object,...){ } gamma_pruning<-function(par,nrates=4,tree,x,model=NULL,median=TRUE,...){ + if(hasArg(fn_min)) fn_min<-list(...)$fn_min + else fn_min<--Inf if(hasArg(marginal)) marginal<-list(...)$marginal else marginal<-FALSE if(marginal){ @@ -122,8 +127,8 @@ gamma_pruning<-function(par,nrates=4,tree,x,model=NULL,median=TRUE,...){ } else ind<-1:nrates } else ind<-1:nrates P<-Reduce("+",lapply(r[ind], - function(rr,k,Q,edge) EXPM(Q*rr*edge)/k, - k=nrates,Q=Q,edge=pw$edge.length[ee[j]])) + function(rr,nr,Q,edge) expm(Q*rr*edge)/nr, + nr=nrates,Q=Q,edge=pw$edge.length[ee[j]])) PP[j,]<-P%*%L[pw$edge[ee[j],2],] } L[nn[i],]<-apply(PP,2,prod) @@ -137,13 +142,15 @@ gamma_pruning<-function(par,nrates=4,tree,x,model=NULL,median=TRUE,...){ prob<-sum(log(pp)) if(return=="likelihood") if(is.na(prob)||is.nan(prob)) - return(-Inf) else return(prob) + return(fn_min) else return(prob) else if(return=="conditional") L else if(return=="pi") pi } fitgammaMk<-function(tree,x,model="ER",fixedQ=NULL,nrates=4,...){ median<-TRUE + if(hasArg(fn_min)) fn_min<-list(...)$fn_min + else fn_min<--Inf if(hasArg(marginal)) marginal<-list(...)$marginal else marginal<-FALSE if(hasArg(parallel)) parallel<-list(...)$parallel @@ -260,25 +267,27 @@ fitgammaMk<-function(tree,x,model="ER",fixedQ=NULL,nrates=4,...){ fit<-if(logscale) optim(c(q.init,alpha.init),function(p) -gamma_pruning(exp(p),nrates=nrates,tree=pw,x=x,model=MODEL, - median=TRUE,pi=pi),method="L-BFGS-B",lower=c(rep(log(min.q),k), - log(min.alpha)),upper=c(rep(log(max.q),k), - log(max.alpha))) else - optim(c(q.init,alpha.init),function(p) -pruning(p,nrates=nrates, - tree=pw,x=x,model=MODEL,median=TRUE,pi=pi),method="L-BFGS-B", - lower=c(rep(min.q,k),min.alpha),upper=c(rep(max.q,k),max.alpha)) + median=TRUE,pi=pi,fn_min=fn_min),method="L-BFGS-B", + lower=c(rep(log(min.q),k),log(min.alpha)), + upper=c(rep(log(max.q),k),log(max.alpha))) else + optim(c(q.init,alpha.init),function(p) -gamma_pruning(p,nrates=nrates, + tree=pw,x=x,model=MODEL,median=TRUE,pi=pi,fn_min=fn_min), + method="L-BFGS-B",lower=c(rep(min.q,k),min.alpha), + upper=c(rep(max.q,k),max.alpha)) } else if(opt.method=="none"){ - fit<-list(objective=-gamma_pruning(c(q.init,alpha.init), - nrates=nrates,pw,x,MODEL,median=TRUE,pi=pi),par=q.init) + fit<-list(objective=-gamma_pruning(c(q.init,alpha.init), + nrates=nrates,pw,x,MODEL,median=TRUE,pi=pi),par=q.init) } else { fit<-if(logscale) nlminb(c(q.init,alpha.init),function(p) -gamma_pruning(exp(p), - nrates=nrates,tree=pw,x=x,model=MODEL,median=TRUE,pi=pi), - lower=c(rep(log(min.q),k),log(min.alpha)), + nrates=nrates,tree=pw,x=x,model=MODEL,median=TRUE,pi=pi, + fn_min=fn_min),lower=c(rep(log(min.q),k),log(min.alpha)), upper=c(rep(log(max.q),k),log(max.alpha))) else nlminb(c(q.init,alpha.init),function(p) -gamma_pruning(p, - nrates=nrates,tree=pw,x=x,model=MODEL,median=TRUE,pi=pi), - lower=c(rep(min.q,k),min.alpha),upper=c(rep(max.q,k),max.alpha)) + nrates=nrates,tree=pw,x=x,model=MODEL,median=TRUE,pi=pi, + fn_min=fn_min),lower=c(rep(min.q,k),min.alpha), + upper=c(rep(max.q,k),max.alpha)) } if(logscale) fit$par<-exp(fit$par) if(pi[1]=="fitzjohn") pi<-setNames( From a9f05d6b81c1578a90190f06f227b26a5773c9f1 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Sat, 16 Dec 2023 10:06:35 -0500 Subject: [PATCH 02/51] increment subversion number --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 09deca93..6b3701ea 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: phytools -Version: 2.0-11 -Date: 2023-12-11 +Version: 2.0-13 +Date: 2023-12-15 Title: Phylogenetic Tools for Comparative Biology (and Other Things) Author: Liam J. Revell Maintainer: Liam J. Revell From e10502140c7195c16723d7a02b098165e83878b9 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Sat, 16 Dec 2023 14:42:25 -0500 Subject: [PATCH 03/51] update legend text in plot.fitgammaMk --- R/fitgammaMk.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/fitgammaMk.R b/R/fitgammaMk.R index d43953e1..621d51a8 100644 --- a/R/fitgammaMk.R +++ b/R/fitgammaMk.R @@ -55,7 +55,7 @@ plot.fitgammaMk<-function(x,...){ rep(-0.25*h+LWD*15/2+0.02*h,nticks)) for(i in 1:nrow(Y)) lines(X[i,],Y[i,]) add.color.bar(Nt-2/40*Nt-1,cols, - title="relative rate", + title="relative edge rate", lims=NULL,digits=3, direction="upwards", subtitle="",lwd=15, From d2d290c01b43cbe4cbd6aa55186f1affa2d41d9b Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Fri, 5 Jan 2024 10:47:33 -0500 Subject: [PATCH 04/51] update citation to phytools 2.0 --- DESCRIPTION | 4 ++-- NAMESPACE | 2 +- R/fitgammaMk.R | 4 ++-- inst/CITATION | 15 +++++++-------- man/Dtest.Rd | 2 +- man/add.arrow.Rd | 2 +- man/add.color.bar.Rd | 2 ++ man/add.everywhere.Rd | 2 +- man/add.random.Rd | 2 +- man/add.simmap.legend.Rd | 2 +- man/add.species.to.genus.Rd | 2 +- man/aic.w.Rd | 2 +- man/allFurcTrees.Rd | 2 +- man/anc.Bayes.Rd | 2 +- man/anc.ML.Rd | 2 +- man/anc.trend.Rd | 2 +- man/ancThresh.Rd | 2 ++ man/ancr.Rd | 4 +++- man/ansi_phylo.Rd | 2 +- man/applyBranchLengths.Rd | 2 +- man/as.Qmatrix.Rd | 4 ++-- man/as.multiPhylo.Rd | 2 +- man/ave.rates.Rd | 2 +- man/averageTree.Rd | 2 +- man/bd.Rd | 2 +- man/bind.tip.Rd | 2 +- man/bind.tree.simmap.Rd | 2 +- man/bmPlot.Rd | 6 +++--- man/branching.diffusion.Rd | 2 +- man/brownie.lite.Rd | 4 ++-- man/brownieREML.Rd | 6 +++--- man/cladelabels.Rd | 2 +- man/collapse.to.star.Rd | 2 +- man/collapseTree.Rd | 2 +- man/compare.chronograms.Rd | 2 +- man/consensus.edges.Rd | 3 +++ man/contMap.Rd | 12 ++++++++---- man/cophylo.Rd | 2 +- man/cospeciation.Rd | 2 +- man/countSimmap.Rd | 2 +- man/ctt.Rd | 2 +- man/density.multiSimmap.Rd | 2 +- man/densityMap.Rd | 10 +++++----- man/densityTree.Rd | 2 +- man/describe.simmap.Rd | 2 +- man/di2multi.simmap.Rd | 2 +- man/dotTree.Rd | 2 +- man/drop.clade.Rd | 2 +- man/drop.leaves.Rd | 2 +- man/drop.tip.contMap.Rd | 2 +- man/drop.tip.multiSimmap.Rd | 2 +- man/drop.tip.simmap.Rd | 2 +- man/edge.widthMap.Rd | 2 +- man/edgeProbs.Rd | 2 +- man/estDiversity.Rd | 2 +- man/evol.rate.mcmc.Rd | 6 +++--- man/evol.vcv.Rd | 4 ++-- man/evolvcv.lite.Rd | 2 +- man/exhaustiveMP.Rd | 2 +- man/expand.clade.Rd | 2 +- man/export.as.xml.Rd | 2 +- man/fancyTree.Rd | 8 +++++++- man/fastAnc.Rd | 2 +- man/fastBM.Rd | 2 +- man/fastMRCA.Rd | 2 +- man/findMRCA.Rd | 2 +- man/fit.bd.Rd | 4 ++-- man/fitBayes.Rd | 2 +- man/fitDiversityModel.Rd | 4 ++-- man/fitMk.Rd | 6 ++++-- man/fitPagel.Rd | 2 +- man/force.ultrametric.Rd | 2 +- man/gamma_pruning.Rd | 26 ++++++++++++++++++++++++++ man/gammatest.Rd | 2 +- man/genSeq.Rd | 2 +- man/geo.legend.Rd | 2 +- man/get.treepos.Rd | 2 +- man/getCladesofSize.Rd | 2 +- man/getDescendants.Rd | 2 +- man/getExtant.Rd | 2 +- man/getSisters.Rd | 2 +- man/getStates.Rd | 2 +- man/labelnodes.Rd | 2 +- man/ladderize.simmap.Rd | 2 +- man/lambda.transform.Rd | 2 +- man/likMlambda.Rd | 2 +- man/linklabels.Rd | 2 +- man/locate.fossil.Rd | 2 +- man/locate.yeti.Rd | 2 +- man/ls.tree.Rd | 2 +- man/ltt.Rd | 2 +- man/ltt95.Rd | 2 +- man/make.era.map.Rd | 2 +- man/make.simmap.Rd | 6 ++++-- man/map.overlap.Rd | 2 +- man/map.to.singleton.Rd | 2 +- man/mapped.states.Rd | 2 +- man/markChanges.Rd | 2 +- man/matchNodes.Rd | 2 +- man/mergeMappedStates.Rd | 2 +- man/midpoint.root.Rd | 2 +- man/minRotate.Rd | 2 +- man/minSplit.Rd | 2 +- man/modified.Grafen.Rd | 2 +- man/mrp.supertree.Rd | 2 +- man/multi.mantel.Rd | 4 ++-- man/multiC.Rd | 2 +- man/multiRF.Rd | 4 ++-- man/multirateBM.Rd | 4 ++-- man/nodeHeights.Rd | 2 +- man/nodelabels.cophylo.Rd | 2 +- man/optim.phylo.ls.Rd | 2 +- man/orderMappedEdge.Rd | 2 +- man/paintSubTree.Rd | 2 +- man/paste.tree.Rd | 2 +- man/pbtree.Rd | 2 +- man/pgls.Ives.Rd | 2 +- man/phenogram.Rd | 8 +++++++- man/phyl.RMA.Rd | 2 +- man/phyl.cca.Rd | 2 +- man/phyl.pairedttest.Rd | 2 +- man/phyl.pca.Rd | 2 +- man/phyl.resid.Rd | 2 +- man/phyl.vcv.Rd | 2 +- man/phylANOVA.Rd | 6 +++--- man/phylo.heatmap.Rd | 2 +- man/phylo.impute.Rd | 2 +- man/phylo.to.map.Rd | 4 +++- man/phylo.toBackbone.Rd | 2 +- man/phyloDesign.Rd | 2 +- man/phylomorphospace.Rd | 4 +++- man/phylomorphospace3d.Rd | 4 +++- man/phylosig.Rd | 6 +++--- man/phytools-package.Rd | 2 +- man/plot.backbonePhylo.Rd | 2 +- man/plotBranchbyTrait.Rd | 2 +- man/plotSimmap.Rd | 6 ++++-- man/plotThresh.Rd | 4 ++-- man/plotTree.Rd | 4 +++- man/plotTree.datamatrix.Rd | 2 +- man/plotTree.errorbars.Rd | 2 +- man/plotTree.wBars.Rd | 2 +- man/posterior.evolrate.Rd | 2 ++ man/posthoc.Rd | 3 +++ man/print.backbonePhylo.Rd | 2 +- man/pscore.Rd | 4 +++- man/ratebystate.Rd | 2 +- man/ratebytree.Rd | 8 ++++---- man/rateshift.Rd | 4 +++- man/read.newick.Rd | 2 +- man/read.simmap.Rd | 2 +- man/reorder.backbonePhylo.Rd | 2 +- man/reorderSimmap.Rd | 2 +- man/rep.phylo.Rd | 2 +- man/reroot.Rd | 2 +- man/rerootingMethod.Rd | 2 +- man/rescale.Rd | 2 +- man/rescaleSimmap.Rd | 2 +- man/resolveNode.Rd | 2 +- man/rotateNodes.Rd | 2 +- man/roundBranches.Rd | 2 +- man/roundPhylogram.Rd | 2 +- man/rstate.Rd | 2 +- man/sampleFrom.Rd | 2 +- man/setMap.Rd | 6 +++++- man/sim.corrs.Rd | 2 +- man/sim.history.Rd | 2 +- man/sim.ratebystate.Rd | 2 +- man/sim.rates.Rd | 2 +- man/simBMphylo.Rd | 2 +- man/skewers.Rd | 4 ++-- man/splitEdgeColor.Rd | 2 +- man/splitTree.Rd | 2 +- man/splitplotTree.Rd | 2 +- man/starTree.Rd | 2 +- man/strahlerNumber.Rd | 2 +- man/threshBayes.Rd | 4 ++-- man/threshDIC.Rd | 6 ++++-- man/threshState.Rd | 4 ++-- man/to.matrix.Rd | 2 +- man/tree.grow.Rd | 2 +- man/treeSlice.Rd | 2 +- man/untangle.Rd | 2 +- man/vcvPhylo.Rd | 2 +- man/write.simmap.Rd | 2 +- man/writeAncestors.Rd | 2 +- man/writeNexus.Rd | 2 +- 187 files changed, 305 insertions(+), 226 deletions(-) create mode 100644 man/gamma_pruning.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 6b3701ea..5d44c91f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: phytools -Version: 2.0-13 -Date: 2023-12-15 +Version: 2.1-0 +Date: 2024-01-05 Title: Phylogenetic Tools for Comparative Biology (and Other Things) Author: Liam J. Revell Maintainer: Liam J. Revell diff --git a/NAMESPACE b/NAMESPACE index 5a4b55a6..2cc004d0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -17,7 +17,7 @@ export(extract.clade.simmap, extract.strahlerNumber) export(fancyTree, fastAnc, fastBM, fastDist, fastHeight, fastMRCA, findMRCA, fit.bd) export(fit.yule, fitBayes, fitgammaMk, fitHRM, fitMk, fitMk.parallel, fitmultiMk, fitpolyMk) export(fitDiversityModel, fitPagel, force.ultrametric) -export(gammatest, genus.to.species.tree, genSeq, geo.palette, geo.legend, get.treepos) +export(gamma_pruning, gammatest, genus.to.species.tree, genSeq, geo.palette, geo.legend, get.treepos) export(getCladesofSize, getDescendants, getExtant, getExtinct, getnode, getParent) export(getSisters, getStates, graph.polyMk, gtt) export(hide.hidden) diff --git a/R/fitgammaMk.R b/R/fitgammaMk.R index 621d51a8..5abb3dda 100644 --- a/R/fitgammaMk.R +++ b/R/fitgammaMk.R @@ -147,7 +147,7 @@ gamma_pruning<-function(par,nrates=4,tree,x,model=NULL,median=TRUE,...){ else if(return=="pi") pi } -fitgammaMk<-function(tree,x,model="ER",fixedQ=NULL,nrates=4,...){ +fitgammaMk<-function(tree,x,model="ER",fixedQ=NULL,nrates=8,...){ median<-TRUE if(hasArg(fn_min)) fn_min<-list(...)$fn_min else fn_min<--Inf @@ -346,7 +346,7 @@ fitgammaMk<-function(tree,x,model="ER",fixedQ=NULL,nrates=4,...){ mc<-makeCluster(ncores,type="PSOCK") registerDoParallel(cl=mc) tmpRATES<-foreach(i=1:nrow(tree$edge))%dopar%{ - foo<-function(X) phytools:::gamma_pruning( + foo<-function(X) phytools::gamma_pruning( par=c(obj$rates,obj$alpha), nrates=nrates,tree=tree,x=x,model=MODEL,median=TRUE, pi=pi,marginal=TRUE,edge=tree$edge[i,2],rate=X) diff --git a/inst/CITATION b/inst/CITATION index c6b3e915..67acd4e3 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -1,11 +1,10 @@ bibentry(bibtype = "Article", - title = "phytools: An {R} package for phylogenetic comparative biology (and other things).", + title = "{p}hytools 2.0: an updated {R} ecosystem for phylogenetic comparative methods (and other things).", author = person("Liam J.", "Revell"), - journal = "Methods in Ecology and Evolution", - year = "2012", - volume = "3", - pages = "217-223", - doi = "10.1111/j.2041-210X.2011.00169.x", + journal = "PeerJ", + year = "2024", + volume = "12", + pages = "e16505", + doi = "10.7717/peerj.16505", header = "To cite phytools in a publication please use:", - textVersion = "Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods in Ecology and Evolution, 3, 217-223.", - footer = "As phytools is continually evolving you may also want to cite its version number (found with 'library(help = phytools)' or 'packageVersion(\"phytools\")').") + textVersion = "Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). PeerJ, 12, e16505.", footer = "As phytools is continually evolving you may also want to cite its version number (found with 'library(help = phytools)' or 'packageVersion(\"phytools\")').") diff --git a/man/Dtest.Rd b/man/Dtest.Rd index 2c7597fc..9924a2f0 100644 --- a/man/Dtest.Rd +++ b/man/Dtest.Rd @@ -22,7 +22,7 @@ Dtest(t1, t2, nsim=100, ...) \references{ Huelsenbeck, J. P., R. Neilsen, and J. P. Bollback (2003) Stochastic mapping of morphological characters. \emph{Systematic Biology}, \bold{52}, 131-138. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/add.arrow.Rd b/man/add.arrow.Rd index bd4d6491..10021a5e 100644 --- a/man/add.arrow.Rd +++ b/man/add.arrow.Rd @@ -16,7 +16,7 @@ add.arrow(tree=NULL, tip, ...) Trees can be plotted using \pkg{phytools} function \code{plotTree}, \code{plotSimmap}, \code{contMap}, \code{densityMap}, and \pkg{ape} S3 method \code{plot.phylo}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/add.color.bar.Rd b/man/add.color.bar.Rd index e693a26a..2ca44cb9 100644 --- a/man/add.color.bar.Rd +++ b/man/add.color.bar.Rd @@ -26,6 +26,8 @@ add.color.bar(leg, cols, title=NULL, lims=c(0,1), digits=1, prompt=TRUE, } \references{ Revell, L. J. (2013) Two new graphical methods for mapping trait evolution on phylogenies. \emph{Methods in Ecology and Evolution}, \bold{4}, 754-759. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/add.everywhere.Rd b/man/add.everywhere.Rd index 2b46a154..571b00d7 100644 --- a/man/add.everywhere.Rd +++ b/man/add.everywhere.Rd @@ -16,7 +16,7 @@ add.everywhere(tree, tip.name) } \author{Liam Revell \email{liam.revell@umb.edu}} \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \seealso{ \code{\link{allFurcTrees}}, \code{\link{exhaustiveMP}} diff --git a/man/add.random.Rd b/man/add.random.Rd index 2c6bf56b..322f0810 100644 --- a/man/add.random.Rd +++ b/man/add.random.Rd @@ -25,7 +25,7 @@ add.random(tree, n=NULL, tips=NULL, edge.length=NULL, order=c("random","input")) An object of class \code{"phylo"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/add.simmap.legend.Rd b/man/add.simmap.legend.Rd index 50158051..3d833194 100644 --- a/man/add.simmap.legend.Rd +++ b/man/add.simmap.legend.Rd @@ -18,7 +18,7 @@ add.simmap.legend(leg=NULL, colors, prompt=TRUE, vertical=TRUE, ...) Redundant with \code{\link{legend}}, which is much more powerful but somewhat more complicated to use. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/add.species.to.genus.Rd b/man/add.species.to.genus.Rd index e1b0ae5d..980e7ed9 100644 --- a/man/add.species.to.genus.Rd +++ b/man/add.species.to.genus.Rd @@ -30,7 +30,7 @@ genus.to.species.tree(tree, species) An object of class \code{"phylo"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/aic.w.Rd b/man/aic.w.Rd index b90d68de..6d17c88f 100644 --- a/man/aic.w.Rd +++ b/man/aic.w.Rd @@ -21,7 +21,7 @@ aic.w(aic) \references{ Akaike, H. (1974) A new look at the statistical model identification. \emph{IEEE Transactions on Automatic Control}, \bold{19}, 716-723. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{statistics} diff --git a/man/allFurcTrees.Rd b/man/allFurcTrees.Rd index 90eec30a..d05b208c 100644 --- a/man/allFurcTrees.Rd +++ b/man/allFurcTrees.Rd @@ -21,7 +21,7 @@ allFurcTrees(n, tip.label=NULL, to.plot=TRUE) \references{ Felsenstein, J. 2004. \emph{Inferring Phylogenies}. Sinauer. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/anc.Bayes.Rd b/man/anc.Bayes.Rd index e300dd8d..334040c9 100644 --- a/man/anc.Bayes.Rd +++ b/man/anc.Bayes.Rd @@ -31,7 +31,7 @@ anc.Bayes(tree, x, ngen=10000, control=list(), ...) The \code{print} and \code{summary} methods for this object class also return (invisibly) a vector of estimated ancestral states based on a user-supplied burn-in (or 20\% of the number of generations of MCMC, if no burn-in is provided). Burn-in can be specified with the optional argument \code{burnin}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/anc.ML.Rd b/man/anc.ML.Rd index fe04fc93..7b6079b9 100644 --- a/man/anc.ML.Rd +++ b/man/anc.ML.Rd @@ -29,7 +29,7 @@ anc.ML(tree, x, maxit=2000, model=c("BM","OU","EB"), ...) \item{convergence}{the value of \code{convergence} returned by \code{\link{optim}} (0 is good).} } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. Schluter, D., Price, T., Mooers, A. O., and Ludwig, D. (1997) Likelihood of ancestor states in adaptive radiation. \emph{Evolution} \bold{51}, 1699-1711. } diff --git a/man/anc.trend.Rd b/man/anc.trend.Rd index 17329482..1231855a 100644 --- a/man/anc.trend.Rd +++ b/man/anc.trend.Rd @@ -26,7 +26,7 @@ anc.trend(tree, x, maxit=2000) \item{convergence}{the value of \code{$convergence} returned by \code{optim()} (0 is good).} } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/ancThresh.Rd b/man/ancThresh.Rd index dd44bbb4..385e04d4 100644 --- a/man/ancThresh.Rd +++ b/man/ancThresh.Rd @@ -34,6 +34,8 @@ ancThresh(tree, x, ngen=100000, sequence=NULL, method="mcmc", Felsenstein, J. (2012) A comparative method for both discrete and continuous characters using the threshold model. \emph{American Naturalist}, \bold{179}, 145-156. Revell, L. J. (2014) Ancestral character estimation under the threshold model from quantitative genetics. \emph{Evolution}, \bold{68}, 743-759. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/ancr.Rd b/man/ancr.Rd index 6853676c..6148341a 100644 --- a/man/ancr.Rd +++ b/man/ancr.Rd @@ -31,7 +31,9 @@ hide.hidden(object, ...) An object of class \code{"ancr"}. In the case of \code{type="marginal"}, this object consists of a matrix of marginal (empirical Bayes) probabilities and a likelihood. In the case of \code{type="joint"}, the object contains a set of most-likely internal node states stored in a data frame. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Pagel, M. (1999) The Maximum Likelihood approach to reconstructing ancestral character states of discrete characters on phylogenies. \emph{Systematic Biology}, \bold{3}, 612-622. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/ansi_phylo.Rd b/man/ansi_phylo.Rd index 5317b6c3..b8e48896 100644 --- a/man/ansi_phylo.Rd +++ b/man/ansi_phylo.Rd @@ -16,7 +16,7 @@ ansi_phylo(tree, vertical=c("|","-"), ...) A plotted tree. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/applyBranchLengths.Rd b/man/applyBranchLengths.Rd index a3dea7d5..fa7eedc6 100644 --- a/man/applyBranchLengths.Rd +++ b/man/applyBranchLengths.Rd @@ -18,7 +18,7 @@ applyBranchLengths(tree, edge.length) An object of class \code{"phylo"} or \code{"simmap"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/as.Qmatrix.Rd b/man/as.Qmatrix.Rd index 4cb2a179..0cbea16a 100644 --- a/man/as.Qmatrix.Rd +++ b/man/as.Qmatrix.Rd @@ -26,9 +26,9 @@ as.Qmatrix(x, ...) \code{plot.Qmatrix} invisibly returns the coordinates of vertices of the plotted \bold{Q}-matrix. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } -\author{Liam Revell \email{liam.revell@umb.edu}, Joan Maspons} +\author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ \code{\link{fitMk}} } diff --git a/man/as.multiPhylo.Rd b/man/as.multiPhylo.Rd index 7ddb3a74..81afc7d2 100644 --- a/man/as.multiPhylo.Rd +++ b/man/as.multiPhylo.Rd @@ -19,7 +19,7 @@ as.multiPhylo(x, ...) An object of class \code{"multiPhylo"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/ave.rates.Rd b/man/ave.rates.Rd index d2644af4..b29533d0 100644 --- a/man/ave.rates.Rd +++ b/man/ave.rates.Rd @@ -21,7 +21,7 @@ ave.rates(tree, shift, tips, sig1, sig2, ave.shift, showTree=TRUE) A list of the rates. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/averageTree.Rd b/man/averageTree.Rd index 8d3ffc8b..879d6b58 100644 --- a/man/averageTree.Rd +++ b/man/averageTree.Rd @@ -34,7 +34,7 @@ minTreeDist(tree, trees, method="quadratic.path.difference", ...) \references{ Lapointe, F.-J., G. Cucumel (1997) The average consensus procedure: Combination of weighted trees containing identical or overlapping sets of taxa. \emph{Systematic Biology}, \bold{46}, 306-312. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/bd.Rd b/man/bd.Rd index ea32b1d0..7eec3acf 100644 --- a/man/bd.Rd +++ b/man/bd.Rd @@ -17,7 +17,7 @@ bd(x) A vector. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/bind.tip.Rd b/man/bind.tip.Rd index c4e40f29..b1c7e26c 100644 --- a/man/bind.tip.Rd +++ b/man/bind.tip.Rd @@ -26,7 +26,7 @@ bind.tip(tree, tip.label, edge.length=NULL, where=NULL, position=0, An object of class \code{"phylo"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \examples{ diff --git a/man/bind.tree.simmap.Rd b/man/bind.tree.simmap.Rd index 3b2d3ba7..dcf1f2c1 100644 --- a/man/bind.tree.simmap.Rd +++ b/man/bind.tree.simmap.Rd @@ -19,7 +19,7 @@ bind.tree.simmap(x, y, where="root") An object of class \code{"simmap"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/bmPlot.Rd b/man/bmPlot.Rd index 92991792..f8d1e9e8 100644 --- a/man/bmPlot.Rd +++ b/man/bmPlot.Rd @@ -26,11 +26,11 @@ bmPlot(tree, type="BM", anc=0, sig2=1/1000, ngen=1000, ...) It also returns, by default (although this can be turned off) a tree with the branch lengths in discrete time and with a mapped discrete character (for \code{type="threshold"}). } \references{ - Felsenstein, J. 2012. A comparative method for both discrete and continuous characters using the threshold model. \emph{American Naturalist}, \bold{179}, 145-156. - - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Felsenstein, J. (2012) A comparative method for both discrete and continuous characters using the threshold model. \emph{American Naturalist}, \bold{179}, 145-156. Revell, L. J. (2014) Ancestral character estimation under the threshold model from quantitative genetics. \emph{Evolution}, \bold{68}, 743-759. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/branching.diffusion.Rd b/man/branching.diffusion.Rd index 8d09d807..8e95aae5 100644 --- a/man/branching.diffusion.Rd +++ b/man/branching.diffusion.Rd @@ -26,7 +26,7 @@ branching.diffusion(sig2=1, b=0.0023, time.stop=1000, ylim=NULL, An animated plot and (optionally) a recorded video file. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/brownie.lite.Rd b/man/brownie.lite.Rd index 1d3e75cc..a1963146 100644 --- a/man/brownie.lite.Rd +++ b/man/brownie.lite.Rd @@ -38,9 +38,9 @@ brownie.lite(tree, x, maxit=2000, test="chisq", nsim=100, se=NULL, ...) \item{convergence}{logical value indicating if the likelihood optimization converged.} } \references{ - O'Meara, B. C., C. Ane, M. J. Sanderson, and P. C. Wainwright. (2006) Testing for different rates of continuous trait evolution using likelihood. \emph{Evolution}, \bold{60}, 922-933. + O'Meara, B. C., C. Ane, M. J. Sanderson, and P. C. Wainwright (2006) Testing for different rates of continuous trait evolution using likelihood. \emph{Evolution}, \bold{60}, 922-933. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/brownieREML.Rd b/man/brownieREML.Rd index 8d4a0162..24eb129d 100644 --- a/man/brownieREML.Rd +++ b/man/brownieREML.Rd @@ -26,11 +26,11 @@ brownieREML(tree, x, maxit=2000, ...) \item{convergence}{numerical value from \code{\link{optim}}.} } \references{ - Felsenstein, J. 1985. Phylogenies and the comparative method. \emph{American Naturalist}, \bold{125}, 1-15. + Felsenstein, J. (1985) Phylogenies and the comparative method. \emph{American Naturalist}, \bold{125}, 1-15. - O'Meara, B. C., C. Ane, M. J. Sanderson, and P. C. Wainwright. 2006. Testing for different rates of continuous trait evolution using likelihood. \emph{Evolution}, \bold{60}, 922-933. + O'Meara, B. C., C. Ane, M. J. Sanderson, and P. C. Wainwright (2006) Testing for different rates of continuous trait evolution using likelihood. \emph{Evolution}, \bold{60}, 922-933. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/cladelabels.Rd b/man/cladelabels.Rd index 93328dfa..895d680c 100644 --- a/man/cladelabels.Rd +++ b/man/cladelabels.Rd @@ -32,7 +32,7 @@ arc.cladelabels(tree=NULL, text, node=NULL, ln.offset=1.02, \references{ Paradis, E., J. Claude, and K. Strimmer (2004) APE: Analyses of phylogenetics and evolution in R language. \emph{Bioinformatics}, \bold{20}, 289-290. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/collapse.to.star.Rd b/man/collapse.to.star.Rd index 7146d60f..e79c5e2e 100644 --- a/man/collapse.to.star.Rd +++ b/man/collapse.to.star.Rd @@ -20,7 +20,7 @@ collapse.to.star(tree, node) An object of class \code{"phylo"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/collapseTree.Rd b/man/collapseTree.Rd index 8752e1da..15ed2cba 100644 --- a/man/collapseTree.Rd +++ b/man/collapseTree.Rd @@ -20,7 +20,7 @@ collapseTree(tree, ...) Returns the final plotted tree. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/compare.chronograms.Rd b/man/compare.chronograms.Rd index e2ea2357..d7a58ddb 100644 --- a/man/compare.chronograms.Rd +++ b/man/compare.chronograms.Rd @@ -19,7 +19,7 @@ compare.chronograms(t1, t2, ...) Function creates a plot. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/consensus.edges.Rd b/man/consensus.edges.Rd index 966f5a45..d1edc840 100644 --- a/man/consensus.edges.Rd +++ b/man/consensus.edges.Rd @@ -15,6 +15,9 @@ consensus.edges(trees, method=c("mean.edge","least.squares"), ...) \value{ An object of class \code{"phylo"} with edge lengths. } +\references{ + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. +} \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} \keyword{consensus tree} diff --git a/man/contMap.Rd b/man/contMap.Rd index 2888d3a9..a36f791c 100644 --- a/man/contMap.Rd +++ b/man/contMap.Rd @@ -45,11 +45,15 @@ errorbar.contMap(obj, ...) \code{errorbar.contMap} adds colorful error bars to a plotted tree. } \references{ - Felsenstein, J. 1985. Phylogenies and the comparative method. \emph{American Naturalist}, \bold{125}, 1-15. + Felsenstein, J. (1985) Phylogenies and the comparative method. \emph{American Naturalist}, \bold{125}, 1-15. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. - - Revell, L. J. 2013. Two new graphical methods for mapping trait evolution on phylogenies. \emph{Methods in Ecology and Evolution}, \bold{4}, 754-759. + Revell, L. J. (2013) Two new graphical methods for mapping trait evolution on phylogenies. \emph{Methods in Ecology and Evolution}, \bold{4}, 754-759. + + Revell, L. J. (2014) Graphical methods for visualizing comparative data on phylogenies. Chapter 4 in \emph{Modern phylogenetic comparative methods and their application in evolutionary biology: Concepts and practice} (L. Z. Garamszegi ed.), pp. 77-103. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. + + Revell, L. J., K. Schliep, E. Valderrama, and J. E. Richardson (2018) Graphs in phylogenetic comparative analysis: Anscombe's quartet revisited. \emph{Methods in Ecology and Evolution}, \bold{9}, 2145-2154. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/cophylo.Rd b/man/cophylo.Rd index 0b88f195..5c1b156a 100644 --- a/man/cophylo.Rd +++ b/man/cophylo.Rd @@ -34,7 +34,7 @@ cotangleplot(tr1, tr2, type=c("cladogram","phylogram"), An object of class \code{"cophylo"} which includes the following components or a pair of plotted facing phylogenies with links between tips as specified in \code{assoc}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/cospeciation.Rd b/man/cospeciation.Rd index ee471afe..2770453a 100644 --- a/man/cospeciation.Rd +++ b/man/cospeciation.Rd @@ -32,7 +32,7 @@ cospeciation(t1, t2, distance=c("RF","SPR"), An object of class \code{"cospeciation"}, which includes the test-statistic, the null distribution, and a p-value for the test of the null hypothesis of no topological similarity between the two trees. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/countSimmap.Rd b/man/countSimmap.Rd index e859fd52..79228a9b 100644 --- a/man/countSimmap.Rd +++ b/man/countSimmap.Rd @@ -25,7 +25,7 @@ anoletree countSimmap(anoletree) } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{ancestral states} diff --git a/man/ctt.Rd b/man/ctt.Rd index 7fecf693..3b85e920 100644 --- a/man/ctt.Rd +++ b/man/ctt.Rd @@ -28,7 +28,7 @@ sim.multiCtt(tree, Q, anc=NULL, nmaps=100, nsim=100, ...) An object of class \code{"ctt"} or \code{"multiCtt"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/density.multiSimmap.Rd b/man/density.multiSimmap.Rd index 6e9e529a..af43f983 100644 --- a/man/density.multiSimmap.Rd +++ b/man/density.multiSimmap.Rd @@ -32,7 +32,7 @@ \code{plot.changesMap} generates a plot. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{ancestral states} diff --git a/man/densityMap.Rd b/man/densityMap.Rd index 770bf3b8..39fbfe95 100644 --- a/man/densityMap.Rd +++ b/man/densityMap.Rd @@ -33,13 +33,13 @@ densityMap(trees, res=100, fsize=NULL, ftype=NULL, lwd=3, check=FALSE, Plots a tree and returns an object of class \code{"densityMap"} invisibly. } \references{ - Bollback, J. P. 2006. Stochastic character mapping of discrete traits on phylogenies. \emph{BMC Bioinformatics}, \bold{7}, 88. + Bollback, J. P. (2006) Stochastic character mapping of discrete traits on phylogenies. \emph{BMC Bioinformatics}, \bold{7}, 88. - Huelsenbeck, J. P., R. Neilsen, and J. P. Bollback. 2003. Stochastic mapping of morphological characters. \emph{Systematic Biology}, \bold{52}, 131-138. + Huelsenbeck, J. P., R. Neilsen, and J. P. Bollback (2003) Stochastic mapping of morphological characters. \emph{Systematic Biology}, \bold{52}, 131-138. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. - - Revell, L. J. 2013. Two new graphical methods for mapping trait evolution on phylogenies. \emph{Methods in Ecology and Evolution}, \bold{4}, 754-759. + Revell, L. J. (2013) Two new graphical methods for mapping trait evolution on phylogenies. \emph{Methods in Ecology and Evolution}, \bold{4}, 754-759. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/densityTree.Rd b/man/densityTree.Rd index aaa1c2b8..714b7a4b 100644 --- a/man/densityTree.Rd +++ b/man/densityTree.Rd @@ -30,7 +30,7 @@ make.transparent(color, alpha) Function creates a plot. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/describe.simmap.Rd b/man/describe.simmap.Rd index fda8ba33..d75c2728 100644 --- a/man/describe.simmap.Rd +++ b/man/describe.simmap.Rd @@ -28,7 +28,7 @@ describe.simmap(tree, ...) if \code{class(tree)="simmap"} then the function simply returns the results of \code{\link{countSimmap}} combined with the states at each node of the tree and a matrix containing the total and relative times spent in each state on the tree. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{ancestral states} diff --git a/man/di2multi.simmap.Rd b/man/di2multi.simmap.Rd index 6858b710..4a6e21c3 100644 --- a/man/di2multi.simmap.Rd +++ b/man/di2multi.simmap.Rd @@ -36,7 +36,7 @@ An object of class \code{"simmap"}, \code{"multiSimmap"}, \code{"contMap"}, or \code{"densityMap"}, depending on the class of \code{phy}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/dotTree.Rd b/man/dotTree.Rd index 635e95a1..7ff959a4 100644 --- a/man/dotTree.Rd +++ b/man/dotTree.Rd @@ -28,7 +28,7 @@ dot.legend(x, y, min, max, Ntip, length=5, prompt=FALSE, method="plotTree", Function creates a plot. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \examples{ ## load data from Garland et al. (1992) diff --git a/man/drop.clade.Rd b/man/drop.clade.Rd index 64f76173..33a3533c 100644 --- a/man/drop.clade.Rd +++ b/man/drop.clade.Rd @@ -20,7 +20,7 @@ drop.clade(tree, tip) An object of class \code{"phylo"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/drop.leaves.Rd b/man/drop.leaves.Rd index 39bf4a3a..1240d93e 100644 --- a/man/drop.leaves.Rd +++ b/man/drop.leaves.Rd @@ -15,7 +15,7 @@ drop.leaves(tree, ...) An object of class \code{"phylo"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/drop.tip.contMap.Rd b/man/drop.tip.contMap.Rd index 2c164b2e..e86b5c74 100644 --- a/man/drop.tip.contMap.Rd +++ b/man/drop.tip.contMap.Rd @@ -27,7 +27,7 @@ An object of class \code{"contMap"} or \code{"densityMap"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/drop.tip.multiSimmap.Rd b/man/drop.tip.multiSimmap.Rd index 7c22d7a3..92c6d78e 100644 --- a/man/drop.tip.multiSimmap.Rd +++ b/man/drop.tip.multiSimmap.Rd @@ -23,7 +23,7 @@ An object of class \code{"multiSimmap"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/drop.tip.simmap.Rd b/man/drop.tip.simmap.Rd index 6a1c887f..74c6fa89 100644 --- a/man/drop.tip.simmap.Rd +++ b/man/drop.tip.simmap.Rd @@ -29,7 +29,7 @@ extract.clade.simmap(tree, node) A modified object of class \code{"phylo"} containing the elements \code{maps} and \code{$mapped.edge} with the time spent in each state along each edge of the tree. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/edge.widthMap.Rd b/man/edge.widthMap.Rd index 30b5353f..dca41aac 100644 --- a/man/edge.widthMap.Rd +++ b/man/edge.widthMap.Rd @@ -22,7 +22,7 @@ edge.widthMap(tree, x, ...) \code{plot.edge.widthMap} can be used to plot this object. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/edgeProbs.Rd b/man/edgeProbs.Rd index fd8dbfb2..ff9a10ac 100644 --- a/man/edgeProbs.Rd +++ b/man/edgeProbs.Rd @@ -19,7 +19,7 @@ edgeProbs(trees) The object that is returned is a matrix with the state changes & the relative frequency of each state change. Rows are in the order of the matrix \code{edge} for any of the mapped trees. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/estDiversity.Rd b/man/estDiversity.Rd index af623e92..0920376b 100644 --- a/man/estDiversity.Rd +++ b/man/estDiversity.Rd @@ -29,7 +29,7 @@ estDiversity(tree, x, method=c("asr","simulation"), model="ER", ...) \references{ Mahler, D. L, L. J. Revell, R. E. Glor, and J. B. Losos. (2010) Ecological opportunity and the rate of morphological evolution in the diversification of Greater Antillean anoles. \emph{Evolution}, \bold{64}, 2731-2745. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. Yang, Z. (2006) \emph{Computational Molecular Evolution}. Oxford University Press. } diff --git a/man/evol.rate.mcmc.Rd b/man/evol.rate.mcmc.Rd index a6be8bce..34bb4569 100644 --- a/man/evol.rate.mcmc.Rd +++ b/man/evol.rate.mcmc.Rd @@ -34,9 +34,9 @@ evol.rate.mcmc(tree, x, ngen=10000, control=list(), ...) \item{tips}{list of tips in rate \eqn{\sigma_1^2} for each sampled generation of MCMC (to polarize the rate shift).} } \references{ - Revell, L. J. (2012a) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. - - Revell, L. J., D. L. Mahler, P. Peres-Neto, and B. D. Redelings. (2012b) A new method for identifying exceptional phenotypic diversification. \emph{Evolution}, \bold{66}, 135-146. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. + + Revell, L. J., D. L. Mahler, P. Peres-Neto, and B. D. Redelings (2012) A new method for identifying exceptional phenotypic diversification. \emph{Evolution}, \bold{66}, 135-146. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/evol.vcv.Rd b/man/evol.vcv.Rd index 41d616b8..133c48bc 100644 --- a/man/evol.vcv.Rd +++ b/man/evol.vcv.Rd @@ -33,9 +33,9 @@ evol.vcv(tree, X, maxit=2000, vars=FALSE, ...) \item{convergence}{logical value indicating whether or not the optimization has converged.} } \references{ - Revell, L. J., and D. C. Collar (2009) Phylogenetic analysis of the evolutionary correlation using likelihood. \emph{Evolution}, \bold{63}, 1090-1100. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J., and D. C. Collar (2009) Phylogenetic analysis of the evolutionary correlation using likelihood. \emph{Evolution}, \bold{63}, 1090-1100. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/evolvcv.lite.Rd b/man/evolvcv.lite.Rd index 84f99afe..02fb8960 100644 --- a/man/evolvcv.lite.Rd +++ b/man/evolvcv.lite.Rd @@ -31,7 +31,7 @@ evolvcv.lite(tree, X, maxit=2000, tol=1e-10, ...) A list with the results summarized for each model. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. Revell, L. J., and D. C. Collar (2009) Phylogenetic analysis of the evolutionary correlation using likelihood. \emph{Evolution}, \bold{63}, 1090-1100. diff --git a/man/exhaustiveMP.Rd b/man/exhaustiveMP.Rd index 53dbec67..d55cf4dd 100644 --- a/man/exhaustiveMP.Rd +++ b/man/exhaustiveMP.Rd @@ -21,7 +21,7 @@ exhaustiveMP(data, tree=NULL, method="branch.and.bound") \references{ Felsenstein, J. (2004) \emph{Inferring Phylogenies}. Sinauer. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. Schliep, K. P. (2011) phangorn: phylogenetic analysis in R. \emph{Bioinformatics}, \bold{27}, 592-593. } diff --git a/man/expand.clade.Rd b/man/expand.clade.Rd index 0d0fc1c6..0f8bbea7 100644 --- a/man/expand.clade.Rd +++ b/man/expand.clade.Rd @@ -25,7 +25,7 @@ expand.clade(tree, node, factor=5) This object can be plotted using the S3 \code{plot} method for the object class; or it can be plotted simply by calling a standard plotting function on the tree & tip spacings. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/export.as.xml.Rd b/man/export.as.xml.Rd index 0651dc2f..59ed01fb 100644 --- a/man/export.as.xml.Rd +++ b/man/export.as.xml.Rd @@ -21,7 +21,7 @@ export.as.xml(file, trees, X) \references{ Bollback, J. P. (2006) Stochastic character mapping of discrete traits on phylogenies. \emph{BMC Bioinformatics}, \bold{7}, 88. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/fancyTree.Rd b/man/fancyTree.Rd index 43b20d2c..bde2e211 100644 --- a/man/fancyTree.Rd +++ b/man/fancyTree.Rd @@ -45,7 +45,13 @@ phenogram95(tree, x=NULL, ...) This function plots different types of phylogenetic trees. For \code{type="droptip"} the function also returns the pruned tree. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Evans, M. E. K., Smith, S. A., Flynn, R. S., Donoghue, M. J. (2009) Climate, niche evolution, and diversification of the "bird-cage" evening primroses (Oenothera, sections Anogra and Kleinia). \emph{American Naturalist}, \bold{173}, 225-240. + + Revell, L. J. (2013) Two new graphical methods for mapping trait evolution on phylogenies. \emph{Methods in Ecology and Evolution}, \bold{4}, 754-759. + + Revell, L. J. (2014) Graphical methods for visualizing comparative data on phylogenies. Chapter 4 in \emph{Modern phylogenetic comparative methods and their application in evolutionary biology: Concepts and practice} (L. Z. Garamszegi ed.), pp. 77-103. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/fastAnc.Rd b/man/fastAnc.Rd index 5d135804..da4600a7 100644 --- a/man/fastAnc.Rd +++ b/man/fastAnc.Rd @@ -23,7 +23,7 @@ fastAnc(tree, x, vars=FALSE, CI=FALSE, ...) An object of class \code{"fastAnc"} consisting of either: a named vector containing the states at internal nodes - names are node numbers; or a list containing ancestral state estimates (\code{ace}), variances on the estimates (\code{var}), and/or 95\% confidence intervals (\code{CI95}). } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/fastBM.Rd b/man/fastBM.Rd index ee1cdc5b..a41ab7c2 100644 --- a/man/fastBM.Rd +++ b/man/fastBM.Rd @@ -25,7 +25,7 @@ fastBM(tree, a=0, mu=0, sig2=1, bounds=c(-Inf,Inf), internal=FALSE, nsim=1, A vector (for \code{nsim=1}) or matrix containing the tip states for the \code{n} species in the tree, and (optionally) the ancestral states for internal nodes. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/fastMRCA.Rd b/man/fastMRCA.Rd index 6b0628b7..fa0dcf96 100644 --- a/man/fastMRCA.Rd +++ b/man/fastMRCA.Rd @@ -27,7 +27,7 @@ fastDist(tree, sp1, sp2) The node number of the MRCA, the height above the root (for \code{fastHeight}), or the patristic distance between two taxa (for \code{fastDist}). } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/findMRCA.Rd b/man/findMRCA.Rd index 5156a919..1b9f93d5 100644 --- a/man/findMRCA.Rd +++ b/man/findMRCA.Rd @@ -25,7 +25,7 @@ findMRCA(tree, tips=NULL, type=c("node","height")) The node number of the MRCA, or a matrix of node numbers (if \code{tips==NULL}) - for \code{type="node"}; or the height of the MRCA, or a matrix of heights (if \code{tips==NULL}) - for \code{type="height"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/fit.bd.Rd b/man/fit.bd.Rd index 1b94bbaf..f62ad47f 100644 --- a/man/fit.bd.Rd +++ b/man/fit.bd.Rd @@ -38,10 +38,10 @@ lik.bd(theta, t, rho=1, N=NULL) } \references{ Nee, S., May, R. M. and Harvey, P. H. (1994) The reconstructed evolutionary process. \emph{Philosophical Transactions of the Royal Society of London B}, \bold{344}, 305-311. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. Stadler, T. (2012) How can we improve the accuracy of macroevolutionary rate estimates? \emph{Systematic Biology}, \bold{62}, 321-329. - - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/fitBayes.Rd b/man/fitBayes.Rd index 522ef23d..99436ac3 100644 --- a/man/fitBayes.Rd +++ b/man/fitBayes.Rd @@ -21,7 +21,7 @@ fitBayes(tree, x, ngen=10000, model="BM", method="reduced", control=list()) Matrix columns are labeled by species (for species means and variances), or by the corresponding evolutionary parameter. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. Revell, L. J. and R. G. Reynolds. (2012) A new Bayesian method for fitting evolutionary models to comparative data with intraspecific variation. \emph{Evolution}, 66, 2697-2707. } diff --git a/man/fitDiversityModel.Rd b/man/fitDiversityModel.Rd index 87c90979..15de31a0 100644 --- a/man/fitDiversityModel.Rd +++ b/man/fitDiversityModel.Rd @@ -28,9 +28,9 @@ fitDiversityModel(tree, x, d=NULL, showTree=TRUE, tol=1e-6) \item{vcv}{a matrix with the variances and covariance of the estimated parameters (from the Hessian).} } \references{ - Mahler, D. L, L. J. Revell, R. E. Glor, and J. B. Losos. 2010. Ecological opportunity and the rate of morphological evolution in the diversification of Greater Antillean anoles. \emph{Evolution}, \bold{64}, 2731-2745. + Mahler, D. L, L. J. Revell, R. E. Glor, and J. B. Losos (2010) Ecological opportunity and the rate of morphological evolution in the diversification of Greater Antillean anoles. \emph{Evolution}, \bold{64}, 2731-2745. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/fitMk.Rd b/man/fitMk.Rd index 5c777766..1a1e4c95 100644 --- a/man/fitMk.Rd +++ b/man/fitMk.Rd @@ -30,7 +30,7 @@ mcmcMk(tree, x, model="ER", ngen=10000, ...) fitHRM(tree, x, model="ARD", ncat=2, ...) \method{plot}{fitHRM}(x, ...) fitMk.parallel(tree, x, model="SYM", ncores=1, ...) -fitgammaMk(tree, x, model="ER", fixedQ=NULL, nrates=4, ...) +fitgammaMk(tree, x, model="ER", fixedQ=NULL, nrates=8, ...) } \arguments{ \item{tree}{an object of class \code{"phylo"}. In the case of \code{fitmultiMk} an object of class \code{"simmap"} with a mapped discrete character.} @@ -79,7 +79,9 @@ fitgammaMk(tree, x, model="ER", fixedQ=NULL, nrates=4, ...) Lewis, P. O. (2001) A likelihood approach to estimating phylogeny from discrete morphological character data. \emph{Systematic Biology}, \bold{50}, 913-925. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. + + Revell, L. J. and L. J. Harmon (2022) \emph{Phylogenetic Comparative Methods in R}. Princeton University Press. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/fitPagel.Rd b/man/fitPagel.Rd index 332815a3..30141103 100644 --- a/man/fitPagel.Rd +++ b/man/fitPagel.Rd @@ -32,7 +32,7 @@ fitPagel(tree, x, y, method="fitMk", model="ARD", dep.var="xy", ...) \references{ Pagel, M. (1994) Detecting correlated evolution on phylogenies: A general method for the comparative analysis of discrete characters. \emph{Proceedings of the Royal Society B}, \bold{255}, 37-45. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/force.ultrametric.Rd b/man/force.ultrametric.Rd index 42068947..9191a8d3 100644 --- a/man/force.ultrametric.Rd +++ b/man/force.ultrametric.Rd @@ -26,7 +26,7 @@ force.ultrametric(tree, method=c("nnls","extend"), ...) \code{\link{is.ultrametric}}, \code{\link{nnls.tree}} } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{statistics} diff --git a/man/gamma_pruning.Rd b/man/gamma_pruning.Rd new file mode 100644 index 00000000..f0c99e68 --- /dev/null +++ b/man/gamma_pruning.Rd @@ -0,0 +1,26 @@ +\name{gamma_pruning} +\alias{gamma_pruning} +\title{Internally used function} +\usage{ +gamma_pruning(par, nrates=4, tree, x, model=NULL, median=TRUE, ...) +} +\arguments{ + \item{par}{function parameters.} + \item{nrates}{number of discrete rate categories.} + \item{tree}{object of class \code{"phylo"}.} + \item{x}{data in the form of a binary matrix.} + \item{model}{design matrix of fitted model.} + \item{median}{use the median of each rate category.} + \item{...}{optional arguments.} +} +\description{ + Internally used function to compute the likelihood under a \eqn{\Gamma} model. +} +\value{ + A value of the log-likelihood. +} +\references{ + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. +} +\author{Liam Revell \email{liam.revell@umb.edu}} +\keyword{utilities} diff --git a/man/gammatest.Rd b/man/gammatest.Rd index a686c757..3e2c43c0 100644 --- a/man/gammatest.Rd +++ b/man/gammatest.Rd @@ -18,7 +18,7 @@ gammatest(x) \references{ Pybus, O. G., and P. H. Harvey (2000) Testing macro-evolutionary models using incomplete molecular phylogenies. \emph{Proc. R. Soc. Lond. B}, \bold{267}, 2267-2272. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/genSeq.Rd b/man/genSeq.Rd index e8fa5892..b8fd23a2 100644 --- a/man/genSeq.Rd +++ b/man/genSeq.Rd @@ -22,7 +22,7 @@ genSeq(tree, l=1000, Q=NULL, rate=1, format="DNAbin", ...) An object of class \code{"DNAbin"} or \code{"phyDat"}, or a matrix of nucleotides. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \examples{ diff --git a/man/geo.legend.Rd b/man/geo.legend.Rd index 16a531b3..69f262fc 100644 --- a/man/geo.legend.Rd +++ b/man/geo.legend.Rd @@ -26,7 +26,7 @@ geo.palette() \code{geo.palette} simply returns a geological timescale color palette as an object of class \code{"geo.palette"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \examples{ data(anoletree) diff --git a/man/get.treepos.Rd b/man/get.treepos.Rd index 35375aba..a5f7c1a0 100644 --- a/man/get.treepos.Rd +++ b/man/get.treepos.Rd @@ -24,7 +24,7 @@ getnode(...) A list for \code{get.treepos} and a node number for \code{getnode}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{utilities} diff --git a/man/getCladesofSize.Rd b/man/getCladesofSize.Rd index e52155fe..06a74ba3 100644 --- a/man/getCladesofSize.Rd +++ b/man/getCladesofSize.Rd @@ -15,7 +15,7 @@ getCladesofSize(tree, clade.size=2) An object of class \code{"multiPhylo"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/getDescendants.Rd b/man/getDescendants.Rd index c49da48b..95b31f77 100644 --- a/man/getDescendants.Rd +++ b/man/getDescendants.Rd @@ -23,7 +23,7 @@ getParent(tree, node) The set of node and tip numbers for the nodes and tips descended from \code{node} in a vector, or for \code{getParent} the single node preceding \code{node} in the tree. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/getExtant.Rd b/man/getExtant.Rd index 35e56d5b..410f07eb 100644 --- a/man/getExtant.Rd +++ b/man/getExtant.Rd @@ -22,7 +22,7 @@ getExtinct(tree, tol=1e-8) A vector with the tip names of extant or extinct species in the tree. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/getSisters.Rd b/man/getSisters.Rd index 7b2c2811..5514e7be 100644 --- a/man/getSisters.Rd +++ b/man/getSisters.Rd @@ -22,7 +22,7 @@ getSisters(tree, node, mode=c("number","label")) \code{\link{getDescendants}}, \code{\link{Siblings}} } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/getStates.Rd b/man/getStates.Rd index e050e105..d7c818dd 100644 --- a/man/getStates.Rd +++ b/man/getStates.Rd @@ -15,7 +15,7 @@ getStates(tree, type=c("nodes","tips","both")) A named vector (for \code{"phylo"}) or matrix (for \code{"multiPhylo"}). } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/labelnodes.Rd b/man/labelnodes.Rd index b450c613..7727cec6 100644 --- a/man/labelnodes.Rd +++ b/man/labelnodes.Rd @@ -25,7 +25,7 @@ labelnodes(text, node=NULL, interactive=TRUE, shape=c("circle","ellipse", \code{\link{cladelabels}}, \code{\link{nodelabels}} } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{plotting} diff --git a/man/ladderize.simmap.Rd b/man/ladderize.simmap.Rd index 62f4dd75..4c791670 100644 --- a/man/ladderize.simmap.Rd +++ b/man/ladderize.simmap.Rd @@ -20,7 +20,7 @@ ladderize.simmap(tree, right=TRUE) A ladderized object of class \code{"simmap"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/lambda.transform.Rd b/man/lambda.transform.Rd index 82fcea81..52324cd9 100644 --- a/man/lambda.transform.Rd +++ b/man/lambda.transform.Rd @@ -18,7 +18,7 @@ lambda.transform(lambda, C) Typically an among-species phylogenetic variance covariance matrix (e.g., \code{\link{vcv.phylo}}) in which the off-diagonal elements have been multiplied by \code{lambda}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/likMlambda.Rd b/man/likMlambda.Rd index 547555ab..9424d0e2 100644 --- a/man/likMlambda.Rd +++ b/man/likMlambda.Rd @@ -19,7 +19,7 @@ likMlambda(lambda, X, C) The log-likelihood. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/linklabels.Rd b/man/linklabels.Rd index 50c803c1..ea4c4018 100644 --- a/man/linklabels.Rd +++ b/man/linklabels.Rd @@ -24,7 +24,7 @@ linklabels(text,tips,link.type=c("bent","curved","straight"), \code{\link{cladelabels}}, \code{\link{nodelabels}}, \code{\link{tiplabels}} } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{plotting} diff --git a/man/locate.fossil.Rd b/man/locate.fossil.Rd index 2e3e0451..5fd73df1 100644 --- a/man/locate.fossil.Rd +++ b/man/locate.fossil.Rd @@ -20,7 +20,7 @@ locate.fossil(tree, X, ...) Felsenstein, J. (2002) Quantitative characters, phylogenies, and morphometrics. In: MacLeod, N. and P. Forey (Eds.) \emph{Morphology, Shape and Phylogeny} (pp. 27-44). Taylor and Francis, London. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. Revell, L. J., D. L. Mahler, R. G. Reynolds, and G. J. Slater. (2015) Placing cryptic, recently extinct, or hypothesized taxa into an ultrametric phylogeny using continuous, character data: A case study with the lizard \emph{Anolis roosevelti}. \emph{Evolution}, \bold{69}, 1027-1035. } diff --git a/man/locate.yeti.Rd b/man/locate.yeti.Rd index 14e495e8..ed59c58e 100644 --- a/man/locate.yeti.Rd +++ b/man/locate.yeti.Rd @@ -18,7 +18,7 @@ locate.yeti(tree, X, ...) \references{ Felsenstein, J. (1981) Maximum likelihood estimation of evolutionary trees from continuous characters. \emph{American Journal of Human Genetics}, 25, 471-492. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. Revell, L. J., D. L. Mahler, R. G. Reynolds, and G. J. Slater. (2015) Placing cryptic, recently extinct, or hypothesized taxa into an ultrametric phylogeny using continuous, character data: A case study with the lizard \emph{Anolis roosevelti}. \emph{Evolution}, \bold{69}, 1027-1035. } diff --git a/man/ls.tree.Rd b/man/ls.tree.Rd index 051f743e..0fc05842 100644 --- a/man/ls.tree.Rd +++ b/man/ls.tree.Rd @@ -18,7 +18,7 @@ ls.tree(tree, D) A tree with branch lengths. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/ltt.Rd b/man/ltt.Rd index 232a33b0..e38106a5 100644 --- a/man/ltt.Rd +++ b/man/ltt.Rd @@ -57,7 +57,7 @@ mccr(obj, rho=1, nsim=100, ...) \references{ Pybus, O. G., and P. H. Harvey (2000) Testing macro-evolutionary models using incomplete molecular phylogenies. \emph{Proc. R. Soc. Lond. B}, \bold{267}, 2267-2272. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/ltt95.Rd b/man/ltt95.Rd index cfaeb445..0fea022d 100644 --- a/man/ltt95.Rd +++ b/man/ltt95.Rd @@ -23,7 +23,7 @@ ltt95(trees, alpha=0.05, log=FALSE, method=c("lineages","times"), This function creates a plot and invisibly returns an object of class \code{"ltt95"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/make.era.map.Rd b/man/make.era.map.Rd index 99637a0b..4306297a 100644 --- a/man/make.era.map.Rd +++ b/man/make.era.map.Rd @@ -16,7 +16,7 @@ make.era.map(tree, limits, ...) An object of class \code{"simmap"} with the specified eras mapped as different regimes. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/make.simmap.Rd b/man/make.simmap.Rd index cba55e8c..1f011667 100644 --- a/man/make.simmap.Rd +++ b/man/make.simmap.Rd @@ -42,13 +42,15 @@ simmap(object, ...) \references{ Bollback, J. P. (2006) Stochastic character mapping of discrete traits on phylogenies. \emph{BMC Bioinformatics}, \bold{7}, 88. - Fitzjohn, R. G., W. P. Maddison, and S. P. Otto (2009) Estimating trait-dependent speciation and extinction rates from incompletely resolved phylogenies. \emph{Systematic Biology}, \bold{58}, 595-611. + FitzJohn, R. G., W. P. Maddison, and S. P. Otto (2009) Estimating trait-dependent speciation and extinction rates from incompletely resolved phylogenies. \emph{Systematic Biology}, \bold{58}, 595-611. Huelsenbeck, J. P., R. Neilsen, and J. P. Bollback (2003) Stochastic mapping of morphological characters. \emph{Systematic Biology}, \bold{52}, 131-138. Paradis, E., J. Claude, and K. Strimmer (2004) APE: Analyses of phylogenetics and evolution in R language. \emph{Bioinformatics}, \bold{20}, 289-290. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. + + Revell, L. J. and L. J. Harmon (2022) \emph{Phylogenetic Comparative Methods in R}. Princeton University Press. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/map.overlap.Rd b/man/map.overlap.Rd index ead7738e..b7813669 100644 --- a/man/map.overlap.Rd +++ b/man/map.overlap.Rd @@ -25,7 +25,7 @@ Map.Overlap(tree1, tree2, tol=1e-06, standardize=TRUE, ...) A numerical value on the interval (0, 1), for \code{map.overlap}; or a matrix whose elements should sum to 1.0 (\code{Map.Overlap}). } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/map.to.singleton.Rd b/man/map.to.singleton.Rd index 20d0a5ac..2fdabb65 100644 --- a/man/map.to.singleton.Rd +++ b/man/map.to.singleton.Rd @@ -34,7 +34,7 @@ rootedge.to.singleton(tree) If \code{names(tree$edge.length)!=NULL} \code{plotTree.singletons} will use a different color from \code{\link{palette}} for each mapped state. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/mapped.states.Rd b/man/mapped.states.Rd index e2e9e4ce..e24d0310 100644 --- a/man/mapped.states.Rd +++ b/man/mapped.states.Rd @@ -15,7 +15,7 @@ mapped.states(tree, ...) A vector, matrix, or list. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{comparative method} diff --git a/man/markChanges.Rd b/man/markChanges.Rd index ab552b67..67023d50 100644 --- a/man/markChanges.Rd +++ b/man/markChanges.Rd @@ -18,7 +18,7 @@ markChanges(tree, colors=NULL, cex=1, lwd=2, plot=TRUE) This function returns (invisibly) a matrix containing the x & y coordinates of the marked changes on the plotted tree. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/matchNodes.Rd b/man/matchNodes.Rd index 83c3b708..ff7651b4 100644 --- a/man/matchNodes.Rd +++ b/man/matchNodes.Rd @@ -26,7 +26,7 @@ matchLabels(tr1, tr2) A matrix in which the first column contains the nodes of \code{tr1} with the second column containing matching nodes in \code{tr2}, with the criterion for matching defined by \code{method}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/mergeMappedStates.Rd b/man/mergeMappedStates.Rd index 1f784289..10fafad4 100644 --- a/man/mergeMappedStates.Rd +++ b/man/mergeMappedStates.Rd @@ -19,7 +19,7 @@ mergeMappedStates(tree, old.states, new.state) An object of class \code{"simmap"} or \code{"multiSimmap"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/midpoint.root.Rd b/man/midpoint.root.Rd index aadbc4f6..4edc5ea6 100644 --- a/man/midpoint.root.Rd +++ b/man/midpoint.root.Rd @@ -29,7 +29,7 @@ midpoint_root(tree) Paradis, E., J. Claude, and K. Strimmer (2004) APE: Analyses of phylogenetics and evolution in R language. \emph{Bioinformatics}, \bold{20}, 289-290. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. Schliep K. P. (2011) phangorn: phylogenetic analysis in R. \emph{Bioinformatics}, \bold{27}, 592-593. } diff --git a/man/minRotate.Rd b/man/minRotate.Rd index 850e56db..8296dab2 100644 --- a/man/minRotate.Rd +++ b/man/minRotate.Rd @@ -21,7 +21,7 @@ tipRotate(tree, x, ...) A node-rotated object of class \code{"phylo"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/minSplit.Rd b/man/minSplit.Rd index 94fbcfe1..c75735c4 100644 --- a/man/minSplit.Rd +++ b/man/minSplit.Rd @@ -19,7 +19,7 @@ minSplit(tree, split.list, method="sum", printD=FALSE) \item{bp}{location on the branch leading to \code{node} of the minimum split.} } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. Revell, L. J., D. L. Mahler, P. Peres-Neto, and B. D. Redelings (2012) A new method for identifying exceptional phenotypic diversification. \emph{Evolution}, \bold{66}, 135-146. } diff --git a/man/modified.Grafen.Rd b/man/modified.Grafen.Rd index b26388bc..8296da35 100644 --- a/man/modified.Grafen.Rd +++ b/man/modified.Grafen.Rd @@ -25,7 +25,7 @@ node.paths(tree, node) \references{ Grafen, A. (1989) The phylogenetic regression. \emph{Philosophical Transactions of the Royal Society of London. Series B. Biological Sciences}, \bold{326}, 119-157. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/mrp.supertree.Rd b/man/mrp.supertree.Rd index e80a8c4d..9803918b 100644 --- a/man/mrp.supertree.Rd +++ b/man/mrp.supertree.Rd @@ -36,7 +36,7 @@ compute.mr(trees, type=c("phyDat","matrix")) Ragan, M. A. (1992) Phylogenetic inference based on matrix representation of trees. \emph{Molecular Phylogenetics and Evolution}, \emph{1}, 53-58. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. Schliep, K. P. (2011) phangorn: phylogenetic analysis in R. \emph{Bioinformatics}, \bold{27}, 592-593. } diff --git a/man/multi.mantel.Rd b/man/multi.mantel.Rd index 4c133b7f..12134b2b 100644 --- a/man/multi.mantel.Rd +++ b/man/multi.mantel.Rd @@ -30,9 +30,9 @@ multi.mantel(Y, X, nperm=1000) Methods \code{residuals} and \code{fitted} can be used to return residual and fitted matrices, respectively. } \references{ - Mantel, N. (1967) The detection of disease clustering and a generalized regression approach. \emph{Cancer Research}, \bold{27}, 209--220. + Mantel, N. (1967) The detection of disease clustering and a generalized regression approach. \emph{Cancer Research}, \bold{27}, 209-220. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{comparative method} diff --git a/man/multiC.Rd b/man/multiC.Rd index 3f24383d..942c2870 100644 --- a/man/multiC.Rd +++ b/man/multiC.Rd @@ -20,7 +20,7 @@ multiC(tree, internal=FALSE) A list of matrices. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/multiRF.Rd b/man/multiRF.Rd index cc77d8b0..20971388 100644 --- a/man/multiRF.Rd +++ b/man/multiRF.Rd @@ -19,9 +19,9 @@ multiRF(trees,quiet=FALSE,multi2di=FALSE) A matrix containing distances. } \references{ - Robinson, D. R., Foulds, L. R. (1981) Comparison of phylogenetic trees. \emph{Mathematical Biosciences}, \bold{53}, 131-147. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Robinson, D. R., Foulds, L. R. (1981) Comparison of phylogenetic trees. \emph{Mathematical Biosciences}, \bold{53}, 131-147. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/multirateBM.Rd b/man/multirateBM.Rd index 9bd48032..090866aa 100644 --- a/man/multirateBM.Rd +++ b/man/multirateBM.Rd @@ -32,9 +32,9 @@ multirateBM(tree, x, method=c("ML","REML"), An object of class \code{"multirateBM"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. - Revell, L. J. (2021) A variable-rate quantitative trait evolution model using penalized-likelihood. \emph{PeerJ}, \bold{9}, e11997. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/nodeHeights.Rd b/man/nodeHeights.Rd index d67bac82..e2e072f7 100644 --- a/man/nodeHeights.Rd +++ b/man/nodeHeights.Rd @@ -23,7 +23,7 @@ nodeheight(tree, node, ...) Either a matrix of the same dimensions as \code{tree$edge} containing the height above the root of each node in \code{edge} (for \code{nodeHeights}); or a single positive number (for \code{nodeheight}). } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/nodelabels.cophylo.Rd b/man/nodelabels.cophylo.Rd index 59dda82f..32f3adc1 100644 --- a/man/nodelabels.cophylo.Rd +++ b/man/nodelabels.cophylo.Rd @@ -21,7 +21,7 @@ tiplabels.cophylo(..., which=c("left","right")) \references{ Paradis, E., J. Claude, and K. Strimmer (2004) APE: Analyses of phylogenetics and evolution in R language. \emph{Bioinformatics}, \bold{20}, 289-290. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/optim.phylo.ls.Rd b/man/optim.phylo.ls.Rd index 43778452..078cbf47 100644 --- a/man/optim.phylo.ls.Rd +++ b/man/optim.phylo.ls.Rd @@ -31,7 +31,7 @@ optim.phylo.ls(D, stree=NULL, set.neg.to.zero=TRUE, fixed=FALSE, Paradis, E., J. Claude, and K. Strimmer. (2004) APE: Analyses of phylogenetics and evolution in R language. \emph{Bioinformatics}, \bold{20}, 289-290. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. Schliep, K. P. (2011) phangorn: phylogenetic analysis in R. \emph{Bioinformatics}, \bold{27}, 592-593. } diff --git a/man/orderMappedEdge.Rd b/man/orderMappedEdge.Rd index 4bc6ad95..67d09605 100644 --- a/man/orderMappedEdge.Rd +++ b/man/orderMappedEdge.Rd @@ -20,7 +20,7 @@ orderMappedEdge(trees, ordering=NULL) An object of class \code{"simmap"} or (normally) \code{"multiSimmap"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/paintSubTree.Rd b/man/paintSubTree.Rd index 79416ea5..284424a1 100644 --- a/man/paintSubTree.Rd +++ b/man/paintSubTree.Rd @@ -26,7 +26,7 @@ paintBranches(tree, edge, state, anc.state="1") An object of class \code{"simmap"} that contains the specified paintings as a mapped discrete character. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/paste.tree.Rd b/man/paste.tree.Rd index 17c2e114..7eb85d93 100644 --- a/man/paste.tree.Rd +++ b/man/paste.tree.Rd @@ -20,7 +20,7 @@ paste.tree(tr1, tr2) A tree. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \examples{ diff --git a/man/pbtree.Rd b/man/pbtree.Rd index 72243373..4f7cd8c7 100644 --- a/man/pbtree.Rd +++ b/man/pbtree.Rd @@ -35,7 +35,7 @@ pbtree(b=1, d=0, n=NULL, t=NULL, scale=NULL, nsim=1, type=c("continuous", A tree or set of trees as an object of class \code{"phylo"} or \code{"multiPhylo"}, respectively. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \examples{ diff --git a/man/pgls.Ives.Rd b/man/pgls.Ives.Rd index cbef911e..02b186e8 100644 --- a/man/pgls.Ives.Rd +++ b/man/pgls.Ives.Rd @@ -52,7 +52,7 @@ pgls.SEy(model, data, corClass=corBrownian, tree, \references{ Ives, A. R., P. E. Midford, and T. Garland Jr. (2007) Within-species measurement error in phylogenetic comparative methods. \emph{Systematic Biology}, \bold{56}, 252-270. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/phenogram.Rd b/man/phenogram.Rd index 52777e16..3b627987 100644 --- a/man/phenogram.Rd +++ b/man/phenogram.Rd @@ -28,8 +28,14 @@ phenogram(tree, x, fsize=1.0, ftype="reg", colors=NULL, axes=list(), } \references{ Evans, M. E. K., Smith, S. A., Flynn, R. S., Donoghue, M. J. (2009) Climate, niche evolution, and diversification of the "bird-cage" evening primroses (Oenothera, sections Anogra and Kleinia). \emph{American Naturalist}, \bold{173}, 225-240. + + Revell, L. J. (2013) Two new graphical methods for mapping trait evolution on phylogenies. \emph{Methods in Ecology and Evolution}, \bold{4}, 754-759. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2014) Graphical methods for visualizing comparative data on phylogenies. Chapter 4 in \emph{Modern phylogenetic comparative methods and their application in evolutionary biology: Concepts and practice} (L. Z. Garamszegi ed.), pp. 77-103. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. + + Revell, L. J., K. Schliep, E. Valderrama, and J. E. Richardson (2018) Graphs in phylogenetic comparative analysis: Anscombe's quartet revisited. \emph{Methods in Ecology and Evolution}, \bold{9}, 2145-2154. } \author{Liam Revell \email{liam.revell@umb.edu}} \examples{ diff --git a/man/phyl.RMA.Rd b/man/phyl.RMA.Rd index 26895d6c..86079600 100644 --- a/man/phyl.RMA.Rd +++ b/man/phyl.RMA.Rd @@ -43,7 +43,7 @@ phyl.RMA(x, y, tree, method="BM", lambda=NULL, fixed=FALSE, h0=1.0) McArdle, B. H. (1988) The structural relationship: Regression in biology. \emph{Can. J. Zool.}, \bold{66}, 2329-2339. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/phyl.cca.Rd b/man/phyl.cca.Rd index a0ea1afa..9735bb7c 100644 --- a/man/phyl.cca.Rd +++ b/man/phyl.cca.Rd @@ -30,7 +30,7 @@ phyl.cca(tree, X, Y, lambda=1.0, fixed=TRUE) \references{ Revell, L. J., Harrison, A. S. (2008) PCCA: A program for phylogenetic canonical correlation analysis. \emph{Bioinformatics}, \bold{24}, 1018-1020. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/phyl.pairedttest.Rd b/man/phyl.pairedttest.Rd index 221b4cbf..8c12db09 100644 --- a/man/phyl.pairedttest.Rd +++ b/man/phyl.pairedttest.Rd @@ -41,7 +41,7 @@ phyl.pairedttest(tree, x1, x2=NULL, se1=NULL, se2=NULL, lambda=1.0, h0=0.0, \references{ Lindenfors, P., L. J. Revell, and C. L. Nunn (2010) Sexual dimorphism in primate aerobic capacity: A phylogenetic test. \emph{J. Evol. Biol.}, \bold{23}, 1183-1194. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/phyl.pca.Rd b/man/phyl.pca.Rd index a55254e3..60cc2c81 100644 --- a/man/phyl.pca.Rd +++ b/man/phyl.pca.Rd @@ -47,7 +47,7 @@ as.prcomp(x, ...) \references{ Revell, L. J. (2009) Size-correction and principal components for interspecific comparative studies. \emph{Evolution}, \bold{63}, 3258-3268. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}, Joan Maspons} \seealso{ diff --git a/man/phyl.resid.Rd b/man/phyl.resid.Rd index 18b32ff3..b02a90f9 100644 --- a/man/phyl.resid.Rd +++ b/man/phyl.resid.Rd @@ -32,7 +32,7 @@ phyl.resid(tree, x, Y, method="BM") Revell, L. J. (2010) Phylogenetic signal and linear regression on species data. \emph{Methods in Ecology and Evolution}, \bold{1}, 319-329. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/phyl.vcv.Rd b/man/phyl.vcv.Rd index 7fdc5763..f4caa3ee 100644 --- a/man/phyl.vcv.Rd +++ b/man/phyl.vcv.Rd @@ -21,7 +21,7 @@ phyl.vcv(X, C, lambda) A list containing three elements, as follows: \code{C}, the matrix \code{vcv.phylo} transformed by \code{lambda}; \code{R}, the among trait variance-covariance matrix for the data in \code{X}; and \code{alpha}, a vector of ancestral states at the root node of the tree. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/phylANOVA.Rd b/man/phylANOVA.Rd index 4014be28..48e431eb 100644 --- a/man/phylANOVA.Rd +++ b/man/phylANOVA.Rd @@ -28,11 +28,11 @@ phylANOVA(tree, x, y, nsim=1000, posthoc=TRUE, p.adj="holm") \item{Pt}{matrix of multiple test corrected P-values from posthoc t-tests.} } \references{ - Garland, T., Jr., A. W. Dickerman, C. M. Janis, & J. A. Jones. (1993) Phylogenetic analysis of covariance by computer simulation. \emph{Systematic Biology}, \bold{42}, 265-292. + Garland, T., Jr., A. W. Dickerman, C. M. Janis, & J. A. Jones (1993) Phylogenetic analysis of covariance by computer simulation. \emph{Systematic Biology}, \bold{42}, 265-292. - Harmon, L. J., J. T. Weir, C. D. Brock, R. E. Glor, W. Challenger. (2008) GEIGER: investigating evolutionary radiations. \emph{Bioinformatics}, 24, 129-131. + Harmon, L. J., J. T. Weir, C. D. Brock, R. E. Glor, W. Challenger (2008) GEIGER: investigating evolutionary radiations. \emph{Bioinformatics}, 24, 129-131. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/phylo.heatmap.Rd b/man/phylo.heatmap.Rd index 2da8a13c..2c12f360 100644 --- a/man/phylo.heatmap.Rd +++ b/man/phylo.heatmap.Rd @@ -19,7 +19,7 @@ phylo.heatmap(tree, X, fsize=1, colors=NULL, standardize=FALSE, ...) Function creates a plot. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \examples{ diff --git a/man/phylo.impute.Rd b/man/phylo.impute.Rd index 7d178684..7333c5d5 100644 --- a/man/phylo.impute.Rd +++ b/man/phylo.impute.Rd @@ -25,7 +25,7 @@ phylo.impute(tree, X, ...) Since optimization is performed numerically using likelihood, a summary of the optimization can be seen by evaluating \code{attr(object,"optim")}, in which \code{object} is of class \code{"phylo.impute"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/phylo.to.map.Rd b/man/phylo.to.map.Rd index 242acf27..ba2d6dd6 100644 --- a/man/phylo.to.map.Rd +++ b/man/phylo.to.map.Rd @@ -28,7 +28,9 @@ phylo.to.map(tree, coords, rotate=TRUE, ...) \code{plot.phylo.to.map} plots on object of class \code{"phylo.to.map"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2014) Graphical methods for visualizing comparative data on phylogenies. Chapter 4 in \emph{Modern phylogenetic comparative methods and their application in evolutionary biology: Concepts and practice} (L. Z. Garamszegi ed.), pp. 77-103. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \examples{ ## generally recommend using higher resolution map diff --git a/man/phylo.toBackbone.Rd b/man/phylo.toBackbone.Rd index cf23f80a..1ff0f50b 100644 --- a/man/phylo.toBackbone.Rd +++ b/man/phylo.toBackbone.Rd @@ -18,7 +18,7 @@ backbone.toPhylo(x) Either an object of class \code{"phylo"} or an object of class \code{"backbonePhylo"}, depending on the method. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/phyloDesign.Rd b/man/phyloDesign.Rd index 5093b5a5..09f75769 100644 --- a/man/phyloDesign.Rd +++ b/man/phyloDesign.Rd @@ -17,7 +17,7 @@ phyloDesign(tree) A matrix. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/phylomorphospace.Rd b/man/phylomorphospace.Rd index b86ada6b..c9e6eeae 100644 --- a/man/phylomorphospace.Rd +++ b/man/phylomorphospace.Rd @@ -33,7 +33,9 @@ project.phylomorphospace(tree, X, nsteps=200, sleep=0, \references{ Paradis, E., J. Claude, and K. Strimmer (2004) APE: Analyses of phylogenetics and evolution in R language. \emph{Bioinformatics}, \bold{20}, 289-90. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2014) Graphical methods for visualizing comparative data on phylogenies. Chapter 4 in \emph{Modern phylogenetic comparative methods and their application in evolutionary biology: Concepts and practice} (L. Z. Garamszegi ed.), pp. 77-103. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. Sidlauskas, B. (2008) Continuous and arrested morphological diversification in sister clades of characiform fishes: A phylomorphospace approach. \emph{Evolution}, \bold{62}, 3135-3156. } diff --git a/man/phylomorphospace3d.Rd b/man/phylomorphospace3d.Rd index e0146906..ee0aa20a 100644 --- a/man/phylomorphospace3d.Rd +++ b/man/phylomorphospace3d.Rd @@ -24,7 +24,9 @@ phylomorphospace3d(tree, X, A=NULL, label=TRUE, control=list(), This function creates a three dimensional phylomorphospace plot. The function returns a function from \code{spin3d} (for \code{method="dynamic"}); or a series of functions from \code{\link{scatterplot3d}} (for \code{method="static"}). } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2014) Graphical methods for visualizing comparative data on phylogenies. Chapter 4 in \emph{Modern phylogenetic comparative methods and their application in evolutionary biology: Concepts and practice} (L. Z. Garamszegi ed.), pp. 77-103. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. Sidlauskas, B. (2008) Continuous and arrested morphological diversification in sister clades of characiform fishes: A phylomorphospace approach. \emph{Evolution}, \bold{62}, 3135-3156. } diff --git a/man/phylosig.Rd b/man/phylosig.Rd index e73be6cc..bda53e1c 100644 --- a/man/phylosig.Rd +++ b/man/phylosig.Rd @@ -45,13 +45,13 @@ phylosig(tree, x, method="K", test=FALSE, nsim=1000, se=NULL, start=NULL, \item{message}{message from \code{\link{optim}}, for estimation with sampling error only.} } \references{ - Blomberg, S. P., T. Garland Jr., A. R. Ives (2003) Testing for phylogenetic signal in comparative data: Behavioral traits are more labile. \emph{Evolution}, \bold{57}, 717-745. + Blomberg, S. P., T. Garland Jr., and A. R. Ives (2003) Testing for phylogenetic signal in comparative data: Behavioral traits are more labile. \emph{Evolution}, \bold{57}, 717-745. - Ives, A. R., P. E. Midford, T. Garland Jr. (2007) Within-species variation and measurement error in phylogenetic comparative biology. \emph{Systematic Biology}, \bold{56}, 252-270. + Ives, A. R., P. E. Midford, and T. Garland Jr. (2007) Within-species variation and measurement error in phylogenetic comparative biology. \emph{Systematic Biology}, \bold{56}, 252-270. Pagel, M. (1999) Inferring the historical patterns of biological evolution. \emph{Nature}, \bold{401}, 877-884. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \examples{ diff --git a/man/phytools-package.Rd b/man/phytools-package.Rd index a1906f4c..3fded2de 100644 --- a/man/phytools-package.Rd +++ b/man/phytools-package.Rd @@ -22,6 +22,6 @@ Maintainer: Liam J. Revell } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \keyword{package} diff --git a/man/plot.backbonePhylo.Rd b/man/plot.backbonePhylo.Rd index aae0f839..faa27f9d 100644 --- a/man/plot.backbonePhylo.Rd +++ b/man/plot.backbonePhylo.Rd @@ -15,7 +15,7 @@ Plots a tree. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/plotBranchbyTrait.Rd b/man/plotBranchbyTrait.Rd index 21f883c8..cea9c744 100644 --- a/man/plotBranchbyTrait.Rd +++ b/man/plotBranchbyTrait.Rd @@ -26,7 +26,7 @@ plotBranchbyTrait(tree, x, mode=c("edges","tips","nodes"), palette="rainbow", Plots a phylogeny. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{ancestral states} diff --git a/man/plotSimmap.Rd b/man/plotSimmap.Rd index 5b666832..af117691 100644 --- a/man/plotSimmap.Rd +++ b/man/plotSimmap.Rd @@ -56,9 +56,11 @@ plotSimmap(tree, colors=NULL, fsize=1.0, ftype="reg", lwd=2, pts=FALSE, Felsenstein, J. (2004) \emph{Inferring Phylogenies}. Sinauer. - Huelsenbeck, J. P., R. Neilsen, and J. P. Bollback. (2003) Stochastic mapping of morphological characters. \emph{Systematic Biology}, \bold{52}, 131-138. + Huelsenbeck, J. P., R. Neilsen, and J. P. Bollback (2003) Stochastic mapping of morphological characters. \emph{Systematic Biology}, \bold{52}, 131-138. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2014) Graphical methods for visualizing comparative data on phylogenies. Chapter 4 in \emph{Modern phylogenetic comparative methods and their application in evolutionary biology: Concepts and practice} (L. Z. Garamszegi ed.), pp. 77-103. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/plotThresh.Rd b/man/plotThresh.Rd index 0632be22..4ec1a48f 100644 --- a/man/plotThresh.Rd +++ b/man/plotThresh.Rd @@ -27,9 +27,9 @@ plotThresh(tree, x, mcmc, burnin=NULL, piecol, tipcol="input", legend=TRUE, Plots a tree. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. - Revell, L. J. (2014) Ancestral character estimation under the threshold model from quantitative genetics. \emph{Evolution}, \bold{68}, 743-759. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/plotTree.Rd b/man/plotTree.Rd index f4e4d6b2..efdff2f0 100644 --- a/man/plotTree.Rd +++ b/man/plotTree.Rd @@ -18,7 +18,9 @@ plotTree(tree, ...) This function plots a rooted phylogram or cladogram. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2014) Graphical methods for visualizing comparative data on phylogenies. Chapter 4 in \emph{Modern phylogenetic comparative methods and their application in evolutionary biology: Concepts and practice} (L. Z. Garamszegi ed.), pp. 77-103. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/plotTree.datamatrix.Rd b/man/plotTree.datamatrix.Rd index 13d54dde..f45ac8ed 100644 --- a/man/plotTree.datamatrix.Rd +++ b/man/plotTree.datamatrix.Rd @@ -16,7 +16,7 @@ plotTree.datamatrix(tree, X, ...) Invisibly returns a list containing the font size, a list of the colors used for each column of the plotted data matrix, and the x-coordinate of the rightmost edge of the matrix. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/plotTree.errorbars.Rd b/man/plotTree.errorbars.Rd index 48c053e9..d9c09caa 100644 --- a/man/plotTree.errorbars.Rd +++ b/man/plotTree.errorbars.Rd @@ -21,7 +21,7 @@ plotTree.errorbars(tree, CI, ...) Plots a tree with error bars around internal nodes.. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/plotTree.wBars.Rd b/man/plotTree.wBars.Rd index 65f02d4b..079c3cf8 100644 --- a/man/plotTree.wBars.Rd +++ b/man/plotTree.wBars.Rd @@ -41,7 +41,7 @@ plotTree.boxplot(tree, x, args.plotTree=list(), args.boxplot=list(), Plots a tree with an associated bar plot for a continuously valued character at the tips. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/posterior.evolrate.Rd b/man/posterior.evolrate.Rd index bf71dc09..fadfedee 100644 --- a/man/posterior.evolrate.Rd +++ b/man/posterior.evolrate.Rd @@ -21,6 +21,8 @@ posterior.evolrate(tree, ave.shift, mcmc, tips, showTree=FALSE) A matrix containing the posterior sample of evolutionary rates and shift-points between rates. } \references{ + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. + Revell, L. J., D. L. Mahler, P. Peres-Neto, and B. D. Redelings (2012) A new method for identifying exceptional phenotypic diversification. \emph{Evolution}, \bold{66}, 135-146. } \author{Liam Revell \email{liam.revell@umb.edu}} diff --git a/man/posthoc.Rd b/man/posthoc.Rd index ec5a7de6..7d32b833 100644 --- a/man/posthoc.Rd +++ b/man/posthoc.Rd @@ -17,6 +17,9 @@ posthoc(x, ...) \value{ An object of the appropriate class containing the results of a posthoc test. } +\references{ + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. +} \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ \code{\link{ratebytree}} diff --git a/man/print.backbonePhylo.Rd b/man/print.backbonePhylo.Rd index 4af92f41..40e8ddbe 100644 --- a/man/print.backbonePhylo.Rd +++ b/man/print.backbonePhylo.Rd @@ -15,7 +15,7 @@ Prints to screen. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/pscore.Rd b/man/pscore.Rd index 5f85d152..8b49ef72 100644 --- a/man/pscore.Rd +++ b/man/pscore.Rd @@ -19,7 +19,9 @@ pscore(tree, x, ...) A numerical value or vector of values. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Felsenstein, J. (2004) \emph{Inferring Phylogenies}. Sinauer. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/ratebystate.Rd b/man/ratebystate.Rd index c57662fa..bc1e6e1f 100644 --- a/man/ratebystate.Rd +++ b/man/ratebystate.Rd @@ -26,7 +26,7 @@ ratebystate(tree, x, y, nsim=100, corr=c("pearson","spearman"), ...) \item{method}{string giving the value of \code{method}.} } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/ratebytree.Rd b/man/ratebytree.Rd index 8ea5d74d..ad394a50 100644 --- a/man/ratebytree.Rd +++ b/man/ratebytree.Rd @@ -52,14 +52,14 @@ ratebytree(trees, x, ...) Nee, S., May, R. M. and Harvey, P. H. (1994) The reconstructed evolutionary process. \emph{Philosophical Transactions of the Royal Society of London B}, \bold{344}, 305-311. O'Meara, B. C., C. Ane, M. J. Sanderson, and P. C. Wainwright. (2006) Testing for different rates of continuous trait evolution using likelihood. \emph{Evolution}, \bold{60}, 922-933. - - Stadler, T. (2012) How can we improve the accuracy of macroevolutionary rate estimates? \emph{Systematic Biology}, \bold{62}, 321-329. - - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. Revell, L. J. (2018) Comparing the rates of speciation and extinction between phylogenetic trees. \emph{Ecology and Evolution}, \bold{8}, 5303-5312. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. + Revell, L. J., Gonzalez-Valenzuela, L. E., Alfonso, A., Castellanos-Garcia, L. A., Guarnizo, C. E., and Crawford, A. J. (2018) Comparing evolutionary rates between trees, clades, & traits. \emph{Methods Ecol. Evol.}, \bold{9}, 994-1005. + + Stadler, T. (2012) How can we improve the accuracy of macroevolutionary rate estimates? \emph{Systematic Biology}, \bold{62}, 321-329. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/rateshift.Rd b/man/rateshift.Rd index 5fc6ed5f..2898c1b2 100644 --- a/man/rateshift.Rd +++ b/man/rateshift.Rd @@ -32,7 +32,9 @@ likSurface.rateshift(tree, x, nrates=2, shift.range=NULL, A fitted object of class \code{"rateshift"}, or, in the case of \code{likSurface.rateshift}, a likelihood surface for the shift points. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. + + Revell, L. J. and L. J. Harmon (2022) \emph{Phylogenetic Comparative Methods in R}. Princeton University Press. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/read.newick.Rd b/man/read.newick.Rd index f646fd50..a5b4f0a7 100644 --- a/man/read.newick.Rd +++ b/man/read.newick.Rd @@ -24,7 +24,7 @@ readNexus(file="", format=c("standard","raxml")) An object of class \code{"phylo"}, possibly containing singletons (see \code{\link{collapse.singles}}); or an object of class \code{"multiPhylo"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/read.simmap.Rd b/man/read.simmap.Rd index d0ea4fe1..199044be 100644 --- a/man/read.simmap.Rd +++ b/man/read.simmap.Rd @@ -29,7 +29,7 @@ read.simmap(file="", text, format="nexus", rev.order=TRUE, version=1) Paradis, E., J. Claude, and K. Strimmer (2004) APE: Analyses of phylogenetics and evolution in R language. \emph{Bioinformatics}, \bold{20}, 289-290. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/reorder.backbonePhylo.Rd b/man/reorder.backbonePhylo.Rd index 1bc25a90..dc5f79ce 100644 --- a/man/reorder.backbonePhylo.Rd +++ b/man/reorder.backbonePhylo.Rd @@ -16,7 +16,7 @@ An object of class \code{"backbonePhylo"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/reorderSimmap.Rd b/man/reorderSimmap.Rd index d31e87ae..38a43196 100644 --- a/man/reorderSimmap.Rd +++ b/man/reorderSimmap.Rd @@ -17,7 +17,7 @@ reorderSimmap(tree, order="cladewise", index.only=FALSE, ...) A modified object of class \code{"phylo"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/rep.phylo.Rd b/man/rep.phylo.Rd index 30ea3d5b..ff9c71db 100644 --- a/man/rep.phylo.Rd +++ b/man/rep.phylo.Rd @@ -24,7 +24,7 @@ repPhylo(tree, times) An object of class \code{"multiPhylo"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \examples{ diff --git a/man/reroot.Rd b/man/reroot.Rd index 2a01ce71..76af4fa2 100644 --- a/man/reroot.Rd +++ b/man/reroot.Rd @@ -23,7 +23,7 @@ reroot(tree, node.number, position=NULL, interactive=FALSE, ...) \references{ Paradis, E., J. Claude, and K. Strimmer (2004) APE: Analyses of phylogenetics and evolution in R language. \emph{Bioinformatics}, \bold{20}, 289-290. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/rerootingMethod.Rd b/man/rerootingMethod.Rd index 5167e28c..7c73bf8a 100644 --- a/man/rerootingMethod.Rd +++ b/man/rerootingMethod.Rd @@ -29,7 +29,7 @@ rerootingMethod(tree, x, model=c("ER","SYM"), ...) \references{ Paradis, E., J. Claude, and K. Strimmer (2004) APE: Analyses of phylogenetics and evolution in R language. \emph{Bioinformatics}, \bold{20}, 289-290. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. Yang, Z., Kumar, S., Nei, M. (1995) A new method of inference of ancestral nucleotide and amino acid sequences. \emph{Genetics}, \bold{141}, 1641-1650. } diff --git a/man/rescale.Rd b/man/rescale.Rd index a4190e1b..ccdd2447 100644 --- a/man/rescale.Rd +++ b/man/rescale.Rd @@ -20,7 +20,7 @@ rescale(x, ...) \references{ Pennell, M.W., J. M. Eastman, G. J. Slater, J. W. Brown, J. C. Uyeda, R. G. FitzJohn, M. E. Alfaro, and L. J. Harmon (2014) geiger v2.0: an expanded suite of methods for fitting macroevolutionary models to phylogenetic trees. \emph{Bioinformatics}, \bold{30}, 2216-2218. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/rescaleSimmap.Rd b/man/rescaleSimmap.Rd index a3f45867..1f883db3 100644 --- a/man/rescaleSimmap.Rd +++ b/man/rescaleSimmap.Rd @@ -24,7 +24,7 @@ rescaleSimmap(tree, ...) An object of class \code{"simmap"} or \code{"multiSimmap"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/resolveNode.Rd b/man/resolveNode.Rd index bb3525c6..a6329f71 100644 --- a/man/resolveNode.Rd +++ b/man/resolveNode.Rd @@ -24,7 +24,7 @@ resolveAllNodes(tree) An object of class \code{"multiPhylo"} - or, if the input tree is already fully resolved, an object of class \code{"phylo"} identical to \code{tree}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/rotateNodes.Rd b/man/rotateNodes.Rd index f669a3fa..2dcbb484 100644 --- a/man/rotateNodes.Rd +++ b/man/rotateNodes.Rd @@ -29,7 +29,7 @@ allRotations(tree) An object of class \code{"phylo"} (i.e., a phylogenetic tree), in the case of \code{rotateNodes}, or an object of class \code{"multiPhylo"} for \code{rotate.multi} or \code{allRotations}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/roundBranches.Rd b/man/roundBranches.Rd index abfeb31b..4ce96026 100644 --- a/man/roundBranches.Rd +++ b/man/roundBranches.Rd @@ -19,7 +19,7 @@ roundBranches(tree, digits) An object of class \code{"phylo"}, \code{"multiPhylo"}, \code{"simmap"}, or \code{"multiSimmap"}, with rounded edge lengths. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/roundPhylogram.Rd b/man/roundPhylogram.Rd index 023fffcd..e29f3510 100644 --- a/man/roundPhylogram.Rd +++ b/man/roundPhylogram.Rd @@ -32,7 +32,7 @@ splinePhylogram(tree, ...) Plots a tree. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/rstate.Rd b/man/rstate.Rd index 94bd6406..9b683d40 100644 --- a/man/rstate.Rd +++ b/man/rstate.Rd @@ -17,7 +17,7 @@ rstate(y) A character or string. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{math} diff --git a/man/sampleFrom.Rd b/man/sampleFrom.Rd index 80b85852..65fe240c 100644 --- a/man/sampleFrom.Rd +++ b/man/sampleFrom.Rd @@ -18,7 +18,7 @@ sampleFrom(xbar=0, xvar=1, n=1, randn=NULL, type="norm") A vector, with labels. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/setMap.Rd b/man/setMap.Rd index 5ed7519f..6b93a0fd 100644 --- a/man/setMap.Rd +++ b/man/setMap.Rd @@ -25,7 +25,11 @@ setMap(x, ...) \references{ Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. - Revell, L. J. 2013. Two new graphical methods for mapping trait evolution on phylogenies. \emph{Methods in Ecology and Evolution}, \bold{4}, 754-759. + Revell, L. J. (2013) Two new graphical methods for mapping trait evolution on phylogenies. \emph{Methods in Ecology and Evolution}, \bold{4}, 754-759. + + Revell, L. J. (2014) Graphical methods for visualizing comparative data on phylogenies. Chapter 4 in \emph{Modern phylogenetic comparative methods and their application in evolutionary biology: Concepts and practice} (L. Z. Garamszegi ed.), pp. 77-103. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/sim.corrs.Rd b/man/sim.corrs.Rd index d56d920c..76551d45 100644 --- a/man/sim.corrs.Rd +++ b/man/sim.corrs.Rd @@ -24,7 +24,7 @@ sim.corrs(tree, vcv, anc=NULL, internal=FALSE) \references{ Revell, L. J., and D. C. Collar (2009) Phylogenetic analysis of the evolutionary correlation using likelihood. \emph{Evolution}, \bold{63}, 1090-1100. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/sim.history.Rd b/man/sim.history.Rd index d236aa12..4fbd6739 100644 --- a/man/sim.history.Rd +++ b/man/sim.history.Rd @@ -33,7 +33,7 @@ sim.multiMk(tree, Q, anc=NULL, nsim=1, ...) \code{sim.Mk} and \code{sim.multiMk} return a factor with the states of our discrete character at the tips of the tree only. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/sim.ratebystate.Rd b/man/sim.ratebystate.Rd index f32bdef0..2742cff6 100644 --- a/man/sim.ratebystate.Rd +++ b/man/sim.ratebystate.Rd @@ -23,7 +23,7 @@ sim.ratebystate(tree, sig2x=1, sig2y=1, beta=c(0,1), ...) This function returns a matrix. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/sim.rates.Rd b/man/sim.rates.Rd index 963b7fe0..af0424dc 100644 --- a/man/sim.rates.Rd +++ b/man/sim.rates.Rd @@ -30,7 +30,7 @@ multiOU(tree, alpha, sig2, theta=NULL, a0=NULL, nsim=1, internal=FALSE, ...) A vector (for \code{nsim=1}) or matrix containing the tip states for the \code{n} species in the tree. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/simBMphylo.Rd b/man/simBMphylo.Rd index 14fb323f..0bb55cf4 100644 --- a/man/simBMphylo.Rd +++ b/man/simBMphylo.Rd @@ -24,7 +24,7 @@ simBMphylo(n, t, sig2, plot=TRUE, ...) An object of class \code{"simBMphylo"} or a plot. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/skewers.Rd b/man/skewers.Rd index c3629dbe..1d48d67b 100644 --- a/man/skewers.Rd +++ b/man/skewers.Rd @@ -24,9 +24,9 @@ skewers(X, Y, nsim=100, method=NULL) \references{ Cheverud, J. M. (1996) Quantitative genetic analysis of cranial morphology in the cotton-top (\emph{Saguinus oedipus}) and saddle-back (\emph{S. fuscicollis}) tamarins. \emph{J. Evol. Biol.}, \bold{9}, 5--42. - Cheverud, J. M. & Marroig, G. (2007) Comparing covariance matrices: Random skewers method compared to the common principal components model. \emph{Genetics & Molecular Biology}, \bold{30}, 461--469. + Cheverud, J. M. and G. Marroig (2007) Comparing covariance matrices: Random skewers method compared to the common principal components model. \emph{Genetics & Molecular Biology}, \bold{30}, 461--469. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{comparative method} diff --git a/man/splitEdgeColor.Rd b/man/splitEdgeColor.Rd index 46400b16..35e7835d 100644 --- a/man/splitEdgeColor.Rd +++ b/man/splitEdgeColor.Rd @@ -16,7 +16,7 @@ splitEdgeColor(tree,colors,lwd=2) This function splits the vertical line colors to match the daughter edges when the daughters have different states. Mostly to be used with trees generated using \code{\link{paintBranches}} or \code{\link{paintSubTree}}. Also used internally by \code{\link{plotSimmap}}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/splitTree.Rd b/man/splitTree.Rd index a88a2922..63644ab8 100644 --- a/man/splitTree.Rd +++ b/man/splitTree.Rd @@ -20,7 +20,7 @@ splitTree(tree, split) Two trees in a list. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/splitplotTree.Rd b/man/splitplotTree.Rd index 1dd86e03..08672cfc 100644 --- a/man/splitplotTree.Rd +++ b/man/splitplotTree.Rd @@ -25,7 +25,7 @@ plotTree.splits(tree, splits=NULL, file=NULL, fn=NULL, ...) Plots a tree. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/starTree.Rd b/man/starTree.Rd index cac5226e..709353f5 100644 --- a/man/starTree.Rd +++ b/man/starTree.Rd @@ -18,7 +18,7 @@ starTree(species, branch.lengths=NULL) An object of class \code{"phylo"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/strahlerNumber.Rd b/man/strahlerNumber.Rd index 8dc2f926..1c7bea70 100644 --- a/man/strahlerNumber.Rd +++ b/man/strahlerNumber.Rd @@ -21,7 +21,7 @@ extract.strahlerNumber(tree, i, plot=TRUE) Either a vector with the Strahler number for each tip and internal node; or (for \code{extract.strahlerNumber} the set of (most inclusive) subtrees with Strahler number \code{i} as an object of class \code{"multiPhylo"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/threshBayes.Rd b/man/threshBayes.Rd index 75865461..7f9f905c 100644 --- a/man/threshBayes.Rd +++ b/man/threshBayes.Rd @@ -30,9 +30,9 @@ threshBayes(tree, X, types=NULL, ngen=10000, control=list(), ...) \references{ Felsenstein, J. (2012) A comparative method for both discrete and continuous characters using the threshold model. \emph{American Naturalist}, \bold{179}, 145-156. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. - Revell, L. J. (2014) Ancestral character estimation under the threshold model from quantitative genetics. \emph{Evolution}, \bold{68}, 743-759. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/threshDIC.Rd b/man/threshDIC.Rd index e35d880b..6f8edabe 100644 --- a/man/threshDIC.Rd +++ b/man/threshDIC.Rd @@ -22,9 +22,11 @@ threshDIC(tree, x, mcmc, burnin=NULL, sequence=NULL, method="pD") A vector containing the mean deviance and deviance for the parameter means, the effective number of parameters, and the DIC. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. - Revell, L. J. (2014) Ancestral character estimation under the threshold model from quantitative genetics. \emph{Evolution}, \bold{68}, 743-759. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. + + Spiegelhalter, D. J., N. G. Best, B. P. Carlin, and A. Van Der Linde (2002) Bayesian measures of model complexity and fit. \emph{Journal of the Royal Statistical Society Series B: Statistical Methodology}, \bold{64}, 583-639. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/threshState.Rd b/man/threshState.Rd index 89391a4f..5baea55e 100644 --- a/man/threshState.Rd +++ b/man/threshState.Rd @@ -18,9 +18,9 @@ threshState(x, thresholds) A discrete character value. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. - Revell, L. J. (2014) Ancestral character estimation under the threshold model from quantitative genetics. \emph{Evolution}, \bold{68}, 743-759. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/to.matrix.Rd b/man/to.matrix.Rd index 31f6c831..e59bc8a0 100644 --- a/man/to.matrix.Rd +++ b/man/to.matrix.Rd @@ -20,7 +20,7 @@ to.matrix(x, seq) A binary matrix of dimensions \code{length(x)} by \code{length(seq)}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{utilities} diff --git a/man/tree.grow.Rd b/man/tree.grow.Rd index e420427e..70d4b0c0 100644 --- a/man/tree.grow.Rd +++ b/man/tree.grow.Rd @@ -20,7 +20,7 @@ tree.grow(..., res=200, direction="rightwards", ladderize=TRUE) An object of class \code{"phylo"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/treeSlice.Rd b/man/treeSlice.Rd index 5842997b..72d6d3c7 100644 --- a/man/treeSlice.Rd +++ b/man/treeSlice.Rd @@ -23,7 +23,7 @@ treeSlice(tree, slice, trivial=FALSE, prompt=FALSE, ...) An object of class \code{"phylo"} or \code{"multiPhylo"}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/untangle.Rd b/man/untangle.Rd index 43480f7f..e246ef1f 100644 --- a/man/untangle.Rd +++ b/man/untangle.Rd @@ -18,7 +18,7 @@ untangle(tree, method=c("reorder","read.tree")) An object of class \code{"phylo"} or \code{"simmap"}, depending on the class of \code{tree}. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/vcvPhylo.Rd b/man/vcvPhylo.Rd index 228b18b0..822a6cd3 100644 --- a/man/vcvPhylo.Rd +++ b/man/vcvPhylo.Rd @@ -21,7 +21,7 @@ vcvPhylo(tree, anc.nodes=TRUE, ...) A matrix. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \keyword{phylogenetics} diff --git a/man/write.simmap.Rd b/man/write.simmap.Rd index f0b3d759..6c41117e 100644 --- a/man/write.simmap.Rd +++ b/man/write.simmap.Rd @@ -25,7 +25,7 @@ write.simmap(tree, file=NULL, append=FALSE, map.order=NULL, quiet=FALSE, Huelsenbeck, J. P., R. Neilsen, and J. P. Bollback (2003) Stochastic mapping of morphological characters. \emph{Systematic Biology}, \bold{52}, 131-138. - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ diff --git a/man/writeAncestors.Rd b/man/writeAncestors.Rd index 2a0cb3b2..d8a5e99e 100644 --- a/man/writeAncestors.Rd +++ b/man/writeAncestors.Rd @@ -17,7 +17,7 @@ writeAncestors(tree, Anc=NULL, file="", digits=6, format=c("phylip","nexus"), This function writes a tree to file with ancestral character states and (optionally) 95\% confidence intervals stored as node value. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \value{ A file, string, or vector of strings. diff --git a/man/writeNexus.Rd b/man/writeNexus.Rd index 2c48e284..41d8eba6 100644 --- a/man/writeNexus.Rd +++ b/man/writeNexus.Rd @@ -17,7 +17,7 @@ writeNexus(tree, file="") Trees written to file. } \references{ - Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). \emph{Methods Ecol. Evol.}, \bold{3}, 217-223. + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ From b7bdea3ec479dcdf41525b36474a8716678f3808 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Sun, 7 Jan 2024 22:05:26 -0500 Subject: [PATCH 05/51] add safeguard on internally-used phyl.vcv --- R/utilities.R | 5 +++-- man/phyl.vcv.Rd | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/R/utilities.R b/R/utilities.R index 4b88b8ff..4769af23 100644 --- a/R/utilities.R +++ b/R/utilities.R @@ -1,6 +1,6 @@ ## some utility functions ## written by Liam J. Revell 2011, 2012, 2013, 2014, 2015, 2016, 2017, -## 2018, 2019, 2020, 2021, 2022, 2023 +## 2018, 2019, 2020, 2021, 2022, 2023, 2024 ## function forces a tree to be ultrametric using two different methods ## written by Liam J. Revell 2017, 2021, 2022, 2023 @@ -2083,9 +2083,10 @@ applyBranchLengths<-function(tree,edge.length){ } # function to compute phylogenetic VCV using joint Pagel's lambda -# written by Liam Revell 2011 +# written by Liam Revell 2011, 2024 phyl.vcv<-function(X,C,lambda){ + if(!is.null(rownames(X))) C<-C[rownames(X),rownames(X)] ## sort by rownames of X (if present) C<-lambda.transform(lambda,C) invC<-solve(C) a<-matrix(colSums(invC%*%X)/sum(invC),ncol(X),1) diff --git a/man/phyl.vcv.Rd b/man/phyl.vcv.Rd index f4caa3ee..8d5c3bd2 100644 --- a/man/phyl.vcv.Rd +++ b/man/phyl.vcv.Rd @@ -16,6 +16,8 @@ phyl.vcv(X, C, lambda) Primarily designed as an internal function for \code{\link{phyl.pca}}; \code{phyl.vcv} can be used to compute the phylogenetic trait variance-covariance matrix given a phylogenetic VCV, \eqn{\lambda}, and a data matrix. This function should not be confused with \code{\link{vcv.phylo}} in the \pkg{ape} package (although one of the objects returned is the output of \code{vcv.phylo}). + + Note that prior to \pkg{phytools} 2.1-0 the matrix \code{X} was not sorted to match the rows of \code{C} since that was assumed to have been done in the function calling \code{phyl.vcv} internally; however, I recently discovered that this had caused the function to be used incorrectly resulting in a paper correction. This is now fixed such that \code{X} is checked for row names and (if present) \code{C} is sorted to match the rows of \code{X}. Hopefully this does not cause any problems for other functions using \code{phyl.vcv}! } \value{ A list containing three elements, as follows: \code{C}, the matrix \code{vcv.phylo} transformed by \code{lambda}; \code{R}, the among trait variance-covariance matrix for the data in \code{X}; and \code{alpha}, a vector of ancestral states at the root node of the tree. From 81941f23162a163addc17cc4b07fbe799d52f3f0 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Sun, 7 Jan 2024 22:05:50 -0500 Subject: [PATCH 06/51] small updates/fixes --- R/anc.Bayes.R | 2 +- R/ratebystate.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/anc.Bayes.R b/R/anc.Bayes.R index 98eff40d..f59e675b 100644 --- a/R/anc.Bayes.R +++ b/R/anc.Bayes.R @@ -4,7 +4,7 @@ anc.Bayes<-function(tree,x,ngen=10000,control=list(),...){ if(!inherits(tree,"phylo")) stop("tree should be an object of class \"phylo\".") # give the function some defaults (in case none are provided) - temp<-phyl.vcv(as.matrix(x),vcv(tree),1) + temp<-phyl.vcv(as.matrix(x[tree$tip.label]),vcv(tree),1) sig2<-temp$R[1,1] a<-temp$alpha y<-rep(a,tree$Nnode-1) diff --git a/R/ratebystate.R b/R/ratebystate.R index bb01c687..0a53080a 100644 --- a/R/ratebystate.R +++ b/R/ratebystate.R @@ -13,7 +13,7 @@ ratebystate<-function(tree,x,y,nsim=100,corr=c("pearson","spearman"),...){ if(hasArg(logarithm)) logarithm<-list(...)$logarithm else logarithm<-FALSE if(!is.binary(tree)) tree<-multi2di(tree,random=FALSE) - V<-phyl.vcv(cbind(x,y),vcv(tree),lambda=1)$R + V<-phyl.vcv(cbind(x[tree$tip.label],y[tree$tip.label]),vcv(tree),lambda=1)$R if(method=="by.branch"){ aa<-c(x[tree$tip.label],fastAnc(tree,x)) names(aa)[1:length(tree$tip)]<-1:length(tree$tip) From 26726da7f174b2e4aea6694eb832f1919e2856fa Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Sun, 7 Jan 2024 22:06:05 -0500 Subject: [PATCH 07/51] increment subversion number --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5d44c91f..2b140004 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: phytools -Version: 2.1-0 -Date: 2024-01-05 +Version: 2.1-1 +Date: 2024-01-07 Title: Phylogenetic Tools for Comparative Biology (and Other Things) Author: Liam J. Revell Maintainer: Liam J. Revell From 5a8c2a7c4c505a26967b8510bdc4f19325ef6904 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Wed, 31 Jan 2024 14:42:43 -0500 Subject: [PATCH 08/51] add more control of matrix exponentiation method in fitMk --- R/asr.R | 4 +++- R/fitMk.R | 23 +++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/R/asr.R b/R/asr.R index cd1e49ad..87d4235f 100644 --- a/R/asr.R +++ b/R/asr.R @@ -346,6 +346,8 @@ ancr.fitMk<-function(object,...){ pruning<-function(q,tree,x,model=NULL,...){ if(hasArg(return)) return<-list(...)$return else return<-"likelihood" + if(hasArg(expm.method)) expm.method<-list(...)$expm.method + else expm.method<-"Higham08.b" pw<-if(!is.null(attr(tree,"order"))&& attr(tree,"order")=="postorder") tree else reorder(tree,"postorder") @@ -369,7 +371,7 @@ pruning<-function(q,tree,x,model=NULL,...){ ee<-which(pw$edge[,1]==nn[i]) PP<-matrix(NA,length(ee),k) for(j in 1:length(ee)){ - P<-expm(Q*pw$edge.length[ee[j]]) + P<-expm(Q*pw$edge.length[ee[j]],method=expm.method) PP[j,]<-P%*%L[pw$edge[ee[j],2],] } L[nn[i],]<-apply(PP,2,prod) diff --git a/R/fitMk.R b/R/fitMk.R index d3544950..c8c62cdb 100644 --- a/R/fitMk.R +++ b/R/fitMk.R @@ -206,6 +206,8 @@ fitMk<-function(tree,x,model="SYM",fixedQ=NULL,...){ MODEL<-rate MODEL[is.na(MODEL)]<-0 diag(MODEL)<-0 + if(hasArg(expm.method)) expm.method<-list(...)$expm.method + else expm.method<-"Higham08.b" } tmp<-cbind(1:m,1:m) rate[tmp]<-0 @@ -267,17 +269,20 @@ fitMk<-function(tree,x,model="SYM",fixedQ=NULL,...){ method="L-BFGS-B",lower=rep(min.q,k),upper=rep(max.q,k)) } else if(lik.func=="pruning") { fit<-if(logscale) - optim(q.init,function(p) -pruning(exp(p),tree=pw,x=x,model=MODEL,pi=pi), - method="L-BFGS-B",lower=rep(log(min.q),k),upper=rep(log(max.q),k)) else - optim(q.init,function(p) -pruning(p,tree=pw,x=x,model=MODEL,pi=pi), - method="L-BFGS-B",lower=rep(min.q,k),upper=rep(max.q,k)) + optim(q.init,function(p) -pruning(exp(p),tree=pw,x=x,model=MODEL,pi=pi, + expm.method=expm.method),method="L-BFGS-B",lower=rep(log(min.q),k), + upper=rep(log(max.q),k)) else + optim(q.init,function(p) -pruning(p,tree=pw,x=x,model=MODEL,pi=pi, + expm.method=expm.method),method="L-BFGS-B",lower=rep(min.q,k), + upper=rep(max.q,k)) } } else if(opt.method=="none"){ if(lik.func=="lik") fit<-list(objective=lik(makeQ(m,q.init,index.matrix),pi=pi), par=q.init) else if(lik.func=="pruning") - fit<-list(objective=-pruning(q.init,pw,x,MODEL,pi=pi),par=q.init) + fit<-list(objective=-pruning(q.init,pw,x,MODEL,pi=pi,expm.method=expm.method), + par=q.init) } else { if(lik.func=="lik"){ fit<-if(logscale) @@ -288,9 +293,10 @@ fitMk<-function(tree,x,model="SYM",fixedQ=NULL,...){ } else if(lik.func=="pruning"){ fit<-if(logscale) nlminb(q.init,function(p) -pruning(exp(p),tree=pw,x=x,model=MODEL, - pi=pi),lower=rep(log(min.q),k),upper=rep(log(max.q),k)) else + pi=pi,expm.method=expm.method),lower=rep(log(min.q),k), + upper=rep(log(max.q),k)) else nlminb(q.init,function(p) -pruning(p,tree=pw,x=x,model=MODEL, - pi=pi),lower=rep(0,k),upper=rep(max.q,k)) + pi=pi,expm.method=expm.method),lower=rep(0,k),upper=rep(max.q,k)) } } if(logscale) fit$par<-exp(fit$par) @@ -331,7 +337,8 @@ fitMk<-function(tree,x,model="SYM",fixedQ=NULL,...){ q<-sapply(1:max(MODEL), function(ind,q,MODEL) q[which(MODEL==ind)], q=q,MODEL=MODEL) pruning(q,tree=pw,x=x,model=MODEL, - pi=if(root.prior=="nuisance") "fitzjohn" else pi) + pi=if(root.prior=="nuisance") "fitzjohn" else pi, + expm.method=expm.method) } } obj$data<-x From 6a6de42f80560df9563dae9ebd896b410025b7d3 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Wed, 31 Jan 2024 14:42:54 -0500 Subject: [PATCH 09/51] increment subversion number --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2b140004..17eae063 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: phytools -Version: 2.1-1 -Date: 2024-01-07 +Version: 2.1-2 +Date: 2024-01-30 Title: Phylogenetic Tools for Comparative Biology (and Other Things) Author: Liam J. Revell Maintainer: Liam J. Revell From 197b2ea3cae4d1144ac89e3914c74b44cae435ad Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Sun, 4 Feb 2024 11:52:31 -0500 Subject: [PATCH 10/51] various updates to allow large matrix exponentiation to be done in parallel --- R/asr.R | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++----- R/fitMk.R | 86 ++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 162 insertions(+), 17 deletions(-) diff --git a/R/asr.R b/R/asr.R index 87d4235f..070540d0 100644 --- a/R/asr.R +++ b/R/asr.R @@ -314,6 +314,16 @@ ancr.fitMk<-function(object,...){ else type<-"marginal" if(hasArg(tips)) tips<-list(...)$tips else tips<-FALSE + if(hasArg(lik.func)) lik.func<-list(...)$lik.func + else lik.func<-"pruning" + if(lik.func=="parallel"){ + if(hasArg(ncores)) ncores<-list(...)$ncores + else ncores<-min(nrow(tree$edge),detectCores()-1) + mc<-makeCluster(ncores,type="PSOCK") + registerDoParallel(cl=mc) + } + if(hasArg(expm.method)) expm.method<-list(...)$expm.method + else expm.method<-"Higham08.b" x<-object$data tree<-object$tree q<-object$rates @@ -321,11 +331,21 @@ ancr.fitMk<-function(object,...){ model[is.na(model)]<-0 pi<-object$pi if(type=="marginal"){ - plik<-pruning(q,tree,x,model=model,pi=pi, - return="conditional") - ace<-marginal_asr(q,tree,plik,model,tips) - result<-list(ace=ace, - logLik=pruning(q,tree,x,model=model,pi=pi)) + if(lik.func=="pruning"){ + plik<-pruning(q,tree,x,model=model,pi=pi, + return="conditional",expm.method=expm.method) + } else if(lik.func=="parallel"){ + plik<-parallel_pruning(q,tree,x,model=model,pi=pi, + return="conditional",expm.method=expm.method) + } + ace<-marginal_asr(q,tree,plik,model,tips, + parallel=if(lik.func=="parallel") TRUE else FALSE, + expm.method=expm.method) + result<-if(lik.func=="parallel") list(ace=ace, + logLik=parallel_pruning(q,tree,x,model=model,pi=pi, + expm.method=expm.method)) else list(ace=ace,logLik=pruning(q, + tree,x,model=model,pi=pi,expm.method=expm.method)) + if(lik.func=="parallel") stopCluster(mc) attr(result$logLik,"df")<-max(model) attr(result,"type")<-"marginal" attr(result,"tree")<-tree @@ -377,6 +397,7 @@ pruning<-function(q,tree,x,model=NULL,...){ L[nn[i],]<-apply(PP,2,prod) if(nn[i]==root){ if(pi[1]=="fitzjohn") pi<-L[nn[i],]/sum(L[nn[i],]) + else if(pi[1]=="mle") pi<-as.numeric(L[nn[i],]==max(L[nn[i],])) L[nn[i],]<-pi*L[nn[i],] } pp[i]<-sum(L[nn[i],]) @@ -390,7 +411,8 @@ pruning<-function(q,tree,x,model=NULL,...){ else if(return=="pi") pi } -marginal_asr<-function(q,tree,L,model=NULL,tips=FALSE){ +marginal_asr<-function(q,tree,L,model=NULL,tips=FALSE, + parallel=FALSE,expm.method="Higham08.b"){ pw<-reorder(tree,"postorder") k<-ncol(L) if(is.null(model)){ @@ -401,10 +423,16 @@ marginal_asr<-function(q,tree,L,model=NULL,tips=FALSE){ Q[]<-c(0,q)[model+1] diag(Q)<--rowSums(Q) nn<-unique(pw$edge[,1]) + if(parallel){ + P.all<-foreach(i=1:nrow(pw$edge))%dopar%{ + expm(Q*pw$edge.length[i],method=expm.method) + } + } for(i in length(nn):1){ ee<-which(pw$edge[,1]==nn[i]) for(j in 1:length(ee)){ - P<-expm(Q*pw$edge.length[ee[j]]) + if(parallel) P<-P.all[[ee[j]]] + else P<-expm(Q*pw$edge.length[ee[j]]) pp<-t(L[nn[i],]/(P%*%L[pw$edge[ee[j],2],])) pp[is.nan(pp)]<-0 L[pw$edge[ee[j],2],]<-(pp%*%P)* @@ -492,4 +520,55 @@ marginal_asr_gamma<-function(q,alpha,nrates,tree,L, } anc<-L/rep(rowSums(L),k) if(tips) anc else anc[1:Nnode(tree)+Ntip(tree),] +} + +parallel_pruning<-function(q,tree,x,model=NULL,...){ + if(hasArg(return)) return<-list(...)$return + else return<-"likelihood" + if(hasArg(expm.method)) expm.method<-list(...)$expm.method + else expm.method<-"Higham08.b" + pw<-if(!is.null(attr(tree,"order"))&& + attr(tree,"order")=="postorder") tree else + reorder(tree,"postorder") + k<-ncol(x) + if(is.null(model)){ + model<-matrix(1,k,k) + diag(model)<-0 + } + if(hasArg(pi)) pi<-list(...)$pi + else pi<-rep(1/k,k) + Q<-matrix(0,k,k) + Q[]<-c(0,q)[model+1] + diag(Q)<--rowSums(Q) + L<-rbind(x[pw$tip.label,], + matrix(0,pw$Nnode,k, + dimnames=list(1:pw$Nnode+Ntip(pw)))) + nn<-unique(pw$edge[,1]) + pp<-vector(mode="numeric",length=length(nn)) + root<-min(nn) + P.all<-foreach(i=1:nrow(pw$edge))%dopar%{ + expm(Q*pw$edge.length[i],method=expm.method) + } + for(i in 1:length(nn)){ + ee<-which(pw$edge[,1]==nn[i]) + PP<-matrix(NA,length(ee),k) + for(j in 1:length(ee)){ + P<-P.all[[ee[j]]] + PP[j,]<-P%*%L[pw$edge[ee[j],2],] + } + L[nn[i],]<-apply(PP,2,prod) + if(nn[i]==root){ + if(pi[1]=="fitzjohn") pi<-L[nn[i],]/sum(L[nn[i],]) + else if(pi[1]=="mle") pi<-as.numeric(L[nn[i],]==max(L[nn[i],])) + L[nn[i],]<-pi*L[nn[i],] + } + pp[i]<-sum(L[nn[i],]) + L[nn[i],]<-L[nn[i],]/pp[i] + } + prob<-sum(log(pp)) + if(return=="likelihood") + if(is.na(prob)||is.nan(prob)) + return(-Inf) else return(prob) + else if(return=="conditional") L + else if(return=="pi") pi } \ No newline at end of file diff --git a/R/fitMk.R b/R/fitMk.R index c8c62cdb..ac7aa457 100644 --- a/R/fitMk.R +++ b/R/fitMk.R @@ -113,6 +113,10 @@ fitMk<-function(tree,x,model="SYM",fixedQ=NULL,...){ else opt.method<-"nlminb" if(hasArg(lik.func)) lik.func<-list(...)$lik.func else lik.func<-"lik" + if(lik.func=="parallel"){ + if(hasArg(ncores)) ncores<-list(...)$ncores + else ncores<-min(nrow(tree$edge),detectCores()-1) + } if(opt.method=="optimParallel"){ if(hasArg(ncores)) ncores<-list(...)$ncores else ncores<-detectCores() @@ -164,7 +168,9 @@ fitMk<-function(tree,x,model="SYM",fixedQ=NULL,...){ print(round(pi,6)) cat("\n") root.prior<-"stationary" - } else if(pi[1]=="fitzjohn") root.prior<-"nuisance" + } else if(pi[1]=="fitzjohn"){ + root.prior<-"nuisance" + } else if(pi[1]=="mle") root.prior<-"it's MLE" if(is.numeric(pi)){ pi<-pi/sum(pi) if(is.null(names(pi))) pi<-setNames(pi,states) @@ -202,7 +208,7 @@ fitMk<-function(tree,x,model="SYM",fixedQ=NULL,...){ Q<-fixedQ } index.matrix<-rate - if(lik.func=="pruning"){ + if(lik.func%in%c("pruning","parallel")){ MODEL<-rate MODEL[is.na(MODEL)]<-0 diag(MODEL)<-0 @@ -275,6 +281,16 @@ fitMk<-function(tree,x,model="SYM",fixedQ=NULL,...){ optim(q.init,function(p) -pruning(p,tree=pw,x=x,model=MODEL,pi=pi, expm.method=expm.method),method="L-BFGS-B",lower=rep(min.q,k), upper=rep(max.q,k)) + } else if(lik.func=="parallel") { + mc<-makeCluster(ncores,type="PSOCK") + registerDoParallel(cl=mc) + fit<-if(logscale) + optim(q.init,function(p) -parallel_pruning(exp(p),tree=pw,x=x,model=MODEL, + pi=pi,expm.method=expm.method),method="L-BFGS-B",lower=rep(log(min.q),k), + upper=rep(log(max.q),k)) else + optim(q.init,function(p) -parallel_pruning(p,tree=pw,x=x,model=MODEL,pi=pi, + expm.method=expm.method),method="L-BFGS-B",lower=rep(min.q,k), + upper=rep(max.q,k)) } } else if(opt.method=="none"){ if(lik.func=="lik") @@ -283,6 +299,12 @@ fitMk<-function(tree,x,model="SYM",fixedQ=NULL,...){ else if(lik.func=="pruning") fit<-list(objective=-pruning(q.init,pw,x,MODEL,pi=pi,expm.method=expm.method), par=q.init) + else if(lik.func=="parallel"){ + mc<-makeCluster(ncores,type="PSOCK") + registerDoParallel(cl=mc) + fit<-list(objective=-parallel_pruning(q.init,pw,x,MODEL,pi=pi, + expm.method=expm.method),par=q.init) + } } else { if(lik.func=="lik"){ fit<-if(logscale) @@ -297,10 +319,26 @@ fitMk<-function(tree,x,model="SYM",fixedQ=NULL,...){ upper=rep(log(max.q),k)) else nlminb(q.init,function(p) -pruning(p,tree=pw,x=x,model=MODEL, pi=pi,expm.method=expm.method),lower=rep(0,k),upper=rep(max.q,k)) + } else if(lik.func=="parallel"){ + mc<-makeCluster(ncores,type="PSOCK") + registerDoParallel(cl=mc) + fit<-if(logscale) + nlminb(q.init,function(p) -parallel_pruning(exp(p),tree=pw,x=x, + model=MODEL,pi=pi,expm.method=expm.method),lower=rep(log(min.q),k), + upper=rep(log(max.q),k)) else + nlminb(q.init,function(p) -parallel_pruning(p,tree=pw,x=x,model=MODEL, + pi=pi,expm.method=expm.method),lower=rep(0,k),upper=rep(max.q,k)) } } if(logscale) fit$par<-exp(fit$par) - if(pi[1]=="fitzjohn") pi<-setNames( + if(pi[1]=="fitzjohn") pi<-if(lik.func=="parallel") setNames( + parallel_pruning(fit$par,tree=pw,x=x,model=MODEL,pi="fitzjohn", + expm.method=expm.method,return="pi"),states) else setNames( + lik(makeQ(m,fit$par,index.matrix),FALSE,pi=pi,output.pi=TRUE), + states) + else if(pi[1]=="mle") pi<-if(lik.func=="parallel") setNames( + parallel_pruning(fit$par,tree=pw,x=x,model=MODEL,pi="mle", + expm.method=expm.method,return="pi"),states) else setNames( lik(makeQ(m,fit$par,index.matrix),FALSE,pi=pi,output.pi=TRUE), states) obj<-list(logLik= @@ -318,9 +356,30 @@ fitMk<-function(tree,x,model="SYM",fixedQ=NULL,...){ if(output.liks) obj$lik.anc<-lik(makeQ(m,obj$rates,index.matrix),TRUE, pi=pi) } else { - fit<-lik(Q,pi=pi) - if(pi[1]=="fitzjohn") pi<-setNames(lik(Q,FALSE,pi=pi,output.pi=TRUE),states) - obj<-list(logLik=-fit, + if(lik.func=="lik"){ + fit<--lik(Q,pi=pi) + if(pi[1]=="fitzjohn") pi<-setNames(lik(Q,FALSE,pi=pi,output.pi=TRUE), + states) + } else if(lik.func%in%c("pruning","parallel")){ + q<-Q[sapply(1:k,function(x,y) which(x==y),index.matrix)] + if(lik.func=="pruning"){ + fit<-pruning(q,pw,x,model=MODEL,expm.method=expm.method,pi=pi) + if(pi[1]=="fitzjohn") pi<-setNames(pruning(q,tree=pw,x=x,model=MODEL, + pi="fitzjohn",expm.method=expm.method,return="pi"),states) + else if(pi[1]=="mle") pi<-setNames(pruning(q,tree=pw,x=x,model=MODEL, + pi="mle",expm.method=expm.method,return="pi"),states) + } else if(lik.func=="parallel"){ + mc<-makeCluster(ncores,type="PSOCK") + registerDoParallel(cl=mc) + fit<-parallel_pruning(q,pw,x,model=MODEL,expm.method=expm.method,pi=pi) + if(pi[1]=="fitzjohn") pi<-setNames(parallel_pruning(q,tree=pw,x=x, + model=MODEL,pi="fitzjohn",expm.method=expm.method,return="pi"), + states) + else if(pi[1]=="mle") pi<-setNames(parallel_pruning(q,tree=pw,x=x, + model=MODEL,pi="mle",expm.method=expm.method,return="pi"),states) + } + } + obj<-list(logLik=fit, rates=Q[sapply(1:k,function(x,y) which(x==y),index.matrix)], index.matrix=index.matrix, states=states, @@ -332,19 +391,26 @@ fitMk<-function(tree,x,model="SYM",fixedQ=NULL,...){ if(lik.func=="lik") lik.f<-function(q) -lik(q,output.liks=FALSE, pi=if(root.prior=="nuisance") "fitzjohn" else pi) - else if(lik.func=="pruning") { + else if(lik.func%in%c("pruning","parallel")) { lik.f<-function(q){ q<-sapply(1:max(MODEL), function(ind,q,MODEL) q[which(MODEL==ind)], q=q,MODEL=MODEL) - pruning(q,tree=pw,x=x,model=MODEL, - pi=if(root.prior=="nuisance") "fitzjohn" else pi, - expm.method=expm.method) + if(lik.func=="pruning"){ + pruning(q,tree=pw,x=x,model=MODEL, + pi=if(root.prior=="nuisance") "fitzjohn" else pi, + expm.method=expm.method) + } else if(lik.func=="parallel"){ + parallel_pruning(q,tree=pw,x=x,model=MODEL, + pi=if(root.prior=="nuisance") "fitzjohn" else pi, + expm.method=expm.method) + } } } obj$data<-x obj$tree<-tree obj$lik<-lik.f class(obj)<-"fitMk" + if(lik.func=="parallel") stopCluster(cl=mc) } return(obj) } From 0ac5e3954efc8c5f89c9092481a0575f5c08c8cb Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Sun, 4 Feb 2024 11:52:44 -0500 Subject: [PATCH 11/51] increment subversion number --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 17eae063..76764106 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: phytools -Version: 2.1-2 -Date: 2024-01-30 +Version: 2.1-7 +Date: 2024-02-04 Title: Phylogenetic Tools for Comparative Biology (and Other Things) Author: Liam J. Revell Maintainer: Liam J. Revell From 1664cd8475d9ef14cb833ea90cdbf7cb8decca08 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Mon, 5 Feb 2024 14:16:59 -0500 Subject: [PATCH 12/51] bounded Brownian motion model --- R/bounded_bm.R | 116 ++++++++++++++++++++++++++++++++++++++++++++++ man/bounded_bm.Rd | 37 +++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 R/bounded_bm.R create mode 100644 man/bounded_bm.Rd diff --git a/R/bounded_bm.R b/R/bounded_bm.R new file mode 100644 index 00000000..f22db9c2 --- /dev/null +++ b/R/bounded_bm.R @@ -0,0 +1,116 @@ +## bounded Brownian model based on Boucher & Demery 2016 and +## wrapped (circular) Brownian model based on Kuhn et al + +bounded_bm<-function(tree,x,lims=NULL,...){ + if(is.null(lims)) lims<-range(x) + if(hasArg(levs)) levs<-list(...)$levs + else levs<-100 + if(hasArg(wrapped)) wrapped<-list(...)$wrapped + else wrapped<-TRUE + if(hasArg(expm.method)) expm.method<-list(...)$expm.method + else expm.method<-"R_Eigen" + if(hasArg(lik.func)) lik.func<-list(...)$lik.func + else lik.func<-"pruning" + if(hasArg(root)) root=list(...)$root + else root<-"nuisance" + if(root=="nuisance") pi<-"fitzjohn" + else if(root=="mle") pi<-"mle" + dd<-diff(lims) + tol<-1e-8*dd/levs + bins<-cbind(seq(from=lims[1]-tol,by=(dd+2*tol)/levs,length.out=levs), + seq(to=lims[2]+tol,by=(dd+2*tol)/levs,length.out=levs)) + xx<-setNames( + sapply(x,function(y,bins) which((y>=bins[,1])+(y0.025)][1] + ci[i,2]<-mids[which(cumprob>0.975)][1] + } + result<-list( + ace=ace, + CI95=ci) + class(result)<-"ancr.bounded_bm" + result +} + +print.ancr.bounded_bm<-function(x,digits=6,printlen=6,...){ + cat("Ancestral character estimates from \"bounded_bm\" object:\n") + Nnode<-length(x$ace) + if(is.null(printlen)||printlen>=Nnode) print(round(x$ace,digits)) + else printDotDot(x$ace,digits,printlen) + cat("\nLower & upper 95% CIs:\n") + colnames(x$CI95)<-c("lower","upper") + if(is.null(printlen)||printlen>=Nnode) print(round(x$CI95,digits)) + else printDotDot(x$CI95,digits,printlen) + cat("\n") +} diff --git a/man/bounded_bm.Rd b/man/bounded_bm.Rd new file mode 100644 index 00000000..a273b8b3 --- /dev/null +++ b/man/bounded_bm.Rd @@ -0,0 +1,37 @@ +\name{bounded_bm} +\alias{bounded_bm} +\title{Fits bounded and wrapped Brownian motion models} +\usage{ + bounded_bm(tree, x, lims=NULL, ...) +} +\arguments{ + \item{tree}{object of class \code{"phylo"}.} + \item{x}{continuous character data in a vector.} + \item{lims}{bounds. If \code{NULL} will be set to the observed range of the trait.} + \item{...}{optional arguments.} +} +\description{ + Fits a bounded Brownian motion model using the discrete approximation of Boucher & Demery (2016). +} +\details{ + Optional arguments. +} +\value{ + An object of class \code{"bounded_bm"}. +} +\references{ + Boucher, F. C., and V. Demery (2016) Inferring bounded evolution in phenotypic characters from phylogenetic comparative data. \emph{Systematic Biology}, \bold{65}, 651-661. + + Juhn, M., K. Martinet, F. Boucher, A. Schultz, L. Harmon, K. Burns, and M. Alfaro (In review) A wrapped Brownian motion model for the evolution of color. + + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. +} +\author{Liam Revell \email{liam.revell@umb.edu}} +\seealso{ + \code{\link{fitMk}} +} +\keyword{phylogenetics} +\keyword{comparative method} +\keyword{maximum likelihood} +\keyword{continuous character} +\keyword{ancestral states} From 3e6075a1b9534761f4b316ec010349c5ace2d727 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Mon, 5 Feb 2024 14:17:20 -0500 Subject: [PATCH 13/51] names and methods for bounded_bm --- NAMESPACE | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/NAMESPACE b/NAMESPACE index 2cc004d0..56689842 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,7 +4,7 @@ export(add.species.to.genus, aic.w, allFurcTrees, allRotations, anc.Bayes, anc.M export(anc.trend, ancr, ancThresh, ansi_phylo, applyBranchLengths, arc.cladelabels, as.multiPhylo) export(as.prcomp, as.princomp, as.Qmatrix, ave.rates, averageTree) export(backbone.toPhylo, bd, bmPlot, bind.tip, bind.tree.simmap, biplot.phyl.pca) -export(branching.diffusion, brownie.lite, brownieREML) +export(bounded_bm, branching.diffusion, brownie.lite, brownieREML) export(cladelabels, coef.phyl.RMA, collapse.to.star, collapseTree, compare.chronograms) export(consensus.edges, contMap, cophylo, countSimmap, compute.mr, cotangleplot, cospeciation) export(ctt) @@ -280,6 +280,9 @@ S3method(anova, fitgammaMk) S3method(ancr, fitgammaMk) S3method(as.Qmatrix, fitgammaMk) S3method(plot, fitgammaMk) +S3method(ancr, bounded_bm) +S3method(print, bounded_bm) +S3method(print, ancr.bounded_bm) ## default methods S3method(ancr, default) From d447e62ac3ad0c27009fbff0ccaccd4431bea0f3 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Mon, 5 Feb 2024 14:17:31 -0500 Subject: [PATCH 14/51] increment subversion number --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 76764106..cd92dd73 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: phytools -Version: 2.1-7 +Version: 2.1-8 Date: 2024-02-04 Title: Phylogenetic Tools for Comparative Biology (and Other Things) Author: Liam J. Revell From e63fa7476d46390bf5fa7683bcaf26468c81fbf2 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Tue, 6 Feb 2024 15:35:58 -0500 Subject: [PATCH 15/51] fix likelihood calculation in bounded_bm --- R/bounded_bm.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/R/bounded_bm.R b/R/bounded_bm.R index f22db9c2..58644b5d 100644 --- a/R/bounded_bm.R +++ b/R/bounded_bm.R @@ -29,15 +29,15 @@ bounded_bm<-function(tree,x,lims=NULL,...){ pic_x<-pic(x,multi2di(tree)) nn<-max(c(floor(0.2*multi2di(tree)$Nnode),1)) max.q=20*(1/2)*mean(sort(pic_x^2,decreasing=TRUE)[1:nn])* - ((levs-1)/dd)^2 + (levs/dd)^2 q.init<-runif(n=1,0,2)*(1/2)*mean(sort(pic_x^2,decreasing=TRUE)[1:nn])* - ((levs-1)/dd)^2 + (levs/dd)^2 fit<-fitMk(tree,X,model=MODEL,lik.func=lik.func,pi=pi, expm.method=expm.method,logscale=TRUE,max.q=max.q,q.init=q.init) - lik<-logLik(fit)-Ntip(tree)*log(dd/(levs-1)) + lik<-logLik(fit)-Ntip(tree)*log(dd/levs) attr(lik,"df")<-2 class(lik)<-"logLik" - sigsq<-2*fit$rates*(dd/(levs-1))^2 + sigsq<-2*fit$rates*(dd/levs)^2 ff<-if(lik.func%in%c("pruning","parallel")) lik.func else "pruning" x0<-sum(ancr(fit,lik.func=ff,expm.method=expm.method)$ace[1,]* rowMeans(bins)) @@ -64,7 +64,7 @@ print.bounded_bm<-function(x,digits=6,...){ ",",round(x$bounds[2],digits),"]\n\n")) cat("Fitted model parameters:\n") cat(paste(" sigsq:",round(x$sigsq,6),"\n")) - cat(paste(" x0:",round(x$x0,6),"\n\n")) + cat(paste(" x0:",round(x$x0,6),"\n\n")) cat(paste("Log-likelihood:",round(x$logLik,digits),"\n\n")) if(x$opt_results$convergence == 0) cat("R thinks it has found the ML solution.\n\n") From 0be5d4526737b4e6a4b37b14b10ab1247190d43c Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Tue, 6 Feb 2024 15:36:16 -0500 Subject: [PATCH 16/51] increment subversion number --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index cd92dd73..9b053be4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: phytools -Version: 2.1-8 -Date: 2024-02-04 +Version: 2.1-9 +Date: 2024-02-06 Title: Phylogenetic Tools for Comparative Biology (and Other Things) Author: Liam J. Revell Maintainer: Liam J. Revell From 6cf0b95b9cee26f21363717dee210e1a063c7cda Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Tue, 6 Feb 2024 20:53:25 -0500 Subject: [PATCH 17/51] small fix to ancr.fitMk for parallel --- R/asr.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/asr.R b/R/asr.R index 070540d0..83125077 100644 --- a/R/asr.R +++ b/R/asr.R @@ -318,7 +318,7 @@ ancr.fitMk<-function(object,...){ else lik.func<-"pruning" if(lik.func=="parallel"){ if(hasArg(ncores)) ncores<-list(...)$ncores - else ncores<-min(nrow(tree$edge),detectCores()-1) + else ncores<-min(nrow(object$tree$edge),detectCores()-1) mc<-makeCluster(ncores,type="PSOCK") registerDoParallel(cl=mc) } From e7bfccfe3724e1739ec7d2de503f506f93d9b3e0 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Tue, 6 Feb 2024 21:16:33 -0500 Subject: [PATCH 18/51] update default to wrapped=FALSE --- R/bounded_bm.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/bounded_bm.R b/R/bounded_bm.R index 58644b5d..747e3faf 100644 --- a/R/bounded_bm.R +++ b/R/bounded_bm.R @@ -6,7 +6,7 @@ bounded_bm<-function(tree,x,lims=NULL,...){ if(hasArg(levs)) levs<-list(...)$levs else levs<-100 if(hasArg(wrapped)) wrapped<-list(...)$wrapped - else wrapped<-TRUE + else wrapped<-FALSE if(hasArg(expm.method)) expm.method<-list(...)$expm.method else expm.method<-"R_Eigen" if(hasArg(lik.func)) lik.func<-list(...)$lik.func From 4ad63b2bd941b3f64e30422de16973fcd422607b Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Wed, 7 Feb 2024 11:08:15 -0500 Subject: [PATCH 19/51] fix internally used function splitEdgeColor for up & down-facing trees --- R/plotSimmap.R | 51 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/R/plotSimmap.R b/R/plotSimmap.R index 8bf6da1d..4bca4007 100644 --- a/R/plotSimmap.R +++ b/R/plotSimmap.R @@ -137,7 +137,7 @@ arcPhylogram<-function(tree,colors,fsize,ftype,lwd,mar,add,part,setEnv, } ## function to plot simmap tree in type "phylogram" -## written by Liam J. Revell 2011-2023 +## written by Liam J. Revell 2011-2024 updownPhylogram<-function(tree,colors,fsize,ftype,lwd,pts,node.numbers,mar, add,offset,direction,setEnv,xlim,ylim,placement,tips,split.vertical,lend, asp,plot,underscore){ @@ -754,23 +754,42 @@ plot.simmap<-function(x,...) plotSimmap(x,...) plot.multiSimmap<-function(x,...) plotSimmap(x,...) ## function to split vertical plotted lines by the states of daughter edges -## written by Liam J. Revell 2015 +## written by Liam J. Revell 2015, 2024 splitEdgeColor<-function(tree,colors,lwd=2){ obj<-get("last_plot.phylo",envir=.PlotPhyloEnv) - for(i in 1:tree$Nnode+Ntip(tree)){ - daughters<-tree$edge[which(tree$edge[,1]==i),2] - cols<-vector() - for(j in 1:length(daughters)){ - jj<-which(tree$edge[,2]==daughters[j]) - cols[j]<-if(tree$maps[[jj]][1]==0&&length(tree$maps[[jj]])>1) colors[names(tree$maps[[jj]])[2]] - else colors[names(tree$maps[[jj]])[1]] + if(obj$direction%in%c("leftwards","rightwards")){ + for(i in 1:tree$Nnode+Ntip(tree)){ + daughters<-tree$edge[which(tree$edge[,1]==i),2] + cols<-vector() + for(j in 1:length(daughters)){ + jj<-which(tree$edge[,2]==daughters[j]) + cols[j]<-if(tree$maps[[jj]][1]==0&&length(tree$maps[[jj]])>1) + colors[names(tree$maps[[jj]])[2]] else colors[names(tree$maps[[jj]])[1]] + } + ii<-order(obj$yy[c(i,daughters)]) + jj<-order(obj$yy[daughters]) + x0<-x1<-rep(obj$xx[i],length(daughters)) + y0<-obj$yy[c(i,daughters)][ii][1:length(daughters)] + y1<-obj$yy[c(i,daughters)][ii][2:(length(daughters)+1)] + cols<-cols[jj] + for(j in 1:length(x0)) segments(x0[j],y0[j],x1[j],y1[j],col=cols[j],lwd=lwd,lend=2) + } + } else if(obj$direction%in%c("upwards","downwards")){ + for(i in 1:tree$Nnode+Ntip(tree)){ + daughters<-tree$edge[which(tree$edge[,1]==i),2] + cols<-vector() + for(j in 1:length(daughters)){ + jj<-which(tree$edge[,2]==daughters[j]) + cols[j]<-if(tree$maps[[jj]][1]==0&&length(tree$maps[[jj]])>1) + colors[names(tree$maps[[jj]])[2]] else colors[names(tree$maps[[jj]])[1]] + } + ii<-order(obj$xx[c(i,daughters)]) + jj<-order(obj$xx[daughters]) + y0<-y1<-rep(obj$yy[i],length(daughters)) + x0<-obj$xx[c(i,daughters)][ii][1:length(daughters)] + x1<-obj$xx[c(i,daughters)][ii][2:(length(daughters)+1)] + cols<-cols[jj] + for(j in 1:length(x0)) segments(x0[j],y0[j],x1[j],y1[j],col=cols[j],lwd=lwd,lend=2) } - ii<-order(obj$yy[c(i,daughters)]) - jj<-order(obj$yy[daughters]) - x0<-x1<-rep(obj$xx[i],length(daughters)) - y0<-obj$yy[c(i,daughters)][ii][1:length(daughters)] - y1<-obj$yy[c(i,daughters)][ii][2:(length(daughters)+1)] - cols<-cols[jj] - for(j in 1:length(x0)) segments(x0[j],y0[j],x1[j],y1[j],col=cols[j],lwd=lwd,lend=2) } } From f4c28bfb4450dbde4d8518339bf48933085d6048 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Wed, 7 Feb 2024 11:08:34 -0500 Subject: [PATCH 20/51] increment subversion number --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9b053be4..a1c7bf57 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: phytools -Version: 2.1-9 -Date: 2024-02-06 +Version: 2.1-10 +Date: 2024-02-07 Title: Phylogenetic Tools for Comparative Biology (and Other Things) Author: Liam J. Revell Maintainer: Liam J. Revell From 858084824b9abeb3b99ac7ebbd2d36489a5f7d90 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Thu, 8 Feb 2024 22:08:33 -0500 Subject: [PATCH 21/51] update default bounds to unbounded in bounded_bm --- R/bounded_bm.R | 13 +++++++++---- man/bounded_bm.Rd | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/R/bounded_bm.R b/R/bounded_bm.R index 747e3faf..43efe2ee 100644 --- a/R/bounded_bm.R +++ b/R/bounded_bm.R @@ -2,11 +2,16 @@ ## wrapped (circular) Brownian model based on Kuhn et al bounded_bm<-function(tree,x,lims=NULL,...){ - if(is.null(lims)) lims<-range(x) - if(hasArg(levs)) levs<-list(...)$levs - else levs<-100 if(hasArg(wrapped)) wrapped<-list(...)$wrapped else wrapped<-FALSE + if(is.null(lims)){ + lims<-expand.range(x,p=3) + df<-2 + } else if(wrapped){ + df<-2 + } else df<-4 + if(hasArg(levs)) levs<-list(...)$levs + else levs<-200 if(hasArg(expm.method)) expm.method<-list(...)$expm.method else expm.method<-"R_Eigen" if(hasArg(lik.func)) lik.func<-list(...)$lik.func @@ -35,7 +40,7 @@ bounded_bm<-function(tree,x,lims=NULL,...){ fit<-fitMk(tree,X,model=MODEL,lik.func=lik.func,pi=pi, expm.method=expm.method,logscale=TRUE,max.q=max.q,q.init=q.init) lik<-logLik(fit)-Ntip(tree)*log(dd/levs) - attr(lik,"df")<-2 + attr(lik,"df")<-df class(lik)<-"logLik" sigsq<-2*fit$rates*(dd/levs)^2 ff<-if(lik.func%in%c("pruning","parallel")) lik.func else "pruning" diff --git a/man/bounded_bm.Rd b/man/bounded_bm.Rd index a273b8b3..6e39896d 100644 --- a/man/bounded_bm.Rd +++ b/man/bounded_bm.Rd @@ -7,7 +7,7 @@ \arguments{ \item{tree}{object of class \code{"phylo"}.} \item{x}{continuous character data in a vector.} - \item{lims}{bounds. If \code{NULL} will be set to the observed range of the trait.} + \item{lims}{bounds. If \code{NULL} will be set to three times the observed range of the trait. (This is designed to be an effectively "unbounded" null model.)} \item{...}{optional arguments.} } \description{ From 43b9c1b8423323e1632956893566e485f1383124 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Thu, 8 Feb 2024 22:08:57 -0500 Subject: [PATCH 22/51] export logLik method for bounded_bm object --- NAMESPACE | 1 + 1 file changed, 1 insertion(+) diff --git a/NAMESPACE b/NAMESPACE index 56689842..aff2158a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -283,6 +283,7 @@ S3method(plot, fitgammaMk) S3method(ancr, bounded_bm) S3method(print, bounded_bm) S3method(print, ancr.bounded_bm) +S3method(logLik, bounded_bm) ## default methods S3method(ancr, default) From a5eb32b857c76a0331e7299cf34e9f2bded9683a Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Thu, 8 Feb 2024 22:09:13 -0500 Subject: [PATCH 23/51] increment subversion number --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index a1c7bf57..3454d324 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: phytools -Version: 2.1-10 -Date: 2024-02-07 +Version: 2.1-11 +Date: 2024-02-08 Title: Phylogenetic Tools for Comparative Biology (and Other Things) Author: Liam J. Revell Maintainer: Liam J. Revell From 9ff57e137b1852aa49f1cb6350c7ff5beb3b58e5 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Sun, 11 Feb 2024 15:18:33 -0500 Subject: [PATCH 24/51] improve behavior when lims=c(-Inf,Inf) for one-sided boundedness, etc. --- R/bounded_bm.R | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/R/bounded_bm.R b/R/bounded_bm.R index 43efe2ee..946ca308 100644 --- a/R/bounded_bm.R +++ b/R/bounded_bm.R @@ -10,6 +10,14 @@ bounded_bm<-function(tree,x,lims=NULL,...){ } else if(wrapped){ df<-2 } else df<-4 + if(lims[1]==-Inf){ + lims[1]<-expand.range(x,p=3)[1] + df<-df-1 + } + if(lims[2]==Inf){ + lims[2]<-expand.range(x,p=3)[2] + df<-df-1 + } if(hasArg(levs)) levs<-list(...)$levs else levs<-200 if(hasArg(expm.method)) expm.method<-list(...)$expm.method @@ -21,7 +29,8 @@ bounded_bm<-function(tree,x,lims=NULL,...){ if(root=="nuisance") pi<-"fitzjohn" else if(root=="mle") pi<-"mle" dd<-diff(lims) - tol<-1e-8*dd/levs + if(hasArg(tol)) tol<-list(...)$tol + else tol<-1e-8*dd/levs bins<-cbind(seq(from=lims[1]-tol,by=(dd+2*tol)/levs,length.out=levs), seq(to=lims[2]+tol,by=(dd+2*tol)/levs,length.out=levs)) xx<-setNames( From 16d31536c36e139928006cf67b8f97578047c369 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Sun, 11 Feb 2024 15:18:46 -0500 Subject: [PATCH 25/51] increment subversion number --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3454d324..84ae6e6f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: phytools -Version: 2.1-11 -Date: 2024-02-08 +Version: 2.1-12 +Date: 2024-02-10 Title: Phylogenetic Tools for Comparative Biology (and Other Things) Author: Liam J. Revell Maintainer: Liam J. Revell From 3762017b6d4f02e23d4bc0366f2e3369c5d37fd8 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Mon, 12 Feb 2024 12:40:33 -0500 Subject: [PATCH 26/51] faster calculation of the likelihood --- R/asr.R | 36 ++++++++++++++--- R/bounded_bm.R | 103 ++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 123 insertions(+), 16 deletions(-) diff --git a/R/asr.R b/R/asr.R index 83125077..33053eba 100644 --- a/R/asr.R +++ b/R/asr.R @@ -324,6 +324,11 @@ ancr.fitMk<-function(object,...){ } if(hasArg(expm.method)) expm.method<-list(...)$expm.method else expm.method<-"Higham08.b" + if(lik.func=="eigen"){ + QQ<-object$index.matrix + diag(QQ)<--rowSums(QQ) + eQQ<-eigen(QQ) + } x<-object$data tree<-object$tree q<-object$rates @@ -337,14 +342,20 @@ ancr.fitMk<-function(object,...){ } else if(lik.func=="parallel"){ plik<-parallel_pruning(q,tree,x,model=model,pi=pi, return="conditional",expm.method=expm.method) + } else if(lik.func=="eigen"){ + plik<-eigen_pruning(q,tree,x,eQQ,pi=pi,return="conditional") } ace<-marginal_asr(q,tree,plik,model,tips, parallel=if(lik.func=="parallel") TRUE else FALSE, - expm.method=expm.method) + expm.method=expm.method, + eigen=if(lik.func=="eigen") TRUE else FALSE) result<-if(lik.func=="parallel") list(ace=ace, logLik=parallel_pruning(q,tree,x,model=model,pi=pi, - expm.method=expm.method)) else list(ace=ace,logLik=pruning(q, - tree,x,model=model,pi=pi,expm.method=expm.method)) + expm.method=expm.method)) else + if(lik.func=="pruning") list(ace=ace,logLik=pruning(q, + tree,x,model=model,pi=pi,expm.method=expm.method)) else + if(lik.func=="eigen") list(ace=ace, + logLik=eigen_pruning(q,tree,x,eigenQ=eQQ)) if(lik.func=="parallel") stopCluster(mc) attr(result$logLik,"df")<-max(model) attr(result,"type")<-"marginal" @@ -412,7 +423,7 @@ pruning<-function(q,tree,x,model=NULL,...){ } marginal_asr<-function(q,tree,L,model=NULL,tips=FALSE, - parallel=FALSE,expm.method="Higham08.b"){ + parallel=FALSE,expm.method="Higham08.b",eigen=FALSE){ pw<-reorder(tree,"postorder") k<-ncol(L) if(is.null(model)){ @@ -428,10 +439,24 @@ marginal_asr<-function(q,tree,L,model=NULL,tips=FALSE, expm(Q*pw$edge.length[i],method=expm.method) } } + if(eigen){ + QQ<-model + diag(QQ)<--rowSums(QQ) + eigQ<-eigen(Q) + V<-eigQ$vectors + Vi<-t(V) + Vals<-eigQ$values + Expm<-function(t,q) Re(V%*%(exp(q*t*Vals)*Vi)) + if(parallel){ + P.all<-foreach(i=1:nrow(pw$edge))%dopar%{ + Expm(pw$edge.length[i],q) + } + } else P.all<-lapply(pw$edge.length,Expm,q=q) + } for(i in length(nn):1){ ee<-which(pw$edge[,1]==nn[i]) for(j in 1:length(ee)){ - if(parallel) P<-P.all[[ee[j]]] + if(parallel||eigen) P<-P.all[[ee[j]]] else P<-expm(Q*pw$edge.length[ee[j]]) pp<-t(L[nn[i],]/(P%*%L[pw$edge[ee[j],2],])) pp[is.nan(pp)]<-0 @@ -511,7 +536,6 @@ marginal_asr_gamma<-function(q,alpha,nrates,tree,L, P<-Reduce("+",lapply(r, function(rr,k,Q,edge) EXPM(Q*rr*edge)/k, k=nrates,Q=Q,edge=pw$edge.length[ee[j]])) - ## P<-expm(Q*pw$edge.length[ee[j]]) pp<-t(L[nn[i],]/(P%*%L[pw$edge[ee[j],2],])) pp[is.nan(pp)]<-0 L[pw$edge[ee[j],2],]<-(pp%*%P)* diff --git a/R/bounded_bm.R b/R/bounded_bm.R index 946ca308..139e5866 100644 --- a/R/bounded_bm.R +++ b/R/bounded_bm.R @@ -1,5 +1,5 @@ ## bounded Brownian model based on Boucher & Demery 2016 and -## wrapped (circular) Brownian model based on Kuhn et al +## wrapped (circular) Brownian model based on Juhn et al. (in review) bounded_bm<-function(tree,x,lims=NULL,...){ if(hasArg(wrapped)) wrapped<-list(...)$wrapped @@ -23,7 +23,9 @@ bounded_bm<-function(tree,x,lims=NULL,...){ if(hasArg(expm.method)) expm.method<-list(...)$expm.method else expm.method<-"R_Eigen" if(hasArg(lik.func)) lik.func<-list(...)$lik.func - else lik.func<-"pruning" + else lik.func<-"eigen" + if(hasArg(parallel)) parallel<-list(...)$parallel + else parallel<-FALSE if(hasArg(root)) root=list(...)$root else root<-"nuisance" if(root=="nuisance") pi<-"fitzjohn" @@ -44,17 +46,46 @@ bounded_bm<-function(tree,x,lims=NULL,...){ nn<-max(c(floor(0.2*multi2di(tree)$Nnode),1)) max.q=20*(1/2)*mean(sort(pic_x^2,decreasing=TRUE)[1:nn])* (levs/dd)^2 - q.init<-runif(n=1,0,2)*(1/2)*mean(sort(pic_x^2,decreasing=TRUE)[1:nn])* - (levs/dd)^2 - fit<-fitMk(tree,X,model=MODEL,lik.func=lik.func,pi=pi, - expm.method=expm.method,logscale=TRUE,max.q=max.q,q.init=q.init) + if(lik.func%in%c("pruning","parallel")){ + q.init<-runif(n=1,0,2)*(1/2)*mean(sort(pic_x^2,decreasing=TRUE)[1:nn])* + (levs/dd)^2 + fit<-fitMk(tree,X,model=MODEL,lik.func=lik.func,pi=pi, + expm.method=expm.method,logscale=TRUE,max.q=max.q,q.init=q.init) + } else if(lik.func=="eigen"){ + QQ<-MODEL + diag(QQ)<--rowSums(MODEL) + eQQ<-eigen(QQ) + pw<-reorder(tree,"postorder") + if(parallel){ + if(hasArg(ncores)) ncores<-list(...)$ncores + else ncores<-min(nrow(tree$edge),detectCores()-1) + mc<-makeCluster(ncores,type="PSOCK") + registerDoParallel(cl=mc) + } + fit<-optimize(eigen_pruning,c(tol,max.q),tree=pw, + x=X,eigenQ=eQQ,parallel=parallel,pi=pi,maximum=TRUE) + fit<-list( + logLik=fit$objective, + rates=fit$maximum, + index.matrix=MODEL, + states=colnames(X), + pi=eigen_pruning(fit$maximum,pw,X,eQQ,pi=pi,return="pi", + parallel=parallel), + method="optimize", + root.prior=if(pi=="fitzjohn") "nuisance" else pi, + opt_results=list(convergence=0), + data=X, + tree=pw) + class(fit)<-"fitMk" + } lik<-logLik(fit)-Ntip(tree)*log(dd/levs) attr(lik,"df")<-df class(lik)<-"logLik" sigsq<-2*fit$rates*(dd/levs)^2 - ff<-if(lik.func%in%c("pruning","parallel")) lik.func else "pruning" - x0<-sum(ancr(fit,lik.func=ff,expm.method=expm.method)$ace[1,]* - rowMeans(bins)) + ff<-if(lik.func%in%c("pruning","parallel","eigen")) lik.func else "pruning" + x0<-sum(ancr(fit,lik.func=ff,expm.method=expm.method,parallel=parallel)$ace[1,]* + rowMeans(bins)) + if(parallel) stopCluster(cl=mc) object<-list( wrapped=wrapped, sigsq=sigsq, @@ -68,6 +99,57 @@ bounded_bm<-function(tree,x,lims=NULL,...){ object } +eigen_pruning<-function(q,tree,x,eigenQ,...){ + if(hasArg(return)) return<-list(...)$return + else return<-"likelihood" + if(hasArg(parallel)) parallel<-list(...)$parallel + else parallel<-FALSE + pw<-if(!is.null(attr(tree,"order"))&& + attr(tree,"order")=="postorder") tree else + reorder(tree,"postorder") + k<-ncol(x) + if(hasArg(pi)) pi<-list(...)$pi + else pi<-rep(1/k,k) + L<-rbind(x[pw$tip.label,], + matrix(0,pw$Nnode,k, + dimnames=list(1:pw$Nnode+Ntip(pw)))) + nn<-unique(pw$edge[,1]) + pp<-vector(mode="numeric",length=length(nn)) + root<-min(nn) + V<-eigenQ$vectors + Vi<-t(V) + Vals<-eigenQ$values + Expm<-function(t,q) Re(V%*%(exp(q*t*Vals)*Vi)) + if(parallel){ + P.all<-foreach(i=1:nrow(pw$edge))%dopar%{ + Expm(pw$edge.length[i],q) + } + } + for(i in 1:length(nn)){ + ee<-which(pw$edge[,1]==nn[i]) + PP<-matrix(NA,length(ee),k) + for(j in 1:length(ee)){ + if(parallel) P<-P.all[[ee[j]]] + else P<-Expm(q=q,t=pw$edge.length[ee[j]]) + PP[j,]<-P%*%L[pw$edge[ee[j],2],] + } + L[nn[i],]<-apply(PP,2,prod) + if(nn[i]==root){ + if(pi[1]=="fitzjohn") pi<-L[nn[i],]/sum(L[nn[i],]) + else if(pi[1]=="mle") pi<-as.numeric(L[nn[i],]==max(L[nn[i],])) + L[nn[i],]<-pi*L[nn[i],] + } + pp[i]<-sum(L[nn[i],]) + L[nn[i],]<-L[nn[i],]/pp[i] + } + prob<-sum(log(pp)) + if(return=="likelihood") + if(is.na(prob)||is.nan(prob)) + return(-Inf) else return(prob) + else if(return=="conditional") L + else if(return=="pi") pi +} + print.bounded_bm<-function(x,digits=6,...){ cat(paste("Object of class \"bounded_bm\" based on\n", " a discretization with k =", @@ -85,7 +167,7 @@ print.bounded_bm<-function(x,digits=6,...){ else cat("R thinks optimization may not have converged.\n\n") } -logLik.bounded_bm<-function(x) x$logLik +logLik.bounded_bm<-function(object,...) x$logLik ancr.bounded_bm<-function(object,...){ if(hasArg(lik.func)) lik.func<-list(...)$lik.func @@ -128,3 +210,4 @@ print.ancr.bounded_bm<-function(x,digits=6,printlen=6,...){ else printDotDot(x$CI95,digits,printlen) cat("\n") } + From 5aaa2649ea9e12593facbfad944a7c461a35424d Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Mon, 12 Feb 2024 12:40:47 -0500 Subject: [PATCH 27/51] increment subversion number --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 84ae6e6f..61531225 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: phytools -Version: 2.1-12 -Date: 2024-02-10 +Version: 2.1-13 +Date: 2024-02-12 Title: Phylogenetic Tools for Comparative Biology (and Other Things) Author: Liam J. Revell Maintainer: Liam J. Revell From e5539940cd492f02e1f7349b9be84190113c7ef2 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Sat, 17 Feb 2024 21:25:26 -0500 Subject: [PATCH 28/51] various minor updates to bounded_bm --- R/asr.R | 6 ++++-- R/bounded_bm.R | 28 +++++++++++++++++++--------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/R/asr.R b/R/asr.R index 33053eba..9453fdf0 100644 --- a/R/asr.R +++ b/R/asr.R @@ -324,6 +324,8 @@ ancr.fitMk<-function(object,...){ } if(hasArg(expm.method)) expm.method<-list(...)$expm.method else expm.method<-"Higham08.b" + if(hasArg(parallel)) parallel<-list(...)$parallel + else parallel<-FALSE ## only for lik.func="eigen" if(lik.func=="eigen"){ QQ<-object$index.matrix diag(QQ)<--rowSums(QQ) @@ -346,7 +348,7 @@ ancr.fitMk<-function(object,...){ plik<-eigen_pruning(q,tree,x,eQQ,pi=pi,return="conditional") } ace<-marginal_asr(q,tree,plik,model,tips, - parallel=if(lik.func=="parallel") TRUE else FALSE, + parallel=if((lik.func=="parallel")||parallel) TRUE else FALSE, expm.method=expm.method, eigen=if(lik.func=="eigen") TRUE else FALSE) result<-if(lik.func=="parallel") list(ace=ace, @@ -434,7 +436,7 @@ marginal_asr<-function(q,tree,L,model=NULL,tips=FALSE, Q[]<-c(0,q)[model+1] diag(Q)<--rowSums(Q) nn<-unique(pw$edge[,1]) - if(parallel){ + if(parallel&&(!eigen)){ P.all<-foreach(i=1:nrow(pw$edge))%dopar%{ expm(Q*pw$edge.length[i],method=expm.method) } diff --git a/R/bounded_bm.R b/R/bounded_bm.R index 139e5866..1079f432 100644 --- a/R/bounded_bm.R +++ b/R/bounded_bm.R @@ -1,9 +1,18 @@ ## bounded Brownian model based on Boucher & Demery 2016 and ## wrapped (circular) Brownian model based on Juhn et al. (in review) +to_binned<-function(x,bins){ + xx<-setNames( + sapply(x,function(y,bins) which((y>=bins[,1])+(y=bins[,1])+(y Date: Sat, 17 Feb 2024 21:25:38 -0500 Subject: [PATCH 29/51] increment subversion number --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 61531225..0848aa8c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: phytools -Version: 2.1-13 -Date: 2024-02-12 +Version: 2.1-14 +Date: 2024-02-17 Title: Phylogenetic Tools for Comparative Biology (and Other Things) Author: Liam J. Revell Maintainer: Liam J. Revell From 16a8c7549ee46cc0f258db991e3142012a50cf97 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Sun, 18 Feb 2024 12:29:31 -0500 Subject: [PATCH 30/51] export likelihood fn from bounded_bm --- R/bounded_bm.R | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/R/bounded_bm.R b/R/bounded_bm.R index 1079f432..da08af23 100644 --- a/R/bounded_bm.R +++ b/R/bounded_bm.R @@ -94,6 +94,36 @@ bounded_bm<-function(tree,x,lims=NULL,...){ x0<-sum(ancr(fit,lik.func=ff,expm.method=expm.method,parallel=parallel)$ace[1,]* rowMeans(bins)) if(parallel) stopCluster(cl=mc) + lfunc<-function(sig2,x0="nuisance",...){ + if(hasArg(lik.func)) lik.func<-list(...)$lik.func + if(hasArg(parallel)) parallel<-list(...)$parallel + q<-(sig2/2)*(levs/dd)^2 + if(x0=="nuisance") pi<-"fitzjohn" + else if(is.numeric(x0)) pi<-to_binned(x0,bins)[1,] + if(lik.func=="pruning"){ + lnL<-pruning(q,tree,X,MODEL,pi=pi,expm.method=expm.method)- + Ntip(tree)*log(dd/levs) + } else if(lik.func=="parallel"){ + if(!exists("ncores")) ncores<-min(nrow(tree$edge),detectCores()-1) + mc<-makeCluster(ncores,type="PSOCK") + registerDoParallel(cl=mc) + lnL<-parallel_pruning(q,tree,X,MODEL,pi=pi, + expm.method=expm.method)-Ntip(tree)*log(dd/levs) + stopCluster(cl=mc) + } else if(lik.func=="eigen"){ + if(parallel){ + mc<-makeCluster(ncores,type="PSOCK") + registerDoParallel(cl=mc) + } + Q<-MODEL + diag(Q)<--rowSums(MODEL) + eQ<-eigen(Q) + lnL<-eigen_pruning(q,tree,X,eQ,parallel=parallel,pi=pi)- + Ntip(tree)*log(dd/levs) + if(parallel) stopCluster(cl=mc) + } + lnL + } object<-list( wrapped=wrapped, sigsq=sigsq, @@ -102,7 +132,8 @@ bounded_bm<-function(tree,x,lims=NULL,...){ ncat=levs, logLik=lik, opt_results=fit$opt_results, - mk_fit=fit) + mk_fit=fit, + lik=lfunc) class(object)<-"bounded_bm" object } From a755285c4efe0207c998755566942ff8dbdbd917 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Sun, 18 Feb 2024 12:29:50 -0500 Subject: [PATCH 31/51] increment subversion number --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0848aa8c..1b2ff27f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: phytools -Version: 2.1-14 -Date: 2024-02-17 +Version: 2.1-15 +Date: 2024-02-18 Title: Phylogenetic Tools for Comparative Biology (and Other Things) Author: Liam J. Revell Maintainer: Liam J. Revell From 75f4e5d1d6f57e883d5e2dbd4b99886fa416c7e0 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Wed, 21 Feb 2024 12:41:24 -0500 Subject: [PATCH 32/51] new function fitfnMk --- NAMESPACE | 5 +- R/fitfnMk.R | 157 +++++++++++++++++++++++++++++++++++++++++++++++++++ man/fitMk.Rd | 13 +++-- 3 files changed, 170 insertions(+), 5 deletions(-) create mode 100644 R/fitfnMk.R diff --git a/NAMESPACE b/NAMESPACE index aff2158a..a87df91d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -15,7 +15,7 @@ export(edge.widthMap, edgelabels.cophylo, edgeProbs, errorbar.contMap, estDivers export(evol.rate.mcmc, evol.vcv, evolvcv.lite, exhaustiveMP, expand.clade, export.as.xml) export(extract.clade.simmap, extract.strahlerNumber) export(fancyTree, fastAnc, fastBM, fastDist, fastHeight, fastMRCA, findMRCA, fit.bd) -export(fit.yule, fitBayes, fitgammaMk, fitHRM, fitMk, fitMk.parallel, fitmultiMk, fitpolyMk) +export(fit.yule, fitBayes, fitfnMk, fitgammaMk, fitHRM, fitMk, fitMk.parallel, fitmultiMk, fitpolyMk) export(fitDiversityModel, fitPagel, force.ultrametric) export(gamma_pruning, gammatest, genus.to.species.tree, genSeq, geo.palette, geo.legend, get.treepos) export(getCladesofSize, getDescendants, getExtant, getExtinct, getnode, getParent) @@ -284,6 +284,9 @@ S3method(ancr, bounded_bm) S3method(print, bounded_bm) S3method(print, ancr.bounded_bm) S3method(logLik, bounded_bm) +S3method(print, fitfnMk) +S3method(plot, fitfnMk) +S3method(logLik, fitfnMk) ## default methods S3method(ancr, default) diff --git a/R/fitfnMk.R b/R/fitfnMk.R new file mode 100644 index 00000000..2ebeebbb --- /dev/null +++ b/R/fitfnMk.R @@ -0,0 +1,157 @@ +fitfnMk<-function(tree,x,model="polynomial",degree=2,...){ + if(model!="polynomial"){ + stop("Sorry. Only available model (so far) is \"polynomial\". Stopping.\n") + } + if(hasArg(trace)) trace<-list(...)$trace + else trace<-0 + if(hasArg(start)) start<-list(...)$start + else start<-NULL + if(length(degree)==1) degree<-rep(degree,2) + if(is.matrix(x)){ + levs<-colnames(x) + } else if(is.numeric(x)){ + levs<-min(x):max(x) + x<-to.matrix(x,levs) + } else if(is.factor(x)){ + if(suppressWarnings(all(!is.na(as.numeric(levels(x)))))){ + levs<-min(as.numeric(levels(x))):max(as.numeric(levels(x))) + x<-to.matrix(x,levs) + } else { + levs<-sort(levels(x)) + x<-to.matrix(x,levs) + } + } else if(is.character(x)){ + if(suppressWarnings(all(!is.na(as.numeric(x))))){ + levs<-min(as.numeric(x)):max(as.numeric(x)) + x<-to.matrix(x,levs) + } else { + levs<-sort(unique(x)) + x<-to.matrix(x,levs) + } + } + x<-x[tree$tip.label,] + k<-ncol(x) + if(hasArg(pi)) pi<-list(...)$pi + else pi<-"equal" + if(is.numeric(pi)) root.prior<-"given" + if(pi[1]=="equal"){ + pi<-setNames(rep(1/k,k),levs) + root.prior<-"flat" + } else if(pi[1]=="fitzjohn"){ + root.prior<-"nuisance" + } else if(pi[1]=="mle") root.prior<-"it's MLE" + lik<-function(par,pw,X,pi=pi,degree=degree){ + k<-ncol(X) + x<-1:(k-1)-0.5 + q1<-rep(0,length(x)) + for(i in 0:degree[1]) q1<-q1+par[i+1]*x^(degree[1]-i) + q2<-rep(0,length(x)) + for(i in 0:degree[2]) q2<-q2+par[degree[1]+i+2]*x^(degree[2]-i) + q1[q1<0]<-0 + q2[q2<0]<-0 + if(all(q1<0)||all(q2<0)){ + return(Inf) + } else { + MODEL<-matrix(0,k,k,dimnames=list(colnames(X),colnames(X))) + MODEL[cbind(1:(k-1),2:k)]<-1:(k-1) + MODEL[cbind(2:k,1:(k-1))]<-k:(2*k-2) + return(-pruning(c(q1,q2),pw,X,model=MODEL,pi=pi)) + } + } + pw<-reorder(tree,"postorder") + xx<-0:(k-2)+0.5 + if(is.null(start)) q1_start<-q2_start<--1 + else { + q1_start<-q2_start<-rep(0,length(xx)) + for(i in 0:degree[1]) q1_start<-q1_start+start[i+1]*xx^(degree[1]-i) + for(i in 0:degree[2]) q2_start<-q2_start+start[degree[1]+i+2]*xx^(degree[2]-i) + q1_start[q1_start<0]<-0 + q2_start[q2_start<0]<-0 + if(all(q1_start==0)&&all(q2_start==0)) q1_start<-q2_start<--1 + } + while(any(q1_start<0)||any(q2_start<0)){ + start<-runif(n=sum(degree)+2) + q1_start<-q2_start<-rep(0,length(xx)) + for(i in 0:degree[1]) q1_start<-q1_start+start[i+1]*xx^(degree[1]-i) + for(i in 0:degree[2]) q2_start<-q2_start+start[degree[1]+i+2]*xx^(degree[2]-i) + } + fit<-nlminb(start,lik,pw=pw,X=x,pi=pi,degree=degree, + control=list(trace=trace)) + q1_est<-rep(0,length(xx)) + for(i in 0:degree[1]) q1_est<-q1_est+fit$par[i+1]*xx^(degree[1]-i) + q2_est<-rep(0,length(xx)) + for(i in 0:degree[2]) q2_est<-q2_est+fit$par[degree[1]+i+2]*xx^(degree[2]-i) + q1_est[q1_est<0]<-0 + q2_est[q2_est<0]<-0 + index.matrix<-matrix(0,k,k,dimnames=list(colnames(x),colnames(x))) + index.matrix[cbind(1:(k-1),2:k)]<-1:(k-1) + index.matrix[cbind(2:k,1:(k-1))]<-k:(2*k-2) + lik.f<-function(par) lik(par,pw=pw,X=x,pi=pi,degree=degree) + object<-list( + logLik=-fit$objective, + rates=c(q1_est,q2_est), + index.matrix=index.matrix, + states=levs, + pi=pi, + method="nlminb", + root.prior=root.prior, + opt_results=fit[c("convergence","iterations","evaluations","message")], + par=fit$par, + degree=degree, + data=x, + tree=tree, + lik=lik.f) + class(object)<-c("fitfnMk","fitMk") + object +} + +plot.fitfnMk<-function(x,...){ + k<-length(x$states) + q1<-x$rates[1:(k-1)] + q2<-x$rates[k:(2*k-2)] + xx<-0:(k-2)+0.5 + plot(xx,q1,type="b",col="blue",bty="n",las=1, + axes=FALSE,xlab="",ylab="transition rate (q)", + ylim=c(0,max(c(q1,q2)))) + lines(xx,q2,type="b",col="red") + labs<-mapply(function(x,y) bquote(.(x) %<->% .(y)), + x=x$states[1:(k-1)],y=x$states[2:k]) + axis(1,at=seq(0.5,k-1.5,by=1),labels=rep("",k-1)) + nulo<-mapply(mtext,text=labs,at=seq(0.5,k-1.5,by=1), + MoreArgs=list(side=1,line=1,las=3,cex=0.7)) + axis(2,las=1,cex.axis=0.8) + grid() + legend("bottomleft",c("forward","backward"), + col=c("blue","red"), + lty="solid",pch=1,cex=0.8) +} + +logLik.fitfnMk<-function(object,...){ + lik<-object$logLik + attr(lik,"df")<-length(object$par) + lik +} + +## print method for objects of class "fitMk" +print.fitfnMk<-function(x,digits=6,...){ + cat("Object of class \"fitfnMk\".\n\n") + cat("Fitted (or set) value of Q:\n") + Q<-matrix(NA,length(x$states),length(x$states)) + Q[]<-c(0,x$rates)[x$index.matrix+1] + diag(Q)<-0 + diag(Q)<--rowSums(Q) + colnames(Q)<-rownames(Q)<-x$states + print(round(Q,digits)) + cat("\nFitted (or set) value of pi:\n") + print(round(x$pi,digits)) + cat(paste("due to treating the root prior as (a) ",x$root.prior,".\n", + sep="")) + cat(paste("\nLog-likelihood:",round(x$logLik,digits),"\n")) + cat(paste("\nOptimization method used was \"",x$method,"\"\n\n", + sep="")) + if(!is.null(x$opt_results$convergence)){ + if(x$opt_results$convergence==0) + cat("R thinks it has found the ML solution.\n\n") + else cat("R thinks optimization may not have converged.\n\n") + } +} diff --git a/man/fitMk.Rd b/man/fitMk.Rd index 1a1e4c95..8b993437 100644 --- a/man/fitMk.Rd +++ b/man/fitMk.Rd @@ -14,6 +14,7 @@ \alias{plot.fitHRM} \alias{fitMk.parallel} \alias{fitgammaMk} +\alias{fitfnMk} \title{Fits extended M\emph{k} model for discrete character evolution} \usage{ fitMk(tree, x, model="SYM", fixedQ=NULL, ...) @@ -31,11 +32,12 @@ fitHRM(tree, x, model="ARD", ncat=2, ...) \method{plot}{fitHRM}(x, ...) fitMk.parallel(tree, x, model="SYM", ncores=1, ...) fitgammaMk(tree, x, model="ER", fixedQ=NULL, nrates=8, ...) +fitfnMk(tree, x, model="polynomial", degree=2, ...) } \arguments{ \item{tree}{an object of class \code{"phylo"}. In the case of \code{fitmultiMk} an object of class \code{"simmap"} with a mapped discrete character.} - \item{x}{a vector of tip values for species; \code{names(x)} should be the species names. In the case of \code{plot} and \code{density} methods, an object of the appropriate class.} - \item{model}{model. See \code{make.simmap} or \code{ace} for details.} + \item{x}{a vector (or numeric matrix) of tip values for species; \code{names(x)} should be the species names. In the case of \code{plot} and \code{density} methods, an object of the appropriate class.} + \item{model}{model. See \code{make.simmap} or \code{ace} for details. For \code{fitfnMk} the only option is presently \code{model="polynomial"}.} \item{fixedQ}{fixed value of transition matrix \code{Q}, if one is desired.} \item{ordered}{for \code{fitpolyMk}, a logical value indicating whether or not the character should be treated as ordered. For now the function assumes alphanumerical order (i.e., numbers sorted by their initial and then successive digits followed by characters or character strings in alphabetical order).} \item{k}{For \code{graph.polyMk}, the number of monomorphic states for the discrete trait.} @@ -43,10 +45,11 @@ fitgammaMk(tree, x, model="ER", fixedQ=NULL, nrates=8, ...) \item{ncat}{number of rate categories (per level of the discrete trait) in the hidden-rate model.} \item{ncores}{number of cores for \code{fitMk.parallel}.} \item{nrates}{number of rate categories for discretized \eqn{\Gamma} distribution.} + \item{degree}{the degree of the polynomial for \code{fitfnMk}. (Defaults to \code{degree=2}.)} \item{...}{optional arguments, including \code{pi}, the prior distribution at the root node (defaults to \code{pi="equal"}). Other options for \code{pi} include \code{pi="fitzjohn"} (which implements the prior distribution of FitzJohn et al. 2009), \code{pi="estimated"} (which finds the stationary distribution of state frequencies and sets that as the prior), or an arbitrary prior distribution specified by the user. For \code{plot} method optional arguments include (but may not be limited to): \code{signif}, the number of digits for the rates to be plotted; \code{main}, a character vector of length two with the headings for each subplot; \code{cex.main}, \code{cex.traits}, and \code{cex.rates}, font sizes for the various text elements of the plot; and \code{show.zeros}, a logical argument specifying whether or not to plot arrows with the ML estimated transition rate is not different from zero (with tolerance specified by the optional argument \code{tol}). Finally, for \code{fitpolyMk}, both \code{order} (an evolutionary sequence for the monomorphic condition) and \code{max.poly} can be set for the \code{ordered=TRUE} model. If not set, \code{order} defaults to alphanumeric order, and \code{max.poly} defaults to the highest level of polymorphism observed in the data.} } \description{ - The functions \code{fitMk}, \code{fitmultiMk}, \code{fitpolyMk}, \code{fitHRM}, \code{fitMk.parallel}, \code{fitgammaMk}, and \code{mcmcMk} fit various flavors of the extended M\emph{k} model (Lewis, 2001) for discrete character evolution on a reconstructed phylogeny. + The functions \code{fitMk}, \code{fitmultiMk}, \code{fitpolyMk}, \code{fitHRM}, \code{fitMk.parallel}, \code{fitgammaMk}, \code{fitfnMk}, and \code{mcmcMk} fit various flavors of the extended M\emph{k} model (Lewis, 2001) for discrete character evolution on a reconstructed phylogeny. } \details{ The function \code{fitMk} fits a so-called extended M\emph{k} model for discrete character evolution (Lewis, 2001). @@ -57,6 +60,8 @@ fitgammaMk(tree, x, model="ER", fixedQ=NULL, nrates=8, ...) The function \code{fitgammaMk} fits an M\emph{k} model in which the edge rates are assumed to have been sampled randomly from a \eqn{\Gamma} distribution with mean of 1.0 and shape parameter \eqn{\alpha}. + The function \code{fitfnMk} fit an ordered M\emph{k} model in which the backward and forward transition rates between adjacent levels of the trait vary according to a functional form. Presently that function form is an \emph{n}th degree polynomial, in which \code{degree} is set by the user (but defaults to \code{degree = 2}). + The function \code{fitpolyMk} fits an M\emph{k} model to data for a discrete character with intraspecific polymorphism. Polymorphic species should be coded with the name of the two or more states recorded for the species separated by a plus sign \code{+} (e.g., \code{A+B} would indicate that both states \code{A} and \code{B} are found in the corresponding taxon). Invariably it's assumed that transitions between states must occur through a polymorphic condition, whereas transitions \emph{cannot} occur directly between two incompatible polymorphic conditions. For instance, a transition between \code{A+B} and \code{B+C} would have to occur through the monomorphic state \code{B}. At time of writing, this function permits the models \code{"ER"} (equal rates for all permitted transitions), \code{"SYM"} (symmetric backward & forward rates for all permitted transitions), \code{"ARD"} (all-rates-different for permitted transitions), and a new model called \code{"transient"} in which the acquisition of polymorphism (e.g., \code{A -> A+B}) is assumed to occur at a different rate than its loss (e.g., \code{A+B -> B}). The method \code{plot.fitpolyMk} plots the fitted M\emph{k} model with intraspecific polymorphism. The function \code{mcmcMk} runs a Bayesian MCMC version of \code{fitMk}. The shape of the prior distribution of the transition rates is \eqn{\Gamma}, with \eqn{\alpha} and \eqn{\beta} via the argument \code{prior}, which takes the form of a list. The default value of \eqn{\alpha} is 0.1, and \eqn{\beta} defaults to a value such that \eqn{\alpha/\beta} is equal to the parsimony score for \code{x} divided by the sum of the edge lengths of the tree. The shape of the proposal distribution is normal, with mean zero and a variance that can be controlled by the user via the optional argument \code{prior.var}. The argument \code{auto.tune}, if \code{TRUE} or \code{FALSE}, indicates whether or not to 'tune' the proposal variance up or down to target a particular acceptance rate (defaults to 0.5). \code{auto.tune} can also be a numeric value between 0 and 1, in which case this value will be the target acceptance ratio. The argument \code{plot} indicates whether the progress of the MCMC should be plotted (defaults to \code{TRUE}, but runs much faster when set to \code{FALSE}). @@ -68,7 +73,7 @@ fitgammaMk(tree, x, model="ER", fixedQ=NULL, nrates=8, ...) Note that (by default) both \code{fitMk} and \code{fitmultiMk} recycle code from \code{\link{ace}} in the \pkg{ape} package for computing the likelihood. (If the optional argument \code{pruning=TRUE} then alternative, slightly faster, \pkg{phytools} code for the pruning algorithm is used.) \code{fitpolyMk}, \code{mcmcMk}, and \code{fitHRM} use \code{fitMk} internally to compute the likelihood. } \value{ - An object of class \code{"fitMk"}, \code{"fitmultiMk"}, \code{"fitpolyMk"}, \code{"mcmcMk"}, \code{"fitHRM"}, or \code{"fitgammaMk"}. In the case of \code{density.mcmcMk} an object of class \code{"density.mcmcMk"}. + An object of class \code{"fitMk"}, \code{"fitmultiMk"}, \code{"fitpolyMk"}, \code{"mcmcMk"}, \code{"fitHRM"}, \code{"fitgammaMk"}, or \code{"fitfnMk"}. In the case of \code{density.mcmcMk} an object of class \code{"density.mcmcMk"}. \code{plot.fitMk}, \code{plot.gfit}, and \code{plot.HRM} invisibly return the coordinates of vertices of the plotted \bold{Q}-matrix. } From 44366b6845ae2ed4f597093c3448511c27d29e1d Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Wed, 21 Feb 2024 12:41:45 -0500 Subject: [PATCH 33/51] small changes to bounded_bm --- R/bounded_bm.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/bounded_bm.R b/R/bounded_bm.R index da08af23..c3ade29d 100644 --- a/R/bounded_bm.R +++ b/R/bounded_bm.R @@ -198,7 +198,7 @@ print.bounded_bm<-function(x,digits=6,...){ cat(paste("Set or estimated bounds: [",round(x$bounds[1],digits), ",",round(x$bounds[2],digits),"]\n\n")) cat("Fitted model parameters:\n") - cat(paste(" sigsq:",round(x$sigsq,6),"\n")) + cat(paste(" sigsq:",round(x$sigsq,6),"\n")) cat(paste(" x0:",round(x$x0,6),"\n\n")) cat(paste("Log-likelihood:",round(x$logLik,digits),"\n\n")) if(x$opt_results$convergence == 0) From 0929fba3d1a891311c209ff549516689090bd39c Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Wed, 21 Feb 2024 12:41:56 -0500 Subject: [PATCH 34/51] increment subversion number --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1b2ff27f..2003c906 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: phytools -Version: 2.1-15 -Date: 2024-02-18 +Version: 2.1-16 +Date: 2024-02-21 Title: Phylogenetic Tools for Comparative Biology (and Other Things) Author: Liam J. Revell Maintainer: Liam J. Revell From 25aea9bad44fac9f1e099cfb01f1971164a4a449 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Wed, 21 Feb 2024 16:39:11 -0500 Subject: [PATCH 35/51] add smart-start to fitfnMk --- R/fitfnMk.R | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/R/fitfnMk.R b/R/fitfnMk.R index 2ebeebbb..e07797a1 100644 --- a/R/fitfnMk.R +++ b/R/fitfnMk.R @@ -61,7 +61,22 @@ fitfnMk<-function(tree,x,model="polynomial",degree=2,...){ pw<-reorder(tree,"postorder") xx<-0:(k-2)+0.5 if(is.null(start)) q1_start<-q2_start<--1 - else { + else if(start=="smart"){ + MODEL<-matrix(0,k,k,dimnames=list(colnames(x),colnames(x))) + MODEL[cbind(1:(k-1),2:k)]<-1 + MODEL[cbind(2:k,1:(k-1))]<-2 + RATES<-fitMk(pw,x,model=MODEL,pi=pi)$rates + start<-rep(0,sum(degree)+2) + start[c(degree[1]+1,sum(degree)+2)]<-RATES + start<-start+runif(n=sum(degree)+2,min=-0.0001*mean(RATES), + max=0.0001*mean(RATES)) + q1_start<-q2_start<-rep(0,length(xx)) + for(i in 0:degree[1]) q1_start<-q1_start+start[i+1]*xx^(degree[1]-i) + for(i in 0:degree[2]) q2_start<-q2_start+start[degree[1]+i+2]*xx^(degree[2]-i) + q1_start[q1_start<0]<-0 + q2_start[q2_start<0]<-0 + if(all(q1_start==0)&&all(q2_start==0)) q1_start<-q2_start<--1 + } else { q1_start<-q2_start<-rep(0,length(xx)) for(i in 0:degree[1]) q1_start<-q1_start+start[i+1]*xx^(degree[1]-i) for(i in 0:degree[2]) q2_start<-q2_start+start[degree[1]+i+2]*xx^(degree[2]-i) From 06a44d2dd0eac50c20833f742d4d278e4e56c831 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Wed, 21 Feb 2024 19:04:45 -0500 Subject: [PATCH 36/51] other fixes to smart start --- R/fitfnMk.R | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/R/fitfnMk.R b/R/fitfnMk.R index e07797a1..5699f2a6 100644 --- a/R/fitfnMk.R +++ b/R/fitfnMk.R @@ -61,11 +61,13 @@ fitfnMk<-function(tree,x,model="polynomial",degree=2,...){ pw<-reorder(tree,"postorder") xx<-0:(k-2)+0.5 if(is.null(start)) q1_start<-q2_start<--1 - else if(start=="smart"){ + else if(start[1]=="smart"){ + cat("Numerically optimizing simple equal-rates ordered model\n") + cat(" to get better random starting values....\n\n") MODEL<-matrix(0,k,k,dimnames=list(colnames(x),colnames(x))) MODEL[cbind(1:(k-1),2:k)]<-1 MODEL[cbind(2:k,1:(k-1))]<-2 - RATES<-fitMk(pw,x,model=MODEL,pi=pi)$rates + RATES<-fitMk(pw,x,model=MODEL,pi=pi,lik.func="pruning")$rates start<-rep(0,sum(degree)+2) start[c(degree[1]+1,sum(degree)+2)]<-RATES start<-start+runif(n=sum(degree)+2,min=-0.0001*mean(RATES), @@ -76,14 +78,14 @@ fitfnMk<-function(tree,x,model="polynomial",degree=2,...){ q1_start[q1_start<0]<-0 q2_start[q2_start<0]<-0 if(all(q1_start==0)&&all(q2_start==0)) q1_start<-q2_start<--1 - } else { + } else if(is.numeric(start)) { q1_start<-q2_start<-rep(0,length(xx)) for(i in 0:degree[1]) q1_start<-q1_start+start[i+1]*xx^(degree[1]-i) for(i in 0:degree[2]) q2_start<-q2_start+start[degree[1]+i+2]*xx^(degree[2]-i) q1_start[q1_start<0]<-0 q2_start[q2_start<0]<-0 if(all(q1_start==0)&&all(q2_start==0)) q1_start<-q2_start<--1 - } + } else q1_start<-q2_start<--1 while(any(q1_start<0)||any(q2_start<0)){ start<-runif(n=sum(degree)+2) q1_start<-q2_start<-rep(0,length(xx)) From fae825515311c3ba2681478d7f140743fe267dee Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Thu, 22 Feb 2024 17:17:26 -0500 Subject: [PATCH 37/51] add frame=FALSE argument to remove textboxes around labels --- R/cophylo.R | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/R/cophylo.R b/R/cophylo.R index e1c929f8..1d3d4a2c 100644 --- a/R/cophylo.R +++ b/R/cophylo.R @@ -1,5 +1,5 @@ ## creates an object of class "cophylo" -## written by Liam J. Revell 2015, 2016, 2017, 2019, 2021, 2023 +## written by Liam J. Revell 2015, 2016, 2017, 2019, 2021, 2023, 2024 cophylo<-function(tr1,tr2,assoc=NULL,rotate=TRUE,...){ if(!inherits(tr1,"phylo")||!inherits(tr2,"phylo")) @@ -125,6 +125,8 @@ phylogram<-function(tree,part=1,direction="rightwards",fsize=1,ftype="i",lwd=1,. if(hasArg(tip.len)) tip.len<-list(...)$tip.len else tip.len<-0.1 if(pts==TRUE&&tip.len==0) tip.len<-0.1 + if(hasArg(frame)) frame<-list(...)$frame + else frame<-TRUE d<-if(direction=="rightwards") 1 else -1 ## sub "_" for " " tree$tip.label<-gsub("_"," ",tree$tip.label) @@ -183,7 +185,7 @@ phylogram<-function(tree,part=1,direction="rightwards",fsize=1,ftype="i",lwd=1,. for(i in 1:n) TEXTBOX(d*(h[i]+fsize*strwidth(tree$tip.label[i])+ tip.len*(max(X)-min(X))),y[i], tree$tip.label[i], pos=if(d<0) 4 else 2,offset=0, - cex=fsize,font=font) + cex=fsize,font=font,frame=frame) } PP<-list(type="phylogram",use.edge.length=TRUE,node.pos=1, show.tip.label=if(ftype!="off") TRUE else FALSE,show.node.label=FALSE, @@ -209,6 +211,8 @@ cladogram<-function(tree,part=1,direction="rightwards",fsize=1,ftype="i",lwd=1,. if(hasArg(tip.len)) tip.len<-list(...)$tip.len else tip.len<-0.1 if(pts==TRUE&&tip.len==0) tip.len<-0.1 + if(hasArg(frame)) frame<-list(...)$frame + else frame<-TRUE d<-if(direction=="rightwards") 1 else -1 ## sub "_" for " " tree$tip.label<-gsub("_"," ",tree$tip.label) @@ -257,7 +261,7 @@ cladogram<-function(tree,part=1,direction="rightwards",fsize=1,ftype="i",lwd=1,. for(i in 1:n) TEXTBOX(d*(h[i]+fsize*strwidth(tree$tip.label[i])+ tip.len*(max(X)-min(X))),y[i], tree$tip.label[i], pos=if(d<0) 4 else 2,offset=0, - cex=fsize,font=font) + cex=fsize,font=font,frame=frame) } PP<-list(type="cladogram",use.edge.length=TRUE,node.pos=1, show.tip.label=if(ftype!="off") TRUE else FALSE,show.node.label=FALSE, @@ -273,8 +277,9 @@ cladogram<-function(tree,part=1,direction="rightwards",fsize=1,ftype="i",lwd=1,. ## internally used function -TEXTBOX<-function(x,y,label,pos,offset,cex,font){ - rect(x,y-0.5*strheight(label,cex=cex,font=font),x+if(pos==4) strwidth(label, +TEXTBOX<-function(x,y,label,pos,offset,cex,font,frame=TRUE){ + if(frame) rect(x,y-0.5*strheight(label,cex=cex,font=font), + x+if(pos==4) strwidth(label, cex=cex,font=font) else -strwidth(label,cex=cex,font=font), y+0.5*strheight(label,cex=cex,font=font),border=FALSE, col=if(par()$bg%in%c("white","transparent")) "white" else par()$bg) @@ -339,6 +344,9 @@ plot.cophylo<-function(x,...){ else edge.col<-list( left=rep("black",nrow(x$trees[[1]]$edge)), right=rep("black",nrow(x$trees[[2]]$edge))) + if(hasArg(frame)) frame<-list(...)$frame + else frame<-c(TRUE,TRUE) + if(length(frame)==1) frame<-rep(frame,2) obj<-list(...) if(is.null(obj$part)) obj$part<-0.4 par(mar=mar) @@ -359,6 +367,8 @@ plot.cophylo<-function(x,...){ rightArgs$ftype<-obj$ftype[2] } } + leftArgs$frame<-frame[1] + rightArgs$frame<-frame[2] plotter<-if(type[1]=="cladogram") "cladogram" else "phylogram" x1<-do.call(plotter,c(list(tree=x$trees[[1]]),leftArgs)) plotter<-if(type[2]=="cladogram") "cladogram" else "phylogram" From c9c4de938b7efdc46f748941fc81cc41374d3742 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Fri, 23 Feb 2024 17:05:58 -0500 Subject: [PATCH 38/51] have exported likelihood return lik instead of -lik in bounded_bm --- R/fitfnMk.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/fitfnMk.R b/R/fitfnMk.R index 5699f2a6..83eca414 100644 --- a/R/fitfnMk.R +++ b/R/fitfnMk.R @@ -103,7 +103,7 @@ fitfnMk<-function(tree,x,model="polynomial",degree=2,...){ index.matrix<-matrix(0,k,k,dimnames=list(colnames(x),colnames(x))) index.matrix[cbind(1:(k-1),2:k)]<-1:(k-1) index.matrix[cbind(2:k,1:(k-1))]<-k:(2*k-2) - lik.f<-function(par) lik(par,pw=pw,X=x,pi=pi,degree=degree) + lik.f<-function(par) -lik(par,pw=pw,X=x,pi=pi,degree=degree) object<-list( logLik=-fit$objective, rates=c(q1_est,q2_est), From 1e7e042ce7f44770715498c3a1371ad1be96116b Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Fri, 23 Feb 2024 17:06:35 -0500 Subject: [PATCH 39/51] new function plotTree.lollipop --- R/plotTree.lollipop.R | 62 ++++++++++++++++++++++++++++++++++++++++ man/plotTree.lollipop.Rd | 43 ++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 R/plotTree.lollipop.R create mode 100644 man/plotTree.lollipop.Rd diff --git a/R/plotTree.lollipop.R b/R/plotTree.lollipop.R new file mode 100644 index 00000000..8bb7deba --- /dev/null +++ b/R/plotTree.lollipop.R @@ -0,0 +1,62 @@ +plotTree.lollipop<-function(tree,x, + args.plotTree=list(),args.lollipop=list(),...){ + if(!inherits(x,c("matrix","data.frame"))) x<-as.matrix(x) + h<-max(nodeHeights(tree)) + if(hasArg(panel_height)) panel_height<-list(...)$panel_height + else panel_height<-1.0 + panel_height<-panel_height*h + args.plotTree$tree<-tree + args.plotTree$direction<-"upwards" + if(is.null(args.plotTree$mar)) + args.plotTree$mar<-c(0.1,5.1,0.1,0.1) + if(is.null(args.plotTree$ylim)) + args.plotTree$ylim<-c(0,h+ncol(x)*panel_height) + if(is.null(args.plotTree$ftype)) + args.plotTree$ftype<-"off" + if(is.null(args.plotTree$lwd)) args.plotTree$lwd<-1 + do.call(plotTree,args.plotTree) + pp<-get("last_plot.phylo",envir=.PlotPhyloEnv) + if(pp$font){ + dx<-abs(diff(pp$x.lim)) + pdin<-par()$din[2] + sh<-(pp$cex*strwidth(paste(" ",tree$tip.label,sep=""))+ + 0.3*pp$cex*strwidth("W"))*(par()$din[1]/par()$din[2])* + (diff(par()$usr[3:4])/diff(par()$usr[1:2])) + new_h<-h+max(sh) + panel_height<-(h-new_h+ncol(x)*panel_height)/ncol(x) + h<-new_h + } + if(hasArg(ylab)) ylab<-list(...)$ylab + else ylab<-if(!is.null(colnames(x))) + colnames(x) else rep("",ncol(x)) + for(i in ncol(x):1){ + d<-max(c(diff(range(x[,i])),max(x[,i]))) + y<-setNames(x[,i]/d*0.8*panel_height,rownames(x)) + lower<-h+(i-1)*panel_height+panel_height*0.05 + upper<-h+(i-1)*panel_height+panel_height*0.95 + polygon(c(0,max(pp$xx)+1,max(pp$xx)+1,0), + c(lower,lower,upper,upper), + border=FALSE,col="#F2F2F2") + hh<-lower-min(c(0,min(y)))+0.05*panel_height + lines(range(pp$xx),rep(hh,2),col="black",lty="dotted") + segments(x0=pp$xx[1:Ntip(tree)],y0=rep(hh,Ntip(tree)), + x1=pp$xx[1:Ntip(tree)],y1=y[tree$tip.label]+hh) + labs<-pretty(c(min(c(0,min(x[,i]))),x[,i]),n=4) + labs[!(labs>max(x[,i]))]->labs + labs[!(labslabs + axis(2,at=hh+max(y)/max(x[,i])*labs, + labels=labs,las=1,cex.axis=0.6) + args.lollipop$bg<-setNames( + hcl.colors(n=100)[ceiling(99*((y- + min(y))/diff(range(y))))+1], + names(y)) + args.lollipop$bg<-args.lollipop$bg[tree$tip.label] + if(is.null(args.lollipop$pch)) args.lollipop$pch<-21 + if(is.null(args.lollipop$cex)) args.lollipop$cex<-1.2 + args.lollipop$x<-pp$xx[1:Ntip(tree)] + args.lollipop$y<-y[tree$tip.label]+hh + do.call(points,args.lollipop) + mtext(ylab[i],2,line=3,at=mean(hh+max(y)/ + max(x[,i])*labs),cex=0.8) + } +} diff --git a/man/plotTree.lollipop.Rd b/man/plotTree.lollipop.Rd new file mode 100644 index 00000000..89846cf4 --- /dev/null +++ b/man/plotTree.lollipop.Rd @@ -0,0 +1,43 @@ +\name{plotTree.lollipop} +\alias{plotTree.lollipop} +\title{Plot a tree with one or more matched lollipop plots} +\usage{ +plotTree.lollipop(tree, x, args.plotTree=list(), args.lollipop=list(), ...) +} +\arguments{ + \item{tree}{an object of class \code{"phylo"}.} + \item{x}{a matrix, data frame, or vector of numeric values.} + \item{args.plotTree}{list of arguments to be passed to \code{\link{plotTree}}.} + \item{args.lollilop}{list of arguments for the lollipop plot(s).} + \item{...}{optional arguments.} +} +\description{ + Plots an upward facing phylogenetic tree with one or more matched lollipop plots. +} +\value{ + Creates a plot. +} +\references{ + Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. +} +\author{Liam Revell \email{liam.revell@umb.edu}} +\seealso{ + \code{\link{phylo.heatmap}}, \code{\link{plotTree.barplot}} +} +\examples{ +data(anoletree) +anole_tree<-as.phylo(anoletree) +data(anole.data) +anole_data<-cbind(phyl.resid(anole_tree, + x=as.matrix(anole.data[,"SVL",drop=FALSE]), + Y=as.matrix(anole.data[,c(6,4,2)]))$resid, + exp(anole.data[,"SVL",drop=FALSE])) +plotTree.lollipop(anole_tree,anole_data, + ylab=c("relative (TL)","relative (FLL)", + "relative (HL)","SVL")) +par(mar=c(5.1,4.1,4.1,2.1)) +} +\keyword{phylogenetics} +\keyword{plotting} +\keyword{comparative method} +\keyword{discrete character} From 0eba6e6a2cb66c64f72586b80459f4d1191ba442 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Fri, 23 Feb 2024 17:06:58 -0500 Subject: [PATCH 40/51] add plotTree.lollipop to name space --- NAMESPACE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index a87df91d..3cec000b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -40,7 +40,7 @@ export(plot.anc.Bayes, plot.ancr, plot.changesMap, plot.contMap, plot.cophylo, p export(plot.edge.widthMap, plot.fitMk, plot.fitPagel, plot.gfit, plot.phyl.RMA) export(plot.phylo.to.map, plot.Qmatrix, plot.simBMphylo, plotBranchbyTrait, plot.phylosig) export(plotSimmap, plotThresh, plotTree, plotTree.barplot, plotTree.boxplot) -export(plotTree.datamatrix, plotTree.errorbars, plotTree.singletons, plotTree.splits) +export(plotTree.datamatrix, plotTree.errorbars, plotTree.lollipop, plotTree.singletons, plotTree.splits) export(plotTree.wBars, posterior.evolrate, posthoc, posthoc.ratebytree, print.Qmatrix) export(project.phylomorphospace, pscore) export(ratebystate, ratebytree, rateshift, read.newick, read.simmap, readNexus) @@ -321,7 +321,7 @@ importFrom(graphics, rect, curve, image, mtext, arrows, barplot, boxplot, contou importFrom(graphics, abline, legend, grid, clip) importFrom(grDevices, palette, palette.colors, colors, dev.hold, dev.flush, rainbow, heat.colors, gray) importFrom(grDevices, colorRamp, colorRampPalette, dev.new, rgb, pdf, dev.off, col2rgb, dev.size) -importFrom(grDevices, xy.coords, dev.cur) +importFrom(grDevices, xy.coords, dev.cur, hcl.colors) importFrom(maps, map) importFrom(MASS, ginv) importFrom(methods, hasArg, is) From 191813ed47f713994b8eb0d884196204425c843a Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Fri, 23 Feb 2024 17:07:13 -0500 Subject: [PATCH 41/51] increment subversion number --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2003c906..1e75a940 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: phytools -Version: 2.1-16 -Date: 2024-02-21 +Version: 2.1-18 +Date: 2024-02-23 Title: Phylogenetic Tools for Comparative Biology (and Other Things) Author: Liam J. Revell Maintainer: Liam J. Revell From 9576acb030778bfe4797346568e98039daaa2890 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Thu, 29 Feb 2024 14:58:24 -0500 Subject: [PATCH 42/51] add DEoptim optimization method to fitfnMk --- NAMESPACE | 1 + R/fitfnMk.R | 333 ++++++++++++++++++++++++++++++++++------------------ 2 files changed, 222 insertions(+), 112 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 3cec000b..892c7bfd 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -312,6 +312,7 @@ importFrom(ape, tiplabels, unroot, vcv, vcv.phylo, write.tree) importFrom(coda, as.mcmc, HPDinterval) importFrom(combinat, permn) importFrom(clusterGeneration, genPositiveDefMat) +importFrom(DEoptim, DEoptim) importFrom(doParallel, registerDoParallel) importFrom(expm, expm) importFrom(foreach, "%dopar%", foreach) diff --git a/R/fitfnMk.R b/R/fitfnMk.R index 83eca414..84771ec1 100644 --- a/R/fitfnMk.R +++ b/R/fitfnMk.R @@ -1,124 +1,233 @@ fitfnMk<-function(tree,x,model="polynomial",degree=2,...){ + if(hasArg(quiet)) quiet<-list(...)$quiet + else quiet<-FALSE if(model!="polynomial"){ stop("Sorry. Only available model (so far) is \"polynomial\". Stopping.\n") } - if(hasArg(trace)) trace<-list(...)$trace - else trace<-0 - if(hasArg(start)) start<-list(...)$start - else start<-NULL - if(length(degree)==1) degree<-rep(degree,2) - if(is.matrix(x)){ - levs<-colnames(x) - } else if(is.numeric(x)){ - levs<-min(x):max(x) - x<-to.matrix(x,levs) - } else if(is.factor(x)){ - if(suppressWarnings(all(!is.na(as.numeric(levels(x)))))){ - levs<-min(as.numeric(levels(x))):max(as.numeric(levels(x))) - x<-to.matrix(x,levs) + if(hasArg(niter)) niter<-list(...)$niter + else niter<-10 + if(niter>1){ + if(hasArg(parallel)) parallel<-list(...)$parallel + else parallel<-FALSE + if(hasArg(opt.method)) opt.method<-list(...)$opt.method + else opt.method<-"nlminb" + } else parallel<-FALSE + if(niter>1){ + args<-list(...) + args$niter<-1 + args$tree<-tree + args$x<-x + args$degree<-degree + if(parallel&&(opt.method!="DEoptim")){ + if(hasArg(ncores)) ncores<-list(...)$ncores + else ncores<-min(c(detectCores()-1,niter)) + mc<-makeCluster(ncores,type="PSOCK") + registerDoParallel(cl=mc) + if(!quiet){ + cat(paste("Opened cluster with",ncores,"cores.\n")) + cat("Running optimization iterations in parallel.\n") + cat("Please wait....\n") + flush.console() + } + fits<-foreach(i = 1:niter)%dopar%{ + do.call(fitfnMk,args) + } + stopCluster(cl=mc) + lnL<-sapply(fits,logLik) } else { - levs<-sort(levels(x)) - x<-to.matrix(x,levs) + fits<-list() + for(i in 1:niter){ + fits[[i]]<-do.call(fitfnMk,args) + lnL<-sapply(fits,logLik) + if(!quiet){ + cat(paste("log-likelihood from current iteration:", + round(logLik(fits[[i]]),4),"\n")) + cat(paste(" --- Best log-likelihood so far:", + round(max(lnL), 4),"---\n")) + flush.console() + } + } } - } else if(is.character(x)){ - if(suppressWarnings(all(!is.na(as.numeric(x))))){ - levs<-min(as.numeric(x)):max(as.numeric(x)) - x<-to.matrix(x,levs) - } else { - levs<-sort(unique(x)) + object<-fits[[which(lnL==max(lnL))[1]]] + object$all.fits<-fits + } else { + if(hasArg(trace)) trace<-list(...)$trace + else trace<-0 + if(hasArg(start)) start<-list(...)$start + else start<-NULL + if(hasArg(opt.method)) opt.method<-list(...)$opt.method + else opt.method<-"nlminb" + if(length(degree)==1) degree<-rep(degree,2) + if(is.matrix(x)){ + levs<-colnames(x) + } else if(is.numeric(x)){ + levs<-min(x):max(x) x<-to.matrix(x,levs) + } else if(is.factor(x)){ + if(suppressWarnings(all(!is.na(as.numeric(levels(x)))))){ + levs<-min(as.numeric(levels(x))):max(as.numeric(levels(x))) + x<-to.matrix(x,levs) + } else { + levs<-sort(levels(x)) + x<-to.matrix(x,levs) + } + } else if(is.character(x)){ + if(suppressWarnings(all(!is.na(as.numeric(x))))){ + levs<-min(as.numeric(x)):max(as.numeric(x)) + x<-to.matrix(x,levs) + } else { + levs<-sort(unique(x)) + x<-to.matrix(x,levs) + } } - } - x<-x[tree$tip.label,] - k<-ncol(x) - if(hasArg(pi)) pi<-list(...)$pi - else pi<-"equal" - if(is.numeric(pi)) root.prior<-"given" - if(pi[1]=="equal"){ - pi<-setNames(rep(1/k,k),levs) - root.prior<-"flat" - } else if(pi[1]=="fitzjohn"){ - root.prior<-"nuisance" - } else if(pi[1]=="mle") root.prior<-"it's MLE" - lik<-function(par,pw,X,pi=pi,degree=degree){ - k<-ncol(X) - x<-1:(k-1)-0.5 - q1<-rep(0,length(x)) - for(i in 0:degree[1]) q1<-q1+par[i+1]*x^(degree[1]-i) - q2<-rep(0,length(x)) - for(i in 0:degree[2]) q2<-q2+par[degree[1]+i+2]*x^(degree[2]-i) - q1[q1<0]<-0 - q2[q2<0]<-0 - if(all(q1<0)||all(q2<0)){ - return(Inf) - } else { - MODEL<-matrix(0,k,k,dimnames=list(colnames(X),colnames(X))) - MODEL[cbind(1:(k-1),2:k)]<-1:(k-1) - MODEL[cbind(2:k,1:(k-1))]<-k:(2*k-2) - return(-pruning(c(q1,q2),pw,X,model=MODEL,pi=pi)) + x<-x[tree$tip.label,] + k<-ncol(x) + if(hasArg(pi)) pi<-list(...)$pi + else pi<-"equal" + if(is.numeric(pi)) root.prior<-"given" + if(pi[1]=="equal"){ + pi<-setNames(rep(1/k,k),levs) + root.prior<-"flat" + } else if(pi[1]=="fitzjohn"){ + root.prior<-"nuisance" + } else if(pi[1]=="mle") root.prior<-"it's MLE" + lik<-function(par,pw,Y,pi=pi,degree=degree){ + k<-ncol(Y) + m<-1:(k-1)-0.5 + q1<-rep(0,length(m)) + for(i in 0:degree[1]) q1<-q1+par[i+1]*m^(degree[1]-i) + q2<-rep(0,length(m)) + for(i in 0:degree[2]) q2<-q2+par[degree[1]+i+2]*m^(degree[2]-i) + q1[q1<0]<-0 + q2[q2<0]<-0 + if(all(q1<0)||all(q2<0)){ + return(Inf) + } else { + MODEL<-matrix(0,k,k,dimnames=list(colnames(Y),colnames(Y))) + MODEL[cbind(1:(k-1),2:k)]<-1:(k-1) + MODEL[cbind(2:k,1:(k-1))]<-k:(2*k-2) + return(-pruning(c(q1,q2),pw,Y,model=MODEL,pi=pi)) + } } - } - pw<-reorder(tree,"postorder") - xx<-0:(k-2)+0.5 - if(is.null(start)) q1_start<-q2_start<--1 - else if(start[1]=="smart"){ - cat("Numerically optimizing simple equal-rates ordered model\n") - cat(" to get better random starting values....\n\n") - MODEL<-matrix(0,k,k,dimnames=list(colnames(x),colnames(x))) - MODEL[cbind(1:(k-1),2:k)]<-1 - MODEL[cbind(2:k,1:(k-1))]<-2 - RATES<-fitMk(pw,x,model=MODEL,pi=pi,lik.func="pruning")$rates - start<-rep(0,sum(degree)+2) - start[c(degree[1]+1,sum(degree)+2)]<-RATES - start<-start+runif(n=sum(degree)+2,min=-0.0001*mean(RATES), - max=0.0001*mean(RATES)) - q1_start<-q2_start<-rep(0,length(xx)) - for(i in 0:degree[1]) q1_start<-q1_start+start[i+1]*xx^(degree[1]-i) - for(i in 0:degree[2]) q2_start<-q2_start+start[degree[1]+i+2]*xx^(degree[2]-i) - q1_start[q1_start<0]<-0 - q2_start[q2_start<0]<-0 - if(all(q1_start==0)&&all(q2_start==0)) q1_start<-q2_start<--1 - } else if(is.numeric(start)) { - q1_start<-q2_start<-rep(0,length(xx)) - for(i in 0:degree[1]) q1_start<-q1_start+start[i+1]*xx^(degree[1]-i) - for(i in 0:degree[2]) q2_start<-q2_start+start[degree[1]+i+2]*xx^(degree[2]-i) - q1_start[q1_start<0]<-0 - q2_start[q2_start<0]<-0 - if(all(q1_start==0)&&all(q2_start==0)) q1_start<-q2_start<--1 - } else q1_start<-q2_start<--1 - while(any(q1_start<0)||any(q2_start<0)){ - start<-runif(n=sum(degree)+2) - q1_start<-q2_start<-rep(0,length(xx)) - for(i in 0:degree[1]) q1_start<-q1_start+start[i+1]*xx^(degree[1]-i) - for(i in 0:degree[2]) q2_start<-q2_start+start[degree[1]+i+2]*xx^(degree[2]-i) - } - fit<-nlminb(start,lik,pw=pw,X=x,pi=pi,degree=degree, - control=list(trace=trace)) - q1_est<-rep(0,length(xx)) - for(i in 0:degree[1]) q1_est<-q1_est+fit$par[i+1]*xx^(degree[1]-i) - q2_est<-rep(0,length(xx)) - for(i in 0:degree[2]) q2_est<-q2_est+fit$par[degree[1]+i+2]*xx^(degree[2]-i) - q1_est[q1_est<0]<-0 - q2_est[q2_est<0]<-0 - index.matrix<-matrix(0,k,k,dimnames=list(colnames(x),colnames(x))) - index.matrix[cbind(1:(k-1),2:k)]<-1:(k-1) - index.matrix[cbind(2:k,1:(k-1))]<-k:(2*k-2) - lik.f<-function(par) -lik(par,pw=pw,X=x,pi=pi,degree=degree) - object<-list( - logLik=-fit$objective, - rates=c(q1_est,q2_est), - index.matrix=index.matrix, - states=levs, - pi=pi, - method="nlminb", - root.prior=root.prior, - opt_results=fit[c("convergence","iterations","evaluations","message")], - par=fit$par, - degree=degree, - data=x, - tree=tree, - lik=lik.f) - class(object)<-c("fitfnMk","fitMk") + pw<-reorder(tree,"postorder") + xx<-0:(k-2)+0.5 + if(is.null(start)) q1_start<-q2_start<--1 + else if(start[1]=="smart"){ + cat("Numerically optimizing simple equal-rates ordered model\n") + cat(" to get better random starting values....\n\n") + MODEL<-matrix(0,k,k,dimnames=list(colnames(x),colnames(x))) + MODEL[cbind(1:(k-1),2:k)]<-1 + MODEL[cbind(2:k,1:(k-1))]<-2 + RATES<-fitMk(pw,x,model=MODEL,pi=pi,lik.func="pruning")$rates + start<-rep(0,sum(degree)+2) + start[c(degree[1]+1,sum(degree)+2)]<-RATES + start<-start+runif(n=sum(degree)+2,min=-0.0001*mean(RATES), + max=0.0001*mean(RATES)) + q1_start<-q2_start<-rep(0,length(xx)) + for(i in 0:degree[1]) q1_start<-q1_start+start[i+1]*xx^(degree[1]-i) + for(i in 0:degree[2]) q2_start<-q2_start+start[degree[1]+i+2]*xx^(degree[2]-i) + q1_start[q1_start<0]<-0 + q2_start[q2_start<0]<-0 + if(all(q1_start==0)&&all(q2_start==0)) q1_start<-q2_start<--1 + } else if(is.numeric(start)) { + q1_start<-q2_start<-rep(0,length(xx)) + for(i in 0:degree[1]) q1_start<-q1_start+start[i+1]*xx^(degree[1]-i) + for(i in 0:degree[2]) q2_start<-q2_start+start[degree[1]+i+2]*xx^(degree[2]-i) + q1_start[q1_start<0]<-0 + q2_start[q2_start<0]<-0 + if(all(q1_start==0)&&all(q2_start==0)) q1_start<-q2_start<--1 + } else q1_start<-q2_start<--1 + while(any(q1_start<0)||any(q2_start<0)){ + start<-runif(n=sum(degree)+2) + q1_start<-q2_start<-rep(0,length(xx)) + for(i in 0:degree[1]) q1_start<-q1_start+start[i+1]*xx^(degree[1]-i) + for(i in 0:degree[2]) q2_start<-q2_start+start[degree[1]+i+2]*xx^(degree[2]-i) + } + if(opt.method=="nlminb"){ + fit<-nlminb(start,lik,pw=pw,Y=x,pi=pi,degree=degree, + control=list(trace=trace)) + } else if(opt.method=="DEoptim"){ + if(hasArg(maxit)) maxit<-list(...)$maxit + else maxit<-1000 + if(hasArg(prompt)) prompt<-list(...)$prompt + else prompt<-FALSE + if(hasArg(parallel)) parallel<-list(...)$parallel + else parallel<-FALSE + if(hasArg(trace)) trace<-list(...)$trace + else trace<-if(maxit>100) 100 else 1 + parallelType<-if(parallel) 1 else 0 + if(hasArg(NP)) NP<-list(...)$NP + else NP<-100*length(start) + if(hasArg(F)) F<-list(...)$F + else F<-0.8 + if(hasArg(CR)) CR<-list(...)$CR + else CR<-0.9 + initialpop<-matrix(rep(start,NP)*runif(NP*length(start)), + NP,length(start),byrow=TRUE) + if(parallel){ + if(hasArg(ncores)) ncores<-list(...)$ncores + else ncores<-detectCores()-1 + mc<-makeCluster(ncores,type="PSOCK") + registerDoParallel(cl=mc) + } + if(trace>0) cat("\n") + fit<-DEoptim(lik, + lower=rep(-3,length(start)),upper=rep(3,length(start)), + pw=pw,Y=x,pi=pi,degree=degree, + control=list(itermax=maxit, + initialpop=initialpop, + cluster=if(parallel) mc else NULL, + trace=trace,F=F,CR=CR,NP=NP)) + if(prompt){ + cat("\nMax iterations (itermax) reached. Continue? (yes/no):") + continue<-readline() + } else continue<-"no" + while(continue=="yes"&&prompt){ + fit<-DEoptim(lik, + lower=rep(-10*max(start),length(start)), + upper=rep(10*max(start),length(start)), + pw=pw,Y=x,pi=pi,degree=degree, + control=list(itermax=maxit, + initialpop=fit$member$pop, + cluster=if(parallel) mc else NULL, + trace=trace,F=F,CR=CR,NP=NP)) + cat("\nMax iterations (itermax) reached. Continue? (yes/no):") + continue<-readline() + } + if(trace>0) cat("\n") + stopCluster(cl=mc) + fit<-list( + par=fit$optim$bestmem, + objective=fit$optim$bestval, + iterations=fit$optim$iter, + evaluations=fit$optim$nfeval) + } + q1_est<-rep(0,length(xx)) + for(i in 0:degree[1]) q1_est<-q1_est+fit$par[i+1]*xx^(degree[1]-i) + q2_est<-rep(0,length(xx)) + for(i in 0:degree[2]) q2_est<-q2_est+fit$par[degree[1]+i+2]*xx^(degree[2]-i) + q1_est[q1_est<0]<-0 + q2_est[q2_est<0]<-0 + index.matrix<-matrix(0,k,k,dimnames=list(colnames(x),colnames(x))) + index.matrix[cbind(1:(k-1),2:k)]<-1:(k-1) + index.matrix[cbind(2:k,1:(k-1))]<-k:(2*k-2) + lik.f<-function(par) -lik(par,pw=pw,Y=x,pi=pi,degree=degree) + object<-list( + logLik=-fit$objective, + rates=c(q1_est,q2_est), + index.matrix=index.matrix, + states=levs, + pi=pi, + method=opt.method, + root.prior=root.prior, + opt_results=fit[c("convergence","iterations","evaluations","message")], + par=fit$par, + degree=degree, + data=x, + tree=tree, + lik=lik.f) + class(object)<-c("fitfnMk","fitMk") + } object } From 1bd8aacd89a3f1a9a1a09b89a9b2931bcf25f398 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Thu, 29 Feb 2024 14:58:59 -0500 Subject: [PATCH 43/51] fix plotTree.lollipop man page --- man/plotTree.lollipop.Rd | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/man/plotTree.lollipop.Rd b/man/plotTree.lollipop.Rd index 89846cf4..f0036236 100644 --- a/man/plotTree.lollipop.Rd +++ b/man/plotTree.lollipop.Rd @@ -8,17 +8,19 @@ plotTree.lollipop(tree, x, args.plotTree=list(), args.lollipop=list(), ...) \item{tree}{an object of class \code{"phylo"}.} \item{x}{a matrix, data frame, or vector of numeric values.} \item{args.plotTree}{list of arguments to be passed to \code{\link{plotTree}}.} - \item{args.lollilop}{list of arguments for the lollipop plot(s).} + \item{args.lollipop}{list of arguments for the lollipop plot(s).} \item{...}{optional arguments.} } \description{ - Plots an upward facing phylogenetic tree with one or more matched lollipop plots. + Plots an upward facing phylogenetic tree with one or more matched lollipop plots. Inspired by a plotting style used by Title et al. (2024). } \value{ Creates a plot. } \references{ Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. + + Title, P. O., Singhal, S., Grundler, M. C., Costa, G. C., Pyron, R. A., Colston, T. J., Grundler, M. R., Prates, I., Stepanova, N., Jones, M. E. H., Cavalcanti, L. B. Q., Colli, G. R., Di-Poi, N., Donnellan, S. C., Moritz, C., Mesquita, D. O., Pianka, E. R., Smith, S. A., Vitt, L. J., and Rabosky, D. L. (2024) The macroevolutionary singularity of snakes. \emph{Science}, \bold{383}, 918-923. } \author{Liam Revell \email{liam.revell@umb.edu}} \seealso{ @@ -40,4 +42,4 @@ par(mar=c(5.1,4.1,4.1,2.1)) \keyword{phylogenetics} \keyword{plotting} \keyword{comparative method} -\keyword{discrete character} +\keyword{continuous character} From fa8d1e2902c2d5b64cdcdb1ac2d8547522cfe938 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Thu, 29 Feb 2024 14:59:19 -0500 Subject: [PATCH 44/51] increment version number, import DEoptim --- DESCRIPTION | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1e75a940..ebd5afe9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,12 +1,12 @@ Package: phytools -Version: 2.1-18 -Date: 2024-02-23 +Version: 2.2-0 +Date: 2024-02-28 Title: Phylogenetic Tools for Comparative Biology (and Other Things) Author: Liam J. Revell Maintainer: Liam J. Revell Depends: R (>= 3.5.0), ape (>= 5.7), maps -Imports: clusterGeneration, coda, combinat, doParallel, expm, foreach, - graphics, grDevices, MASS, methods, mnormt, nlme, numDeriv, +Imports: clusterGeneration, coda, combinat, DEoptim, doParallel, expm, + foreach, graphics, grDevices, MASS, methods, mnormt, nlme, numDeriv, optimParallel, parallel, phangorn (>= 2.3.1), scatterplot3d, stats, utils Suggests: animation, geiger, plotrix, RColorBrewer, rgl From cfdff2390a9a297fc2a2dda5f180b998d5a87121 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Sun, 3 Mar 2024 14:57:58 -0500 Subject: [PATCH 45/51] fix starting values for fitfnMk --- R/fitfnMk.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/fitfnMk.R b/R/fitfnMk.R index 84771ec1..671d315d 100644 --- a/R/fitfnMk.R +++ b/R/fitfnMk.R @@ -172,7 +172,8 @@ fitfnMk<-function(tree,x,model="polynomial",degree=2,...){ } if(trace>0) cat("\n") fit<-DEoptim(lik, - lower=rep(-3,length(start)),upper=rep(3,length(start)), + lower=rep(-10*max(start),length(start)), + upper=rep(10*max(start),length(start)), pw=pw,Y=x,pi=pi,degree=degree, control=list(itermax=maxit, initialpop=initialpop, From 5aab341e616dcd0411b941d8c68115dff152dab0 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Sat, 16 Mar 2024 19:36:24 -0400 Subject: [PATCH 46/51] small fixes and updates to contMap and phenogram --- R/contMap.R | 23 +++++++++++++++++------ R/phenogram.R | 22 +++++++++++++++------- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/R/contMap.R b/R/contMap.R index daa7a48f..88f92d24 100644 --- a/R/contMap.R +++ b/R/contMap.R @@ -1,5 +1,6 @@ ## function plots reconstructed values for ancestral characters along the edges of the tree -## written by Liam J. Revell 2012-2023 +## written by Liam J. Revell 2012-2024 + contMap<-function(tree,x,res=100,fsize=NULL,ftype=NULL,lwd=4,legend=NULL, lims=NULL,outline=TRUE,sig=3,type="phylogram",direction="rightwards", plot=TRUE,...){ @@ -183,11 +184,18 @@ plot.contMap<-function(x,...){ if(direction=="rightwards") xx[1:N]<-xx[1:N]+strwidth(paste(obj$tip.label,"__",sep=""),cex=fsize[1])+offset } - DROP<-if(type=="arc") DROP<-Ntip(x$tree)+1 else DROP<-NULL - points(xx[-DROP],yy[-DROP],pch=if(outline) 21 else 16, - col=if(outline) par()$fg else node.cols[-DROP], - bg=if(outline) node.cols[-DROP] else NULL, - cex=c(rep(cex[2],N),rep(cex[1],obj$Nnode-length(DROP)))) + if(type=="arc"){ + DROP<-Ntip(x$tree)+1 + points(xx[-DROP],yy[-DROP],pch=if(outline) 21 else 16, + col=if(outline) par()$fg else node.cols[-DROP], + bg=if(outline) node.cols[-DROP] else NULL, + cex=c(rep(cex[2],N),rep(cex[1],obj$Nnode-length(DROP)))) + } else { + points(xx,yy,pch=if(outline) 21 else 16, + col=if(outline) par()$fg else node.cols, + bg=if(outline) node.cols else NULL, + cex=c(rep(cex[2],N),rep(cex[1],obj$Nnode))) + } if(legend){ if(is.logical(legend)) legend<-0.5*max(H) if(length(leg.txt)==1) @@ -250,6 +258,7 @@ plot.contMap<-function(x,...){ ## S3 print method for object of class 'contMap' ## written by Liam J. Revell 2013 + print.contMap<-function(x,digits=6,...){ cat("Object of class \"contMap\" containing:\n\n") cat(paste("(1) A phylogenetic tree with ",length(x$tree$tip.label)," tips and ",x$tree$Nnode," internal nodes.\n\n",sep="")) @@ -258,6 +267,7 @@ print.contMap<-function(x,digits=6,...){ ## drop tips from an object of class 'contMap' ## written by Liam J. Revell 2014, 2023 + drop.tip.contMap<-function(phy,tip,...){ if(!inherits(phy,"contMap")) cat("phy should be an object of class \"contMap\"\n") else { @@ -268,6 +278,7 @@ drop.tip.contMap<-function(phy,tip,...){ ## add error bars to contMap plot ## written by Liam J. Revell 2017 + errorbar.contMap<-function(obj,...){ if(hasArg(x)) x<-list(...)$x else x<-setNames(sapply(1:Ntip(obj$tree),function(x,obj){ diff --git a/R/phenogram.R b/R/phenogram.R index d5bb8329..3412f61d 100644 --- a/R/phenogram.R +++ b/R/phenogram.R @@ -1,5 +1,5 @@ ## function creates a phenogram (i.e., 'traitgram') -## written by Liam J. Revell 2011, 2012, 2013, 2014, 2015, 2016, 2020, 2021 +## written by Liam J. Revell 2011, 2012, 2013, 2014, 2015, 2016, 2020, 2021, 2024 phenogram<-function(tree,x,fsize=1.0,ftype="reg",colors=NULL,axes=list(),add=FALSE,...){ ## get optional arguments @@ -54,6 +54,8 @@ phenogram<-function(tree,x,fsize=1.0,ftype="reg",colors=NULL,axes=list(),add=FAL else cex.lab<-par()$cex.lab if(hasArg(las)) las<-list(...)$las else las<-par()$las + if(hasArg(Axes)) Axes<-list(...)$Axes + else Axes<-TRUE ## end optional arguments # check tree if(!inherits(tree,"phylo")) stop("tree should be an object of class \"phylo\".") @@ -68,10 +70,15 @@ phenogram<-function(tree,x,fsize=1.0,ftype="reg",colors=NULL,axes=list(),add=FAL x[1:length(tree$tip)]<-x[tree$tip.label] names(x)[1:length(tree$tip)]<-1:length(tree$tip) X<-matrix(x[as.character(tree$edge)],nrow(tree$edge),ncol(tree$edge)) - # legacy 'axes' argument trumps ylim & xlim from optional (...) - if(is.null(axes$trait)&&is.null(ylim)) ylim<-c(min(x),max(x)) - else if(!is.null(axes$trait)) ylim<-axes$trait - if(!is.null(axes$time)) xlim<-axes$time + ## legacy 'axes' argument trumps ylim & xlim from optional (...) + if(is.logical(axes)){ + Axes<-axes + if(is.null(ylim)) ylim<-c(min(x),max(x)) + } else { + if(is.null(axes$trait)&&is.null(ylim)) ylim<-c(min(x),max(x)) + else if(!is.null(axes$trait)) ylim<-axes$trait + if(!is.null(axes$time)) xlim<-axes$time + } if(!add&&is.null(xlim)){ pp<-par("pin")[1] sw<-fsize*(max(strwidth(tree$tip.label,units="inches")))+ @@ -153,8 +160,9 @@ phenogram<-function(tree,x,fsize=1.0,ftype="reg",colors=NULL,axes=list(),add=FAL } } } - if(!add){ - at<-round(0:(nticks-1)*max(H)/(nticks-1),digits) + if(!add&&Axes){ + at<-pretty(round(0:(nticks-1)*max(H)/(nticks-1),digits)) + at<-at[which(at<=max(H))] axis(1,at=at,cex.axis=cex.axis,cex.lab=cex.lab,las=las) axis(2,cex.axis=cex.axis,cex.lab=cex.lab,las=las) title(xlab=xlab,ylab=ylab,main=main,sub=sub) From 63c07a99a1cd7dbcfdf70cf0c5dfdc2ddf3d6a87 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Sat, 16 Mar 2024 19:36:38 -0400 Subject: [PATCH 47/51] increment subversion number --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index ebd5afe9..2fc230ec 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: phytools -Version: 2.2-0 -Date: 2024-02-28 +Version: 2.2-1 +Date: 2024-03-11 Title: Phylogenetic Tools for Comparative Biology (and Other Things) Author: Liam J. Revell Maintainer: Liam J. Revell From 107b0b3c8415fc11b72f104cfae2ce49fc010f87 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Thu, 28 Mar 2024 23:20:44 -0400 Subject: [PATCH 48/51] new function plotFanTree.wTraits --- R/plotFanTree.wTraits.R | 83 ++++++++++++++++++++++++++++++++++++++ man/plotTree.datamatrix.Rd | 41 +++++++++++++++++-- 2 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 R/plotFanTree.wTraits.R diff --git a/R/plotFanTree.wTraits.R b/R/plotFanTree.wTraits.R new file mode 100644 index 00000000..91517250 --- /dev/null +++ b/R/plotFanTree.wTraits.R @@ -0,0 +1,83 @@ +## plot fan or arc tree with trait data + +plotFanTree.wTraits<-function(tree,X,type=c("arc","fan"),...){ + X<-if(is.vector(X)) as.matrix(X[tree$tip.label]) else + X[tree$tip.label,] + h<-max(nodeHeights(tree)) + d<-min(ncol(X)*0.07*h,h) + type<-type[1] + if(!(type%in%c("arc","fan"))) type<-"fan" + ftype<-if(hasArg(ftype)) list(...)$ftype else "i" + fsize<-if(hasArg(fsize)) list(...)$fsize else 0.5 + part<-if(hasArg(part)) list(...)$part else + min(0.99,(Ntip(tree)-2)/Ntip(tree)) + arc_height<-if(hasArg(arc_height)) list(...)$arc_height else + 0.7 + spacer<-if(hasArg(spacer)) list(...)$spacer else 0.025 + spacer<-spacer*(2*pi*part/(Ntip(tree)-1))/2 + xlim<-if(hasArg(xlim)) list(...)$xlim else NULL + ylim<-if(hasArg(ylim)) list(...)$ylim else NULL + if(hasArg(colors)) colors<-list(...)$colors + else { + colors<-list() + for(i in 1:ncol(X)){ + if(is.numeric(X[,i])){ + colors[[i]]<-setNames(hcl.colors(n=100),1:100) + } else { + if(!is.factor(X[,i])) X[,i]<-as.factor(X[,i]) + colors[[i]]<-setNames( + palette.colors(n=length(levels(X[,i]))), + levels(X[,i])) + } + } + } + tt<-uu<-force.ultrametric(tree,method="extend",message=FALSE) + tt$edge.length[which(tt$edge[,2]<=Ntip(tt))]<- + tt$edge.length[which(tt$edge[,2]<=Ntip(tt))]+d + plotTree(tt,type=type,ftype=ftype,fsize=fsize, + part=part,color="transparent", + arc_height=arc_height*h/max(nodeHeights(tt)), + xlim=xlim,ylim=ylim) + pp<-get("last_plot.phylo",envir=.PlotPhyloEnv) + outer_rad<-max(pp$xx) + plotTree(uu,type=type,ftype="off",part=part, + lwd=1,add=TRUE,xlim=pp$x.lim,ylim=pp$y.lim, + arc_height=arc_height,ftype="off",color="#D3D3D3") + pp<-get("last_plot.phylo",envir=.PlotPhyloEnv) + inner_rad<-max(pp$xx) + par(lty="solid") + plotTree(tree,type=type,ftype="off",part=part, + lwd=1,add=TRUE,xlim=pp$x.lim,ylim=pp$y.lim, + arc_height=arc_height,ftype="off") + par(lend=3) + for(i in 1:ncol(X)){ + if(is.numeric(X[,i])){ + x_seq<-seq(min(X[,i]),max(X[,i]),length.out=100) + x_ind<-sapply(X[,i],function(x,y) which.min((x-y)^2), + y=x_seq) + colors[[i]]<-colorRampPalette(colors[[i]])(n=100) + cols<-colors[[i]][x_ind] + } else { + cols<-colors[[i]][X[tree$tip.label,i]] + } + for(j in 1:Ntip(tree)){ + start<-if(pp$xx[j]>0) + (i-1)*(d/ncol(X))+(2/7)*(d/ncol(X)) else + -((i-1)*(d/ncol(X))+(2/7)*(d/ncol(X))) + end<-if(pp$xx[j]>0) i*d/ncol(X) else -i*d/ncol(X) + th<-atan(pp$yy[j]/pp$xx[j]) + theta<-(2*pi*part/(Ntip(tree)-1))/2-spacer + sign<-if(pp$xx[j]>0) 1 else -1 + H1<-(sign*inner_rad+start)/cos(theta) + H2<-(sign*inner_rad+end)/cos(theta) + th_up<-th+theta + th_down<-th-theta + x<-c(H1*cos(th_down),H2*cos(th_down), + H2*cos(th_up),H1*cos(th_up)) + y<-c(H1*sin(th_down),H2*sin(th_down), + H2*sin(th_up),H1*sin(th_up)) + polygon(x,y,col=cols[j],border=FALSE) + } + } + invisible(colors) +} \ No newline at end of file diff --git a/man/plotTree.datamatrix.Rd b/man/plotTree.datamatrix.Rd index f45ac8ed..254482ce 100644 --- a/man/plotTree.datamatrix.Rd +++ b/man/plotTree.datamatrix.Rd @@ -1,19 +1,24 @@ \name{plotTree.datamatrix} \alias{plotTree.datamatrix} -\title{Plot a tree with a discrete character data matrix at the tips} +\alias{plotFanTree.wTraits} +\title{Plot a tree with a discrete (or continuous) character data matrix at the tips} \usage{ plotTree.datamatrix(tree, X, ...) +plotFanTree.wTraits(tree, X, type=c("arc","fan"), ...) } \arguments{ \item{tree}{an object of class \code{"phylo"}.} - \item{X}{a data frame with columns as factors.} + \item{X}{a data frame with columns as factors for \code{plotTree.datamatrix}, or a matrix of data frame containing continuous and/or discrete characters for \code{plotFanTree.wTraits}.} + \item{type}{plot type for \code{plotFanTree.wTraits}.} \item{...}{optional arguments.} } \description{ - Plots a phylogeny next to a matrix of discrete character data. + \code{plotTree.datamatrix} plots a phylogeny next to a matrix of discrete characters. \code{plotFanTree.wTraits} plots an arc or fan style tree with discrete or continuous data at the tips. } \value{ - Invisibly returns a list containing the font size, a list of the colors used for each column of the plotted data matrix, and the x-coordinate of the rightmost edge of the matrix. + \code{plotTree.datamatrix} invisibly returns a list containing the font size, a list of the colors used for each column of the plotted data matrix, and the x-coordinate of the rightmost edge of the matrix. + + \code{plotFanTree.wTraits} invisibly returns the color palette used for plotting. } \references{ Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). \emph{PeerJ}, \bold{12}, e16505. @@ -22,6 +27,34 @@ plotTree.datamatrix(tree, X, ...) \seealso{ \code{\link{dotTree}}, \code{\link{phylo.heatmap}} } +\examples{ +data("liolaemid.data") +data("liolaemid.tree") +liolaemid.data[liolaemid.tree$tip.label,]->liolaemid.data +colors<-list( + c("blue","white","red"), + terrain.colors(n=10), + setNames(c("#F0EAD6","#DF536B"),c("O","V"))) +cols<-plotFanTree.wTraits(liolaemid.tree, + liolaemid.data[,3:1],lwd=12,colors=colors,ftype="off", + spacer=0) +legend(x=0,y=0.7*max(nodeHeights(liolaemid.tree)), + names(colors[[3]]),lwd=8,col=colors[[3]], + title="parity mode",bty="n",xjust=0.5,yjust=0.5) +add.color.bar(1.5*max(nodeHeights(liolaemid.tree)),cols[[2]], + title="maximum altitude (m)", + lims=range(liolaemid.data[,2]),digits=2,prompt=FALSE, + x=-0.75*max(nodeHeights(liolaemid.tree)), + y=0.2*max(nodeHeights(liolaemid.tree)),subtitle="", + lwd=8,outline=FALSE) +add.color.bar(1.5*max(nodeHeights(liolaemid.tree)),cols[[1]], + title="environmental temp.", + lims=range(liolaemid.data[,3]),digits=2,prompt=FALSE, + x=-0.75*max(nodeHeights(liolaemid.tree)), + y=-0.15*max(nodeHeights(liolaemid.tree)),subtitle="", + lwd=8,outline=FALSE) +par(mar=c(5.1,4.1,4.1,2.1)) ## reset margins to default +} \keyword{phylogenetics} \keyword{plotting} \keyword{comparative method} From 5b8e0607eb226dcc2fd3effde9798ad3d40017cb Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Thu, 28 Mar 2024 23:21:11 -0400 Subject: [PATCH 49/51] increment version number --- DESCRIPTION | 4 ++-- NAMESPACE | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2fc230ec..3628404b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: phytools -Version: 2.2-1 -Date: 2024-03-11 +Version: 2.2-2 +Date: 2024-03-28 Title: Phylogenetic Tools for Comparative Biology (and Other Things) Author: Liam J. Revell Maintainer: Liam J. Revell diff --git a/NAMESPACE b/NAMESPACE index 892c7bfd..f95388f0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -39,7 +39,7 @@ export(phyloDesign, phylomorphospace, phylomorphospace3d, phyloScattergram, phyl export(plot.anc.Bayes, plot.ancr, plot.changesMap, plot.contMap, plot.cophylo, plot.densityMap) export(plot.edge.widthMap, plot.fitMk, plot.fitPagel, plot.gfit, plot.phyl.RMA) export(plot.phylo.to.map, plot.Qmatrix, plot.simBMphylo, plotBranchbyTrait, plot.phylosig) -export(plotSimmap, plotThresh, plotTree, plotTree.barplot, plotTree.boxplot) +export(plotFanTree.wTraits, plotSimmap, plotThresh, plotTree, plotTree.barplot, plotTree.boxplot) export(plotTree.datamatrix, plotTree.errorbars, plotTree.lollipop, plotTree.singletons, plotTree.splits) export(plotTree.wBars, posterior.evolrate, posthoc, posthoc.ratebytree, print.Qmatrix) export(project.phylomorphospace, pscore) From 87b5b32674f294549d4b1f1ffc9f9530fd090473 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Wed, 3 Apr 2024 11:31:00 -0400 Subject: [PATCH 50/51] make sure dim doesn't get dropped --- R/plotFanTree.wTraits.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/plotFanTree.wTraits.R b/R/plotFanTree.wTraits.R index 91517250..abd8e01c 100644 --- a/R/plotFanTree.wTraits.R +++ b/R/plotFanTree.wTraits.R @@ -2,7 +2,7 @@ plotFanTree.wTraits<-function(tree,X,type=c("arc","fan"),...){ X<-if(is.vector(X)) as.matrix(X[tree$tip.label]) else - X[tree$tip.label,] + X[tree$tip.label,,drop=FALSE] h<-max(nodeHeights(tree)) d<-min(ncol(X)*0.07*h,h) type<-type[1] From 544c3c597f9849a7484698b78b1a0b42f4874372 Mon Sep 17 00:00:00 2001 From: "Liam J. Revell" Date: Wed, 3 Apr 2024 11:31:21 -0400 Subject: [PATCH 51/51] increment subversion number --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3628404b..cfa0c9a1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: phytools -Version: 2.2-2 -Date: 2024-03-28 +Version: 2.2-3 +Date: 2024-04-03 Title: Phylogenetic Tools for Comparative Biology (and Other Things) Author: Liam J. Revell Maintainer: Liam J. Revell