[Picante-commits] r209 - in pkg: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Feb 8 23:26:08 CET 2010
Author: skembel
Date: 2010-02-08 23:26:07 +0100 (Mon, 08 Feb 2010)
New Revision: 209
Added:
pkg/R/evol.distinct.R
pkg/R/get.nodes.R
pkg/R/node.desc.R
pkg/R/node.number.R
pkg/R/tax.distinctiveness.R
pkg/man/evol.distinct.Rd
pkg/man/get.nodes.Rd
pkg/man/node.desc.Rd
pkg/man/node.number.Rd
pkg/man/tax.distinctiveness.Rd
Modified:
pkg/DESCRIPTION
pkg/man/picante-package.Rd
Log:
Merging Will's code into trunk
Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION 2009-11-20 05:28:30 UTC (rev 208)
+++ pkg/DESCRIPTION 2010-02-08 22:26:07 UTC (rev 209)
@@ -1,10 +1,10 @@
Package: picante
Type: Package
Title: R tools for integrating phylogenies and ecology
-Version: 0.7-2
-Date: 2009-10-27
-Author: Steven Kembel <skembel at uoregon.edu>, David Ackerly <dackerly at berkeley.edu>, Simon Blomberg <s.blomberg1 at uq.edu.au>, Peter Cowan <pdc at berkeley.edu>, Matthew Helmus <mrhelmus at wisc.edu>, Helene Morlon <morlon.helene at gmail.com>, Campbell Webb <cwebb at oeb.harvard.edu>
-Maintainer: Steven Kembel <skembel at uoregon.edu>
+Version: 0.8-0
+Date: 2010-2-8
+Author: Steven W. Kembel <skembel at uoregon.edu>, David D. Ackerly <dackerly at berkeley.edu>, Simon P. Blomberg <s.blomberg1 at uq.edu.au>, Peter D. Cowan <pdc at berkeley.edu>, Matthew R. Helmus <mrhelmus at wisc.edu>, Helene Morlon <morlon.helene at gmail.com>, Campbell O. Webb <cwebb at oeb.harvard.edu>
+Maintainer: Steven W. Kembel <skembel at uoregon.edu>
Depends: ape, vegan, nlme
Suggests: brglm, circular, quantreg
Description: Phylocom integration, community analyses, null-models, traits and evolution in R
Copied: pkg/R/evol.distinct.R (from rev 208, branches/will/R/evol.distinct.R)
===================================================================
--- pkg/R/evol.distinct.R (rev 0)
+++ pkg/R/evol.distinct.R 2010-02-08 22:26:07 UTC (rev 209)
@@ -0,0 +1,56 @@
+#Evolutionary distinctiveness by:
+#a) equal splits (Redding and Mooers 2006)
+#b) fair proportions (Isaac et al., 2007)
+#The scale option refers to whether or not the phylogeny should be scaled to a depth of 1 or, in the case of an ultrametric tree, scaled such that branch lengths are relative.
+#If use.branch.lengths=FALSE, then all branch lengths are changed to 1.
+
+evol.distinct<- function(tree, type=c("equal.splits", "fair.proportion"), scale=FALSE, use.branch.lengths=TRUE){
+
+if(is.rooted(tree)==FALSE)
+warning("A rooted phylogeny is required for meaningful output of this function", call.=FALSE)
+
+if(scale==TRUE){
+#Scale tree to have unit depth (for an ultrametric tree) or scale all branches to unit length (for an additive tree)
+
+if(is.ultrametric(tree)==TRUE)
+tree$edge.length<- tree$edge.length/(as.numeric(branching.times(tree)[1])) else
+tree$edge.length<- tree$edge.length/sum(tree$edge.length)
+}
+
+if(use.branch.lengths==FALSE)
+tree$edge.length<- rep(1, length(tree$edge.length))
+
+
+for(i in 1:length(tree$tip.label)){
+ spp<- tree$tip.label[i]
+ nodes<- get.nodes(tree, spp)
+ #get rid of root node
+ nodes<- nodes[1:(length(nodes)-1)]
+
+ internal.brlen<- tree$edge.length[which(tree$edge[,2] %in% nodes)]
+
+#apportion internal branch lengths appropriately
+if(length(internal.brlen)!=0){
+internal.brlen<- internal.brlen*switch(type,
+ "equal.splits"= sort(rep(.5,length(internal.brlen))^c(1:length(internal.brlen))),
+ "fair.proportion"= 1/for(j in 1:length(nodes)){
+ sons<-node.desc(tree, nodes[j])
+ n.descendents<- length(sons$tips)
+ if(j==1)
+ portion<- n.descendents else
+ portion<- c(n.descendents, portion)
+ })}
+
+ #sum internal branch lengths with the pendant edge
+ ED<- sum(internal.brlen, tree$edge.length[which.edge(tree, spp)])
+
+ if(i==1)
+ w<- ED else
+ w<- c(w, ED)
+ }
+results<- cbind(tree$tip.label, as.data.frame(w))
+names(results)<- c("Species", "w")
+results
+
+ }
+
\ No newline at end of file
Copied: pkg/R/get.nodes.R (from rev 208, branches/will/R/get.nodes.R)
===================================================================
--- pkg/R/get.nodes.R (rev 0)
+++ pkg/R/get.nodes.R 2010-02-08 22:26:07 UTC (rev 209)
@@ -0,0 +1,15 @@
+#GET.NODES FUNCTION
+#Get a vector of the nodes that are along the path from the root to spp x. This may then be used to determine the number of nodes between the root and the tip (see node.number function) or the length of this path.
+
+
+get.nodes<- function(tree, spp){
+ edge<- which.edge(tree, spp)
+ nodes<- tree$edge[edge,1]
+ root.edge<- which(tree$edge[,1]==(length(tree$tip.label)+1))
+while(!(edge %in% root.edge)){
+ edge<- which.edge(tree, tree$edge[edge,1])
+ next.node<- tree$edge[edge,1]
+ nodes<- c(nodes, next.node)
+ }
+ nodes
+ }
\ No newline at end of file
Copied: pkg/R/node.desc.R (from rev 208, branches/will/R/node.desc.R)
===================================================================
--- pkg/R/node.desc.R (rev 0)
+++ pkg/R/node.desc.R 2010-02-08 22:26:07 UTC (rev 209)
@@ -0,0 +1,29 @@
+
+#modified from a function by Walton Green, Gene Hunt, Scott Wing
+#found at http://bricol.net/research/extinctmodel/Rfunctions/lop.R
+node.desc<- function(tr, node)
+# returns vector of decendents for a particular node
+{
+ ee<- tr$edge
+ nT<- length(tr$tip.label)
+ nN<- tr$Nnode
+ d.tips<- numeric()
+ d.nodes<- numeric()
+
+ desc<- ee[ee[,1]==node,2]
+ #print (desc)
+ d.tips<- append(d.tips, desc[desc<=nT])
+ d.nodes<- append(d.nodes, desc[desc>nT])
+
+ if (node<=nT) d.tips<- node
+ else{
+ while(!all(desc<=nT)) # true if some desc are nodes not tips
+ {
+ desc<- ee[ee[,1] %in% desc,2]
+ #print(desc)
+ d.tips<- append(d.tips, desc[desc<=nT])
+ d.nodes<- append(d.nodes, desc[desc>nT])
+ }
+ }
+ return(list(tips=d.tips, nodes=d.nodes, node.label=node))
+}
\ No newline at end of file
Copied: pkg/R/node.number.R (from rev 208, branches/will/R/node.number.R)
===================================================================
--- pkg/R/node.number.R (rev 0)
+++ pkg/R/node.number.R 2010-02-08 22:26:07 UTC (rev 209)
@@ -0,0 +1,15 @@
+#NODE.NUMBER FUNCTION
+#get the number of internal nodes for each spp
+
+node.number<- function(tree){
+ for(i in 1:length(tree$tip.label)){
+ spp<- tree$tip.label[i]
+ n.node<- length(get.nodes(tree, spp))
+ if(i==1)
+ n.node.all<- n.node else
+ n.node.all<- c(n.node.all, n.node)
+ }
+n.node.all<- cbind(tree$tip.label, as.data.frame(n.node.all))
+names(n.node.all)<- c("Species", "n.Nodes")
+n.node.all<- n.node.all
+}
\ No newline at end of file
Copied: pkg/R/tax.distinctiveness.R (from rev 208, branches/will/R/tax.distinctiveness.R)
===================================================================
--- pkg/R/tax.distinctiveness.R (rev 0)
+++ pkg/R/tax.distinctiveness.R 2010-02-08 22:26:07 UTC (rev 209)
@@ -0,0 +1,28 @@
+#Taxic diversity: Vane-Wright et al., 1991 and May 1990 which accounts for polytomies by counting the number of branches descending from each node that lies on the path from a spp tip to the root (not just counting the number of nodes.
+
+tax.distinctiveness<- function(tree, type=c("Vane-Wright", "May")){
+
+if(is.rooted(tree)==FALSE)
+warning("A rooted phylogeny is required for meaningful output of this function", call.=FALSE)
+
+n.nodes<- switch(type, "Vane-Wright"=node.number(tree),
+ "May"={edge<- tree$edge
+
+ for(i in 1:length(tree$tip.label)){
+ spp<- tree$tip.label[i]
+ nodes<- get.nodes(tree, spp)
+ n.branch<- nrow(edge[edge[,1] %in% nodes,])
+ if(i==1)
+ n.branch.all<- n.branch else
+ n.branch.all<- c(n.branch.all, n.branch)}
+ n.nodes<- cbind(tree$tip.label, as.data.frame(n.branch.all))
+ })
+
+ w<- as.data.frame(1/n.nodes[,2])/sum(1/n.nodes[,2])
+ results<- cbind(tree$tip.label, w)
+ names(results)<- c("Species", "w")
+ results
+}
+
+
+
Copied: pkg/man/evol.distinct.Rd (from rev 208, branches/will/man/evol.distinct.Rd)
===================================================================
--- pkg/man/evol.distinct.Rd (rev 0)
+++ pkg/man/evol.distinct.Rd 2010-02-08 22:26:07 UTC (rev 209)
@@ -0,0 +1,54 @@
+\name{evol.distinct}
+\Rdversion{1.1}
+\alias{evol.distinct}
+%- Also NEED an '\alias' for EACH other topic documented here.
+
+\title{
+Species' evolutionary distinctiveness
+}
+\description{
+Calculates evolutionary distinctiveness measures for a suite of species by: a) equal splits (Redding and Mooers 2006) b) fair proportions (Isaac et al., 2007). Returns a datafram with species identifiers and species scores.
+}
+\usage{
+evol.distinct(tree, type = c("equal.splits", "fair.proportion"), scale = FALSE, use.branch.lengths = TRUE)
+}
+%- maybe also 'usage' for other objects documented here.
+\arguments{
+ \item{tree}{
+an object of class phylo}
+ \item{type}{
+a) equal splits (Redding and Mooers 2006) or b) fair proportions (Isaac et al., 2007)
+}
+ \item{scale}{
+The scale option refers to whether or not the phylogeny should be scaled to a depth of 1 or, in the case of an ultrametric tree, scaled such that branch lengths are relative.
+}
+ \item{use.branch.lengths}{
+If use.branch.lengths=FALSE, then all branch lengths are changed to 1.
+}
+}
+
+\references{
+Redding, D.W. and Mooers, A.O. (2006). Incorporating evolutionary measures into conservation
+prioritisation. Conservation Biology, 20, 1670-1678.
+
+Isaac, N.J.B., Turvey, S.T., Collen, B., Waterman, C. and Baillie, J.E.M. (2007). Mammals on
+the EDGE: conservation priorities based on threat and phylogeny. PLoS ONE, 2, e296.
+
+Mark Vellend, William K. Cornwell, Karen Magnuson-Ford, and Arne Mooers. Measuring phylogenetic biodiversity
+In: Biological diversity: frontiers in measurement and assessment. Edited by Anne Magurran and Brian McGill. in press
+}
+
+\author{
+Karen Magnuson-Ford
+Will Cornwell
+Arne Mooers
+Mark Vellend
+}
+
+\note{
+This function will return a vector of evolutionary distinctivenss for every species in the given tree.
+If only a subset of values are needed there are two, concetually distinct options: either prune the tree first and then pass the tree in or subset the resulting vector. These two options
+will provide very different outputs.
+}
+
+
Copied: pkg/man/get.nodes.Rd (from rev 208, branches/will/man/get.nodes.Rd)
===================================================================
--- pkg/man/get.nodes.Rd (rev 0)
+++ pkg/man/get.nodes.Rd 2010-02-08 22:26:07 UTC (rev 209)
@@ -0,0 +1,33 @@
+\name{get.nodes}
+\Rdversion{1.1}
+\alias{get.nodes}
+%- Also NEED an '\alias' for EACH other topic documented here.
+\title{
+gets nodes along the evolutionary path to a given species
+}
+\description{
+Get a vector of the nodes that are along the path from the root to spp x. Used in other functions.
+}
+\usage{
+get.nodes(tree, spp)
+}
+%- maybe also 'usage' for other objects documented here.
+\arguments{
+ \item{tree}{
+APP tree
+}
+ \item{spp}{
+specific species; same format as which.edge in the APE library
+}
+}
+
+
+\author{
+Karen Magnuson-Ford
+Will Cornwell
+Arne Mooers
+Mark Vellend
+}
+
+
+
Copied: pkg/man/node.desc.Rd (from rev 208, branches/will/man/node.desc.Rd)
===================================================================
--- pkg/man/node.desc.Rd (rev 0)
+++ pkg/man/node.desc.Rd 2010-02-08 22:26:07 UTC (rev 209)
@@ -0,0 +1,30 @@
+\name{node.desc}
+\Rdversion{1.1}
+\alias{node.desc}
+\title{
+Descendants of a particular node
+}
+\description{
+Finds the descendants from a particular node
+}
+\usage{
+node.desc(tr, node)
+}
+%- maybe also 'usage' for other objects documented here.
+\arguments{
+ \item{tr}{
+an object of class phylo
+}
+ \item{node}{
+node number
+}
+}
+
+
+\note{
+utility function. modified from node.sons from Walton Green, Gene Hunt, Scott Wing
+This function could easily be hidden for simplicity's sake.
+
+}
+
+
Copied: pkg/man/node.number.Rd (from rev 208, branches/will/man/node.number.Rd)
===================================================================
--- pkg/man/node.number.Rd (rev 0)
+++ pkg/man/node.number.Rd 2010-02-08 22:26:07 UTC (rev 209)
@@ -0,0 +1,29 @@
+\name{node.number}
+\Rdversion{1.1}
+\alias{node.number}
+%- Also NEED an '\alias' for EACH other topic documented here.
+\title{
+get number of internal nodes for each species
+}
+\description{
+get the number of internal nodes for each spp
+}
+\usage{
+node.number(tree)
+}
+%- maybe also 'usage' for other objects documented here.
+\arguments{
+ \item{tree}{
+APE phylogeny
+}
+}
+
+
+\author{
+Will Cornwell
+}
+\note{
+function for internal use
+}
+
+
Modified: pkg/man/picante-package.Rd
===================================================================
--- pkg/man/picante-package.Rd 2009-11-20 05:28:30 UTC (rev 208)
+++ pkg/man/picante-package.Rd 2010-02-08 22:26:07 UTC (rev 209)
@@ -12,14 +12,13 @@
\tabular{ll}{
Package: \tab picante\cr
Type: \tab Package\cr
-Version: \tab 0.7-2\cr
-Date: \tab 2009-10-27\cr
+Version: \tab 0.8-0\cr
+Date: \tab 2009-2-8\cr
License: \tab GPL-2\cr
}
}
\author{
-Steven Kembel <skembel at uoregon.edu>, David Ackerly <dackerly at berkeley.edu>, Simon Blomberg <s.blomberg1 at uq.edu.au>, Peter Cowan <pdc at berkeley.edu>, Matthew Helmus <mrhelmus at wisc.edu>, Helene Morlon <morlon.helene at gmail.com>, Campbell Webb <cwebb at oeb.harvard.edu>
-
-Maintainer: Steven Kembel <skembel at uoregon.edu>
+Author: Steven W. Kembel <skembel at uoregon.edu>, David D. Ackerly <dackerly at berkeley.edu>, Simon P. Blomberg <s.blomberg1 at uq.edu.au>, Peter D. Cowan <pdc at berkeley.edu>, Matthew R. Helmus <mrhelmus at wisc.edu>, Helene Morlon <morlon.helene at gmail.com>, Campbell O. Webb <cwebb at oeb.harvard.edu>
+Maintainer: Steven W. Kembel <skembel at uoregon.edu>
}
\keyword{package}
Copied: pkg/man/tax.distinctiveness.Rd (from rev 208, branches/will/man/tax.distinctiveness.Rd)
===================================================================
--- pkg/man/tax.distinctiveness.Rd (rev 0)
+++ pkg/man/tax.distinctiveness.Rd 2010-02-08 22:26:07 UTC (rev 209)
@@ -0,0 +1,42 @@
+\name{tax.distinctiveness}
+\Rdversion{1.1}
+\alias{tax.distinctiveness}
+%- Also NEED an '\alias' for EACH other topic documented here.
+\title{
+Taxonomic distinctiveness sensu Vane-Wright or May
+}
+\description{
+Taxic diversity: Vane-Wright et al., 1991 and May 1990 which accounts for polytomies by counting the number of branches descending from each node that lies on the path from a spp tip to the root (not just counting the number of nodes).
+}
+\usage{
+tax.distinctiveness(tree, type = c("Vane-Wright", "May"))
+}
+%- maybe also 'usage' for other objects documented here.
+\arguments{
+ \item{tree}{
+an object of class phylo
+}
+ \item{type}{
+specify "Vane-Wright" or "May"
+}
+}
+
+
+\references{
+Vane-Wright, R.I., Humphries, C.J. and Williams, P.H. (1991). What to protect? - Systematics
+and the agony of choice. Biological Conservation, 55, 235-254.
+
+May, R.M. (1990). Taxonomy as destiny. Nature, 347, 129-130.
+
+Mark Vellend, William K. Cornwell, Karen Magnuson-Ford, and Arne Mooers. Measuring phylogenetic biodiversity
+In: Biological diversity: frontiers in measurement and assessment.
+Edited by Anne Magurran and Brian McGill. in press
+}
+
+\author{
+Karen Magnuson-Ford
+Will Cornwell
+Arne Mooers
+Mark Vellend
+}
+
More information about the Picante-commits
mailing list