Title: | Fossil Analysis |
---|---|
Description: | Functions for downloading, reshaping, culling, cleaning, and analyzing fossil data from the Paleobiology Database <https://paleobiodb.org>. |
Authors: | Andrew A. Zaffos |
Maintainer: | Andrew A Zaffos <[email protected]> |
License: | GPL-3 |
Version: | 1.1.0 |
Built: | 2025-03-13 03:15:43 UTC |
Source: | https://github.com/cran/velociraptr |
Creates a community matrix of taxon abundances, with samples as rows and species as columns, from a data frame.
abundanceMatrix(Data, Rows = "geoplate", Columns = "genus")
abundanceMatrix(Data, Rows = "geoplate", Columns = "genus")
Data |
A data.frame of taxonomic occurrences. Must have at least two columns. One column representing the samples, and one column representing the taxa. |
Rows |
A characer string |
Columns |
A character string |
Note that older versions of this function automatically checked for and removed hanging factors. However, this is something that should really be dictated by the user, and that step is no longer a part of the function. This is unlikely to introduce any breaking changes in older scripts, but we note it here for documentation purposes..
A numeric matrix of taxon abundances. Samples as the rownames and species as the column names.
Andrew A. Zaffos
# Download a test dataset of pleistocene bivalves. # DataPBDB<-downloadPBDB(Taxa="Bivalvia", StartInterval="Pleistocene", StopInterval="Pleistocene") # Clean the genus column # DataPBDB<-cleanTaxonomy(DataPBDB,"genus") # Create a community matrix of genera by tectonic plate id# # CommunityMatrix<-abundanceMatrix(Data=DataPBDB, Rows="geoplate", Columns="genus")
# Download a test dataset of pleistocene bivalves. # DataPBDB<-downloadPBDB(Taxa="Bivalvia", StartInterval="Pleistocene", StopInterval="Pleistocene") # Clean the genus column # DataPBDB<-cleanTaxonomy(DataPBDB,"genus") # Create a community matrix of genera by tectonic plate id# # CommunityMatrix<-abundanceMatrix(Data=DataPBDB, Rows="geoplate", Columns="genus")
Find the age range (first occurrence and last occurrence) for each taxon in a PBDB dataset. Can be run for any level of the taxonomic hierarchy (e.g., family, genus).
ageRanges(Data, Taxonomy = "genus")
ageRanges(Data, Taxonomy = "genus")
Data |
A data frame downloaded from the paleobiology database API. |
Taxonomy |
A characer string identifying the desired level of the taxonomic hierarchy. |
Returns a data frame of that states gives the time of origination and extinction for each taxon as numeric values. Note that older versions of this function automatically dropped hanging factors and NA's, but that cleaning step should ideally be dictated by the user up-front. So that functionality has been dropped. This may introduce breaking chanes in legacy scripts, but is easily fixed by standard data cleaning steps.
A numeric matrix of first and last ages for each taxon, with tax as rownames.
Andrew A. Zaffos
# Download a test dataset of Cenozoic bivalves. # DataPBDB<-downloadPBDB(Taxa="Bivalvia",StartInterval="Cenozoic",StopInterval="Cenozoic") # Find the first occurrence and last occurrence for all Cenozoic bivalves in DataPBDB # AgeRanges<-ageRanges(DataPBDB,"genus")
# Download a test dataset of Cenozoic bivalves. # DataPBDB<-downloadPBDB(Taxa="Bivalvia",StartInterval="Cenozoic",StopInterval="Cenozoic") # Find the first occurrence and last occurrence for all Cenozoic bivalves in DataPBDB # AgeRanges<-ageRanges(DataPBDB,"genus")
Removes NAs and subgenera from the genus column.
cleanTaxonomy(Data, Taxonomy = "genus")
cleanTaxonomy(Data, Taxonomy = "genus")
Data |
A data frame of taxonomic ocurrences downloaded from the paleobiology database API. |
Taxonomy |
A character string |
Will remove NA's and subgenera from the genus column of a PBDB dataset. It can also be used on other datasets of similar structure to convert species names to genus, or remove NAs.
Will return a data frame identical to the original, but with the genus column cleaned.
Andrew A. Zaffos
# Download a test dataset of Cenozoic bivalves. # DataPBDB<-downloadPBDB(Taxa="Bivalvia",StartInterval="Cenozoic",StopInterval="Cenozoic") # Clean up the genus column. # CleanedPBDB<-cleanTaxonomy(DataPBDB,"genus")
# Download a test dataset of Cenozoic bivalves. # DataPBDB<-downloadPBDB(Taxa="Bivalvia",StartInterval="Cenozoic",StopInterval="Cenozoic") # Clean up the genus column. # CleanedPBDB<-cleanTaxonomy(DataPBDB,"genus")
Assign fossil occurrences to different intervals within a geologic timescale, then remove occurrences that are not temporally constrained to a single interval within that timescale.
constrainAges(Data, Timescale) multiplyAges(Data, Timescale)
constrainAges(Data, Timescale) multiplyAges(Data, Timescale)
Data |
A data frame |
Timescale |
A data frame |
Cull a paleobiology database data frame to only occurrences temporally constrained to be within a certain level of the geologic timescale (e.g., period, epoch). The geologic timescale should come from the Macrostrat database, but custom time-scales can be used if structured in the same way. See downloadTime
for how to download a timescale.
A data frame
Andrew A. Zaffos
# Download a test dataset of Cenozoic bivalves. # DataPBDB<-downloadPBDB(Taxa="Bivalvia",StartInterval="Cenozoic",StopInterval="Cenozoic") # Download the international epochs timescale from macrostrat.org # Epochs<-downloadTime("international epochs") # Find only occurrences that are temporally constrained to a single international epoch # ConstrainedPBDB<-constrainAges(DataPBDB,Timescale=Epochs) # Create mutliple instances of a single occurrence for each epoch it occurs in # MultipliedPBDB<-multiplyAges(DataPBDB,Timescale=Epochs)
# Download a test dataset of Cenozoic bivalves. # DataPBDB<-downloadPBDB(Taxa="Bivalvia",StartInterval="Cenozoic",StopInterval="Cenozoic") # Download the international epochs timescale from macrostrat.org # Epochs<-downloadTime("international epochs") # Find only occurrences that are temporally constrained to a single international epoch # ConstrainedPBDB<-constrainAges(DataPBDB,Timescale=Epochs) # Create mutliple instances of a single occurrence for each epoch it occurs in # MultipliedPBDB<-multiplyAges(DataPBDB,Timescale=Epochs)
Functions for recursively culling community matrices of rare taxa and depauperate samples.
cullMatrix(CommunityMatrix, Rarity = 2, Richness = 2, Silent = FALSE)
cullMatrix(CommunityMatrix, Rarity = 2, Richness = 2, Silent = FALSE)
CommunityMatrix |
a matrix |
Rarity |
a whole number |
Richness |
a whole number |
Silent |
logical |
Takes a community matrix (see presenceMatrix
or abundanceMatrix
) and removes all samples with fewer than a certain number of taxa and all taxa that occur below a certain threshold of samples. The function operates recursively, and will check to see if removing a rare taxon drops a sampe below the input minimum richness and vice-versa. This means that it is possible to eliminate all taxa and samples if the rarity and richness minimums are too high. If the Silent
argument is set to FALSE
the function will throw an error and print a warning if no taxa or samples are left after culling. If Silent
is set to TRUE
the function will simply return NULL
. The latter case is useful if many matrices are being culled as a part of a loop, and you do not want to break the loop with an error.
These functions originally appeared in the R script appendix of Holland, S.M. and A. Zaffos (2011) "Niche conservatism along an onshore-offshore gradient". Paleobiology 37:270-286.
A community matrix with depauperate samples and rare taxa removed.
Andrew A. Zaffos
# Download a test dataset of pleistocene bivalves. # DataPBDB<-downloadPBDB(Taxa="Bivalvia",StartInterval="Pleistocene",StopInterval="Pleistocene") # Create a community matrix with tectonic plates as "samples". # CommunityMatrix<-abundanceMatrix(DataPBDB,"geoplate") # Remove taxa that occur in less than 5 samples and samples with fewer than 25 taxa. # cullMatrix(CommunityMatrix,Rarity=5,Richness=25,Silent=FALSE)
# Download a test dataset of pleistocene bivalves. # DataPBDB<-downloadPBDB(Taxa="Bivalvia",StartInterval="Pleistocene",StopInterval="Pleistocene") # Create a community matrix with tectonic plates as "samples". # CommunityMatrix<-abundanceMatrix(DataPBDB,"geoplate") # Remove taxa that occur in less than 5 samples and samples with fewer than 25 taxa. # cullMatrix(CommunityMatrix,Rarity=5,Richness=25,Silent=FALSE)
Download a paleogeographic map for an age expressed in millions of years ago.
downloadPaleogeography(Age = 0)
downloadPaleogeography(Age = 0)
Age |
A whole number up to 550 |
Downloads a map of paleocontinents for a specific age from Macrostrat.org as a shapefile. The given age must be expressed as a whole number. Note that the function makes use of the rgdal and RCurl packages.
A simple features object
Andrew A. Zaffos
# Download a test dataset of Maastrichtian bivalves. # DataPBDB<-downloadPBDB(Taxa="Bivalvia",StartInterval="Maastrichtian",StopInterval="Maastrichtian") # Download a paleogeographic map. # KTBoundary<-downloadPaleogeography(Age=66) # Plot the paleogeographic map (uses rgdal) and the PBDB points. # plot(KTBoundary,col="grey") # points(x=DataPBDB[,"paleolng"],y=DataPBDB[,"paleolat"],pch=16,cex=2)
# Download a test dataset of Maastrichtian bivalves. # DataPBDB<-downloadPBDB(Taxa="Bivalvia",StartInterval="Maastrichtian",StopInterval="Maastrichtian") # Download a paleogeographic map. # KTBoundary<-downloadPaleogeography(Age=66) # Plot the paleogeographic map (uses rgdal) and the PBDB points. # plot(KTBoundary,col="grey") # points(x=DataPBDB[,"paleolng"],y=DataPBDB[,"paleolat"],pch=16,cex=2)
Downloads a data frame of Paleobiology Database fossil occurrences.
downloadPBDB(Taxa, StartInterval = "Pliocene", StopInterval = "Pleistocene")
downloadPBDB(Taxa, StartInterval = "Pliocene", StopInterval = "Pleistocene")
Taxa |
a character vector |
StartInterval |
a character vector |
StopInterval |
a character vector |
Downloads a data frame of Paleobiology Database fossil occurrences matching certain taxonomic groups and age range. This is simply a convenience function for rapid data download, and only returns the most generically useful fields. Go directly to the Paleobiology Database to make more complex searches or access additional fields. This function makes use of the RCurl package.
ocurrence_no: The Paleobiology Database occurrence number.
collection_no: The Paleobiology Database collection number.
reference_no: The Paleobiology Database reference number.
Classifications: The stated Linnean classification of the occurence from phylum through genus. See cleanTaxonomy
for how to simplify these fields.
accepted_name: The highest resolution taxonomic name assigned to the occurrence.
Geologic Intervals: The earliest possible age of the occurrence and latest possible age of the occurrence, expressed in terms of geologic intervals. See constrainAge
for how to simplify these fields.
Numeric Ages: The earliest possible age of the occurrence and latest possible age of the occurrence, expressed as millions of years ago.
Geolocation: Both present-day and rotated paleocoordinates of the occurrence. The geoplate id used by the rotation model is also included. The key for geoplate ids can be found in the Paleobiology Database API documentation.
a data frame
Andrew A. Zaffos
# Download a test dataset of Ypresian bivalves. # DataPBDB<-downloadPBDB(Taxa="Bivalvia",StartInterval="Ypresian",StopInterval="Ypresian") # Download a test dataset of Ordovician-Silurian trilobites and brachiopods. # DataPBDB<-downloadPBDB(c("Trilobita","Brachiopoda"),"Ordovician","Silurian")
# Download a test dataset of Ypresian bivalves. # DataPBDB<-downloadPBDB(Taxa="Bivalvia",StartInterval="Ypresian",StopInterval="Ypresian") # Download a test dataset of Ordovician-Silurian trilobites and brachiopods. # DataPBDB<-downloadPBDB(c("Trilobita","Brachiopoda"),"Ordovician","Silurian")
Download a shapefile of a geolocation from the Macrostrat API's implementation of the Who's on First database by MapZen.
downloadPlaces(Place = "Wisconsin", Type = "region")
downloadPlaces(Place = "Wisconsin", Type = "region")
Place |
A character string; the name of a place |
Type |
A character string; a type of place |
Download a shapefile of a geolocation from the Macrostrat API. The Macrostrat database provides a GeoJSON of a particular location given the location's name
and type
. Type can be of the categories: "continent"
, "country"
, "region"
, "county"
, and "locality"
.
If multiple locations of the same type share the same name (e.g., Alexandria), the route will return a feature collection of all matching polygons.
An rgdal compatible shapefile
Andrew A. Zaffos
# Download a polygon of Dane County, Wisconsin, United States, North America # DaneCounty<-downloadPlaces(Place="Dane",Type="county") # Download a polygon of Wisconsin, United States, North America # Wisconsin<-downloadPlaces(Place="Wisconsin",Type="region") # Download a polygon of North America # NorthAmerica<-downloadPlaces(Place="North America",Type="continent")
# Download a polygon of Dane County, Wisconsin, United States, North America # DaneCounty<-downloadPlaces(Place="Dane",Type="county") # Download a polygon of Wisconsin, United States, North America # Wisconsin<-downloadPlaces(Place="Wisconsin",Type="region") # Download a polygon of North America # NorthAmerica<-downloadPlaces(Place="North America",Type="continent")
Downloads a geologic timescale from the Macrostrat.org database.
downloadTime(Timescale = "interational epochs")
downloadTime(Timescale = "interational epochs")
Timescale |
character string; a recognized timescale in the Macrostrat.org database |
Downloads a recognized timescale from the Macrostrat.org database. This includes the name, minimum age, maximum age, midpoint age, and official International Commission on Stratigraphy color hexcode if applicable of each interval in the timescale. Go to https://macrostrat.org/api/defs/timescales?all for a list of recognized timescales.
A data frame
Andrew A. Zaffos
# Download the ICS recognized periods timescale Timescale<-downloadTime(Timescale="international periods")
# Download the ICS recognized periods timescale Timescale<-downloadTime(Timescale="international periods")
Download an equal-area grid of the world with fixed latitudinal spacing and variable longitudinal spacing.
fixedLatitude(LatSpacing = 5, CellArea = "500000")
fixedLatitude(LatSpacing = 5, CellArea = "500000")
LatSpacing |
Number of degrees desired between latitudinal bands |
CellArea |
Desired target area of the cells in km^2 as a character string |
Downloads an equal-area grid with fixed latitudinal spacing and variable longitudinal spacing. The distance between longitudinal borders of grids will adjust to the target area size within each band of latitude. The algorithm will adjust the area of the grids to ensure that the total surface of the globe is covered.
A simple features object
Andrew A. Zaffos
# Download an equal area grid with 10 degree latitudinal spacing and 1,000,000 km^2 grids # EqualArea<-fixedLatitude(LatSpacing=10,CellArea="1000000")
# Download an equal area grid with 10 degree latitudinal spacing and 1,000,000 km^2 grids # EqualArea<-fixedLatitude(LatSpacing=10,CellArea="1000000")
Calculates beta diversity under various Multiplicative Diversity Partitioning paradigms.
multiplicativeBeta(CommunityMatrix) completeTurnovers(CommunityMatrix) notEndemic(CommunityMatrix)
multiplicativeBeta(CommunityMatrix) completeTurnovers(CommunityMatrix) notEndemic(CommunityMatrix)
CommunityMatrix |
a matrix |
Takes a community matrix (see presenceMatrix
or abundanceMatrix
) and returns one of three types of multiplicative beta diversity.
Refer to Tuomisto, H (2010) "A diversity of beta diversities: straightening up a concept gone awry. Part 1. Defining beta diversity as a function of alpha and gamma diversity". Ecography 33:2-22.
multiplicativeBeta(CommunityMatrix):
Calculates the original beta diversity ratio - Gamma/Alpha. It quantifies how many times as rich gamma is than alpha.
completeTurnovers(CommunityMatrix):
The number of complete effective species turnovers observed among compositonal units in the dataset - (Gamma-Alpha)/Alpha.
notEndemic(CommunityMatrix):
The proportion of taxa in the dataset not limited to a single sample - (Gamma-Alpha)/Gamma
A numeric vector
Andrew A. Zaffos
# Download a test dataset of pleistocene bivalves from the Paleobiology Database. # DataPBDB<-downloadPBDB(Taxa="Bivalvia","Pleistocene","Pleistocene") # Create a community matrix with tectonic plates as "samples". # CommunityMatrix<-abundanceMatrix(DataPBDB,"geoplate") # "True local diversity ratio" # multiplicativeBeta(CommunityMatrix) # Whittaker's effective species turnover # completeTurnovers(CommunityMatrix) # Proportional effective species turnover # notEndemic(CommunityMatrix)
# Download a test dataset of pleistocene bivalves from the Paleobiology Database. # DataPBDB<-downloadPBDB(Taxa="Bivalvia","Pleistocene","Pleistocene") # Create a community matrix with tectonic plates as "samples". # CommunityMatrix<-abundanceMatrix(DataPBDB,"geoplate") # "True local diversity ratio" # multiplicativeBeta(CommunityMatrix) # Whittaker's effective species turnover # completeTurnovers(CommunityMatrix) # Proportional effective species turnover # notEndemic(CommunityMatrix)
Creates a community matrix of taxon presences and absences from a data frame with a column of sites and a column of species.
presenceMatrix(Data, Rows = "geoplate", Columns = "genus")
presenceMatrix(Data, Rows = "geoplate", Columns = "genus")
Data |
A dataframe or matrix |
Rows |
A characer string |
Columns |
A character string |
A presence-absence matrix
Andrew A. Zaffos
# Download a test dataset of pleistocene bivalves. # DataPBDB<-downloadPBDB(Taxa="Bivalvia","Pleistocene","Pleistocene") # Create a community matrix of genera by plates. # CommunityMatrix<-presenceMatrix(DataPBDB,Rows="geoplate",Columns="genus") # Create a community matrix of families by geologic interval. # CommunityMatrix<-presenceMatrix(DataPBDB,Rows="early_interval",Columns="family")
# Download a test dataset of pleistocene bivalves. # DataPBDB<-downloadPBDB(Taxa="Bivalvia","Pleistocene","Pleistocene") # Create a community matrix of genera by plates. # CommunityMatrix<-presenceMatrix(DataPBDB,Rows="geoplate",Columns="genus") # Create a community matrix of families by geologic interval. # CommunityMatrix<-presenceMatrix(DataPBDB,Rows="early_interval",Columns="family")
Functions for calculating alpha, beta, and gamma richness of a community matrix under the Additive Diversity partitioning paradigm of R. Lande.
taxonAlpha(CommunityMatrix) meanAlpha(CommunityMatrix) taxonBeta(CommunityMatrix) sampleBeta(CommunityMatrix) totalBeta(CommunityMatrix) totalGamma(CommunityMatrix)
taxonAlpha(CommunityMatrix) meanAlpha(CommunityMatrix) taxonBeta(CommunityMatrix) sampleBeta(CommunityMatrix) totalBeta(CommunityMatrix) totalGamma(CommunityMatrix)
CommunityMatrix |
a matrix |
Takes a community matrix (see presenceMatrix
or abundanceMatrix
) and returns the either the alpha, beta, or gamma richness of a community matrix.
These functions were originally presented in Holland, SM (2010) "Additive diversity partitioning in palaeobiology: revisiting Sepkoskiās question" Paleontology 53:1237-1254.
taxonAlpha(CommunityMatrix)
Calculates the contribution to alpha diversity of each taxon.
meanAlpha(CommunityMatrix)
Calculates the average alpha diversity of all samples.
taxonBeta(CommunityMatrix)
Calculates the contribution to beta diversity of each taxon.
sampleBeta(CommunityMatrix)
Calculates the contribution to beta diversity of each sample.
totalBeta(CommunityMatrix)
Calculates the total beta diversity.
totalGamma(CommunityMatrix)
Calculates the richness of all samples in the community matrix.
A vector of the alpha, beta, or gamma richness of a taxon, sample, or entire community matrix.
Andrew A. Zaffos
# Download a test dataset of pleistocene bivalves. # DataPBDB<-downloadPBDB(Taxa="Bivalvia",StartInterval="Pleistocene",StopInterval="Pleistocene") # Create a community matrix with tectonic plates as "samples" # CommunityMatrix<-abundanceMatrix(DataPBDB,"geoplate") # Calculate the average richness of all samples in a community. # meanAlpha(CommunityMatrix) # The beta diversity of all samples in a community. # totalBeta(CommunityMatrix) # This is, by definition, equivalent to the gamma diversity - mean alpha diversity. # totalBeta(CommunityMatrix)==(totalGamma(CommunityMatrix)-meanAlpha(CommunityMatrix))
# Download a test dataset of pleistocene bivalves. # DataPBDB<-downloadPBDB(Taxa="Bivalvia",StartInterval="Pleistocene",StopInterval="Pleistocene") # Create a community matrix with tectonic plates as "samples" # CommunityMatrix<-abundanceMatrix(DataPBDB,"geoplate") # Calculate the average richness of all samples in a community. # meanAlpha(CommunityMatrix) # The beta diversity of all samples in a community. # totalBeta(CommunityMatrix) # This is, by definition, equivalent to the gamma diversity - mean alpha diversity. # totalBeta(CommunityMatrix)==(totalGamma(CommunityMatrix)-meanAlpha(CommunityMatrix))