Package 'phyloclim'

Title: Integrating Phylogenetics and Climatic Niche Modeling
Description: Implements some methods in phyloclimatic modeling: estimation of ancestral climatic niches, age-range-correlation, niche equivalency test and background-similarity test.
Authors: Christoph Heibl, Clement Calenge (\code{import.ascii})
Maintainer: Christoph Heibl <[email protected]>
License: GPL (>= 2)
Version: 0.9.5
Built: 2024-12-17 11:31:48 UTC
Source: CRAN

Help Index


Phyloclimatic Data Analysis

Description

This package implements some recently developed methods in phyloclimatic modeling.

Details

Package: phyloclim
Type: Package
Version: 0.9.5
Date: 2018-05-25
License: GPL (>= 2)

phyloclim is intended to provide methods for the quantification of niche occupancy and niche overlap and combine this data with phylogenetic trees. Niche overlap can be quantified either from profiles of environmental suitability for a given environmental variable (PNO or predicted niche occupancy profiles, see pno) or from two-dimensional suitability surfaces (environmental niche models (ENMs) or species distribution models (SDMs)) with niche.overlap. Randomization tests for testing the significance of niche overlap in terms of niche identity and niche similarity are available in niche.equivalency.test and bg.similarity.test. Phylogenetic data can be integrated into comparative methods such as age.range.correlation and the estimation of ancestral environmental tolerances (anc.clim), which is a non-parametric approach based on resampling of PNO profiles. The functions in phyloclim are in an early stage of development, so they should be used with care! Any feedback is welcome!

Author(s)

Maintainer: Christoph Heibl ([email protected])

References

Evans, M. E. K., S. A. Smith, R. S. Flynn, and M. J. Donoghue. 2009. Climate, niche evolution, and diversification of the 'bird-cage evening primroses' (Oenothera, sections Anogra and Kleinia). Am. Nat. 173: 225-240. Fitzpatrick, B.M & Turelli, M. 2006. The geography of mammalian speciation: mixed signals from phylogenies and range maps. Evolution 60: 601-615. Phillips, S.J, M. Dudik, & R.E. Schapire. 2006. Maximum entropy modeling of species geographic distributions. Ecological Modeling 190: 231-259.

Warren, D., R.E. Glor, & M. Turelli. 2008. Environmental niche equivalency versus conservatism: quantitative approaches to niche evolution. Evolution 62: 2868-2883.

See Also

ape


Age-Range Correlation

Description

This function can be used to test for phylogenetic signal in patterns of niche overlap (Warren et al., 2008) based on the age-range correlation (ARC) as implemented by Turelli & Fitzpatrick (2006).

Usage

age.range.correlation(phy, overlap, tri = "upper", n = 10000)

Arguments

phy

an object of class "phylo", which must be ultrametric.

overlap

a matrix of class "niolap", containing pairwise measures of niche overlap as produced by niche.overlap.

tri

either "upper" or "lower", indicating which triangle of the overlap matrix to use (see niche.overlap).

n

an integer giving the number of iterations for the Monte Carlo resampling procedure.

Details

In age-range correlation (ARC; sensu Fitzpatrick & Turelli 2006), phylogentic relationships are taken into account when computing average range (or niche) overlap between two clades at node i by

oˉi=jClade1kClade2(12)njk1ojk\bar{o}_{i} = \sum_{j \in Clade1} \sum_{k \in Clade2} (\frac{1}{2})^{n_{jk} - 1} o_{jk}

where the double sum is over all species in the two clades, o(jk) denotes the overlap between species j and k, and n(jk) is the number of nodes separating the two species on the phylogeny. Plotting oˉi\bar{o}_{i} against node ages depicts the ARC for a given clade. Slopes and intercept derived from a linear model can be used to characterize speciation mode (allopatric versus sympatric) or niche evolution (conservatism versus flexibility) in the clade (see Fitzpatrick & Turelli [2006] and Warren et al. [2008], respectively).

The significance of the ARC is assessed via Monte Carlo simulation by random permutation of the overlap matrix to estimate the distribution of slope and intercept unter the null hypothesis of no phylogenetic signal.

Value

A list of four elements:

age.range.correlation

A matrix with age and average overlap for each node.

linear.regression

A linear model of mean niche (or range)overlap versus node age.

