% \VignetteIndexEntry{pez-intro}
%\VignettePackage{pez}
%\VignetteEngine{knitr::knitr}
\documentclass[12pt]{article}
\usepackage{amssymb,amsmath}
\usepackage{geometry}
\geometry{letterpaper}
\usepackage{graphicx}
\usepackage{url}
\usepackage{natbib}
\usepackage{color} \definecolor{dark-gray}{gray}{0.3}
\usepackage[colorlinks=true,urlcolor=dark-gray,breaklinks,citecolor=black,linkcolor=black]{hyperref}
\bibliographystyle{besjournals}
\title{An introduction to \emph{pez}}
\author{WD Pearse, MW Cadotte, J Cavender-Bares, AR Ives,\\C Tucker, S Walker, \& MR Helmus}
\date{\today}

\begin{document}
\maketitle
\tableofcontents
<<include=FALSE>>=
require(pez)
options(width=40)
@ 
\section{Preamble}
You can install \emph{pez} by typing \texttt{install.packages("pez")},
and get a listing of the functions in the package by typing
\texttt{library(help=pez)}. If you find any bugs, or have any feature
requests for the package, please use
\href{http://github.com/willpearse/pez/issues}{the online
  tracker}. Indeed, please contribute to the package using at its
\href{http://github.com/willpearse/pez/issues}{GitHub site}---help is
always welcome! If you need help, please email the
\href{https://groups.google.com/forum/#!forum/pez_users}{user mailing
  list}, not one of the developers.

While \texttt{\emph{pez}} contains much novel code, it relies heavily
on the \emph{R} ecosystem. Much of the community phylogenetic metric
functions are wrappers around existing code (detailed in the help
files for each function); notably \emph{caper} \citep{Orme2013} and
\emph{picante} \citep{Kembel2010} but many others as well. Please cite
the authors of these packages in your publications so that their
hard-work is rewarded!

The functions within \emph{pez} are grouped into families; thus, while
there is no \texttt{pez.metric} function, there is a help-file with
this title that describes over thirty different functions. Looking for
the help file for each of these functions will take you to combined,
`overview' help-file.

Often, \emph{pez} functions will return warnings (and sometimes error
messages!) because certain metrics or methods are not appropriate for
the kinds of data you are working with. Indeed, you will see such
warnings in this vignette. These are not \emph{bugs}; one simply
cannot calculate some metrics without fully resolved phylogenies, and
some models do not make sense without certain kinds of data.
%\clearpage
\section{Data formats in \emph{pez}}
\emph{pez} functions work with \texttt{comparative.comm} objects
(\emph{comparative community ecology}). These are designed to help
keep phylogenies, community data matrices, species trait data, and
environmental data all in the same place in a format that makes it
easy to work with them. They're much less scary than they sound!

Below we load \emph{pez}, some example data that comes with it, and
then make a \texttt{comparative.comm} object. You can examine the
phylogeny (\texttt{tree}), community data (\texttt{comm}), and trait
data (\texttt{data}) that went into making dataset for yourself,
although all the data types are explained in more detail below. A
phylogeny and a community matrix are all you need to make a
\texttt{comparative.comm} object; everything else is optional. Below
we use the \citet{Helmus2014} dataset to show \emph{pez}'s features.

<<tidy=TRUE, size="small">>=
library(pez)
data(laja)
data <- comparative.comm(invert.tree, river.sites, invert.traits, river.env)
@

\emph{pez} is conservative; if you give it trait data for only half of
the species in your community data, the \texttt{comparative.comm}
object will only contain data on those species that have both trait
data and community data. The same goes for the phylogeny, and for
sites with environmental data. \emph{pez} will warn you about the loss
of species or traits when you print the object to screen, and while
it's making the comparative.comm object (unless you set the argument
\texttt{warn=FALSE}).

You can also subset your comparative.comm object to exclude certain
species or sites, in much the same way you can a
\texttt{data.frame}. Dropping a site that contained the only instance
of a species will remove it from dataset, and \emph{pez} will not warn
you about this unless you specify \texttt{[,,warn=TRUE]}.

<<tidy=TRUE, size="small">>=
site.subset <- data[1:5,]
spp.subset <- data[,1:3]
@

\emph{pez} makes it easier to work with and manipulate datasets. The
functions \texttt{species} and \texttt{sites} are safe ways of
manipulating all the parts of your data at the same time. For example:

<<tidy=TRUE, size="small">>=
species(data)[1:2]
species(data)[1:2] <- c("new", "names")
sites(data)[1:2] <- c("newer", "names")
data <- data[, colSums(data$comm) > 5]
traits(data)$new.trait <- rep("nonsense", nrow(traits(data)))
traits(data)$new.trait <- NULL
@ 

The final example above showed you can work with the internal
components of a \texttt{comparative.comm} to get things done quicker,
in this case removing all species that were only recorded five times
or fewer in the dataset. The help entry for \texttt{cc.manip} contains
more examples, and \texttt{plot.comparative.comm} is a quick plotting
tool. We have also provided the \texttt{comm},
\texttt{phy}(/\texttt{tree}), \texttt{traits}, and \texttt{env}
wrappers to examine and manipulate the community matrix, phylogeny,
trait data, and environmental data, slots in your
\texttt{comparative.comm} objects (\emph{e.g.}, \texttt{phy(data)}
would return your phylogeny). We give some examples above, and you can
find more in the help file for \texttt{cc.manip}. By using these
wrappers, as opposed to interacting directly with the slots in your
\texttt{comparative.comm} object, you ensure your species and sites
remain consistent across your data, and make your code a little easier
to read. Internally, your trait data are stored in the \texttt{data}
slot; this means that \texttt{comparative.comm} is compatible with the
\texttt{caper} package. Anything you can do in that (\emph{e.g.}, PGLS
regression, comparative modelling and simulation) can be done using
you data in \emph{pez} without modification.
%\clearpage
\section{Community phylogenetic metrics}
\emph{pez} splits community phylogenetic metrics into four functions
according to the scheme outlined by \citet{Pearse2014review}:
\texttt{pez.shape}, \texttt{pez.evenness}, \texttt{pez.dispersion},
and \texttt{pez.dissimilarity}. Shape metrics measure the structure of
a community phylogeny, while evenness metrics additionally incorporate
species abundances. Dispersion metrics examine whether phylogenetic
biodiversity in an assemblage differs from the expectation of random
assembly from a given set of species. Finally, dissimilarity measures
the pairwise difference in phylogenetic biodiversity between
assemblages.

You can calculate all metrics within a class at the same time (which
is what we recommend), or you can pick a particular one. The intention
is to make it easy to work with different community phylogenetic
metrics, since each captures a different part of the structure of your
data. Working with \texttt{shape}, \texttt{evenness}, and
\texttt{dispersion} metrics is exactly the same, so below we only show
\texttt{shape}.

<<tidy=TRUE, size="small">>=
shape.output <- pez.shape(data)
dim(shape.output)
shape.output[1:3,1:3]
@

Both \texttt{shape} and \texttt{evenness} metrics, by default, only
calculate the \texttt{all-quick} metrics; specifying
\texttt{metric='all'} will calculate slower metrics such as Pagel's
$\lambda$. These can take a \emph{very} long time to calculate for
large datasets! You can also calculate these metrics using functional
traits, a square-rooted phylogeny \citep[following][]{Letten2014}, or
any kind of distance matrix you can put together. The argument
\texttt{traitgram} can be used to set a distance matrix that mixes
explanatory power from phylogeny and traits, following
\citet{Cadotte2013} (see below), and you can compare the output of
different traitgram values. Not all metrics can meaningfully be
calculated using external distance matrices, traitgrams, or
square-rooted phylogenies, however, and such metrics will not be
calculated (and no errors will be displayed).

<<tidy=TRUE, size="small">>=
sqrt <- pez.shape(data, sqrt.phy=TRUE)
traits <- pez.shape(data, traitgram=1) #traits alone
traits <- pez.shape(data, traitgram=c(0,0.5))#phylogeny and both
traits <- pez.shape(data, ext.dist=as.dist(cophenetic(phy(data))))
@ 

\texttt{dissimilarity} works slightly differently, because it returns
a list of distance matrices that describe your community data.
\emph{phylosor} \citep{Bryant2008} is reported as a dissimilarity in
\emph{pez}: it's not the fraction of shared branch lengths, but 1- the
fraction of shared branch length. This is not how it is in other
packages, but remember: the function is called \texttt{dissimilarity}!

<<tidy=TRUE, fig.width=6, fig.height=4, size="small">>=
dist <- pez.dissimilarity(data, "phylosor")
plot(hclust(dist$phylosor))
@

It is possible to calculate any arbitrary combination of metrics using
\texttt{generic.metrics}, and compare those metrics with values
derived from null distributions (\texttt{generic.null}). You can get
a list of the metrics you can calculate by looking at
\texttt{?pez.metrics}; there are many, but they all follow the same
naming (\texttt{.name}) and argument conventions. Note that you can
also pass arguments (external distance matrices, etc.) to all the
metrics you calculate.

<<tidy=TRUE, size="small">>=
metrics <- generic.metrics(data, c(.mpd,.pse,.ses.mpd))
#null.comparisons <- generic.null(data, c(.mpd,.pse))
metrics <- generic.metrics(data, c(.mpd,.mntd), dist=as.dist(cophenetic(phy(data))))
@
%\clearpage
\section{Eco-evolutionary regression}
Calculating metric values is useful, but often we want to make
statistical models. \emph{pez} features a set of regression techniques,
based on \citet{Cavender-Bares2003}, \citet{Cavender-Bares2004}, and
\citet{Cavender-Bares2006}, which are described in the helpfiles for
\texttt{eco.xxx.regression} and \texttt{fingerprint.regression}.

The functions described in \texttt{eco.xxx.regression} focus on
relating the co-occurrence of species to species' phylogenetic
(\texttt{phy}), trait (\texttt{trait}), and environmental tolerances
(\texttt{env}). The environmental tolerances are based on Pianka's
distance and derived from your \texttt{\$env} data, while the trait
distances can be based on any distance metric you can define. These
are useful to explore your data, but also because the trait results
are used in the \emph{fingerprint regression} described below.

<<tidy=TRUE, size="small">>=
phy <- eco.phy.regression(data, permute=10)
trait <- eco.trait.regression(data, permute=10, method="quantile", tau=c(0.25,0.5,0.7))
trait <- eco.trait.regression(data, altogether=FALSE)
@ 

In the last line above, we calculated separate regressions for each
trait in our dataset (returning a \texttt{eco.xxx.regression.list}
object). While this isn't particularly thrilling in this dataset where
we only have two traits, such a regression forms the basis of the
\texttt{fingerprint.regression}. In this, we will regress the
association between species co-occurrence and trait similarity for each
trait against the phylogenetic conservatism of each trait. Which is a
mouthful, but the papers describing it
\citep{Cavender-Bares2004,Cavender-Bares2006} go into more
detail. \emph{pez} does things slightly differently to these original
papers, in that it uses measures of phylogenetic `signal' instead of
Mantel tests (\texttt{phy.signal}), and provides more distance matrix
and regression model options for the link between co-occurrence and
trait similarity.

\begin{figure}
  \begin{center}
    \includegraphics[width=0.5\textwidth]{fingerprint_regression.png}
    \caption{Overview of a fingerprint regression. A hypothetical
      trait is shown in each quadrant; the size of the circles
      represents the numerical value of the trait, and colour of the
      circles represents hypothetical communities. Areas of interest on
      the diagram are coloured to mirror the discussion in the
      text. The quadrants are based on the framework of
      \citetext{Webb2002}, although the axes are continuous following
      the approach used by \citetext{Cavender-Bares2004}. Trait
      patterns in the bottom left quadrant can be interpreted as
      environmental filtering on labile (or phylogenetically
      convergent) traits. Trait patterns in the top right quadrant may
      be interpreted as indicative of limiting similarity of
      phylogenetically conserved traits: these patterns emerge when
      functionally and phylogenetically similar species co-occur less
      than expected. Finally, trait patterns in the bottom right
      quadrant indicate that functionally similar but phylogenetically
      distantly related species co-occur less than expected. Such a
      pattern may indicate limiting similarity of distantly related
      species but may be difficult to interpret. }
    \label{fingerprint}
  \end{center}
\end{figure}

Figure \ref{fingerprint} may make things clearer. On the horizontal
axis we move from where there is a positive correlation between
co-occurrence and each trait's similarity (left) to a negative
correlation (right). On the vertical axis, traits are arranged
according to whether they show trait conservation (top) or
lability/lack of phylogenetic inertia (bottom). Remember: each of your
traits makes up one data-point in this space, but in figure
\ref{fingerprint} we have made a cartoon of a single trait in
different quadrants of the graph to make things clearer. If
communities are not just assembled \emph{but have also evolved} under
limiting similarity, traits should tend to lie in the blue
circle. Above the blue circle, traits have evolved under niche
conservatism and habitat filtering is taking place across those
traits. By creating a regression such as this with your data, you are
directly relating the present-day ecology of species to their
evolutionary history.

<<warning=FALSE, tidy=TRUE, size="small">>=
model <- fingerprint.regression(data, eco.permute=10)
@

Once you've performed a \emph{fingerprint regression} (the name is new
to \emph{pez}), you can examine the coefficients of each of the
\texttt{\$eco} and \texttt{\$evo} slots in your model, which
correspond to the two axes in figure \ref{fingerprint}. Make sure you
check which traits are where in your graph; not all traits are
independent, either ecologically or evolutionarily, which could lead
to bias. Examine the \texttt{\$eco} and \texttt{\$evo} slots in your
output to see what it plotted where; you can plot these names by
provide these two values and \texttt{traits(data)} to the function
\texttt{text}. In our example here the results are not particularly
interesting as we have only two traits! 

