Fisheries and Oceans Canada (DFO) is responsible for the management of aquatic freshwater habitat and the Fish and Fish Habitat Protection Program is seeking tools that can help in their decision support process. The Fish Ecology Science Lab at DFO has developed general models to predict the presence and cover of submerged aquatic vegetation (SAV) in the Laurentian Great Lakes (Croft-White et al. 2022). SAV is a critical component of fish habitat that is frequently affected by in-water works or habitat improvement initiatives. Croft-White et al. (2022) outlines the completed SAV model and how an R-package and web-application tool could be created and utilized. DFO GLLFAS does not have the capacity to create the necessary R package and requires the services of a contractor to advance these works. A key aspect of package development will be ensuring further tool development within DFO can follow similar methods so tools can be integrated or, at a minimum, contain input or outputs that can be moved among tools.
You can install SAVM from GitHub using the pak package:
# Install pak if you don't have it
install.packages("pak")
# Install SAVM
pak::pak("FishEcologyScience/SAVM")Alternatively, you can use remotes:
# Install remotes if you don't have it
install.packages("remotes")
# Install SAVM
remotes::install_github("FishEcologyScience/SAVM")- R >= 4.2
- Quarto (required for rendering vignettes and documentation)
- Geospatial system libraries required for the
sfpackage (GDAL, GEOS, PROJ)
Download and install Quarto from https://quarto.org/docs/get-started/, or using package managers:
On Ubuntu/Debian:
sudo apt-get install quartoOn macOS (using Homebrew):
brew install quartoOn Ubuntu/Debian:
sudo apt-get install libgdal-dev libgeos-dev libproj-dev libudunits2-devOn macOS (using Homebrew):
brew install gdal geos proj udunitsOn Windows, these dependencies are typically handled automatically during package installation.
SAVM is a hybrid R package that provides both programmatic functions and a comprehensive Shiny web application. The package implements statistical models for predicting submerged aquatic vegetation presence and cover in the Laurentian Great Lakes.
-
R/ - Core source code (20 files, ~6,000 lines)
- Application architecture (
app_*.R) - Shiny modules (
mod_*.R) - Data processing functions (
read.R,compute_fetch.R,model.R) - Visualization (
plot_sav.R) - Utilities (
utils_*.R,zzz.R)
- Application architecture (
-
inst/ - Package resources
extdata/models/- 6 pre-trained models (Random Forest, GAM, LMM)extdata/polygons/- Great Lakes boundary files (GeoPackage format)extdata/templates/- CSV templates for user inputapp/www/- Shiny app assets (CSS, images, HTML documentation)example/- Example datasets (Lake Erie, Lake Ontario)
-
tests/ - Test suite using testthat framework
- Unit tests for core functions
- Visual regression tests for plots
- Snapshot testing for consistent outputs
-
vignettes/ - User documentation
get_started.Rmd- Workflow introductionmodels.Rmd- Model methodology
-
man/ - Function documentation (auto-generated)
The Shiny application follows a step-by-step workflow with dedicated modules:
- mod_data_input.R (856 lines) - Upload and validate CSV/spatial data
- mod_fetch_calc.R (542 lines) - Wind fetch calculation interface
- mod_depth_extract.R (337 lines) - Bathymetric depth extraction
- mod_model_apply.R (672 lines) - Model configuration and prediction
- mod_results_viz.R (994 lines) - Results visualization and export
- mod_input_tab.R (183 lines) - Data assembly overview
- mod_modal_welcome.R (27 lines) - Welcome dialog
Data Input:
read_sav()- Main wrapper for reading dataread_sav_csv()- Read point data from CSVread_sav_pts()- Read spatial point dataread_sav_aoi()- Read polygons and generate grids
Processing:
compute_fetch()- Calculate wind fetch for pointssav_model()- Apply SAV prediction modelssav_load_model()- Load pre-trained models
Visualization:
plot_sav_distribution()- Distribution plotsplot_sav_density()- Density visualizationsplot_sav_tmap()- Interactive maps
Application:
run_app()- Launch Shiny application
Six statistical models available in inst/extdata/models/:
Presence/Absence: rf_pa.rds, gam_pa.rds, lmm_pa.rds
Cover Prediction: rf_cover.rds, gam_cover.rds, lmm_cover.rds
All models use depth (m) and fetch (km) as primary predictors.
-
Croft-White, M.V., Tang, R., Gardner Costa, J., Doka, S.E., and Midwood, J. D. 2022. Modelling submerged aquatic vegetation presence and percent cover to support the development of a freshwater fish habitat management tool. Can. Tech. Rep. Fish. Aquat. Sci. 3497: vi + 30 p.
-
Chambers, P.A., and Kalff, J. 1985. Depth Distribution and Biomass of Submerged aquatic macrophyte communities in relation to secchi depth. Can. J. Fish. Aquat. Sci. 42: 701–709
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