sig

Significance of intercept and slope derived by randomization. f is the fraction of randomized datasets with intercept and slopes greater than the observed data. p-values are calculated as 2 * min(f, 1 - f).

MonteCarlo.replicates

A matrix containing intercepts and slopes of randomized datasets.

Author(s)

Christoph Heibl

References

Fitzpatrick, B.M & Turelli, M. 2006. The geography of mammalian speciation: mixed signals from phylogenies and range maps. Evolution 60: 601-615.

Warren, D., R.E. Glor, & M. Turelli. 2008. Environmental niche equivalency versus conservatism: quantitative approaches to niche evolution. Evolution 62: 2868-2883.

See Also

niche.overlap

Examples

# load PNOs for Oxalis sect. Palmatifoliae ...
data(PNO)

# ... and calculate niche overlap between species
no <- niche.overlap(PNO$AnnualMeanTemperature)

# load phylogeny and PNOs of Oxalis sect. Palmatifoliae
data(tree)

# age-range correlation
x <- age.range.correlation(phy = tree, overlap = no, n = 100)

# plot average niche overlap versus node age
plot(x$age.range.correlation)

# add a regression line
abline(x$linear.regression$coefficients)

# add regression lines from Monte Carlo randomization
apply(x$MonteCarlo.replicates, 1, abline, lwd = 0.2, col = "grey50")

Estimation of Ancestral Climatic Tolerances

Description

This function implements a nonparametric approach to estimate ancestral climatic tolerances proposed by Evans et al. (2009), using ace from the ape package.

Usage

anc.clim(target, posterior = NULL, pno, n = 100, method = "GLS")

Arguments

target

An object of class "phylo"; a best estimate (e.g., ML estimate) of topology on which to summarize mean estimated climatic tolerances, must be ultrametric.

posterior

An object of class "multiPhylo" containing a sample of ultrametric trees from the posterior distribution of a Bayesian tree search to be used for reconstruction of ancestral climatic tolerances. posterior = NULL (the default) means that reconstruction uses target instead.

pno

A data frame containing predicted niche occupancy (PNO) profiles, produced e.g. with pno.

n

An integer: The PNO profile given by pno argument will be resamples n times.

method

A character string specifying the method used for estimation. Two choices are possible: "ML" or "GLS" (see ace for details).

Value

A list containing three elements:

tree

An object of class "phylo", the target tree used in the estimation.

means

A vector containing the means of estimated ancestral climatic tolerances. The elements of means are in the same order as node numbers in element tree.

central.density

A matrix, which for each of the terminal nodes in tree contains the minimum and the maximum of the 80 percent density interval of climatic tolerances (as sampled from the PNO).

Author(s)

Christoph Heibl

References

Evans, M. E. K., S. A. Smith, R. S. Flynn, and M. J. Donoghue. 2009. Climate, niche evolution, and diversification of the 'bird-cage evening primroses' (Oenothera, sections Anogra and Kleinia). Am. Nat. 173: 225-240.

See Also

pno, plotAncClim

Examples

# load phylogeny and PNOs of Oxalis sect. Palmatifoliae
data(tree)
data(PNO)

# choose summer precipitation for analysis
clim <- PNO$PrecipitationWarmestQuarter

# estimate ancestral tolerances
ac <- anc.clim(target = tree, pno = clim, n = 100)

# visualize results
plotAncClim(ac, ylab = "Precipitation of warmest quarter (mm)")

Niche overlap for Oxalis enneaphylla and O. lacinita

Description

Objects equ and sim contain the results of the niche.equivalency.test and the bg.similarity.test (Warren et al. 2008) for Oxalis enneaphylla and O. laciniata from section Palmatifoliae.

Usage

data(equ)
data(sim)

Format

A list containing five elements:

method

Name of the test.

species

Names of the two species compared.

statistic

Test statistics D and I of niche overlap based on Schoeners D and modified Hellinger distances.

p.value

p-values for the test statistics (if method = "niche equivalency test").

null

Formulation of the null hypothesis.

null.distribution

Null distributions of D and I derived from randomization (if method = "niche equivalency test").

ci.x.randomY

Confidence intervals based on null distributions (if method = "background similarity test").

ci.y.randomX

Confidence intervals based on null distributions (if method = "background similarity test").

