trackSpp {plantTracker} | R Documentation |
Tracks genets through time for multiple species and sites
Description
This function tracks individual organisms in mapped quadrats through time to generate a demographic dataset that includes survival and growth for each individual.
Usage
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,
...
)
Arguments
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. |
Details
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")
Value
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. |
See Also
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).
Examples
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
)