Edward Lavender*, Yannick Hunziker, Darryl McLennan, Philip Dermond, Dominique Stalder, Oliver Selz, Jakob Brodersen
*This repository is maintained by Edward Lavender ([email protected]).
This repository contains methods, written in R and organised as an RStudio Project for Lavender et al. (2023). Sex- and length-dependent variation in migratory propensity in brown trout. Ecology of Freshwater Fish. https://doi.org/10.1111/eff.12745
In this project, we studied the migratory propensity of potamodromous brown trout (Salmo trutta) in streams around Lake Lucerne (central Switzerland). In this system, the trout exhibit partial lacustrine–adfluvial migration, with a portion of individuals remaining resident in natal rivers while others migrate into the Lake (where predation risks are higher but growth opportunities are also elevated) for a period of time, before returning to natal streams to overwinter. We captured would-be first-time migrants in streams using electrofishing to study migratory propensity in relation to sex and length. We expected that females, and especially small females, would be more likely to undertake migration than equivalently sized males, and that they would migrate earlier in the season than males. Sampled individuals were measured, sexed using a genetic sex determination method and tagged using passive integrated transponders (PIT), which enabled us to identify migration into the Lake. This repository records how we coupled individual trait-level data (size, sex) with inferred migratory status (migrant, non-migrant) to model migratory propensity.
The project was built in R (version 4.2.3)
in RStudio and implements local dependency
management using
renv. This
manages the installation of the
dv package for project
management (from GitHub), as well as other
packages from the Comprehensive R Archive
Network. The first time the project is
opened, renv can
be used to regenerate the local project library, as described in
renv.lock (via .Rprofile and renv/activate.R).
The project follows a standardised structure encouraged by the
dv package. The high-level
structure was generated via dv::use_template_proj(). The contents as
follows:
-
renv/implements local dependency management. -
data-raw/contains ‘raw’ data:fish/contains dataframes that define individual size, sex and migratory status (0, 1) for sampled individuals (assembled by YH) and associated PIT tag data;spatial/contains supporting spatial datasets, including:altitude.tif, a raster that defines the altitude (at 2 x 2 m resolution) in the study area, from the Swiss Federal Office of Topography;streams/, a directory that defines stream geometries (created manually via https://map.geo.admin.ch/) and associated characteristics;
-
data/contains processed data and results:fish.rdsis the processedfishdataset, fromprocess_data_fish.R(see below);distances-to-lake.rds,migrants.rds,prop_ss.rdsandprop_sss.rdsare supporting datasets generated by data processing scripts (see below);inst/contains RStudio Project-management files generated bydv:tree.rdsis a record of the project directory tree (as generated bydv::use_template_tree()indev/01-dev.R, see below);
-
R/contains scripts for data processing and analysis:define_*scripts define global parameters and functions:define_global_param.Rdefines global parameters;define_helpers.Rdefines helper functions;
get_data*scripts get raw datasets:get_data.Rcopies raw datasets into this Project;
process_*scripts implement data processing:process_data_spatial.Rprocesses spatial datasets (namely, stream geometries), to define distances along streams to sampling sections and related variables;process_data_fish.Rprocesses the fish data used for analysis;
analyse_*scripts analyse the data and produce figures:analyse_data.Rproduces summary statistics;analyse_p1analyses ‘Prediction 1’ (females, and especially small females, should be more likely to undertake migration than males);analyse_p2analyses ‘Prediction 2’ (females should migrate earlier than equivalently sized males);
-
dev/contains project-management scripts.01-dev.Rand02-clone.Rare standarddvscripts:01-dev.Rrecords project set up and development;02-clone.Ris used to clone the project (see ‘Instructions’);
-
fig/contains figures. -
doc/contains supporting documents.
Note that the data-raw/spatial/, data/ (except data/inst/), fig/
and doc directories are not currently provided in the online version
of this repository.
Follow the steps described below to clone the project and reproduce the workflow.
-
Clone the project via GitHub. Follow the instructions in
dev/02-clone.Rto install project packages and create directories:- Packages. Open
dev/02-clone.Rto userenvto regenerate the local project library. Packages can also be manually reinstalled via02-clone.R. (However, note that package versions may differ in this case.) - Directories. Rebuild the project directory tree, via
dv::use_template_proj()anddv::use_template_tree().
- Packages. Open
-
Source (raw) data via the authors and/or links provided.
-
Define global parameters via
define_global_param.Randdefine_helpers.R. -
Process raw data via
process_*scripts. -
Implement analysis via
analyse_*scripts.
Lavender, E., Hunziker, Y. et al. (2023). Sex- and length-dependent variation in migratory propensity in brown trout. Ecology of Freshwater Fish. https://doi.org/10.1111/eff.12745