It is worth pausing to consider the interpretation of various
outcomes. A positive relationship would indicate a combination of
environmental filtering on functional traits with multiple independent
origins and limiting similarity of phylogenetically conserved
functional traits. Note that a non-significant fingerprint regression
does not indicate that the data are not interpretable. For example,
traits concentrated in the top left quadrant (red circle) could most
likely be interpreted in terms of niche conservatism because species
with phylogenetically and functionally similar traits are found in the
same habitats or communities. A negative relationship, in contrast,
would be difficult to interpret because it would indicate a
combination of niche conservatism (environmental filtering on
conserved functional traits) and trait patterns of dissimilar labile
traits within communities that could be generated any number of ways
or result from stochastic processes. A further complication, of
course, is that different measures of phylogenetic signal mean very
different things; ensure that you understand how to interpret the
metric you are using!

An important caveat is that multiple processes may contribute to
observed patterns making interpretation difficult
\citep{Cavender-Bares2009}. However, examination of which traits
fall out in different quadrants can help provide functional
interpretations of community patterns. For example, if disease
resistance traits are highly conserved and occur in the top right
quadrant where close relatives do not co-occur in communities, this
would help implicate Janzen-Connell mechanisms as contributing to the
community structure; testing such a hypothesis with experimental
methods would be an important next step. Alternatively, if fire
tolerance traits were found in the bottom left quadrant, a plausible
interpretation would be that there had been repeated evolutionary
origins of fire tolerance traits, and environmental filtering (by
fire) operated on these phylogenetically convergent traits. Both of
these scenarios could occur simultaneously and both would help explain
an overdispersed (or even) pattern of community phylogenetic
structure. In contrast, if fire tolerance traits appeared in the top
left quadrant, one would implicate niche conservatism for
fire-tolerance traits, and it would be reasonable to assume that fire
acted as an environmental filter causing fire tolerant species to
assemble in fire-dominated habitats and fire-intolerant species to
assemble in habitats lacking fire.

