Applications are needed to map biodiversity from large-scale species occurrence datasets whilst seamlessly integrating with existing functions in R. Phylogenetic endemism (PE) is a biodiversity measure based on range-restricted phylogenetic diversity (PD). Current implementations use area of occupancy (AOO) or frequency to estimate the spatial range of branch-length (i.e. phylogenetic range-rarity), rather than extent of occurrence (EOO; i.e. georeferenced phylogenetic endemism), which is known to produce different range estimates. We present R functions to map PD or PE weighted by AOO or EOO (new georeferenced implementation), taking as inputs georeferenced species occurrences and a phylogeny. Non-parametric statistics distinguish PD/PE from trivial correlates of species richness and sampling intensity. The geographic restriction of biodiversity is of interest to the fields of biogeography and conservation biology [1,2], and in particular the historical development and conservation value of concentrations of endemic species [3,4]. Increasingly sophisticated and numerical methods have been developed to measure range-restricted biodiversity. For example, the sum of inverse range-sizes or ‘SIR’ [5,6] of a set of species in a community sample, is a numerically continuous alternative biodiversity measure to counts of species that have been categorically assigned as endemic to a pre-defined area. Rosauer et al. [7] extended the concept of SIR metrics to Faith’s phylogenetic diversity (PD), which is a measure of the evolutionary history represented among a set of species, calculated as the sum of the branch lengths of a phylogenetic tree containing species in a particular community sample [8–10]. This phylogenetic endemism [7] (PE) was defined as (1): PE = ∑ { c ∈ C } L c R c read as the sum of the lengths of each branch in a tree containing a community sample of species divided by the geographic range of each branch (i.e. based on the species terminating from that branch), where L is branch length, R is range size, C is the tree and c is a particular branch of the tree. While a number of methods exist for estimating range sizes [11,12], previously only the number of occupied map grid cells (based on recorded or modelled species occurrences) has been used to estimate ranges that weight this metric. Guerin et al. [13] showed that species ranges, and resulting SIR for map grid cells, estimated with alternative methods were poorly correlated. Specifically, the number of occupied cells (equivalent to frequency or area of occupancy—AOO) was not rank equivalent to measures of extent of occurrence (EOO), leading to recognition of different SIR measures, range-rarity richness (RRR) and georeferenced weighted endemism (GWE), respectively [5]. Since the concepts of range-restricted PD and SIR metrics are linked, we extend here the georeferenced implementation of SIR [13] to its PD equivalent and present new self-contained R [14] functions for calculating and mapping PD and PE, based on species records and relevant phylogenetic trees. The functions can calculate either the existing implementation of PE, where branch length is weighted by its spatial range in terms of the number of occupied grid cells (phylogenetic range-rarity; PRR), or our novel georeferenced implementation, where branch length is weighted by the ‘span’ of constituent species occurrences (georeferenced phylogenetic endemism; GPE). Alternatively, unweighted PD can be mapped. Non-parametric statistics are used to detect outlying grid cells (explained below). These functions address two gaps in current research software: (1) georeferenced calculation of EOO as a weight for calculating PE, to provide different information on the range-restriction of biodiversity than current AOO implementations; (2) functionality in the R environment to map biodiversity metrics including PD/PE from large-scale species occurrence datasets, and to seamlessly integrate inputs and outputs with existing analysis packages. The functions are currently used by loading source into R and calling the functions on simple input data. The functions are principally suited to mapping regional biodiversity to identify conservation priorities. An example of this application would be to convert georeferenced species inventory data into gridded biodiversity heat maps. The outputs are also useful for ecological models in situations where coarse resolution (i.e. map cells rather than field plots) is relevant, or that are based on existing regional inventory data. The existing implementation of PE (and other biodiversity metrics) is available within the perl-based ‘biodiverse’ software [15] with mapping functionality, as well as in the ‘phylo.endemism.R’ function of David Nipperess (released under the GNU GPL: http://davidnipperess.blogspot.com.au/2012/07/phyloendemism-r-function-for.html, accessed 4/2/2015), which calculates a numeric vector of PE for sites in an occurrence matrix but does not have mapping functionality. Our intention, therefore, is to provide a novel implementation with alternative branch weights and to make these functions available in the R environment with automated integration of point data with maps, without requiring sophisticated custom programming from the user. We modified coding for the conversion of phylogenetic data to matrix representation [16] from David Nipperess’ function, while all other coding is new. 
Mapping phylogenetic endemism in R using georeferenced branch extents