Title: | Predict Fish Hatch and Emergence Timing |
---|---|
Description: | Predict hatch and emergence timing for a wide range of wild fishes using the effective value framework (Sparks et al., (2019) <DOI:10.1139/cjfas-2017-0468>). 'hatchR' offers users access to established phenological models and the flexibility to incorporate custom parameterizations using external datasets. |
Authors: | Bryan M. Maitland [aut, cre] |
Maintainer: | Bryan M. Maitland <[email protected]> |
License: | GPL-3 |
Version: | 0.3.2.9000 |
Built: | 2025-03-13 15:26:25 UTC |
Source: | https://github.com/bmait101/hatchr |
Check if the dates in a data frame are continuous.
check_continuous(data, dates)
check_continuous(data, dates)
data |
A data.frame, or data frame extension (e.g. a tibble). |
dates |
Column representing the date of the temperature measurements. |
A message indicating if the dates are continuous or if there are breaks. If there are breaks, a vector of row numbers where the breaks occur is returned.
library(hatchR) check_continuous(crooked_river, date)
library(hatchR) check_continuous(crooked_river, date)
Daily stream temperature data from Crooked River, a tributary to the North Fork Boise River, Idaho.
crooked_river
crooked_river
Data frame with columns
Date and time measurement was taken.
Temperature in degrees Celsius.
Dan Isaak, US Forest Service Rocky Mountain Research Station.
crooked_river
crooked_river
stats::nls()
Generate your own custom parameterized models for predicting hatching and emergence phenology.
fit_model(temp, days, species = NULL, development_type = NULL)
fit_model(temp, days, species = NULL, development_type = NULL)
temp |
Numeric vector of temperatures |
days |
Numeric vector of days to hatch or emerge |
species |
Character string of species name (e.g., "sockeye") |
development_type |
Character string of development type: "hatch" or "emerge" |
hatchR also includes functionality to generate your own custom parameterized models for predicting hatching and emergence phenology. Importantly, the custom parameterization relies on the model format developed from model 2 of Beacham and Murray (1990), which we chose because of its overall simplicity and negligible loss of accuracy. See Beacham and Murray (1990) and Sparks et al. (2019) for more specific discussion regarding model 2 and the development of the effective value approach.
List with fit model object, model coefficients, model specifications data.frame, and plot of observations and model fit.
library(hatchR) # vector of temperatures temperature <- c(2, 5, 8, 11, 14) # vector of days to hatch days_to_hatch <- c(194, 87, 54, 35, 28) bt_hatch_mod <- fit_model( temp = temperature, days = days_to_hatch, species = "sockeye", development_type = "hatch" )
library(hatchR) # vector of temperatures temperature <- c(2, 5, 8, 11, 14) # vector of days to hatch days_to_hatch <- c(194, 87, 54, 35, 28) bt_hatch_mod <- fit_model( temp = temperature, days = days_to_hatch, species = "sockeye", development_type = "hatch" )
Water temperature data from Isaak et al. (2018). Generally covers the Boise, Payette, Clearwater, and upper Salmon River watersheds.
idaho
idaho
Data frame
Date measurement was taken.
Site ID.
Temperature in degrees Celsius.
https://hess.copernicus.org/articles/22/6225/2018/
Isaak, D.J., Luce, C.H., Chandler, G.L., Horan, D.L., Wollrab, S.P. (1990). Principal components of thermal regimes in mountain river networks. Hydrology and Earth System Sciences, 22(12), 6225–6240.
idaho
idaho
The function calls a model table with the parameterizations for
different species from different studies built in. Refer to the
table (model_table
) before using function to find inputs for
the different function arguments. It pulls the model format as a
string and parses it to be usable in hatchR model.
model_select(author, species, model_id, development_type = "hatch")
model_select(author, species, model_id, development_type = "hatch")
author |
Character string of author name. |
species |
Character string of species name. |
model_id |
Either model number from Beacham and Murray (1990) or specific to other paper (e.g., Sparks et al. 2017 = AK). |
development_type |
The phenology type. A vector with possible values "hatch" or "emerge". The default is "hatch". |
A data.frame giving model specifications to be passed to
predict_phenology()
.
library(hatchR) # access the parameterization for sockeye hatching using # model #2 from Beacham and Murray (1990) sockeye_hatch_mod <- model_select( author = "Beacham and Murray 1990", species = "sockeye", model_id = 2, development_type = "hatch" ) # print sockeye_hatch_mod
library(hatchR) # access the parameterization for sockeye hatching using # model #2 from Beacham and Murray (1990) sockeye_hatch_mod <- model_select( author = "Beacham and Murray 1990", species = "sockeye", model_id = 2, development_type = "hatch" ) # print sockeye_hatch_mod
Table providing the model parameterizations for the phenology models.
model_table
model_table
Data frame with 5 columns:
Author-year short citation
Species name
Identification number for a model parameterization
Hatch or emergence
character string of parameterized function expression
Beacham & Murray (1990), Sparks et al. (2017), Austin et al. (2019).
Beacham, T.D., Murray, C.B. (1990). Temperature, egg size, and development of embryos and alevins of five species of Pacific salmon: a comparative analysis. Canadian Journal of Zoology, 68, 1931–1940.
Sparks, M.M., Westley, P.A.H., Falke, J.A., Quinn, T.A. (2017). Thermal adaptation and phenotypic plasticity in a warming world: Insights from common garden experiments on Alaskan sockeye salmon. Canadian Journal of Fisheries and Aquatic Sciences, 76(1), 123–135.
Austin, C.C., Essington, T.E., Quinn, T.A. (2019). Spawning and emergence phenology of bull trout Salvelinus confluentus under differing thermal regimes. Canadian Journal of Fisheries and Aquatic Sciences, 94(1), 191–195.
model_table
model_table
The plot_check_temp
function is used to plot imported data to check
temperature values. The function takes a data frame with dates and
temperature values, and plots the temperature values over time. The
function also allows users to specify the visual thresholds for minimum and maximum temperature
values to be plotted.
plot_check_temp(data, dates, temperature, temp_min = 0, temp_max = 25)
plot_check_temp(data, dates, temperature, temp_min = 0, temp_max = 25)
data |
A data.frame, or data frame extension (e.g. a tibble). |
dates |
Vector of dates for temperature measurements. Must be date or date-time class. |
temperature |
Vector of temperature values. |
temp_min |
Threshold for lower range of expected temperature. Default is 0. |
temp_max |
Threshold for upper range of expected temperature. Default is 25. |
A object of class "gg" and "ggplot" that can be printed to the console or saved as an image.
library(hatchR) plot_check_temp( data = crooked_river, dates = date, temperature = temp_c )
library(hatchR) plot_check_temp( data = crooked_river, dates = date, temperature = temp_c )
The function takes the output from predict_phenology()
and creates a
basic ggplot2 plot object to visualize the predicted phenology.
plot_phenology(plot, style = "all", labels = TRUE)
plot_phenology(plot, style = "all", labels = TRUE)
plot |
A list containing the output from |
style |
The style of the plot. A vector with possible values "all", "ef_cumsum", "ef_daily". The default is "all". |
labels |
Logical. If TRUE (default), labels are added to the plot. |
A object of class "gg" and "ggplot".
library(hatchR) # get model parameterization sockeye_hatch_mod <- model_select( author = "Beacham and Murray 1990", species = "sockeye", model = 2, development_type = "hatch" ) # predict phenology sockeye_hatch <- predict_phenology( data = woody_island, dates = date, temperature = temp_c, spawn.date = "1990-08-18", model = sockeye_hatch_mod ) plot_phenology(sockeye_hatch) plot_phenology(sockeye_hatch, style = "ef_cumsum") plot_phenology(sockeye_hatch, style = "ef_daily") plot_phenology(sockeye_hatch, labels = FALSE)
library(hatchR) # get model parameterization sockeye_hatch_mod <- model_select( author = "Beacham and Murray 1990", species = "sockeye", model = 2, development_type = "hatch" ) # predict phenology sockeye_hatch <- predict_phenology( data = woody_island, dates = date, temperature = temp_c, spawn.date = "1990-08-18", model = sockeye_hatch_mod ) plot_phenology(sockeye_hatch) plot_phenology(sockeye_hatch, style = "ef_cumsum") plot_phenology(sockeye_hatch, style = "ef_daily") plot_phenology(sockeye_hatch, labels = FALSE)
Predict the phenology of fish using the effective value framework.
predict_phenology(data, dates, temperature, spawn.date, model)
predict_phenology(data, dates, temperature, spawn.date, model)
data |
Data frame with dates and temperature. |
dates |
Date of temperature measurements. |
temperature |
Temperature measurements. |
spawn.date |
Date of spawning, given as a character string (e.g., "1990-08-18"). Must be year-month-day in format shown. |
model |
A data.frame with a column named "expression" or a character vector
giving model specifications. Can be obtained using |
A list with the following elements:
days_to_develop
: A numeric vector of length 1; number of predicted
days to hatch or emerge.
ef_table
: An n x 4 tibble (n = number of days to hatch or emerge) with
the dates, temperature, effective values, and cumulative sum of the
effective values.
dev.period
: a 1x2 dataframe with the dates corresponding to when your
fish's parent spawned (input with predict_phenology(spawn.date = ...)
)
and the date when the fish is predicted to hatch or emerge.
model_specs
: A data.frame with the model specifications.
Sparks, M.M., Falke, J.A., Quinn, T.A., Adkinson, M.D., Schindler, D.E. (2019). Influences of spawning timing, water temperature, and climatic warming on early life history phenology in western Alaska sockeye salmon. Canadian Journal of Fisheries and Aquatic Sciences, 76(1), 123–135.
library(hatchR) # get model parameterization sockeye_hatch_mod <- model_select( author = "Beacham and Murray 1990", species = "sockeye", model_id = 2, development_type = "hatch" ) # predict phenology sockeye_hatch <- predict_phenology( data = woody_island, dates = date, temperature = temp_c, spawn.date = "1990-08-18", model = sockeye_hatch_mod )
library(hatchR) # get model parameterization sockeye_hatch_mod <- model_select( author = "Beacham and Murray 1990", species = "sockeye", model_id = 2, development_type = "hatch" ) # predict phenology sockeye_hatch <- predict_phenology( data = woody_island, dates = date, temperature = temp_c, spawn.date = "1990-08-18", model = sockeye_hatch_mod )
The summarize_temp
function is used to summarize sub-daily temperature
measurements to obtain mean daily temperature.
summarize_temp(data, dates, temperature)
summarize_temp(data, dates, temperature)
data |
A data.frame, or data frame extension (e.g. a tibble). |
dates |
Column representing the date of temperature measurements. |
temperature |
Column representing temperature values. |
A data.frame with summarized daily temperature values.
library(hatchR) summarize_temp( data = idaho, dates = date, temperature = temp_c )
library(hatchR) summarize_temp( data = idaho, dates = date, temperature = temp_c )
Temperature Data from Woody Island in Lake Iliamna, Alaska
woody_island
woody_island
Data frame with columns:
Date measurement was taken.
Temperature in degrees Celsius.
Sparks et al. (2019)
Sparks, M.M., Falke, J.A., Quinn, T.A., Adkinson, M.D., Schindler, D.E., Bartz, K., Young, D., Westley, P.A.H. (2019). Influences of spawning timing, water temperature, and climatic warming on early life history phenology in western Alaska sockeye salmon. Canadian Journal of Fisheries and Aquatic Sciences, 76(1), 123–135.
woody_island
woody_island