%\clearpage
\section{Functional phylogenetic distances and traitgrams}

Taxa differ both functionally and phylogenetically, a fact that is
clearly illustrated using traitgrams \citep{Ackerly2009, Evans2009}.
A traitgram of a \texttt{comparative.comm} object can be made using
the \texttt{traitgram.cc} (a wrapper for the \texttt{traitgram}
function in \texttt{picante}).  Here is a traitgram for a particular
assemblage of species against the \texttt{length} trait,
<<traitgram, warning=FALSE, fig.width=4, fig.height=4.5, dev.args=list(pointsize=8)>>=
assemblage <- c("Nerophilus", "Hydroptila", "Psorophora",
                "Simuliidae", "Psychodidae", "Ceratopogon",
                "Nectopsyche", "Pedomoecus", "Ceratopsyche")
dataAssemblage <- data[, species(data) %in% assemblage]
traitgram.cc(dataAssemblage, "length")
@ %
\noindent The traitgram plots the phylogenetic time on the y-axis and
\texttt{length} on the x-axis.  Note that some taxa are very distantly
related but nevertheless have converged to very similar trait values
(e.g. Psorophora and Simuliidae), whereas others are closely related
but functionally very dissimilar (e.g. Nerophilus and Nectopsyche).

\citet{Cadotte2013} argued that distances in this `traitgram space'
might provide a better indication of ecological differences between
taxa, than if either function or phylogenetic data were used in
isolation.  If $FD_{ij}$ and $PD_{ij}$ are functional and phylogenetic
distances between species $i$ and $j$, the functional-phylogenetic
distance between $i$ and $j$ is \citep{Cadotte2013},
\begin{equation}
  \label{eq:1}
  \left((1-a) FD_{ij}^p + a PD_{ij}^p\right)^{1/p}
\end{equation}
\noindent where $a$ is the phylogenetic weighting parameter and $p$ is
the exponent for the $p$-norm combination of phylogenetic and
functional distances (e.g. $p = 2$ gives a Euclidean combination).
This distance matrix can be computed using the
\texttt{funct.phylo.dist} function.  For example, for $a = 0.5$, and
$p = 2$, we have,
<<FPDist, size="small">>=
fpd.data <- funct.phylo.dist(data, phyloWeight = 0.5, p = 2)
@ %
\noindent One use of these distance matrices is in community
randomisation tests \citep{Cadotte2013}, an example of which can be
computed using the following code:
<<sesFPD, size="small">>=
ses.mfpd.data <- .ses.mpd(data, dist=fpd.data)
head(ses.mfpd.data)[,c("ntaxa", "mpd.obs", "mpd.obs.p")]
@

%\clearpage
\section{Phylogenetic Generalised Linear Mixed Models}
Phylogenetic Generalised Linear Models (PGLMMs) are powerful tools
that permit detailed tests of what structures ecological
communities. They were originally intended to examine phylogenetic
patterns in community composition, sensitivity to environmental
gradients (and variation in species' sensitivity based on trait data),
and species co-occurrence \citep{Ives2011}. They were later extended
to model interaction networks \citep{Rafferty2013}, and both of these
methods are flexibly implemented in \emph{pez} such that they can take
any kind of correlation structure, whether it be among species or
among sites (\emph{e.g.}, spatial auto-correlation). Both species
occurrence and abundance can be modelled, depending on the error
\texttt{family} specified.

What follows is a simple example of how to simulate, and then analyse,
the most basic kind of PGLMM. The help file for PGLMM is quite
thorough; the first section provides a helpful reference for how to
quickly fit different kinds of models once you are familiar with the
approach. What follows is a greatly condensed version of the second
section; the help file contains much more information of why and how
each step of the simulation works.

<<pglmmSim, tidy=TRUE, size="small">>=
# Basic parameters
nspp <- 15; nsite <- 10
# Fixed effects
beta0 <- beta1 <- 0
# Random effects' magnitudes
sd.B0 <- sd.B1 <- 1

# Generate environmental site variable
X <- matrix(1:nsite, nrow=1, ncol=nsite)
X <- (X - mean(X))/sd(X)

# Simulate phylogeny
phy <- compute.brlen(rtree(nspp), method = "Grafen", power = 0.5)
# Standardise phy. covariance matrix
Vphy <- vcv(phy); Vphy <- Vphy/(det(Vphy)^(1/nspp))

# Generate phylogenetic signal in parameters
iD <- t(chol(Vphy))
b0 <- beta0 + iD %*% rnorm(nspp, sd = sd.B0)
b1 <- beta1 + iD %*% rnorm(nspp, sd = sd.B1)

#Simulate presences
y <- matrix(outer(b0, array(1, dim = c(1, nsite))), nrow = nspp, ncol = nsite) + matrix(outer(b1, X), nrow = nspp, ncol = nsite)
e <- rnorm(nspp * nsite, sd = 0)
y <- y + matrix(e, nrow = nspp, ncol = nsite)
y <- matrix(y, nrow = nspp * nsite, ncol = 1)    
Y <- rbinom(n = length(y), size = 1, prob = exp(y)/(1 + exp(y)))
Y <- matrix(Y, nrow = nspp, ncol = nsite)

#Neat up the data to show structure
rownames(Y) <- 1:nspp; colnames(Y) <- 1:nsite
@ 

Arguably the most important thing for you to understand about the
above is what \texttt{Y} represents: it is a matrix where each species
has its own row, and each site its own column (see the final
line). When we take the transpose of it, we have what we need to
create a \texttt{comparative.comm} object.

We will now transform that data such that it is in a `long
format'---each element in the community matrix will become a row in a
\texttt{data.frame} and we will perform a regression (a PGLMM, to be
precise!) on that data. This long format is important because PGLMM is
sufficiently flexible that it can be fitted to data that don't fit
into the \texttt{comparative.comm} format. An example is
interaction-network data, of which there is an example in the help
file. Calling \texttt{as.data.frame} on a \texttt{comparative.comm}
object will convert your data into this long-format structure for you.

