Package 'ppgm'

Title: PaleoPhyloGeographic Modeling of Climate Niches and Species Distributions
Description: Reconstruction of paleoclimate niches using phylogenetic comparative methods and projection reconstructed niches onto paleoclimate maps. The user can specify various models of trait evolution or estimate the best fit model, include fossils, use one or multiple phylogenies for inference, and make animations of shifting suitable habitat through time. This model was first used in Lawing and Polly (2011), and further implemented in Lawing et al (2016) and Rivera et al (2020). Lawing and Polly (2011) <doi:10.1371/journal.pone.0028554> "Pleistocene climate, phylogeny and climate envelope models: An integrative approach to better understand species' response to climate change" Lawing et al (2016) <doi:10.1086/687202> "Including fossils in phylogenetic climate reconstructions: A deep time perspective on the climatic niche evolution and diversification of spiny lizards (Sceloporus)" Rivera et al (2020) <doi:10.1111/jbi.13915> "Reconstructing historical shifts in suitable habitat of Sceloporus lineages using phylogenetic niche modelling.".
Authors: A. Michelle Lawing [aut, cph], Alexandra Howard [aut, cre], Maria-Aleja Hurtado-Materon [aut]
Maintainer: Alexandra Howard <[email protected]>
License: GPL (>= 3)
Version: 1.0.3
Built: 2024-12-09 07:02:53 UTC
Source: CRAN

Help Index


addFossil

Description

Adds a fossil as a tip to a specified phylogeny given either an age range that the fossil occurs in, a specific edge that the fossil diverged from, or both. If the specific edge placement for the fossil is unknown, then this function randomly places the fossil on any edge that is within the age range.

Usage

addFossil(tree, mintime = 0, maxtime = NA, name = "fossil", edge = NA)

Arguments

tree

An object of the class "phylo"

mintime

The minimum age of the fossil. If no minimum time is specified, the default value is 0.

maxtime

The maximum age of the fossil. If no maximum time is specified, the default value is the maximum tree age.

name

The name of the fossil to appear as a tip.label.

edge

The edge on the tree where the fossil presumably diverged. If no edge is specified, then the function randomly selects an edge within the age range of the fossil.

Details

There are several random components to this function. First, if an edge is not specified to place a fossil, then an edge is randomly selected that is within the age range of the fossil. Second, the exact placement of the node leading to the fossil is randomly selected within the age range specified. Third, the length of the edge leading to the fossil is randomly selected with constraints on the maximum length of the edge, where the maximum length of the edge cannot render the fossil younger than the minimum time of occurrence as specified in the mintime argument.

Value

An object of the class "phylo".

Author(s)

A. Michelle Lawing, Alexandra F. C. Howard

Examples

mytree <- phytools::pbtree(n=20)
newtree <- addFossil(mytree, mintime = max(mytree$edge.length)/2, maxtime= max(mytree$edge.length))
plot(newtree)

getBioclimVars

Description

This function retrieves the bioclimatic variables described in Nix & Busby (1986) for the specified variables and the specified time period.

Usage

getBioclimVars(occurrences, which.biovars=c(1:19), 
use.paleoclimate=TRUE, paleoclimateUser=NULL, layerAge=c(0:20))

Arguments

occurrences

a matrix or data.frame with three columns and rows to represent individuals. The first column must be species name for extant occurrences or the age in closest Ma for fossil occurrences. Second and third column must be Longitude and Latitude.

which.biovars

