/packages/archive/2010/04.2010/04.29.2010/spacodi/man/spacodi.matrices.Rd

http://github.com/eastman/spacodiR · Unknown · 82 lines · 65 code · 17 blank · 0 comment · 0 complexity · 59f74500241704fbc3be0e4db5bd72ee MD5 · raw file

  1. \name{spacodi.matrices}
  2. \alias{spacodi.matrices}
  3. \title{generating pairwise-distance matrices of phylogenetic diversity: Ist, Pst, Bst, and PIst}
  4. \description{
  5. This function automates the process of pairwise computation of measures of phylogenetic (or trait)
  6. diversity between all plots of a dataset. Average measures of diversity, from each plot to every other,
  7. are assembled into a distance matrix for use in downstream analyses (e.g., Mantel tests).
  8. }
  9. \usage{spacodi.matrices(sp.plot, phy = NULL, sp.traits = NULL)}
  10. \arguments{
  11. \item{sp.plot}{a community-phylogenetic dataset in \code{SPACoDi} format (see \code{\link{as.spacodi}})}
  12. \item{phy}{a fully resolved phylogenetic tree, most sensibly ultrametric}
  13. \item{sp.traits}{a species-by-trait(s) dataframe}
  14. }
  15. \details{
  16. Either (but not both) a \code{phy} or \code{sp.traits} object is to be supplied along with the community dataset, \code{sp.plot}.
  17. If a tree is given, pairwise values for \code{Ist}, \code{Pst}, \code{Bst}, \code{PIst} are estimated for every
  18. pair of unique plots using \code{\link{spacodi.calc}}. If fewer than two species are sampled for
  19. particular plots, these plots are dynamically removed from the dataset (as phylogenetic diversities are
  20. incalculable in such cases). Analogously, matrices of pairwise \code{Ist}, \code{Tst}, \code{T*st}, \code{TAUst} are generated
  21. if a traits matrix is supplied.
  22. }
  23. \value{A list of four distance matrices (the following measures are further explained in the \code{\link{spacodi.calc}} documentation):
  24. \itemize{
  25. \item{\code{Ist}}{: a distance matrix of average species turnover between plots}
  26. \item{\code{Pst}}{: a distance matrix of average phylogenetic+species turnover between plots}
  27. \item{\code{Bst}}{: a distance matrix of average phylogenetic turnover between plots}
  28. \item{\code{PIst}}{: a distance matrix of \code{Pst}s, for presence | absence of species in plots}
  29. }
  30. See \code{\link{as.spacodi}} for the trait-based analogues of these measures.
  31. }
  32. \references{
  33. HARDY OJ and B SENTERRE. 2007. Characterizing the
  34. phylogenetic structure of communities by an additive partitioning of
  35. phylogenetic diversity. Journal of Ecology 95:493-506.
  36. }
  37. \author{Jonathan Eastman}
  38. \seealso{\code{\link{spacodi.calc}} for interpretation of results; see \code{\link[vegan]{mantel}} for
  39. statistical comparison of dissimilarity matrices}
  40. \examples{
  41. # load a community data matrix, along with a tree
  42. data(sp.example)
  43. attributes(sp.example)
  44. attach(sp.example)
  45. sp.plot
  46. sp.tree
  47. sp.traits
  48. # randomly generate an 'environmental' variable
  49. env.fake <- data.frame(runif(ncol(sp.plot)))
  50. names(env.fake) = "fake.env"
  51. row.names(env.fake)=names(sp.plot)
  52. e.f=dist(env.fake)
  53. # generate phylogenetic diversity matrices
  54. s.out=spacodi.matrices(sp.plot=sp.plot, phy=sp.tree)
  55. t.out=spacodi.matrices(sp.plot=sp.plot, sp.traits=sp.traits)
  56. # conduct Mantel tests, comparing pairwise distances between phylogenetic and environmental diversity
  57. for(ii in 1:length(s.out)) {
  58. print(paste("### a test of environmental variation and ", names(s.out)[ii], sep=""))
  59. print(mantel(e.f, s.out[[ii]]))
  60. }
  61. for(ii in 2:length(s.out)) {
  62. print(paste("### testing trait variation and phylogenetic diversity: ", names(s.out)[ii], " and ", names(t.out)[ii], sep=""))
  63. print(mantel(t.out[[ii]], s.out[[ii]]))
  64. }
  65. }