<<pglmmModel, tidy=TRUE, size="small">>=
# Transform data into 'long' format
# - Occurrence data
YY <- matrix(Y, nrow = nspp * nsite, ncol = 1)
# - Environmental (site) data
XX <- matrix(kronecker(X, matrix(1, nrow = nspp, ncol = 1)), nrow = nspp * nsite, ncol = 1)
site <- matrix(kronecker(1:nsite, matrix(1, nrow = nspp, ncol = 1)), nrow = nspp * nsite, ncol = 1)
sp <- matrix(kronecker(matrix(1, nrow = nsite, ncol = 1), 1:nspp), nrow = nspp * nsite, ncol = 1)
# - Make data.frame with all data
dat <- data.frame(Y = YY, X = XX, site = as.factor(site), sp = as.factor(sp))

# Setup random effects
# - 1: random intercept - species independent
re.1 <- list(1, sp = dat$sp, covar = diag(nspp))
# - 2: random intercept - species phylogenetically covary
re.2 <- list(1, sp = dat$sp, covar = Vphy)
# - 3: random slope - species independent
re.3 <- list(dat$X, sp = dat$sp, covar = diag(nspp))
# - 4: random intercept - species covary
re.4 <- list(dat$X, sp = dat$sp, covar = Vphy)   
# (Random effect for site)
re.site <- list(1, site = dat$site, covar = diag(nsite))