nd.x.randomY

Null distributions of D and I derived from randomization (if method = "background similarity test").

nd.y.randomX

Null distributions of D and I derived from randomization (if method = "background similarity test").

Source

C. Heibl, unpublished data.

References

Warren, D., R.E. Glor, & M. Turelli. 2008. Environmental niche equivalency versus conservatism: quantitative approaches to niche evolution. Evolution. 62: 2868-2883.

Examples

# plot results of niche equivalency test
data(equ)
plot(equ)

# plot results of background similarity test
data(sim)
plot(sim)

Niche Equivalency and Background Similarity Test

Description

Hypothesis testing as proposed by Warren et al. (2008) based on the generation of pseudoreplicate datasets. The niche equivalency (or identity) test asks whether the ecological niche models (ENMs) of two species are more different than expected if they were drawn from the same underlying distribution. The background similarity test asks whether ENMs drawn from populations with partially or entirely non-overlapping distributions are any more different from one another than expected by random chance.

Usage

niche.equivalency.test(p, env, n = 99, app, dir)

bg.similarity.test(p, env, n = 99, conf.level = .95, app, dir)


## S3 method for class 'ntest'
print(x, ...)

## S3 method for class 'ntest'
plot(x, ...)

Arguments

p

a SpatialPointsDataFrame or a simple data frame containing the presence points. In the latter case the first column contains the species names, the second and third column longitude and latitude (see SWD-formatted (=Samples-With-Data) files in the MAXENT tutorial).

env

an object of class SpatialGridDataFrame containing the environmental covariates.

n

an integer giving the number of permutations of the original data (default: n = 99).

conf.level

a real number between 0 and 1 setting the confidence level of the confidence intervals to be calculated.

app

a character string giving the path to the MAXENT application.

dir

a character string giving the name of a directory where the input and output data for MAXENT will be saved. Already existing directories will be overwritten without a warning. If dir is left empty the data will be written to a temporary directory, which will be deleted after execution.

x

an object of class ntest.

...

further arguments passed to or from other methods.

Details

