Title: | Extract Demographic and Competition Data from Fine-Scale Maps |
---|---|
Description: | Extracts growth, survival, and local neighborhood density information from repeated, fine-scale maps of organism occurrence. Further information about this package can be found in our journal article, "plantTracker: An R package to translate maps of plant occurrence into demographic data" published in 2022 in Methods in Ecology and Evolution (Stears, et al., 2022) <doi:10.1111/2041-210X.13950>. |
Authors: | Alice Stears [aut, cre] , Jared Studyvin [aut], David Atkins [aut] |
Maintainer: | Alice Stears <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.1.0 |
Built: | 2024-10-29 04:17:46 UTC |
Source: | https://github.com/aestears/planttracker |
Extracts growth, survival, and local neighborhood density information from repeated, fine-scale maps of organism occurrence. Further information about this package can be found in our journal article, "plantTracker: An R package to translate maps of plant occurrence into demographic data" published in 2022 in Methods in Ecology and Evolution (Stears, et al., 2022) <doi:10.1111/2041-210X.13950>.
The DESCRIPTION file:
Package: | plantTracker |
Title: | Extract Demographic and Competition Data from Fine-Scale Maps |
Version: | 1.1.0 |
Date: | 2023-05-03 |
Authors@R: | c(person(given = "Alice", family = "Stears", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0002-1325-6641")), person(given = "Jared", family = "Studyvin", role = c("aut"), email = "[email protected]"), person(given = "David", family = "Atkins", role = c("aut"), email = "[email protected]")) |
Author: | Alice Stears [aut, cre] (<https://orcid.org/0000-0002-1325-6641>), Jared Studyvin [aut], David Atkins [aut] |
Maintainer: | Alice Stears <[email protected]> |
Description: | Extracts growth, survival, and local neighborhood density information from repeated, fine-scale maps of organism occurrence. Further information about this package can be found in our journal article, "plantTracker: An R package to translate maps of plant occurrence into demographic data" published in 2022 in Methods in Ecology and Evolution (Stears, et al., 2022) <doi:10.1111/2041-210X.13950>. |
License: | MIT + file LICENSE |
URL: | https://github.com/aestears/plantTracker |
Encoding: | UTF-8 |
LazyData: | true |
Roxygen: | list(markdown = TRUE) |
RoxygenNote: | 7.2.3 |
Depends: | R (>= 2.10) |
Suggests: | testthat (>= 3.0.0), knitr, rmarkdown, spelling, minidown, ggplot2 |
Config/testthat/edition: | 3 |
Imports: | Matrix, igraph, sf, methods, stats, graphics, grDevices, units |
VignetteBuilder: | knitr |
Language: | en-US |
Repository: | https://aestears.r-universe.dev |
RemoteUrl: | https://github.com/aestears/planttracker |
RemoteRef: | HEAD |
RemoteSha: | cf3950b630ed73f2a38115d6cf76750bb331f8ef |
Index of help topics:
aggregateByGenet aggregateByGenet assign Tracks genets through time checkDat checkDat drawQuadMap Create maps of a quadrat over time getBasalAreas Calculates basal area for each species in a quadrat getLambda Calculates lambda, the population growth rate, for each species in a quadrat based on changes in basal cover. getNeighbors Calculates local neighborhood density around each individual in a mapped dataset getRecruits Calculates the number of recruits of each species per year in each quadrat grasslandData Chart Quadrat Dataset for grassland species in MT and AZ An example dataset that contains data from mapped plant chart quadrats. Each row is an observation of one plant. grasslandInventory A dataset indicating sampling years for the grasslandData example dataset groupByGenet Group polygon observations together into a 'genet' based on proximity plantTracker-package Extract Demographic and Competition Data from Fine-Scale Maps trackSpp Tracks genets through time for multiple species and sites
Alice Stears [aut, cre] (<https://orcid.org/0000-0002-1325-6641>), Jared Studyvin [aut], David Atkins [aut]
Maintainer: Alice Stears <[email protected]>
Use the following code to see the vignette will guide you through using the plantTracker package
vignette(topic = "Suggested_plantTracker_Workflow", package = "plantTracker")
Use the following code to see the vignette goes through the trackSpp() function step-by-step
vignette(topic = "Using_the_plantTracker_trackSpp_function", package = "plantTracker")
This function aggregates a data.frame by unique trackIDs so that each row represents a genet (unique genetic individual) in a given year.
aggregateByGenet( dat, site = "Site", quad = "Quad", species = "Species", year = "Year", trackID = "trackID", ... )
aggregateByGenet( dat, site = "Site", quad = "Quad", species = "Species", year = "Year", trackID = "trackID", ... )
dat |
An sf data.frame. Typically this is a data.frame that has been
returned from the |
site |
A character string giving the name of the column in 'dat' that contains the values for site. The default is "Site". |
quad |
A character string giving the name of the column in 'dat' that contains the values for quadrat. The default is "Quad". |
species |
A character string giving the name of the column in 'dat' that contains the values for species. The default is "Species". |
year |
A character string giving the name of the column in 'dat' that contains the values for year. The default is "Year". |
trackID |
A character string giving the name of the column in 'dat' that contains the values for the unique identifier, or trackID. The default is "trackID". |
... |
Other arguments passed on to methods. Not currently used. |
This function is a plantTracker-specific, user-friendly
wrapper for the 'aggregate' function. This function was designed for use
within the trackSpp
function, but can be also called
independently by the user. The function is designed to take a data.frame of
the same format that is returned by trackSpp()
, but it can be used to
aggregate any dataset by genet (or some other unique identifier), as long as
there is a column that identifies genet (or unique identifier) identity for
each observation.
An sf data.frame that has been aggregated by genet so that each row represents one unique genetic individual in one year. This data.frame has columns containing data for site, quadrat, species, year, and trackID, as well as columns called 'basalArea_genet', 'age', 'recruit', 'survives_tplus1', 'nearEdge', and 'size_tplus1'. This data.frame will most likely be shorter than the input 'dat', because a genet that was previously broken into multiple rows representing each ramet in each year will now have only one row in each year.
This function is called inside the trackSpp()
function.
dat <- grasslandData[grasslandData$Site == c("AZ") & grasslandData$Species %in% c("Bouteloua rothrockii", "Calliandra eriophylla" ),] names(dat)[1] <- "speciesName" inv <- grasslandInventory[unique(dat$Quad)] outDat <- trackSpp(dat = dat, inv = inv, dorm = 1, buff = .05, buffGenet = 0.005, clonal = data.frame("Species" = unique(dat$speciesName), "clonal" = c(TRUE,FALSE)), species = "speciesName", aggByGenet = FALSE ) aggregateByGenet(dat = outDat, species = 'speciesName')
dat <- grasslandData[grasslandData$Site == c("AZ") & grasslandData$Species %in% c("Bouteloua rothrockii", "Calliandra eriophylla" ),] names(dat)[1] <- "speciesName" inv <- grasslandInventory[unique(dat$Quad)] outDat <- trackSpp(dat = dat, inv = inv, dorm = 1, buff = .05, buffGenet = 0.005, clonal = data.frame("Species" = unique(dat$speciesName), "clonal" = c(TRUE,FALSE)), species = "speciesName", aggByGenet = FALSE ) aggregateByGenet(dat = outDat, species = 'speciesName')
This function tracks individual organisms through time, but only
for one species in one quadrat. It is designed for use within the
trackSpp
function, and is not intended for use on its own.
assign( dat, inv, dorm, buff, buffGenet, clonal, flagSuspects = FALSE, shrink = 0.1, dormSize = 0.05, inheritsFromTrackSpp = FALSE, nearEdgeBox = NULL, ... )
assign( dat, inv, dorm, buff, buffGenet, clonal, flagSuspects = FALSE, shrink = 0.1, dormSize = 0.05, inheritsFromTrackSpp = FALSE, nearEdgeBox = NULL, ... )
dat |
An sf data.frame of the same format as
This function will add columns called "basalArea_ramet", "trackID", "age", "size_tplus1", "recruit" and "survives_tplus1", so 'dat' should not contain columns with these names. |
inv |
An integer vector that contains all of years in which this quadrat (or other unique spatial area) was sampled. Years must be ordered sequentially. |
dorm |
A numeric vector of length 1, indicating the number of years this species is allowed to go dormant, i.e. be absent from the map but be considered the same individual when it reappears. This must be an integer greater than or equal to 0. |
buff |
A numeric vector of length 1 that is greater than or equal to
zero, indicating how far (in the same units as spatial values in 'dat') a
polygon can move from year |
buffGenet |
A numeric vector of length 1 that is greater than or equal
to zero, indicating how close (in the same units as spatial values in 'dat')
polygons must be to one another in the same year to be grouped as a genet
(if 'clonal' argument = TRUE). This argument is passed to
the |
clonal |
A logical argument of length 1, indicating whether this species is allowed to be clonal or not (i.e. if multiple polygons (ramets) can be grouped into one individual (genet)). If clonal = TRUE, the species is allowed to be clonal, and if clonal = FALSE, the species is not allowed to be clonal. |
flagSuspects |
A logical argument of length 1, indicating whether
observations that are 'suspect' will be flagged. The default is
|
shrink |
A single numeric value. This value is only used when
|
dormSize |
A single numeric value. This value is only used when
|
inheritsFromTrackSpp |
A logical argument that is only applicable when 'assign()' is used internally in 'trackSpp()'. |
nearEdgeBox |
An sf data frame indicating the bounding box of the quadrat. This argument is only used if 'assign()' is used internally in 'trackSpp()'. |
... |
Other arguments passed on to methods. Not currently used. |
see trackSpp
for details of arguments and usage.
trackSpp()
, which is a wrapper for the assign()
function that
applies it over many species and quadrats. The assign()
function uses the
groupByGenet()
function to group ramets into genets
(if 'clonal' argument = TRUE).
A function that both checks and prepares a data.frame for use in
the trackSpp
function.
checkDat( dat, inv = NULL, species = "Species", site = "Site", quad = "Quad", year = "Year", geometry = "geometry", reformatDat = FALSE, ... )
checkDat( dat, inv = NULL, species = "Species", site = "Site", quad = "Quad", year = "Year", geometry = "geometry", reformatDat = FALSE, ... )
dat |
An sf data.frame of the same format as
|
inv |
The name of each element of the list is a quadrat name in 'dat', and the contents of that list element is a numeric vector of all of the years in which that quadrat (or other unique spatial area) was sampled. Make sure this is the years the quadrat was actually sampled, not just the years that have data in the 'dat' argument! This argument allows the function to differentiate between years when the quadrat wasn't sampled and years when there just weren't any individuals of a species present in that quadrat. |
species |
An optional character string argument. Indicates the name of the column in 'dat' that contains species name data. It is unnecessary to include a value for this argument if the column name is "Species" (default value is 'Species'). |
site |
An optional character string argument. Indicates the name of the column in 'dat' that contains site name data. It is unnecessary to include a value for this argument if the column name is "Site" (default value is 'Site'). |
quad |
An optional character string argument. Indicates the name of the column in 'dat' that contains quadrat name data. It is unnecessary to include a value for this argument if the column name is "Quad" (default is 'Quad'). |
year |
An optional character string argument. Indicates the name of the column in 'dat' that contains data for year of sampling. It is unnecessary to include a value for this argument if the column name is "Year" (default is 'Year'). |
geometry |
An optional character string argument. Indicates the name of the column in 'dat' that contains sf geometry data. It is unnecessary to include a value for this argument if the column name is "geometry" (default is 'geometry'). |
reformatDat |
A TRUE/FALSE argument. If 'FALSE', which is the default
value, then |
... |
Other arguments passed on to methods. Not currently used. |
This function is used internally in trackSpp
and other
plantTracker functions to check the 'dat' and 'inv' arguments and ensure that
they are in the correct format with the correct column names. checkDat()
can also be used independently to check that a data.frame is in the correct
format and contains the correct data to be used in the trackSpp()
or other
plantTracker functions.
If the 'reformatDat' argument is FALSE (the default), the return of
this function is a message that says the 'dat' and 'inv' datasets are ready
for use in the trackSpp()
function. This message includes any column name
arguments that must be included in the trackSpp()
function call for these
datasets.
If the 'reformatDat' argument is TRUE, then checkDat()
returns a list that
contains versions of 'dat' and 'inv' that are ready to go directly into the
trackSpp()
or assign()
functions. The list has the following elements:
dat |
An sf data.frame that has five columns called 'Species', 'Site',
'Quad', 'Year', and 'geometry'. Any additional columns that were present in
the version of 'dat' input into the |
inv |
A named list. The name of each element of the list is a quadrat name in 'dat', and the contents of that list element is a numeric vector of all of the years in which that quadrat (or other unique spatial area) was sampled. For each list element, the vector of years is in sequential order from oldest to most recent. |
userColNames |
A named character vector. This vector contains the column
names provided by the user for all of the required data columns in the
original version of 'dat'. The name of each vector element indicates the type
of data that is contained in the column with the name in that vector element.
For example, if the 'dat' data.frame input into |
checkDat(dat = grasslandData, inv = grasslandInventory) checkDat(dat = grasslandData, inv = grasslandInventory, reformatDat = TRUE)
checkDat(dat = grasslandData, inv = grasslandInventory) checkDat(dat = grasslandData, inv = grasslandInventory, reformatDat = TRUE)
This function creates maps of a quadrat over time, color-coded by either species or by genet (trackID).
drawQuadMap( dat, type = "bySpecies", addBuffer = FALSE, species = "Species", site = "Site", quad = "Quad", year = "Year", geometry = "geometry", trackID = "trackID", ... )
drawQuadMap( dat, type = "bySpecies", addBuffer = FALSE, species = "Species", site = "Site", quad = "Quad", year = "Year", geometry = "geometry", trackID = "trackID", ... )
dat |
An sf data.frame in which each row represents a unique polygon
(either a genet or a ramet) in a unique site/quadrat/year combination. It is
recommended that you only input data for one quadrat at a time. A data.frame
returned by
|
type |
A character argument indicating how the plots returned by
|
addBuffer |
A logical argument indicating whether |
species |
An optional character string argument. Indicates the name of the column in 'dat' that contains species name data. It is unnecessary to include a value for this argument if the column name is "Species" (default value is 'Species'). |
site |
An optional character string argument. Indicates the name of the column in 'dat' that contains site name data. It is unnecessary to include a value for this argument if the column name is "Site" (default value is 'Site'). |
quad |
An optional character string argument. Indicates the name of the column in 'dat' that contains quadrat name data. It is unnecessary to include a value for this argument if the column name is "Quad" (default is 'Quad'). |
year |
An optional character string argument. Indicates the name of the column in 'dat' that contains data for year of sampling. It is unnecessary to include a value for this argument if the column name is "Year" (default is 'Year'). |
geometry |
An optional character string argument. Indicates the name of the column in 'dat' that contains sf geometry data. It is unnecessary to include a value for this argument if the column name is "geometry" (default is 'geometry'). |
trackID |
An optional character string argument. Indicates the name of the column in 'dat' that contains unique identifiers for each genet. It is unnecessary to include a value for this argument if the column name is "trackID" (default is 'trackID') |
... |
Other arguments passed on to methods. Not currently used. |
This function returns a multipanel plot where each panel shows a map of the quadrat in a unique year. Panels are arranged in chronological order, and plots are color-coded either by species or trackID (unique genet identifier).
#' @seealso trackSpp()
, which can be used to assign trackIDs
to observations.
dat <- grasslandData[grasslandData$Site == c("AZ") & grasslandData$Quad == "SG2" & grasslandData$Year %in% c(1922:1925),] names(dat)[1] <- "speciesName" inv <- grasslandInventory[unique(dat$Quad)] outDat <- trackSpp(dat = dat, inv = inv, dorm = 1, buff = .05, buffGenet = 0.005, clonal = data.frame("Species" = unique(dat$speciesName), "clonal" = c(TRUE,FALSE)), species = "speciesName", aggByGenet = TRUE ) drawQuadMap(dat = outDat, type = "bySpecies", addBuffer = FALSE, species = "speciesName" )
dat <- grasslandData[grasslandData$Site == c("AZ") & grasslandData$Quad == "SG2" & grasslandData$Year %in% c(1922:1925),] names(dat)[1] <- "speciesName" inv <- grasslandInventory[unique(dat$Quad)] outDat <- trackSpp(dat = dat, inv = inv, dorm = 1, buff = .05, buffGenet = 0.005, clonal = data.frame("Species" = unique(dat$speciesName), "clonal" = c(TRUE,FALSE)), species = "speciesName", aggByGenet = TRUE ) drawQuadMap(dat = outDat, type = "bySpecies", addBuffer = FALSE, species = "speciesName" )
This function calculates the total basal area for each species
present in a quadrat for each year of data collection. Both the absolute
basal area (in the same units of area as the input data.frame) is returned,
as well as the percentage of the total occupied basal area in the quadrat
that is occupied by a given species ("percent total basal area"). If you'd
like to ultimately calculate the population growth rate (lambda) for each
species, you can use the getLambda
function directly, which
takes raw species occurrence data (like in 'dat' here) and returns lambda
values for each species and quadrat for each transition in the dataset.
This function should only be used if the individuals in 'dat' were mapped as
polygons that are representative of their actual basal area, i.e. were not
mapped as points.
getBasalAreas( dat, inv, species = "Species", quad = "Quad", site = "Site", year = "Year", geometry = "geometry", ... )
getBasalAreas( dat, inv, species = "Species", quad = "Quad", site = "Site", year = "Year", geometry = "geometry", ... )
dat |
An sf data.frame in which each row represents a unique polygon
(either a genet or a ramet) in a unique site/quadrat/year combination. A
data.frame returned by
This function should only be used if the individuals in 'dat' were mapped as polygons that are representative of their actual basal area, i.e. were not mapped as points. |
inv |
The name of each element of the list is a quadrat name in 'dat', and the contents of that list element is a numeric vector of all of the years in which that quadrat (or other unique spatial area) was sampled. Make sure this is the years the quadrat was actually sampled, not just the years that have data in the 'dat' argument! This argument allows the function to differentiate between years when the quadrat wasn't sampled and years when there just weren't any individuals of a species present in that quadrat. |
species |
An optional character string argument. Indicates the name of the column in 'dat' that contains species name data. It is unnecessary to include a value for this argument if the column name is "Species" (default value is 'Species'). |
quad |
An optional character string argument. Indicates the name of the column in 'dat' that contains quadrat name data. It is unnecessary to include a value for this argument if the column name is "Quad" (default is 'Quad'). |
site |
An optional character string argument. Indicates the name of the column in 'dat' that contains site name data. It is unnecessary to include a value for this argument if the column name is "Site" (default value is 'Site'). |
year |
An optional character string argument. Indicates the name of the column in 'dat' that contains data for year of sampling. It is unnecessary to include a value for this argument if the column name is "Year" (default is 'Year'). |
geometry |
An optional character string argument. Indicates the name of the column in 'dat' that contains sf geometry data. It is unnecessary to include a value for this argument if the column name is "geometry" (default is 'geometry'). |
... |
Other arguments passed on to methods. Not currently used. |
getBasalAreas()
returns a data.frame with the columns "Site",
"Quad", "Year" and "Species". No two rows will have the same values for all
four of these columns. The column "absolute_basalArea" has the area of the
quadrat that is occupied by a species in a given unique site/quadrat/year
combination. This is in the same units as the area in 'dat'.
"quad_basalArea" gives the combined basal area of all organisms in a given
site/quadrat/year. "percent_basalArea" gives the percentage of occupied basal
area within a quadrat that is occupied by each species in a given
site/quadrat/year. For example, species A has a basal area of 22 cm^2 in
quadrat 1 in 2005 ("absolute_basalArea = 22). In 2005, there are 50 cm^2 of
quadrat 1 that are occupied by organisms ("quad_basalArea" = 55). 44% of the
occupied basal area in quadrat 1 in 2005 is occupied by species A
("percent_basalArea" = 44). There may be an 'NA' in the "percent_basalArea"
column if the "quad_basalArea" for that species and year is 0.
getLambda()
, which uses this function to calculate basal areas and
ultimately return population growth rates (lambdas) for each species in
each quadrat.
dat <- grasslandData[grasslandData$Site == "AZ" & grasslandData$Year %in% c(1922:1925),] names(dat)[1] <- "speciesName" inv <- grasslandInventory[unique(dat$Quad)] outDat <- trackSpp(dat = dat, inv = inv, dorm = 1, buff = .05, buffGenet = 0.005, clonal = data.frame("Species" = unique(dat$speciesName), "clonal" = c(TRUE,FALSE)), species = "speciesName", aggByGenet = TRUE ) getBasalAreas(dat = outDat, inv = inv, species = "speciesName")
dat <- grasslandData[grasslandData$Site == "AZ" & grasslandData$Year %in% c(1922:1925),] names(dat)[1] <- "speciesName" inv <- grasslandInventory[unique(dat$Quad)] outDat <- trackSpp(dat = dat, inv = inv, dorm = 1, buff = .05, buffGenet = 0.005, clonal = data.frame("Species" = unique(dat$speciesName), "clonal" = c(TRUE,FALSE)), species = "speciesName", aggByGenet = TRUE ) getBasalAreas(dat = outDat, inv = inv, species = "speciesName")
This function calculates the population growth rate (lambda) for
every species in a quadrat. This value is the ratio of basal area or number
of individuals in the next year to basal area or number of individuals in the
current year (basal area in year t+1/ basal area in year t). A lambda value
greater than 1 indicates a population is growing, while a value less than 1
indicates population decline. Lambda is 'infinity' when the basal area or
number of individuals in year t is 0, and is NA when basal area or number of
individuals in year t is zero (i.e. when there are no organims present in
year =t). Note that a lambda value is calculated between of the years when a
quadrat was sampled, even if there is a gap in sampling. For example, a
quadrat is sampled in 1998, 1999, 2001, and 2002 (but skipped in 2000). A
lambda value will be calculated for 1998-1999 and 2001-2002, which is a
transition from year t
to year t+1
. However, a lambda value is calculated
in the same manner for 1999-2001, which is actually a transition from year
t
to year t+2
. You can remove these values by subsetting the data.frame
returned by getLambda()
for rows when "Year_tplus1"- "Year_t" is equal
to 1.
getLambda( dat, inv, method = "area", species = "Species", quad = "Quad", site = "Site", year = "Year", geometry = "geometry", ... )
getLambda( dat, inv, method = "area", species = "Species", quad = "Quad", site = "Site", year = "Year", geometry = "geometry", ... )
dat |
An sf data.frame in which each row represents a unique polygon
(either a genet or a ramet) in a unique site/quadrat/year combination. A
data.frame returned by
|
inv |
The name of each element of the list is a quadrat name in 'dat', and the contents of that list element is a numeric vector of all of the years in which that quadrat (or other unique spatial area) was sampled. Make sure this is the years the quadrat was actually sampled, not just the years that have data in the 'dat' argument! This argument allows the function to differentiate between years when the quadrat wasn't sampled and years when there just weren't any individuals of a species present in that quadrat. |
method |
A single character argument that determines the method for calculating lambda. The default value is "area", which means that lambda is calculated by comparing total basal area for a given species in year t+1 to year t. If 'method' = "count", then lambda is calculated by comparing total number of individuals for a given species in year t+1 to year t. If each individual in 'dat' is mapped as a point, it is best to use 'method' = "count". |
species |
An optional character string argument. Indicates the name of the column in 'dat' that contains species name data. It is unnecessary to include a value for this argument if the column name is "Species" (default value is 'Species'). |
quad |
An optional character string argument. Indicates the name of the column in 'dat' that contains quadrat name data. It is unnecessary to include a value for this argument if the column name is "Quad" (default is 'Quad'). |
site |
An optional character string argument. Indicates the name of the column in 'dat' that contains site name data. It is unnecessary to include a value for this argument if the column name is "Site" (default value is 'Site'). |
year |
An optional character string argument. Indicates the name of the column in 'dat' that contains data for year of sampling. It is unnecessary to include a value for this argument if the column name is "Year" (default is 'Year'). |
geometry |
An optional character string argument. Indicates the name of the column in 'dat' that contains sf geometry data. It is unnecessary to include a value for this argument if the column name is "geometry" (default is 'geometry'). |
... |
Other arguments passed on to methods. Not currently used. |
This function returns a data.frame with columns containing site, quadrat, and species data, as well as the following columns:
the 'current' year
basal area (in the same units as the spatial elements of 'dat') for this species in this quadrat in year 't'
the 'next' year
basal area (in the same units as the spatial elements of 'dat') for this species in this quadrat in year 't+1'
The population growth rate for this species in this quadrat from year t to year t+1.
getBasalAreas()
, used internally in this function, which
calculates absolute and relative basal areas for each species in each quadrat
for each year of sampling.
dat <- grasslandData[grasslandData$Site == "AZ" & grasslandData$Year %in% c(1922:1925),] names(dat)[1] <- "speciesName" inv <- grasslandInventory[unique(dat$Quad)] outDat <- trackSpp(dat = dat, inv = inv, dorm = 1, buff = .05, buffGenet = 0.005, clonal = data.frame("Species" = unique(dat$speciesName), "clonal" = c(TRUE,FALSE)), species = "speciesName", aggByGenet = TRUE ) getLambda(dat = outDat, inv = inv, method = "area", species = "speciesName")
dat <- grasslandData[grasslandData$Site == "AZ" & grasslandData$Year %in% c(1922:1925),] names(dat)[1] <- "speciesName" inv <- grasslandInventory[unique(dat$Quad)] outDat <- trackSpp(dat = dat, inv = inv, dorm = 1, buff = .05, buffGenet = 0.005, clonal = data.frame("Species" = unique(dat$speciesName), "clonal" = c(TRUE,FALSE)), species = "speciesName", aggByGenet = TRUE ) getLambda(dat = outDat, inv = inv, method = "area", species = "speciesName")
This function calculates the density of individuals around
each distinct individual in a mapped dataset. It is intended for use on
a dataset that has been returned by the trackSpp
function, but
will work with any sf data.frame where each individual row represents a
distinct individual (genet) in a unique year.
getNeighbors( dat, buff, method, compType = "allSpp", output = "summed", trackID = "trackID", species = "Species", quad = "Quad", year = "Year", site = "Site", geometry = "geometry", ... )
getNeighbors( dat, buff, method, compType = "allSpp", output = "summed", trackID = "trackID", species = "Species", quad = "Quad", year = "Year", site = "Site", geometry = "geometry", ... )
dat |
An sf data.frame. Each row must represent a unique individual
organism in a unique year. This argument can be a data.frame that is returned
by the
|
buff |
A numeric value that is greater than or equal to zero. This indicates the distance (in the same units as the spatial data in 'dat') around each focal individual within which you want to look for competitors. OR buff can be a data.frame with the columns "Species" and "buff". This data.frame must have a row for each unique species present in 'dat', with species name as a character string in the "Species" column, and a numeric value in the 'buff' column you'd like to use for that species. |
method |
A character string, either 'count' or 'area'. This argument determines which method is used to calculate local neighborhood density. If 'method' = 'count', then the number of other individuals within the buffer will be returned in the 'neighbors' column. If method = 'area', then the proportion of the buffer area that is occupied by other individuals will be returned in the 'neighbors' column. If the data in 'dat' was mapped initially as points, it is best to use 'method' = 'count'. If the data was mapped as polygons that are representative of individual basal area, using 'method' = 'area' is likely a more accurate representation of the crowding the focal individual is experiencing. |
compType |
A character string, either 'allSpp' or 'oneSpp'. If compType = 'allSpp', then local neighborhood density is calculated considering all individuals around the focal individual, regardless of species (interspecific competition). If compType = 'oneSpp', then local neighborhood density is calculated considering only individuals in the buffer area that are the same species as the focal individual (intraspecific competition). |
output |
A character string, either 'summed' or 'bySpecies'. The default is 'summed'. This argument is only important to consider if you are using compType = 'allSpp'. If output = 'summed', then only one count/area value is returned for each individual. This value is the total count or area of all neighbors within the focal species buffer zone, regardless of species. If output = 'bySpecies', there is a count or area value returned for each species present in the buffer zone. For example, there are 15 individuals inside a buffer zone. Five are species A, three are species B, and 7 are species C. If output = 'summed', then the 'neighbors_count' column in the output data.frame will have the single value '15' in the row for this focal individual. However, if output = 'bySpecies', the row for this focal individual in the output data.frame will contain a named list in the 'neighbors_count' column that looks like the one below. If 'method' = 'area' and 'output' = 'bySpecies', a similar list will be returned, but will be in the 'neighbors_area' column and will contain areas rather than counts. list("Species A "= 5, "Species B" = 3, "Species C" = 7) #> $`Species A ` #> [1] 5 #> #> $`Species B` #> [1] 3 #> #> $`Species C` #> [1] 7 |
trackID |
An optional character string argument. Indicates the name of the column in 'dat' that contains a value that uniquely identifies each individual/genet. It is unnecessary to include a value for this argument if the column name is 'trackID' (the default value is 'trackID'). |
species |
An optional character string argument. Indicates the name of the column in 'dat' that contains species name data. It is unnecessary to include a value for this argument if the column name is "Species" (default value is 'Species'). |
quad |
An optional character string argument. Indicates the name of the column in 'dat' that contains quadrat name data. It is unnecessary to include a value for this argument if the column name is "Quad" (default is 'Quad'). |
year |
An optional character string argument. Indicates the name of the column in 'dat' that contains data for year of sampling. It is unnecessary to include a value for this argument if the column name is "Year" (default is 'Year'). |
site |
An optional character string argument. Indicates the name of the column in 'dat' that contains site name data. It is unnecessary to include a value for this argument if the column name is "Site" (default value is 'Site'). |
geometry |
An optional character string argument. Indicates the name of the column in 'dat' that contains sf geometry data. It is unnecessary to include a value for this argument if the column name is "geometry" (default is 'geometry'). |
... |
Other arguments passed on to methods. Not currently used. |
This function draws a buffer around each individual genet of a distance specified by the user. Then it either counts the number of other genets within that buffer, or calculates the proportion of that buffer area that is occupied by other individuals. getNeighbors can calculate either interspecific local neighborhood density (between the focal individual and all other individuals within the buffer area) or intraspecific local neighborhood density (between the focal individual and other individuals of the same species within the buffer area).
This function returns a data.frame with the same number of rows as 'dat' and all of the same columns, but with an additional column or columns. If method = 'count', then a column called "neighbors_count" is added, which contains a count of the number of individuals within the buffer area that is occupied by other individuals. If method = 'area', two columns are added. The first is called "nBuff_area", which contains the area of the buffer around the focal individual. The second is called "neighbors_area", which contains the area of the individuals within the buffer zone around the focal individual.
The trackSpp()
function returns a data.frame that can be input
directly into this function. If a data.frame is not aggregated by genet such
that each unique genet/year combination is represented by only one row, then
passing it through the aggregateByGenet()
function will return a data.frame
that can be input directly into this function.
dat <- grasslandData[grasslandData$Site == c("AZ") & grasslandData$Species %in% c("Bouteloua rothrockii", "Calliandra eriophylla"),] names(dat)[1] <- "speciesName" inv <- grasslandInventory[unique(dat$Quad)] outDat <- trackSpp(dat = dat, inv = inv, dorm = 1, buff = .05, buffGenet = 0.005, clonal = data.frame("Species" = unique(dat$speciesName), "clonal" = c(TRUE)), species = "speciesName", aggByGenet = TRUE ) finalDat <- getNeighbors(dat = outDat, buff = .15, method = 'count', compType = 'oneSpp', species = "speciesName")
dat <- grasslandData[grasslandData$Site == c("AZ") & grasslandData$Species %in% c("Bouteloua rothrockii", "Calliandra eriophylla"),] names(dat)[1] <- "speciesName" inv <- grasslandInventory[unique(dat$Quad)] outDat <- trackSpp(dat = dat, inv = inv, dorm = 1, buff = .05, buffGenet = 0.005, clonal = data.frame("Species" = unique(dat$speciesName), "clonal" = c(TRUE)), species = "speciesName", aggByGenet = TRUE ) finalDat <- getNeighbors(dat = outDat, buff = .15, method = 'count', compType = 'oneSpp', species = "speciesName")
This function calculates the number of new recruits of
each species in each quadrat in each year. The input data must already
contain a column indicating whether each observation is classified as a
recruit or not. This recruit status can be generated from the
trackSpp
function in plantTracker
, or can be information that
was collected in the field. This function includes an option that determines
whether each ramet of a clonal species is considered an individual recruit,
or if the entire genet is considered a single recruit.
getRecruits( dat, byGenet = TRUE, species = "Species", quad = "Quad", site = "Site", year = "Year", trackID = "trackID", recruit = "recruit", ... )
getRecruits( dat, byGenet = TRUE, species = "Species", quad = "Quad", site = "Site", year = "Year", trackID = "trackID", recruit = "recruit", ... )
dat |
An sf data.frame in which each row represents a unique polygon
(either a genet or a ramet) in a unique site/quadrat/year combination. A
data.frame returned by
|
byGenet |
A logical argument. |
species |
An optional character string argument. Indicates the name of the column in 'dat' that contains species name data. It is unnecessary to include a value for this argument if the column name is "Species" (default value is 'Species'). |
quad |
An optional character string argument. Indicates the name of the column in 'dat' that contains quadrat name data. It is unnecessary to include a value for this argument if the column name is "Quad" (default is 'Quad'). |
site |
An optional character string argument. Indicates the name of the column in 'dat' that contains site name data. It is unnecessary to include a value for this argument if the column name is "Site" (default value is 'Site'). |
year |
An optional character string argument. Indicates the name of the column in 'dat' that contains data for year of sampling. It is unnecessary to include a value for this argument if the column name is "Year" (default is 'Year'). |
trackID |
An optional character string argument. Indicates the name of the column in 'dat' that contains unique identifiers for each genet. It is unnecessary to include a value for this argument if the column name is "trackID" (default is 'trackID') |
recruit |
An optional character string argument. Indicates the name of the column in 'dat' that contains information indicating whether or not this row represents data for a recruit. It is unnecessary to include a value for this argument if the column name is "recruit" (default is "recruit"). |
... |
Other arguments passed on to methods. Not currently used. |
This function returns a table with columns for site, quadrat, species name, year, and number of recruits.
This function returns a data frame with the columns 'Site', 'Quad', 'speciesName', 'Year', and 'recruits'. The 'recruits' column contains a count of the number of individuals of the species and in the site, quadrat, and year indicated in the other columns of the data frame.
dat <- grasslandData[grasslandData$Site == c("AZ") & grasslandData$Species %in% c("Bouteloua rothrockii", "Calliandra eriophylla") & grasslandData$Year %in% c(1922:1925),] names(dat)[1] <- "speciesName" inv <- grasslandInventory[unique(dat$Quad)] outDat <- trackSpp(dat = dat, inv = inv, dorm = 1, buff = .05, buffGenet = 0.005, clonal = data.frame("Species" = unique(dat$speciesName), "clonal" = c(TRUE,FALSE)), species = "speciesName", aggByGenet = TRUE ) getRecruits(dat = outDat, byGenet = TRUE, species = "speciesName" )
dat <- grasslandData[grasslandData$Site == c("AZ") & grasslandData$Species %in% c("Bouteloua rothrockii", "Calliandra eriophylla") & grasslandData$Year %in% c(1922:1925),] names(dat)[1] <- "speciesName" inv <- grasslandInventory[unique(dat$Quad)] outDat <- trackSpp(dat = dat, inv = inv, dorm = 1, buff = .05, buffGenet = 0.005, clonal = data.frame("Species" = unique(dat$speciesName), "clonal" = c(TRUE,FALSE)), species = "speciesName", aggByGenet = TRUE ) getRecruits(dat = outDat, byGenet = TRUE, species = "speciesName" )
Chart Quadrat Dataset for grassland species in MT and AZ An example dataset that contains data from mapped plant chart quadrats. Each row is an observation of one plant.
grasslandData
grasslandData
An sf data frame with 1242 rows and 15 variables:
A character string indicating the specific epithet for this observation. The ideal formats are the 1) the latin binomial separated by a space (i.e. "Bouteloua gracilis"), 2) the latin binomial separated by an underscore (i.e. "Bouteloua_gracilis"), or 3) a species code consisting of the first n' letters of each element of the latin binomial (i.e. "BOUGRA" or "BOGR"). Whichever format is used, it must be used for all rows.
An integer vector. (1) indicates that this individual is a clone (genet). (0) indicates that this individual is not a clone. NA indicates that this data was not recorded.
An integer vector indicating whether this observation was a seedling (1), or not (0). This data was not collected for many observations, which have an NA in this column.
An integer greater than 0 indicating how many stems were present for the observed plant. This data was not collected for many observations, which have an NA in this column.
An integer vector. (1) indicates that the basal area of
this individual was mapped. (0) indicates that the basal area of this
individual was not mapped (in which case it cannot be used in the
assign
function.) NA indicates that this data was not
recorded.
A factor with two levels: 'point' or 'poly', which indicates whether the observation was originally mapped as a 'point' or a 'polygon'.
A character string indicating the sampling location of this observation. In this dataset, this value is either:
AZ (Santa Rita Experimental Range, Tucson, AZ)
MT (Fort Keogh Livestock and Range Research Laboratory, Miles City, MT)
A character string indicating the name of the quadrat where this plant was mapped.
An integer indicating the year when this plant was mapped.
A character string of the 4-letter species code for this observation (The first two letters of the genus name, and first two letters of the species name, capitalized with no spaces).
A character string of the 6-letter species code for this observation (The first three letters of the genus name, and first three letters of the species name, capitalized with no spaces).
A numeric variable indicating the basal area in m^2 of this observation. In this dataset, observations originally mapped as points were assigned an area of 2.46e-05 m^2. For individuals mapped as polygons, the value in this column indicates the basal area of that plant.
The sf geometry of class "MULTIPOLYGON" for this observation. The location of this polygon indicates the plant's location in a 1 m x 1 m square. If the plant was mapped as a polygon, the area of this polygon indicates the basal area of that plant.
...
doi:dx.doi.org/10.1890/11-2200.1
doi:doi.org/10.6084/m9.figshare.c.3304113.v1
This dataset indicates years in which sampling was conducted for each of the
four quadrats included in the grasslandData
example dataset.
grasslandInventory
grasslandInventory
A named list with 8 items, each of which if named for a quadrat included in the grasslandData dataset.
An integer vector indicating the years in which quadrat C5 was mapped.
An integer vector indicating the years in which quadrat D1 was mapped.
An integer vector indicating the years in which quadrat SG2 was mapped.
An integer vector indicating the years in which quadrat SG4 was mapped.
...
doi:dx.doi.org/10.1890/11-2200.1
doi:doi.org/10.6084/m9.figshare.c.3304113.v1
This function assigns a unique 'genetID' to polygons if they are within a user-defined distance from one another. Each ramet is still represented by a single row of data, but all ramets of the same genet have the same 'genetID'.
groupByGenet(dat, buffGenet, ...)
groupByGenet(dat, buffGenet, ...)
dat |
An sf object that contains polygons to be grouped. Typically
should include data only for one species, one quadrat, and one year. For
intended use, this dataset should be of the format described in
|
buffGenet |
A numeric argument indicating half of the maximum distance
between individual ramets (polygons) that the function will group together as
one genet. Note that this argument is in the same units that are used in the
'dat' argument. For example, if buffGenet = 0.005 and we use the
|
... |
Other arguments passed on to methods. Not currently used. |
If polygons are 'grouped,' they are given the same number in the
'genetID' column. This assignment is made using network analysis to group
together polygons that are closest to one another. In the context of
plantTracker, this function was designed to group ramets (vegetative
clones) together into one genet (genetically distinct individual). This
function was designed for use within the assign
function (and
then the trackSpp
function), but can be used independently.
A numeric vector of unique genetIDs that is as long as the number of
rows in 'dat.' Each element i
in the output is the genetID for the
i
th row in 'dat'.
assign()
and trackSpp()
, plantTracker functions that apply
this function across multiple species, quadrats, and years.
dat <- grasslandData[grasslandData$Site == "AZ" & grasslandData$Quad == "SG2" & grasslandData$Species == "Bouteloua rothrockii" & grasslandData$Year == 1922,] groupByGenet(dat = dat, buffGenet = 0.01) groupByGenet(dat = dat, buffGenet = 0.1)
dat <- grasslandData[grasslandData$Site == "AZ" & grasslandData$Quad == "SG2" & grasslandData$Species == "Bouteloua rothrockii" & grasslandData$Year == 1922,] groupByGenet(dat = dat, buffGenet = 0.01) groupByGenet(dat = dat, buffGenet = 0.1)
This function tracks individual organisms in mapped quadrats through time to generate a demographic dataset that includes survival and growth for each individual.
trackSpp( dat, inv, dorm, buff, buffGenet, clonal, species = "Species", site = "Site", quad = "Quad", year = "Year", geometry = "geometry", aggByGenet = TRUE, printMessages = TRUE, flagSuspects = FALSE, shrink = 0.1, dormSize = 0.05, ... )
trackSpp( dat, inv, dorm, buff, buffGenet, clonal, species = "Species", site = "Site", quad = "Quad", year = "Year", geometry = "geometry", aggByGenet = TRUE, printMessages = TRUE, flagSuspects = FALSE, shrink = 0.1, dormSize = 0.05, ... )
dat |
An sf data.frame of the same format as
This function will add columns called "basalArea_ramet", "trackID", "age", "size_tplus1", "recruit," "nearEdge," and "survives_tplus1", so 'dat' should not contain columns with these names. |
inv |
A named list of the same format as
|
dorm |
A numeric vector of length 1, indicating the number of years an individual of these species is allowed to go dormant, i.e. be absent from the map but be considered the same individual when it reappears. This must be an integer greater than or equal to 0. OR dorm can be a data.frame with the columns "Species" and "dorm". This data.frame must have a row for each unique species present in 'dat', with species name as a character string in the "Species" column, and a numeric value greater than or equal to 0 in the 'dorm' column that indicates the number of years each species is allowed to go dormant. |
buff |
A numeric vector of length 1 that is greater than or equal to
zero, indicating how far (in the same units as spatial values in 'dat') a
polygon can move from year |
buffGenet |
A numeric vector of length 1 that is greater than or equal
to zero, indicating how close (in the same units as spatial values in 'dat')
polygons must be to one another in the same year to be grouped as a genet
(if 'clonal' argument = TRUE). OR buffGenet can be a data.frame with
the columns "Species" and "buffGenet". This data.frame must have a row for
each unique species present in 'dat', with species name as a character string
in the "Species" column, and a numeric value greater than or equal to 0 in
the 'buffGenet' specifying the 'buffGenet' argument for each species. This
argument is passed to the |
clonal |
A logical vector of length 1, indicating whether a species is allowed to be clonal or not (i.e. if multiple polygons (ramets) can be grouped as one individual (genet)). If clonal = TRUE, the species is allowed to be clonal, and if clonal = FALSE, the species is not allowed to be clonal. OR clonal can be a data.frame with the columns "Species" and "clonal". This data.frame must have a row for each unique species present in 'dat', with species name as a character string in the "Species" column, and a logical value in the 'clonal' specifying the 'clonal' argument for each species. |
species |
An optional character string argument. Indicates the name of the column in 'dat' that contains species name data. It is unnecessary to provide a value for this argument if the column name is "Species" (default value is 'Species'). |
site |
An optional character string argument. Indicates the name of the column in 'dat' that contains site name data. It is unnecessary to provide a value for this argument if the column name is "Site" (default value is 'Site'). |
quad |
An optional character string argument. Indicates the name of the column in 'dat' that contains quadrat name data. It is unnecessary to provide a value for this argument if the column name is "Quad" (default is 'Quad'). |
year |
An optional character string argument. Indicates the name of the column in 'dat' that contains data for year of sampling. It is unnecessary to provide a value for this argument if the column name is "Year" (default is 'Year'). |
geometry |
An optional character string argument. Indicates the name of the column in 'dat' that contains sf geometry data. It is unnecessary to provide a value for this argument if the column name is "geometry" (default is 'geometry'). |
aggByGenet |
A logical argument that determines whether the output
of |
printMessages |
A logical argument that determines whether this function returns messages about genet aggregation, as well as messages indicating which year is the last year of sampling in each quadrat and which year(s) come before a gap in sampling that exceeds the 'dorm' argument (and thus which years of data have an 'NA' for "survives_tplus1" and "size_tplus1"). If printMessages = TRUE (the default), then messages are printed. If printMessages = FALSE, messages are not printed. |
flagSuspects |
A logical argument of length 1, indicating whether
observations that are 'suspect' will be flagged. The default is
|
shrink |
A single numeric value. This value is only used when
|
dormSize |
A single numeric value. This value is only used when
|
... |
Other arguments passed on to methods. Not currently used. |
This is a wrapper function that applies assign
across multiple
species, quadrats, and sites. For each species and quadrat, trackSpp()
loads a spatially referenced data.frame ('dat'), and then uses the
groupByGenet
function to assign genetIDs to polygons (if
'clonal' = TRUE) such that polygons that form the same genet have the same
genetID. A buffer of a distance defined by 'buff' is applied around each
genet polygon. Then, the spatial data for each genet from the current year
(year t
) is compared to individuals in the next year (year t+1
). Then
trackSpp()
calculates the amount of overlapping area between polygons
of each year t
genet and polygons of each year t+1
genet (using
st_intersection
). If there is unambiguous overlap between a
'parent' genet from year t
and a 'child' genet from year t+1
, then that
'child' gets the same identifying trackID as the parent. If there is a 'tie,'
where more than one parent overlaps the same child or more than one child
overlaps the same parent, the parent-child pair with the greatest amount of
overlap receives the same trackID. Polygons in year t+1
that do not have a
parent are given new trackIDs and are identified as new recruits. If dormancy
is not allowed, then polygons in year t
that do not have child polygons get
a '0' in the 'survival' column. If dormancy is allowed, parent polygons
without child polygons are stored as 'ghosts' and are then compared to data
from year t+1+i
to find potential child polygons, where i
='dorm'
argument. For a more detailed description of the trackSpp()
function, see
the vignette:
vignette("Using_the_plantTracker_trackSpp_function",
package = "plantTracker")
An sf data.frame with the same columns as 'dat,' but with the following additional columns:
trackID |
A unique value for each individual genet, consisting of the 6-letter species code, the year in which this individual was recruited, and a unique index number, all separated by a "_". |
age |
An integer indicating the age of this individual in year |
size_tplus1 |
The size of this genet in year |
recruit |
A Boolean integer indicating whether this individual is a new
recruit in year |
survives_tplus1 |
A Boolean integer indicating whether this individual
survived (1), or died (0) in year |
basalArea_genet |
The size of this entire genet in year |
basalArea_ramet |
This is only included if 'aggByGenet' = FALSE.
This is the size of this ramet in year |
nearEdge |
A logical value indicating whether this individual is within a buffer (specified by the 'buff' argument) from the edge of the quadrat. |
assign()
, which is used inside the trackSpp()
function.
trackSpp()
applies the assign()
function over multiple species and
quadrats, and uses the aggregateByGenet()
function to aggregate the
demographic results by genet (if 'aggByGenet' = TRUE). The assign()
function uses the groupByGenet()
function to group ramets into genets
(if 'clonal' argument = TRUE).
dat <- grasslandData[grasslandData$Site == c("AZ") & grasslandData$Species %in% c("Bouteloua rothrockii", "Calliandra eriophylla"),] names(dat)[1] <- "speciesName" inv <- grasslandInventory[unique(dat$Quad)] outDat <- trackSpp(dat = dat, inv = inv, dorm = 1, buff = .05, buffGenet = 0.005, clonal = data.frame("Species" = unique(dat$speciesName), "clonal" = c(TRUE,FALSE)), species = "speciesName", aggByGenet = TRUE )
dat <- grasslandData[grasslandData$Site == c("AZ") & grasslandData$Species %in% c("Bouteloua rothrockii", "Calliandra eriophylla"),] names(dat)[1] <- "speciesName" inv <- grasslandInventory[unique(dat$Quad)] outDat <- trackSpp(dat = dat, inv = inv, dorm = 1, buff = .05, buffGenet = 0.005, clonal = data.frame("Species" = unique(dat$speciesName), "clonal" = c(TRUE,FALSE)), species = "speciesName", aggByGenet = TRUE )