# Fit model!
model <- communityPGLMM(Y ~ X, data = dat, family = "binomial", sp = dat$sp, site = dat$site, random.effects = list(re.1, re.2, re.3, re.4), REML = TRUE, verbose = FALSE)
@ 

There are three steps: transforming the data (as discussed above),
setting up the random effects, and finally fitting the model. Fitting
the model is comparatively easy; make sure you specify your random
effects, and if you're modelling presence/absence data set the
\texttt{family} to \texttt{binomial} as you might in any GLM.

The random effects describe how likely species are to occur in the
sites based on a regression of the environmental variable we simulated
in the first step. There are random effects for the intercept of the
regression (split into independent and phylogenetically shared
variance for each species) and the slope of their relationship (also
with phylogenetic and non-phylogenetic components). There is also a
random effect for site-level variation. The first section of the help
file (\texttt{?pglmm}) gives examples of how to set up other kinds of
hypotheses involving species traits. These map onto the original
\citet{Ives2011} paper that describes PGLMMs.

Your choice of random effects determines the hypotheses you are
testing with your data---PGLMMs are attractive mostly because of this
flexibility. If you are confused over what random effects to fit, go
back to the original papers \citep{Ives2011,Rafferty2013}, and maybe
check a more recent (but basic) overview
\citep{Pearse2014review}. Powerful methods mean you get to make
powerful choices about what you analyse: this is a good thing!