An installation of MAXENT (Phillips et al., 2006; http://www.cs.princeton.edu/~schapire/maxent/) is required in order to run niche.equivalency.test and bg.similarity.test. Both functions use the logistic output of MAXENT estimated using auto features.

By default, the environmental covariates given with env are assumend to be continuous. In order to use categorical environmental covariates, you have to prepend "cat_" to the layer name, e.g. "cat_landuse".

Value

niche.equivalency.test gives a list with six elements:

method

name of the test.

species

names of the two species compared.

null

formulation of the null hypothesis.

statistic

statistics of niche overlap D based on Schoeners D and modified Hellinger distances.

p.value

p-values associated with the statistics.

null.distribution

null distributions of D and I derived from randomization.

bg.similarity.test gives a list with eight elements:

method

name of the test.

species

names of the two species compared.

null

formulation of the null hypothesis.

statistic

statistics of niche overlap D based on Schoeners D and modified Hellinger distances.

ci.x.randomY

confidence interval for D and I based on the comparison of the first species against a randomized background derived from the second species.

ci.y.randomX

confidence interval for D and I based on the comparison of the second species against a randomized background derived from the first species.

nd.x.randomY

null distributions of D and I calculated from the comparison of the first species against a randomized background derived from the second species.

nd.y.randomX

null distributions of D and I calculated from the comparison of the second species against a randomized background derived from the first species.

Note

These functions have been completely rewritten and have been tested with MAXENT 3.3.3k

Author(s)

Christoph Heibl

References

Phillips, S.J, M. Dudik, & R.E. Schapire. 2006. Maximum entropy modeling of species geographic distributions. Ecological Modeling 190: 231-259.

Warren, D., R.E. Glor, & M. Turelli. 2008. Environmental niche equivalency versus conservatism: quantitative approaches to niche evolution. Evolution. 62: 2868-2883.

See Also

niche.overlap

Examples

# path to MAXENT
# --------------
maxent.exe <- paste(system.file(package="dismo"), 
"/java/maxent.jar", sep = "")

# a data frame of coordinates where two species 
# have been detected ('presence points') and
# a raster stack of environmental covariables
# --------------------------------------
species <- c("enneaphylla", "laciniata")
data(sites)
samples <- sites[grep(paste(species, collapse = "|"), sites$spec), ]
data.path <- system.file("extdata", package = "phyloclim")
preds <- list.files(path = data.path, pattern = "[.]asc")
preds <- paste(data.path, preds, sep = "/")
preds <- stack(lapply(X = preds, FUN = raster))

# testing against 9 permutations of the data
# -------------------------------------------
reps <- 9

# run hypothesis tests
# --------------------
if (file.exists(maxent.exe)){
  net <- niche.equivalency.test(samples, preds, reps, maxent.exe)
  net; plot(net)
  bst <- bg.similarity.test(samples, preds, reps, app = maxent.exe)
  bst; plot(bst)
} else {
  message("get a copy of MAXENT (see Details)")
}

Quantification of Niche Overlap

Description

This function quantifies the degree of niche overlap using the statistics D and I (as proposed by Warren et al., 2008) based on Schoeners D (Schoener, 1968) and Hellinger Distances (van der Vaart, 1998). Niche overlap can be calculated either from the probability surfaces of entire ecological niche models (Warren et al., 2008) or from single dimensions of the climatic niches (Evans et al., 2009).

Usage

niche.overlap(x)

Arguments

x

Might take one of the follwing forms: (1) a data frame containing predicted niche occupancy (PNO) profiles, e.g., as derived by pno; (2) a vector of filenames referencing to probability surfaces saved in ASCII-format with an ArcGIS-compatible header; (3) a list containing probability surfaces stored as objects of class SpatialGrid.

Value

A matrix of class "niolap". The upper triangle contains pairwise comparisons of niche overlap in terms of D, whereas the lower triangle contains values of I.

Author(s)

Christoph Heibl

References

Evans, M. E. K., S. A. Smith, R. S. Flynn, and M. J. Donoghue. 2009. Climate, niche evolution, and diversification of the 'bird-cage evening primroses' (Oenothera, sections Anogra and Kleinia). Am. Nat. 173: 225-240.

Schoener, T.W. 1968. Anolis lizards in Bimini: resource partitioning in a complex fauna. Ecology 49: 704-726.

Van der Vaart, A.W. 1998. Asymptotic statistics. Cambridge University Press, U.K.

Warren, D. L., R. E. Glor, & M. Turelli. 2008. Environmental niche equivalency versus conservatism: quantitative approaches to niche evolution. Evolution 62: 2868-2883.

See Also

pno, niche.equivalency.test, bg.similarity.test, age.range.correlation

Examples

# load PNOs for Oxalis sect. Palmatifoliae
data(PNO)

# niche overlap on a annual precipitation gradient:
no <- niche.overlap(PNO$AnnualPrecipitation)

# upper triangle: based on Schoeners D
# lower triangle: based on Hellinger distances
print(no)

Oxalis section Palmatifoliae

Description

This is a data set of Oxalis sect. Palmatifoliae derived from a larger scale study by Heibl & Renner (2012). The sites data frame gives the coordinates (WGS1984) of the sites where Oxalis sect. Palmatifoliae has been collected. These were taken as presence points in distribution modeling and the list of predicted niche occupancy profiles (PNO). Finally, tree holds a phylogenetic hypothesis for the section extracted from a relaxed molecular clock model of the phylogeny of Oxalidales based approx. 7500 bp of chloroplast and nuclear markers. For 19 bioclimatic variables summarizing temperature and precipiation and five species of Oxalis, the suitability or probability of occurence is given along the environmental gradients.

Usage

data(PNO)
	data(sites)
	data(tree)

Format

sites

a data frame representing 290 collections of Oxalis sect. Palmatifoliae.

PNO

a list consisting of 19 matrixes. Each matrix corresponds to an environmental variable and contains the predicted niche occupancy profile (PNO) for each species of Oxalis sect. Palmatifoliae, whereby column 1 of each matrix gives the values of the environmental variable and columns 2-6 give probabilites of occurance of each species along the environmental gradient in column 1.

tree

an object of class "phylo" (see Value section of read.tree).

Source

Heibl, C. & S.S. Renner. Arid-adapted Distribution models and a dated phylogeny for Chilean Oxalis species reveal occupation of new habitats by different lineages, not rapid adaptive radiation. 2012. Syst. Biol. 61(5): 823-834.

Examples

# 290 collections of Palmatifoliae
# --------------------------------
data(sites)
plot(sites$long, sites$lat,
  xlab = "Longitude", ylab = "Latitude")

## PNO profiles along 19 bioclimatic variables
## -------------------------------------------
data(PNO); names(PNO)
temp <- names(PNO)[1]
plotPNO(PNO[[temp]], xlab = temp)

## phylogenetic hypothesis for Palmatifoliae
## -----------------------------------------
data(tree)
plot(tree)

Chronograms with Climatic Data on the Y-Axis

Description

Plot the history of climatic tolerance for a clade sensu Evans et al. (2009).

Usage

plotAncClim(x, layer, clades = NULL, col, density = TRUE, tipmode = 1,
  nchar = 3, cex, tipspace, cladespace = 1, lwd, ylab = "")

Arguments

x

A list with elements tree, data, and (optional) central.density (see details).

layer

Do not use.

clades

A list containing vectors of tip labels which define the clades to highlight.

col

A vector containing colors for different clades (see Examples).

density

Logical, if TRUE, the central density intervals for recent species are plotted.

tipmode

Integer: tipmode = 0 means no tiplabels (and no central density intervals) are plotted; values 1, 2, and 3 define different ways of plotting the tiplabels (see Examples).

nchar

An integer giving the number of characters to which the tiplabels are truncated.

cex

Numeric character expansion factor for tiplabels; multiplied by par("cex") yields the final character size. NULL is are equivalent to 1.0.

tipspace

The fraction of the x-axis that is reserved for tiplabel plotting. If no value is given (default), plotAncClim calculates the fraction as 1 - (4 / nbtips), but this can be overridden by specifiying a fixed value for tipspace in ]0, 1[.

cladespace

A positive reel number; tentative: a factor controlling the space between tiplabels of different clades.

lwd

The line width, a positive number, defaulting to 1.

ylab

A character string, giving a label for the y-axis, i.e., for the bioclimatic dimension of the plot.

Details

The main argument x is a list consisting of at least the first two of the following elements: (1) tree is an ultrametric phylogenetic tree stored as object of class phylo; (2) data is an object of class matrix; its columns correspond to bioclimatic variables and its rows corresond to node numbers such as defined by class phylo objects; (3) central.density must only be included if density = TRUE – it is a list, which for every bioclimatic variable, contains a matrix that contains the some minimum and maximum quantile of the respective bioclimatic variable for every tip in the tree.

References

Evans, M. E. K., S. A. Smith, R. S. Flynn, and M. J. Donoghue. 2009. Climate, niche evolution, and diversification of the 'bird-cage evening primroses' (Oenothera, sections Anogra and Kleinia). Am. Nat. 173: 225-240.

See Also

pno, pno.weighted.mean, anc.clim

Examples

# load phylogeny and PNOs of Oxalis sect. Palmatifoliae
 data(tree)
 data(PNO)

# choose summer precipitation for analysis
clim <- PNO$PrecipitationWarmestQuarter

# estimate ancestral tolerances
ac <- anc.clim(target = tree, pno = clim, n = 100)

# visualize results with default branch coloration
plotAncClim(ac)

# alternative clade colors are given according to the order
# in which tip labels appear from left to right
plotAncClim(ac, col = c("red", "purple", "blue"))

# the 'tipmode' argument
plotAncClim(ac, tipmode = 0)
plotAncClim(ac, tipmode = 1)
plotAncClim(ac, tipmode = 2, nchar = 5)
plotAncClim(ac, tipmode = 3, nchar = 4)

Plot Predicted Niche Occupancy Profiles

Description

This function can be used to plot predicted niche occupancy profiles (PNOs). PNOs can be obtained in a geographical information system by summing the cumulative probabilies of each climatical value for a species distribution model (SDM).

Usage

plotPNO(x, subset = NULL, thinning = NULL, xlab = NULL, 
	tail_threshold = 0, wm = FALSE, legend.pos = "topleft")

Arguments

x

A data frame or matrix with columns corresponding to species and rows corresponding to values along an environmental gradient. The first columns contains the environmental variable, the remaining colums probabilities of suitability.

subset

A vector of mode "character" which can be used to restrict the calculation of weighted means to those columsn in x whose column names match subset; defaults to NULL.

thinning

An integer that can be used to thin fuzzy PNOs prior to plotting; defaults to NULL.

xlab

A character string given the label for the x-axis.

tail_threshold

A numeric that can be used cut long tails of PNOs; defaults to 0.

wm

A logical indicating if weighted mean should added for each species.

legend.pos

Controls the position of the legend. Might eihter be a list object containing x and y coordinates (such as e.g. returned by locator) of the topleft corner of the legend box or one of the following: "topleft" (default), "bottomleft", "topright", or "bottomright". If legend.pos == NULL the plotting of the legend is suppressed.

Author(s)

Christoph Heibl

References

Evans, M. E. K., S. A. Smith, R. S. Flynn, and M. J. Donoghue. 2009. Climate, niche evolution, and diversification of the 'bird-cage evening primroses' (Oenothera, sections Anogra and Kleinia). Am. Nat. 173: 225-240.

See Also

pno

Examples

# load PNOs for Oxalis sect. Palmatifoliae
data(PNO)

# plot predicted niche occupany for annual mean temperature
plotPNO(x = PNO$AnnualMeanTemperature, 
	xlab = "Annual Mean Temperature (degree C)")
	
# same plot, but with weighted means added
plotPNO(x = PNO$AnnualMeanTemperature, 
	xlab = "Annual Mean Temperature (degree C)", wm = TRUE)

Predicted Niche Occupancy Profiles

Description

Following the approach of Evans et al. (2009), pno integrates species probability (suitability) distributions (e.g. derived with MAXENT) with respect to single climatic (or other environmental) variables in order to get predicted niche occupancy (PNO) profiles for each species and environmenatal variable.

Usage

pno(path_bioclim, path_model, subset = NULL, 
	bin_width = 1, bin_number = NULL)

Arguments

path_bioclim

The path leading to an ASCII raster map with environmental data (bioclimatic layer) and ArcGIS-compatible header.

path_model

The path leading to the directory, where MAXENT probability surfaces are stored as ASCII raster maps with ArcGIS-compatible header.

subset

A vector of mode 'character' giving taxon names if only a subset of the species ENMs in path_model is to be used

bin_width

A numeric, giving the bin interval.

bin_number

An integer, giving the number of bins used.

Details

The path arguments path_bioclim and path_model point to the directories where the environmental data and the MAXENT probability distributions must be stored as ASCII maps with an ArcGIS-compatible header (as obtained with MAXENT output filetype: asc). An example header:

ncols 958
nrows 376
xllcorner -73.440304
yllcorner -55.27622
cellsize 0.0166
NODATA_value -9999

Value

A data frame of cumulative probalities of suitability for each value on an environmental gradient (rows) for the a set of studied taxa (rows). The first column gives the mean of each category.

Author(s)

Christoph Heibl

References

Evans, M. E. K., S. A. Smith, R. S. Flynn, and M. J. Donoghue. 2009. Climate, niche evolution, and diversification of the 'bird-cage evening primroses' (Oenothera, sections Anogra and Kleinia). Am. Nat. 173: 225-240.

See Also

pno.weighted.mean, niche.overlap, anc.clim


Weighted means of niche dimensions

Description

This function calculates the mean of an environmental variable weighted by the cumulative probability of each value of the environmental gradient extracted from a species distibution model (e.g. MAXENT)

Usage

pno.weighted.mean(x, subset = NULL, normalize = TRUE)

Arguments

x

A data frame or matrix with columns corresponding to species and rows corresponding to values along an environmental gradient. The first columns contains the environmental variable, the remaining colums probabilities of suitability.

subset

A vector of mode "character" which can be used to restrict the calculation of weighted means to those columsn in x whose column names match subset; defaults to NULL.

normalize

A logical, indicating whether to normalize PNOs prior to calculation of weighted means.

Value

A vector of weighted means corresponding to the columns in x.

Author(s)

Christoph Heibl

References

Evans, M. E. K., S. A. Smith, R. S. Flynn, and M. J. Donoghue. 2009. Climate, niche evolution, and diversification of the 'bird-cage evening primroses' (Oenothera, sections Anogra and Kleinia) Am. Nat. 173: 225-240.

See Also

pno, anc.clim, plotAncClim