a vector of the numbers of the bioclimatic variables that should be returned. The bioclimatic variables number correspond to the table at (https://www.worldclim.org/data/bioclim.html).

use.paleoclimate

if left blank, default North America paleoclimate data is used. If FALSE, user submitted paleoclimate must be provided

paleoclimateUser

list of data frames with paleoclimates, must be dataframes with columns: GlobalID, Longitude, Latitude, bio1, bio2,...,bio19.

layerAge

vector with the ages of the paleoclimate dataframes, if using user submitted paleoclimate data

Details

The occurrences argument should contain all extant or all fossils. Columns should be in the format: Species, Longitude, Latitude for extant data.

If using the provided paleoclimate data:

Modern time period uses the Hijmans et al. (2005) high resolution climate interpolations.

The time period 10 Ma uses the GCM by Micheels et al (2011) for the Tortonian.

The time period 15 Ma uses the GCM by Krapp & Jungclaus (2011) for the Middle Miocene.

For the one million year intervals outside the modern and past GCMs, the climate was interpolated based on the benthic marine foram stable oxygen isotope ratio curve from Ruddiman et al 1989. The scale of these variables is at a 50 km equidistant point grain size.

Value

Returns a data frame with the original occurrences input appended with columns of bioclimate variables as specified. If fossils are included, the returned bioclimate variables are from the closest 1 Ma interval of isotopically scaled climate.

Author(s)

A. Michelle Lawing, Alexandra F. C. Howard, Maria-Aleja Hurtado-Materon

References

Hijmans, R. J. et al. (2005) Very high resolution interpolated climate surfaces for global land areas

Krapp, M. and Jungclaus, J. H. (2011) The Middle Miocene climate as modeled in an atmosphere-ocean-biosphere model. Climate of the Past 7(4):1169-1188

Micheels, A. et al. (2011) Analysis of heat transport mechanisms from a Late Miocene model experiment with a fully-coupled atmosphere-ocean general circulation model. Palaeogeography, Palaeoclimatology, Palaeocology 304: 337-350

Nix, H. and Busby, J. (1986) BIOCLIM, a bioclimatic analysis and prediction system. CSIRO annual report. CSIRO Division of Water and Land Resources, Canberra.

Ruddiman, W. F. et al. (1989) Pleistocene evolution: Northern hemisphere ice sheets and North Atlantic Ocean. Paleoceanography 4: 353-412

Examples

data(occurrences)
biooccur <- getBioclimVars(occurrences,which.biovars=c(3,5))
#returns data frame with bioclimate variables 3 and 5 for occurrence data

getEnvelopes

Description

This function gets the bioclimate envelopes of species and nodes.

Usage

getEnvelopes(treedata_min, treedata_max, node_est)

Arguments

treedata_min

tree data object with min estimate of the climate envelope for each species.

treedata_max

tree data object with max estimate of the climate envelope for each species

node_est

the estimate of all the nodes, both min and max

Details

Function derives the minimum, and maximum of each climate variable

Value

An array containing climate envelopes for each node

Author(s)

A. Michelle Lawing, Alexandra F. C. Howard

See Also

ppgmMESS(), nodeEstimate, geiger::treedata

Examples

data(sampletrees)
data(occurrences)
tree <- sampletrees[[25]]
biooccu <- getBioclimVars(occurrences, which.biovars=1)
sp_data_min<- tapply(biooccu[,4],biooccu$Species,min)
sp_data_max<- tapply(biooccu[,4],biooccu$Species,max)
treedata_min <- geiger::treedata(tree,sp_data_min,sort=TRUE,warnings=F)
treedata_max <- geiger::treedata(tree,sp_data_max,sort=TRUE,warnings=F)
full_est <- nodeEstimateEnvelopes(treedata_min,treedata_max)
node_est <- full_est$est
example_getEnvelopes <- getEnvelopes(treedata_min, treedata_max, node_est)

getGeoRate

Description

This function calculates the change in suitable habitat through time in geographic space.

Usage

getGeoRate(envelope, tree, which.biovars, use.paleoclimate=TRUE, 
paleoclimateUser=NULL, layerAge=c(0:20))

Arguments

envelope

the min and max climate envelope of each lineage for each time slice, as outputted by getEnvelopes()

tree

the phylogeny of all species. An object of class phylo

which.biovars

a vector of the numbers of the bioclimate variables to be included. The bioclimate variables number correspond to the table at (https://www.worldclim.org/data/bioclim.html).

use.paleoclimate

if left blank, default North America paleoclimate data is used. If FALSE, user submitted paleoclimate must be provided

paleoclimateUser

list of data frames with paleoclimates, must be dataframes with columns: GlobalID, Longitude, Latitude, bio1, bio2,...,bio19. (see getBioclimvars()).

layerAge

vector with the ages of the paleoclimate dataframes, if using user submitted paleoclimate data

Details

Calculates rate of geographic change of all lineages. Outputs both the geographic center change, and the geographic size change.

Value

geo_center change in geographic center of suitable climate envelope

geo_size change in geographic size of suitable climate envelope

time_int time intervals

Author(s)

A. Michelle Lawing, Alexandra F. C. Howard, Maria A. Hurtado-Materon

See Also

getEnvelopes()

Examples

data(sampletrees)
data(occurrences)
data(paleoclimate)
tree <- sampletrees[[25]]
occu <- getBioclimVars(occurrences, which.biovars=1)
sp_data_min<- tapply(occu[,4],occu$Species,min)
sp_data_max<- tapply(occu[,4],occu$Species,max)
treedata_min <- geiger::treedata(tree,sp_data_min,sort=TRUE,warnings=F)
treedata_max <- geiger::treedata(tree,sp_data_max,sort=TRUE,warnings=F)
full_est <- nodeEstimateEnvelopes(treedata_min,treedata_max)
node_est <- full_est$est
example_getEnvelopes <- getEnvelopes(treedata_min, treedata_max, node_est)
example_getGeoRate <- getGeoRate(example_getEnvelopes, tree, which.biovars=1)

getLineageClimate

Description

This function calculates the suitable climate for each specific lineage, starting at the tips and going back through time to the root.

Usage

getLineageClimate(envelope, tree, which.biovars, 
use.paleoclimate=TRUE, paleoclimateUser=NULL, layerAge=c(0:20))

Arguments

envelope

the min and max climate envelope of each lineage for each time slice, as outputted by getEnvelopes()

tree

the phylogeny of all species. An object of class phylo

which.biovars

a vector of the numbers of the bioclimate variables to be included. The bioclimate variables number correspond to the table at (https://www.worldclim.org/data/bioclim.html).

use.paleoclimate

if left blank, default North America paleoclimate data is used. If FALSE, user submitted paleoclimate must be provided

paleoclimateUser

list of data frames with paleoclimates, must be dataframes with columns: GlobalID, Longitude, Latitude, bio1, bio2,...,bio19. (see getBioclimvars()).

layerAge

vector with the ages of the paleoclimate dataframes, if using user submitted paleoclimate data

Details

Calculates rate of geographic change of all lineages. Outputs both the geographic center change, and the geographic size change.

Value

matchedClim list of occurrences points for each lineage, for each time slice of paleoclimate data

lineage list of lineage specific nodes, as output from phangorn::Ancestors

Author(s)

A. Michelle Lawing, Alexandra F. C. Howard, Maria A. Hurtado-Materon

See Also

getEnvelopes() getGeoRate()

Examples

data(sampletrees)
data(occurrences)
data(paleoclimate)
occu <- getBioclimVars(occurrences, which.biovars=1)
tree <- sampletrees[[25]]
#species minimum for biovariable 1
sp_data_min<- tapply(occu[,4],occu$Species,min)
#species maximum for biovariable 1
sp_data_max<- tapply(occu[,4],occu$Species,max)
#convert to treedata object
treedata_min <- geiger::treedata(tree,sp_data_min,sort=TRUE,warnings=F) 
treedata_max <- geiger::treedata(tree,sp_data_max,sort=TRUE,warnings=F)
#estimate node values using Brownian Motion
full_est <- nodeEstimateEnvelopes(treedata_min,treedata_max)
node_est <- full_est$est #extract only node estimates
#calculate climate envelopes
example_getEnvelopes <- getEnvelopes(treedata_min, treedata_max, node_est)
#calculate lineage specific climate
example_getLinClim <- getLineageClimate(example_getEnvelopes, tree, which.biovars=1)

getTimeSlice

Description

This function extracts estimated ancestral reconstructions for continuous characters any time specified along a phylogeny for all lineages present at the specified time.

Usage

getTimeSlice(timeSlice, tree, trait, model = "BM", plot.est = FALSE)

Arguments

timeSlice

single numeric or a vector with the time (or times) to extract the estimated ancestor reconstructions.

tree

an object of the class "phylo" that should be dated

trait

a vector of both tip values and node estimates that correspond to tree

model

if model = "estimate", the best fit model of evolution. If the model was specified, then model is the specified model, passes to geiger::fitContinuous(). Model options currently supported are: "BM", "OU", "EB", "lambda", "kappa", "delta"

plot.est

a conditional stating whether or not to plot the results

Details

The estimated reconstruction relies on an interpolation between node or between tip and node estimates of the trait. This method assumes a constant rate of evolution along the lineage where the interpolation is taking place.

Value

edge for each time specified, a vector of edges that are present during that time are returned

est for each time specified, a vector of estimates of the ancestral reconstruction along each edge

Author(s)

A. Michelle Lawing, Alexandra F. C. Howard

See Also

geiger::fitContinuous(), nodeEstimate()

Examples

data(sampletrees)
data(occurrences)
occurrences <- getBioclimVars(occurrences, which.biovars=1)
sp_data_min<- tapply(occurrences[,4],occurrences$Species,min)
treedata_min <- geiger::treedata(sampletrees[[1]], sp_data_min)
ex_est <- nodeEstimate(treedata_min, 1, model = 'BM') #runs BM model
ex_timeSlice <- getTimeSlice(10,treedata_min$phy,c(treedata_min$data[,1],ex_est$est))

nodeEstimate

Description

This function estimates the ancestral character states for continuous characters given a model of evolution or using the best fit model of evolution from the fitContinuous function in the geiger package. The ancestral states are estimated using GLS described in Martins and Hansen (1997).

Usage

nodeEstimate(treedata.obj, traitnum, model = "BM", bounds = list(), 
control = list(), plot.est = FALSE)

Arguments

treedata.obj

an object of the class "treedata".

traitnum

the column number of the trait within the treedata object to be reconstructed.

model

the model of evolution to use in the ancestral state reconstruction. Options are "estimate", "BM", "OU", "EB", "lambda", "kappa", "delta".

bounds

bounds used for the model, passes to fitContinuous(), uses default if none specified.

control

setting used for optimization of the model likelihood. Passes to fitContinuous().

plot.est

logical. whether or not to plot the traitgram of the estimated ancestor states.

Details

See the fitContinuous() details for descriptions of the models of evolution and parameter estimation. nodeEstimate() currently supports the following models of evolution: Brownian motion (Felsenstein, 1973), Ornstein-Uhlenbeck (Butler and King, 2004), early-burst (Harmon et al., 2010), lambda (Pagel, 1999), kappa (Pagel, 1999), and delta (Pagel, 1999).

Value

an object of the class "nodeEstimate".

model if model = "estimate", the best fit model of evolution. If the model was specified, then model is the specified model.

est the ancestral node estimates of the continuous character.

phy the phylogeny used for the estimates, which might be transformed depending on the evolutionary model.

BM if model = "BM", returned values from fitContinuous() where the model is "BM"

OU if model = "OU", returned values from fitContinuous() where the model is "OU"

EB if model = "EB", returned values from fitContinuous() where the model is "EB"

lambda if model = "lambda", returned values from fitContinuous() where the model is "lambda"

kappa if model = "kappa", returned values from fitContinuous() where the model is "kappa"

delta if model = "delta", returned values from fitContinuous() where the model is "delta"

fitted if model = "estimate", returned values from the best fit model of evolution.

Author(s)

A. Michelle Lawing, Alexandra F. C. Howard

References

Butler, M. A. and King, A. A. (2004) Phylogenetic comparative analysis: a modeling approach for adaptive evolution. American Naturalist, 164:683-695.

Felsenstein, J. (1973) Maximum likelihood estimation of evolutionary trees from continuous characters. American Journal of Human Genetics, 25:471-492

Harmon, L. J. et al. (2010) Early bursts of body size and shape evolution are rare in comparative data. Evolution, 64:2385-2396

Martins, E. P. and Hansen, T. F. (1997) Phylogenies and the comparative method: a general approach to incorporating phylogenetic information into the analysis of interspecific data. American Naturalist, 149, 646–667.

Pagel M. (1999) Inferring the historical patterns of biological evolution. Nature, 401:877-884

See Also

fitContinuous()

Examples

data(sampletrees)
data(occurrences)
occurrences <- getBioclimVars(occurrences, which.biovars=1)
sp_data_min<- tapply(occurrences[,4],occurrences$Species,min)
ex <- geiger::treedata(sampletrees[[1]], sp_data_min)
nodeEstimate(ex, 1, model = 'OU') #runs OU model

nodeEstimateEnvelopes

Description

This function estimates climate envelopes at nodes with the optional placement of fossils on randomly assigned or specified edges on a tree.

Usage

nodeEstimateEnvelopes(treedata_min, treedata_max, fossils=FALSE, 
fossils.edges=FALSE, model="BM", bounds=list(), control=list(), 
use.paleoclimate = TRUE, paleoclimateUser = NULL, layerAge = c(0:20), 
which.biovars = which.biovars)

Arguments

treedata_min

tree data object with min estimate of the climate envelope – list where first object is phylogeny, and second object is array of species with climate data variables (species must match)

treedata_max

tree data object with max estimate of the climate envelope

fossils

a matrix with three columns of age, longitude, and latitude, in that order, and rows that are entries for fossil occurrences.

fossils.edges

the edge number that the fossil occurs on

model

the model of evolution to use in the ancestral state reconstruction. Options are "estimate", "BM", "OU", "EB", "lambda", "kappa", "delta".

bounds

bounds used for the model, passes to fitContinuous(), uses default if none specified.

control

setting used for optimization of the model likelihood. Passes to fitContinuous().

use.paleoclimate

if left blank, default North America paleoclimate data is used. If FALSE, user submitted paleoclimate must be provided

paleoclimateUser

list of data frames with paleoclimates, must be dataframes with columns: GlobalID, Longitude, Latitude, bio1, bio2,...,bio19. (see getBioclimvars()).

layerAge

vector with the ages of the paleoclimate dataframes, if using user submitted paleoclimate data

which.biovars

A vector of the numbers of the bioclimate variables that should be returned. The bioclimate variables number correspond to the Hijmans table at (https://www.worldclim.org/data/bioclim.html).

Details

function adds fossils to trees according to addFossil(), then passes to nodeEstimate().

Value

an object of the class "nodeEstimate".

model if model = "estimate", the best fit model of evolution. If the model was specified, then model is the specified model.

est the ancestral node estimates of the continuous character.

phy the phylogeny used for the estimates, which might be transformed depending on the evolutionary model.

BM if model = "BM", returned values from fitContinuous() where the model is "BM"

OU if model = "OU", returned values from fitContinuous() where the model is "OU"

EB if model = "EB", returned values from fitContinuous() where the model is "EB"

lambda if model = "lambda", returned values from fitContinuous() where the model is "lambda"

kappa if model = "kappa", returned values from fitContinuous() where the model is "kappa"

delta if model = "delta", returned values from fitContinuous() where the model is "delta"

fitted if model = "estimate", returned values from the best fit model of evolution.

Author(s)

A. Michelle Lawing, Alexandra F. C. Howard

See Also

nodeEstimate, fitContinuous

Examples

data(sampletrees)
sampletrees <- sample(sampletrees,5)
data(occurrences)
occu <- getBioclimVars(occurrences, which.biovars=c(1,2))
sp_data_min<-sapply(4:5,function(x) tapply(occu[,x],occu$Species,min))
sp_data_max<-sapply(4:5,function(x) tapply(occu[,x],occu$Species,max))
ex_min <- geiger::treedata(sampletrees[[1]], sp_data_min, sort=TRUE)
ex_max <- geiger::treedata(sampletrees[[1]], sp_data_max, sort=TRUE)
colnames(ex_min$data)<- colnames(ex_max$data)<-c("bio1","bio2")  #labels biovars
nodeest<- nodeEstimateEnvelopes(treedata_min=ex_min,treedata_max=ex_max, 
model="BM",which.biovars=c(1,2),
bounds=list(sigsq = c(min = 0, max = 1000000)))

Sceloporus occurrence data

Description

Occurrences for Sceloporus, as collected for Lawing et al 2016. Occurrence records from GBIF, and vetted using expert range maps from IUCN. See reference for further details Lawing et al (2015) Including fossils in phylogenetic climate reconstructions: A deep time perspective on the climatic niche evolution and diversification of spiny lizards (Sceloporus)

Usage

occurrences

Format

'occurrences' A data frame of Sceloporus occurrence records

Species

Species name

Longitude

Longitude of occurrence

Latitude

Latitude of occurence

Source

<https://www.journals.uchicago.edu/doi/10.1086/687202>


Paleoclimate Data for ppgm examples

Description

North America paleoclimate data used for running ppgm

Usage

paleoclimate

Format

'paleoclimate' A large list of paleoclimates for North America, each element in the list contains a data frame for one time period, from present to 20mya

GlobalID

Global ID references for location

Longitude

Longitude of location

Latitude

Latitude of location

bio1

Value for bioclimatic variable 1: annual mean temperature

bio2

Value for bioclimatic variable 2: mean diurnal range

bio3

Value for bioclimatic variable 3: isothermality

bio4

Value for bioclimatic variable 2: temperature seasonality

bio5

Value for bioclimatic variable 2: max temp of warmest month

bio6

Value for bioclimatic variable 2: min temp of coldest month

bio7

Value for bioclimatic variable 2: temperature annual range

bio8

Value for bioclimatic variable 2: mean temp of wettest quarter

bio9

Value for bioclimatic variable 2: mean temp of driest quarter

bio10

Value for bioclimatic variable 2: mean temp of warmest quarter

bio11

Value for bioclimatic variable 2: mean temp of coldest quarter

bio12

Value for bioclimatic variable 2: annual precipitation

bio13

Value for bioclimatic variable 2: precipitation of wettest month

bio14

Value for bioclimatic variable 2: precipitation of the driest month

bio15

Value for bioclimatic variable 2: precipitation seasonality

bio16

Value for bioclimatic variable 2: precipitation of the wettest quarter

bio17

Value for bioclimatic variable 2: precipitation of the driest quarter

bio18

Value for bioclimatic variable 2: precipitation of the warmest quarter

bio19

Value for bioclimatic variable 2: precipitation of the coldest quarter


plotAnimatedPPGM

Description

This function creates an animated gif showing the change in modelled suitable habitat through time in geographic space.

Usage

plotAnimatedPPGM(envelope, tree, filename="ppgm.gif", which.biovars, 
path="", use.paleoclimate=TRUE, paleoclimateUser=NULL, layerAge=c(0:20))

Arguments

envelope

the min and max envelope of each lineage for each time slice

tree

the phylogeny or multiple phylogenies that show the relationship between species

filename

desired filename of output

which.biovars

A vector of the numbers of the bioclimate variables that should be returned. The bioclimate variables number correspond to the Hijmans table at (https://www.worldclim.org/data/bioclim.html).

path

path to the directory where the results should be saved

use.paleoclimate

if left blank, default North America paleoclimate data is used. If FALSE, user submitted paleoclimate must be provided

paleoclimateUser

list of data frames with paleoclimates, must be dataframes with columns: GlobalID, Longitude, Latitude, bio1, bio2,...,bio19. (see getBioclimvars()).

layerAge

vector with the ages of the paleoclimate dataframes, if using user submitted paleoclimate data

Details

Requires ImageMagick or GraphicsMagick to be installed on the operating system. This is easy to do if you have macports. Just type sudo port install ImageMagick into terminal.

Value

An animated gif of species through time

Author(s)

A. Michelle Lawing, Alexandra F. C. Howard, Maria-Aleja Hurtado-Materon

Examples

data(sampletrees)
data(occurrences)
tree <- sampletrees[[25]]
biooccu <- getBioclimVars(occurrences, which.biovars=1)
sp_data_min<- tapply(biooccu[,4],biooccu$Species,min)
sp_data_max<- tapply(biooccu[,4],biooccu$Species,max)
treedata_min <- geiger::treedata(tree,sp_data_min,sort=TRUE,warnings=F)
treedata_max <- geiger::treedata(tree,sp_data_max,sort=TRUE,warnings=F)
## Not run: full_est <- nodeEstimateEnvelopes(treedata_min,treedata_max)
node_est <- full_est$est
example_getEnvelopes <- getEnvelopes(treedata_min, treedata_max, node_est)
animatedplot <- plotAnimatedPPGM(example_getEnvelopes,tree,which.biovars=1,path=tempdir())
## End(Not run)

plotAnimatedPPGMMultiPhylo

Description

This function creates an animated gif showing the change in modeled suitable habitat through time in geographic space. It requires ImageMagick or GraphicsMagick to be previously installed in the operating system. This is easy to do if you have macports. Just type sudo port install ImageMagick into terminal.

Usage

plotAnimatedPPGMMultiPhylo(envelope, tree, filename="ppgm.gif", 
which.biovars, path="", use.paleoclimate=TRUE, paleoclimateUser=NULL, layerAge=c(0:20))

Arguments

envelope

the min and max envelope of each lineage for each time slice

tree

the phylogeny or multiple phylogenies that show the relationship between species

filename

filename of output

which.biovars

A vector of the numbers of the bioclimate variables that should be returned. The bioclimate variables number correspond to the Hijmans table at (https://www.worldclim.org/data/bioclim.html).

path

path to the directory where the results should be saved

use.paleoclimate

if left blank, default North America paleoclimate data is used. If FALSE, user submitted paleoclimate must be provided

paleoclimateUser

list of data frames with paleoclimates, must be dataframes with columns: GlobalID, Longitude, Latitude, bio1, bio2,...,bio19. (see getBioclimvars()).

layerAge

vector with the ages of the paleoclimate dataframes, if using user submitted paleoclimate data

Details

Requires ImageMagick or GraphicsMagick to be installed on the operating system. This is easy to do if you have macports. Just type sudo port install ImageMagick into terminal.

Value

An animated gif of species through time

Author(s)

A. Michelle Lawing, Alexandra F. C. Howard

Examples

data(sampletrees)
data(occurrences)
sampletrees <- sample(sampletrees,5)
biooccu <- getBioclimVars(occurrences, which.biovars=1)
sp_data_min<- tapply(biooccu[,4],biooccu$Species,min)
sp_data_max<- tapply(biooccu[,4],biooccu$Species,max)
treedata_min <- treedata_max <- node_est <- envelope <- list()
## Not run: for (tr in 1:length(sampletrees)){
  treedata_min[[tr]] <- geiger::treedata(sampletrees[[tr]],sp_data_min,sort=TRUE,warnings=F)
  treedata_max[[tr]] <- geiger::treedata(sampletrees[[tr]],sp_data_max,sort=TRUE,warnings=F)
  full_est <- nodeEstimateEnvelopes(treedata_min[[tr]],treedata_max[[tr]])
  node_est[[tr]] <- full_est$est
  envelope[[tr]] <- getEnvelopes(treedata_min[[tr]], treedata_max[[tr]], node_est[[tr]])
}
animatedplot <- plotAnimatedPPGMMultiPhylo(envelope,sampletrees,which.biovars=1, path=tempdir())
## End(Not run)

plotGeoRates

Description

plotGeoRates

Usage

plotGeoRates(geo_center, geo_size, time_int, trees, path="")

Arguments

geo_center

change in geographic center of suitable climate envelope, see

geo_size

change in geographic size of suitable climate envelope

time_int

time intervals to plot

trees

distribution of phylogenies

path

path to the directory where the results to be saved

Details

Creates plot with gray background of all pairwise comparisons of change in geo center and area through time. Blue points on top show the sequential change in geo center and expansion/contraction for all lineages

Value

plots of geo rate

Author(s)

A. Michelle Lawing, Alexandra F. C. Howard

See Also

getGeoRates

Examples

data(sampletrees)
data(occurrences)
sampletrees <- sample(sampletrees,5)
biooccu <- getBioclimVars(occurrences, which.biovars=1)
sp_data_min<- tapply(biooccu[,4],biooccu$Species,min)
sp_data_max<- tapply(biooccu[,4],biooccu$Species,max)
treedata_min <- treedata_max <- node_est <- envelope <- list()
geo_center<-array(NA,dim=c(100,53,21,21))
geo_size<-array(NA,dim=c(100,53,21,21))
for (tr in 1:length(sampletrees)){
  treedata_min[[tr]] <- geiger::treedata(sampletrees[[tr]],sp_data_min,sort=TRUE,warnings=F)
  treedata_max[[tr]] <- geiger::treedata(sampletrees[[tr]],sp_data_max,sort=TRUE,warnings=F)
  full_est <- nodeEstimateEnvelopes(treedata_min[[tr]],treedata_max[[tr]])
  node_est[[tr]] <- full_est$est
  envelope[[tr]] <- getEnvelopes(treedata_min[[tr]], treedata_max[[tr]], node_est[[tr]])
  temp <- getGeoRate(envelope[[tr]], sampletrees[[tr]], which.biovars=1)
  geo_center[tr,,,]<-temp$geo_center
  geo_size[tr,,,]<-temp$geo_size
}

## Not run: plotGeoRates(geo_center, geo_size, temp$time_int, sampletrees, path="tempdir()")

plotGeoRatesCon

Description

plotGeoRatesCon

Usage

plotGeoRatesCon(geo_center, geo_size, time_int, trees, path="")

Arguments

geo_center

change in geographic center of suitable climate envelope

geo_size

change in geographic size of suitable climate envelope

time_int

time intervals to plot

trees

distribution of phylogenies

path

path to the directory where the results to be saved

Details

Creates plot with gray background of all pairwise comparisons of change in geo center and area through time. Blue points on top show the sequential change in geo center and expansion/contraction for all lineages

Value

plots of geo rate

Author(s)

A. Michelle Lawing, Alexandra F. C. Howard

See Also

getGeoRates

Examples

data(sampletrees)
data(occurrences)
tree <- sampletrees[[25]]
occurrences <- getBioclimVars(occurrences, which.biovars=1)
sp_data_min<- tapply(occurrences[,4],occurrences$Species,min)
sp_data_max<- tapply(occurrences[,4],occurrences$Species,max)
treedata_min <- geiger::treedata(tree,sp_data_min,sort=TRUE,warnings=F)
treedata_max <- geiger::treedata(tree,sp_data_max,sort=TRUE,warnings=F)
full_est <- nodeEstimateEnvelopes(treedata_min,treedata_max)
node_est <- full_est$est
example_getEnvelopes <- getEnvelopes(treedata_min, treedata_max, node_est)
example_getGeoRate <- getGeoRate(example_getEnvelopes, tree,which.biovars=1)

## Not run: plotGeoRatesCon(example_getGeoRate$geo_center,example_getGeoRate$geo_size,
example_getGeoRate$time_int, trees = trees[[1]], path=tempdir())
## End(Not run)

plotTraitGram

Description

Combine the node estimates based on random or specified fossil placement and plot them on a phylotraitgram in a specified directory.

Usage

plotTraitGram(treedata_min, treedata_max, node_est, fossils=FALSE, 
which.biovars, path="", use.paleoclimate=TRUE, paleoclimateUser=NULL,
layerAge=c(0:20))

Arguments

treedata_min

a tree data object with the min estimate of the climate envelope

treedata_max

a tree data object with the max estimate of the climate envelope

node_est

the estimate of all the nodes, both min and max

fossils

a matrix with four columns of min age, max age, longitude, and latitude, in that order, and rows that are entries for fossil occurrences.

which.biovars

A vector of the numbers of the bioclimate variables that should be returned. The bioclimate variables number correspond to the Hijmans table at (https://www.worldclim.org/data/bioclim.html).

path

path to the directory where the results should be saved

use.paleoclimate

if left blank, default North America paleoclimate data is used. If FALSE, user submitted paleoclimate must be provided

paleoclimateUser

list of data frames with paleoclimates, must be dataframes with columns: GlobalID, Longitude, Latitude, bio1, bio2,...,bio19. (see getBioclimvars()).

layerAge

vector with the ages of the paleoclimate dataframes, if using user submitted paleoclimate data

Value

a trait gram for minimum and maximum of biovariables

Author(s)

A. Michelle Lawing, Alexandra F. C. Howard

See Also

plotTraitGramMultiPhylo

Examples

data(sampletrees)
data(occurrences)
bounds <- list(sigsq = c(min = 0, max = 1000000))
ex_mytree <- sampletrees[[3]] #single tree
test_con <- ppgmConsensus(occurrences = occurrences, trees = ex_mytree, 
which.biovars = 1, bounds = bounds, control = list(niter = 20))
## Not run: plotTraitGram(test_con$treedata_min,test_con$treedata_max,test_con$node_est)

plotTraitGramMultiPhylo

Description

Combine the node estimates based on random or specified fossil placement and plot them on a phylotrait gram in a specified directory.

Usage

plotTraitGramMultiPhylo(treedata_min, treedata_max, node_est, 
fossils=FALSE, use.paleoclimate=TRUE, paleoclimateUser=NULL, 
layerAge=c(0:20), which.biovars, path="")

Arguments

treedata_min

tree data object with min estimate of the climate envelope

treedata_max

tree data object with max estimate of the climate envelope

node_est

the estimate of all the nodes, both min and max. Must be in format [[trees]][[permut]][2,species,trait]

fossils

a matrix with four columns of min age, max age, longitude, and latitude, in that order, and rows that are entries for fossil occurrences.

use.paleoclimate

if left blank, default North America paleoclimate data is used. If FALSE, user submitted paleoclimate must be provided

paleoclimateUser

list of data frames with paleoclimates, must be dataframes with columns: GlobalID, Longitude, Latitude, bio1, bio2,...,bio19. (see getBioclimvars()).

layerAge

vector with the ages of the paleoclimate dataframes, if using user submitted paleoclimate data

which.biovars

A vector of the numbers of the bioclimate variables that should be returned. The bioclimate variables number correspond to the Hijmans table at (https://www.worldclim.org/data/bioclim.html).

path

path to the directory where the results should be saved

Details

plots a traitgram over multiple phylogenetic trees

Value

a trait gram for minimum and maximum of biovariables over a distribution of phylogenetic trees

Author(s)

A. Michelle Lawing, Alexandra F. C. Howard

See Also

plotTraitGram

Examples

data(sampletrees)
data(occurrences)
bounds <- list(sigsq = c(min = 0, max = 1000000))
sample <-sample(sampletrees,5)
test_ppgm <- ppgm(occurrences = occurrences,trees = sample, 
model = "BM", which.biovars = c(1), bounds = bounds, 
control = list(niter = 20))
## Not run: plotTraitGramMultiPhylo(test_ppgm$treedata_min,
test_ppgm$treedata_max,test_ppgm$node_est)
## End(Not run)

ppgm

Description

ppgm makes a paleophylogeographic species distribution model using the bioclimate envelope method for a specified time period. Currently, models are only available for North America.

Usage

ppgm(occurrences, fossils = FALSE, trees, fossils.edges = FALSE, 
model = "BM", permut = 1, only.biovars = TRUE, which.biovars = c(1:19), 
path = "", plot.TraitGram = FALSE, plot.AnimatedMaps = FALSE, 
plot.GeoRates = FALSE, bounds = list(), control = list(), 
use.paleoclimate = TRUE, paleoclimateUser = NULL, layerAge=c(0:20), 
verbose = TRUE)

Arguments

occurrences

a matrix with three columns of species name, longitude, and latitude, in that order, and rows that are entries for species occurrences. The bioclimate variables can be included for each occurrence in following columns. They must be in order 1 through 19.

fossils

a matrix with four columns of min age, max age, longitude, and latitude, in that order, and rows that are entries for fossil occurrences. The bioclimate variables can be included for each occurrence in following columns. They must be in order 1 through 19. All 19 variables must be included at this stage, variable selection is done with the argument: "which.biovars".

trees

phylogenies of species from first column of occurrences argument. Object of class multiphylo.

fossils.edges

a vector of edges that the fossils belong to. Must be in the same order of the fossils argument. If fossils.edges is false, the the function randomly assigns the location of the fossils depending on the age (see details for more information).

model

the model of evolution to use to estimate ancestor nodes. Argument is passed onto to function nodeEstimate.

permut

the number of times to randomly place fossils in phylogeny and estimate ancestor states.

only.biovars

logical. If FALSE, user must include biovariables in occurrence object.

which.biovars

a vector with the biovars to include in model (see www.worldclim.org for a list of biovars). If "ALL", then all 19 biovars are included in analysis.

path

path to the directory where the results should be saved.

plot.TraitGram

logical. Whether to plot a TraitGram

plot.AnimatedMaps

logical. Whether to plot AnimatedMaps. Requires ImageMagick to be installed on the system.

plot.GeoRates

logical. Whether to plot GeoRates

bounds

parameters for the evolutionary model selected. If none are supplied the default is used

control

settings used for optimisation of model likelihood. Passes to geiger::fitContinuous

use.paleoclimate

if left blank, default North America paleoclimate data is used. If FALSE, user submitted paleoclimate must be provided

paleoclimateUser

list of data frames with paleoclimates, must be dataframes with columns: GlobalID, Longitude, Latitude, bio1, bio2,...,bio19.

layerAge

vector with the ages of the paleoclimate dataframes, if using user submitted paleoclimate data

verbose

default true, returns all outputs. If FALSE then returns only climate envelopes and geographic data

Details

If the 19 bioclimate variables are not supplied with the occurrences or with the fossils, they will be extracted from the closest 50km point location in the modern or paleoclimate maps that are loaded in with this function. The paleoclimate maps are isotopically scaled between general circulation models (see Lawing and Polly 2011; Rodder et al. 2013) and modern climate (see Hijmans et al. 2005). The fossils paleoclimate data is extracted to the closest million year paleoclimate map. Paleoclimate maps are derived at one million year intervals for the past 20 Ma. The tree (phylogeny) should be dichotomous and the species names should match the names in the first column of the occurrences argument.

Value

cem Estimate of climate envelope for each species in present time. A data frame containing species and min mean and max of biovars specified with which.biovars.

geo_move data frame of RateGeoCenter and RateGeoSize

change_geo_center array of change in geographic center of suitable climate for each lineage

change_geo_size array of change in geographic size of suitable climate for each lineage

time_int matrix array of time intervals

treedata_min list of trees with minimum bioclimatic variables

treedata_max list of trees with maximum bioclimatic variables

model_min list of trees with minimum fitted model as specified in model

model_max list of trees with maximum fitted model as specified in model

node_est list of traits at each node for all trees, min and max for each species. As estimated by nodeEstimate and nodeEstimateEnvelopes

aicmin if model is estimated, table of aic values for minimum trait values for all trees

aicmax if model is estimated, table of aic values for maximum trait values for all trees

Author(s)

A. Michelle Lawing, Alexandra F. C. Howard, Maria A. Hurtado-Materon

Examples

data(sampletrees)
data(occurrences)
bounds <- list(sigsq = c(min = 0, max = 1000000))
test_ppgm <- ppgm(occurrences = occurrences,trees = sampletrees, 
model = "BM", which.biovars = c(1), bounds = bounds, 
control = list(niter = 20))

ppgmConsensus

Description

ppgm makes a paleophylogeographic species distribution model using the bioclimate envelope method for a specified time period. consensus version

Usage

ppgmConsensus(occurrences, fossils = FALSE, trees, 
fossils.edges = FALSE, model = "BM", permut = 1, only.biovars = TRUE, 
which.biovars = c(1:19), path = "", plot.TraitGram = FALSE, 
plot.AnimatedMaps = FALSE, plot.GeoRates = FALSE, bounds = list(), 
control = list(), use.paleoclimate = TRUE, paleoclimateUser = NULL, 
layerAge = c(0:20), verbose = TRUE)

Arguments

occurrences

a matrix with three columns of species name, longitude, and latitude, in that order, and rows that are entries for species occurrences. The bioclimate variables can be included for each occurrence in following columns. They must be in order 1 through 19.

fossils

a matrix with four columns of min age, max age, longitude, and latitude, in that order, and rows that are entries for fossil occurrences. The bioclimate variables can be included for each occurrence in following columns. They must be in order 1 through 19. All 19 variables must be included at this stage, variable selection is done with the argument: "which.biovars".

trees

phylogeny of species from first column of occurrences argument. Object of class phylo.

fossils.edges

a vector of edges that the fossils belong to. Must be in the same order of the fossils argument. If fossils.edges is false, the the function randomly assigns the location of the fossils depending on the age (see details for more information).

model

the model of evolution to use to estimate ancestor nodes. Argument is passed onto to function nodeEstimate.

permut

the number of times to randomly place fossils in phylogeny and estimate ancestor states.

only.biovars

logical. If FALSE, user must include biovariables in occurrence object.

which.biovars

a vector with the biovars to include in model (see www.worldclim.org for a list of biovars). If "ALL", then all 19 biovars are included in analysis.

path

path to the directory where the results should be saved.

plot.TraitGram

logical. Whether to plot a TraitGram

plot.AnimatedMaps

Logical. Whether to plot AnimatedMaps. Requires ImageMagick to be installed on the system.

plot.GeoRates

logical. Whether to plot GeoRates

bounds

parameters for the evolutionary model selected. If none are supplied the default is used

control

settings used for optimisation of model likelihood. Passes to geiger::fitContinuous

use.paleoclimate

if left blank, default North America paleoclimate data is used. If FALSE, user submitted paleoclimate must be provided

paleoclimateUser

list of data frames with paleoclimates, must be dataframes with columns: GlobalID, Longitude, Latitude, bio1, bio2,...,bio19.

layerAge

vector with the ages of the paleoclimate dataframes, if using user submitted paleoclimate data

verbose

default true, returns all outputs. If FALSE then returns only climate envelopes and geographic data

Details

If the 19 bioclimate variables are not supplied with the occurrences or with the fossils, they will be extracted from the closest 50km point location in the modern or paleoclimate maps that are loaded in with this function. The paleoclimate maps are isotopically scaled between general circulation models (see Lawing and Polly 2011; Rodder et al. 2013) and modern climate (see Hijmans et al. 2005). The fossils paleoclimate data is extracted to the closest million year paleoclimate map. Paleoclimate maps are derived at one million year intervals for the past 20 Ma. The tree (phylogeny) should be dichotomous and the species names should match the names in the first column of the occurrences argument.

Value

cem Estimate of climate envelope for each species in present time. A data frame containing species and min mean and max of biovars specified with which.biovars.

geo_move data frame of RateGeoCenter and RateGeoSize

change_geo_center array of change in geographic center of suitable climate for each lineage

change_geo_size array of change in geographic size of suitable climate for each lineage

time_int matrix array of time intervals

treedata_min list of trees with minimum bioclimatic variables

treedata_max list of trees with maximum bioclimatic variables

node_est list of traits at each node for all trees, min and max for each species. As estimated by nodeEstimate and nodeEstimateEnvelopes

aicmin if model is estimated, table of aic values for minimum trait values

aicmax if model is estimated, table of aic values for maximum trait values

Author(s)

A. Michelle Lawing, Alexandra F. C. Howard, Maria A. Hurtado-Materon

Examples

data(sampletrees)
data(occurrences)
data(scel_fossils)
bounds <- list(sigsq = c(min = 0, max = 1000000))
ex_mytree <- sampletrees[[3]] #single tree
test_fossil_con <- ppgmConsensus(occurrences = occurrences, 
fossils = scel_fossils, trees = ex_mytree, fossils.edges = FALSE, model = "BM", 
permut = 5, which.biovars = 1, bounds = bounds, control = list(niter = 20))

ppgmMESS

Description

This creates a MESS map for given time slices, climate envelopes, and paleoclimate models.

Usage

ppgmMESS(cem_min, cem_max, est, tree, fossils=NULL, timeslice, 
which.biovars, path = "", use.paleoclimate=TRUE, paleoclimateUser = NULL, 
layerAge=c(0:20), which.plot = c("all","mess","none"))

Arguments

cem_min

the cem min output from the ppgm function. cbind() if there are multiple variables.

cem_max

the cem max output from the ppgm function. cbind() if there are multiple variables.

est

the node_est output from the ppgm function, in list format. [tree][1][min and max][no.of species]

tree

the phylogeny or multiple phylogenies that show the relationship between species

fossils

a matrix with four columns of age to the closest million year integer, longitude, and latitude, in that order, and rows that are entries for fossil occurrences.

timeslice

the time in million of years ago to project MESS maps (0 to 20). can handle single timeslice or vector of times.

which.biovars

the biovariable number(s) between 1 and 19.

path

directory where plots should be stored

use.paleoclimate

if left blank, default North America paleoclimate data is used. If FALSE, user submitted paleoclimate must be provided

paleoclimateUser

list of data frames with paleoclimates, must be dataframes with columns: GlobalID, Longitude, Latitude, bio1, bio2,...,bio19.

layerAge

vector with the ages of the paleoclimate dataframes, if using user submitted paleoclimate data

which.plot

"all" plots trait maps and MESS, "mess" plots MESS map, "none" does not plot

Details

plots MESS maps of climate envelope model for specific time slices. Can either plot individual biovariables, or combined.

Value

list containing array of MESS scores for bioclimatic variables

Author(s)

A. Michelle Lawing, Alexandra F. C. Howard, Maria-Aleja Hurtado-Materon

See Also

ppgm()

Examples

data(sampletrees)
data(occurrences)
sampletrees <- sample(sampletrees,5)
bounds <- list(sigsq = c(min = 0, max = 1000000))
test_ppgm <- ppgm(occurrences = occurrences,trees = sampletrees, 
model = "BM", which.biovars = c(1,4,15), bounds = bounds, 
control = list(niter = 20))
#extract min climate envelope for species
cem_min <- cbind(test_ppgm$cem[, 1], test_ppgm$cem[, 2], test_ppgm$cem[, 3])
cem_max <- cbind(test_ppgm$cem[, 7], test_ppgm$cem[, 8], test_ppgm$cem[, 9])
rownames(cem_min) <- rownames(cem_max) <- rownames(test_ppgm$cem)
mess <- ppgmMESS(cem_min,cem_max,test_ppgm$node_est,tree=sampletrees,timeslice=10,
which.biovars=c(1,4,15), path=tempdir(), which.plot="none")

Sample of Sceloporus phylogenies

Description

A sample of 100 dated phylogenies from Leache & Sites (2010), trimmed for analysis by Lawing et al (2016) Lawing et al (2016) Including fossils in phylogenetic climate reconstructions: A deep time perspective on the climatic niche evolution and diversification of spiny lizards (Sceloporus) Leache & Sites (2010) Chromosome evolution and diversification in North American Spiny Lizards (Genus Sceloporus)

Usage

sampletrees

Format

'sampletrees' 100 trees as class multiPhylo

Source

<https://www.journals.uchicago.edu/doi/10.1086/687202>

<https://karger.com/cgr/article/127/2-4/166/62387/Chromosome-Evolution-and-Diversification-in-North>


Sceloporus fossil data

Description

Fossil occurrences for Sceloporus, as collected for Lawing et al 2016. Occurrence records from Paleobiology Database. See reference for further details Lawing et al (2016) Including fossils in phylogenetic climate reconstructions: A deep time perspective on the climatic niche evolution and diversification of spiny lizards (Sceloporus)

Usage

scel_fossils

Format

'scel_fossils' A data frame where each row is a single fossil

MinAge

Minimum age of fossil

MaxAge

Maximum age of fossil

Longitude

Longitude of occurrence

Latitude

Latitude of occurence

Source

<https://www.journals.uchicago.edu/doi/10.1086/687202>