%\clearpage
\section{Simulation}

A good simulation is one that does exactly what you want it to do, and
\emph{pez} provides a number of simulation functions that may be
useful to you as (1) tools, or (2) starting points for your own
simulations.

\texttt{scape} allows you to repeat the analysis of
\citet{Helmus2012}, simulating the assembly of species across a
landscape given phylogenetically structured assembly. The parameters
are complex, but they can generate some useful expected distributions,
and give you a feel for regional assembly.

Alternatively, you can model the evolution of species and, at the same
time, their assembly through a community. The only problem here is
that the models are much simpler, but hopefully they are tune-able to
your liking! Explore the \texttt{sim.meta} and \texttt{sim.phy}
functions to find out more.

Finally, you can also simulate sets of communities under phylogenetic
and/or trait repulsion, using \texttt{sim.trait.asm}. These
communities are excellent for use as null models to compare with your
own data, and as such they take a \texttt{comparative.comm} object as
an argument to generate communities that match your own data.

%\clearpage
\begin{thebibliography}{6}
\providecommand{\natexlab}[1]{#1}
\providecommand{\url}[1]{\texttt{#1}}
\providecommand{\urlprefix}{URL }

\bibitem[{Ackerly(2009)Ackerly}]{Ackerly2009}
  Ackerly, D. (2009) {Conservatism and diversification of plant
    functional traits: evolutionary rates versus phylogenetic
    signal}. \emph{Proc. Natl Acad. Sci.} \textbf{106}, 19699--19706.

\bibitem[{Bryant \emph{et~al.}(2008)Bryant, Lamanna, Morlon, Kerkhoff, Enquist
  \& Green}]{Bryant2008}
Bryant, J.A., Lamanna, C., Morlon, H., Kerkhoff, A.J., Enquist, B.J. \& Green,
  J.L. (2008) Microbes on mountainsides: contrasting elevational patterns of
  bacterial and plant diversity. \emph{Proceedings of the National Academy of
  Sciences} \textbf{105}, 11505--11511,
  \urlprefix\url{http://www.pnas.org/content/105/suppl.1/11505.abstract}.

\bibitem[{Cadotte \emph{et~al.}(2013)Cadotte, Albert \& Walker}]{Cadotte2013}
  Cadotte, M., Albert, C. \& Walker, S.C. (2013)
  {The ecology of differences: assessing community assembly with trait
    and evolutionary distances}. \emph{Ecology Letters} \textbf{16}, 1234--1244.

\bibitem[{Cavender-Bares \emph{et~al.}(2004)Cavender-Bares, Ackerly,
    Baum \& Bazzaz}]{Cavender-Bares2004} Cavender-Bares, J., Ackerly,
  D.D., Baum, D.A. \& Bazzaz, F.A. (2004) {Phylogenetic overdispersion
    in Floridian oak communities}. \emph{The American Naturalist}
  \textbf{163}, 823--43.
  
\bibitem[{Cavender-Bares \& Wilczek(2003)Cavender-Bares \&
    Wilczek}]{Cavender-Bares2003} Cavender-Bares, J. \& Wilczek,
  A. (2003). Integrating micro- and macroevolutionary processes in
  community ecology. \emph{Ecology}, \textbf{84}, 592-597.
  
\bibitem[{Cavender-Bares \emph{et~al.}(2006)Cavender-Bares, Keen, \&
    Miles}]{Cavender-Bares2006} Cavender-Bares, J., A. Keen \&
  B. Miles (2006) {Phylogenetic structure of Floridian plant
    communities depends on taxonomic and spatial scale}. \emph{The
    American Naturalist} \textbf{87}, S109--S122.
  
\bibitem[{Cavender-Bares \emph{et~al.}(2009)Cavender-Bares, Kozak,
    Fine, \& Kembel}]{Cavender-Bares2009} Cavender-Bares, J., Kozak,
  K., Fine, P. \& Kembel, S. (2009). The merging of community ecology
  and phylogenetic biology. \emph{Ecology Letters}, \textbf{12},
  693-715.

\bibitem[{Evans \emph{et~al.}(2009)Evans, Smith, Flynn, \& Donoghue}]{Evans2009}
  Evans, M.E.K., Smith, S.A., Flynn, R.S. \& Donoghue, M.J. (200)
  {Climate, niche evolution, and diversification of the ``Bird-cage''
    evening primroses (Oenothera, sections Anogra and 
    Kleinia)}. \emph{Am. Nat.} \textbf{173}, 225--240.

\bibitem[{Helmus \& Ives(2012)}]{Helmus2012}
Helmus, M.R. \& Ives, A.R. (2012) Phylogenetic diversity-area curves.
  \emph{Ecology} \textbf{93}, S31--S43.

\bibitem[{Helmus \emph{et~al.}(2014) Helmus, Mercado-Silva \&
    Zanden(2014)}]{Helmus2014} Helmus, M.R., Mercado-Silva, N., \&
  Zanden, M.J.V. (2014) Subsidies to predators, apparent competition
  and the phylogenetic structure of prey communities \emph{Oceologia}
  \textbf{173}, 997--1007.

\bibitem[{Ives \& Helmus(2011)}]{Ives2011} Ives, A.R. \& Helmus,
  M.R. (2011) Generalized linear mixed models for phylogenetic
  analyses of community structure \emph{Ecological Monographs}
  \textbf{81}, 511--525.  
  
\bibitem[{Kembel \emph{et~al.}(2010)Kembel, Cowan, Helmus, Cornwell, Morlon,
  Ackerly, Blomberg \& Webb}]{Kembel2010}
Kembel, S.W., Cowan, P.D., Helmus, M.R., Cornwell, W.K., Morlon, H., Ackerly,
  D.D., Blomberg, S.P. \& Webb, C.O. (2010) Picante: R tools for integrating
  phylogenies and ecology. \emph{Bioinformatics} \textbf{26}, 1463--1464.

\bibitem[{Letten \& Cornwell(2014)Letten \& Cornwell}]{Letten2014}
  Letten, A.D. \& Cornwell, W.K. (2014) Trees, branches and (square)
  roots: why evolutionary relatedness is not linearly related to
  functional distance. \emph{Methods in Ecology and Evolution}.
  
\bibitem[{Orme \emph{et~al.}(2013)Orme, Freckleton, Thomas, Petzoldt, Fritz,
  Isaac \& Pearse}]{Orme2013}
Orme, D., Freckleton, R., Thomas, G., Petzoldt, T., Fritz, S., Isaac, N. \&
  Pearse, W.D. (2013) \emph{caper: comparative analyses of phylogenetics and
  evolution in {R}}. \urlprefix\url{http://CRAN.R-project.org/package=caper}, r
  package version 0.5.2.

\bibitem[{Pearse \emph{et~al.}(2014)Pearse, Cavender-Bares, Puvis \&
  Helmus}]{Pearse2014review}
Pearse, W.D., Cavender-Bares, J., Puvis, A. \& Helmus, M.R. (2014) Metrics and
  models of community phylogenetics. \emph{Modern Phylogenetic Comparative
  Methods and their Application in Evolutionary Biology---Concepts and
  Practice} (ed. L.Z. Garamszegi), Springer-Verlag, Berlin, Heidelberg.

\bibitem[{Rafferty \& Ives(2013)}]{Rafferty2013} Rafferty, N.E. \&
  Ives, A.R. (2013) Phylogenetic trait-based analyses of ecological
  networks \emph{Ecology} \textbf{94}, 2321--2333.

\bibitem[{Webb \emph{et~al.}(2002)Webb, Ackerly, McPeek \&
    Donoghue}]{Webb2002} Webb, C.O., Ackerly, D.D., McPeek, M.A. \&
  Donoghue M.J. (2002). Phylogenies and community ecology. \emph{Annual
  Review of Ecology and Systematics}, \textbf{33}, 475-505.

\end{thebibliography}

\end{document}
