-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
91 lines (58 loc) · 7.12 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
title: Migratory propensity in juvenile brown trout
author: Edward Lavender*, Yannick Hunziker, Darryl McLennan, Philip Dermond, Dominique Stalder, Oliver Selz, Jakob Brodersen
output: github_document
---
[![Project Status: Inactive – The project has reached a stable, usable state but is no longer being actively developed; support/maintenance will be provided as time allows.](https://www.repostatus.org/badges/latest/inactive.svg)](https://www.repostatus.org/#inactive) [![DOI](https://zenodo.org/badge/630420674.svg)](https://zenodo.org/badge/latestdoi/630420674)
^\*^This repository is maintained by Edward Lavender (edward.lavender@eawag.ch).
# Introduction
This repository contains methods, written in [R](https://www.r-project.org/) and organised as an [RStudio](https://www.rstudio.com/) [Project](https://r4ds.had.co.nz/workflow-projects.html) 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.
# Description
## Dependencies
The project was built in [R](https://www.r-project.org/) (version `r paste0(version$major, ".", version$minor)`) in [RStudio](https://www.rstudio.com/) and implements local dependency management using [`renv`](https://rstudio.github.io/renv/articles/renv.html). This manages the installation of the [`dv`](https://github.com/edwardlavender/dv) package for project management (from [GitHub](https://github.com/)), as well as other packages from the [Comprehensive R Archive Network](https://cran.r-project.org/). The first time the project is opened, [`renv`](https://rstudio.github.io/renv/articles/renv.html) can be used to regenerate the local project library, as described in `renv.lock` (via `.Rprofile` and `renv/activate.R`).
## Directories
The project follows a standardised structure encouraged by the [`dv`](https://github.com/edwardlavender/dv) package. The high-level structure was generated via `dv::use_template_proj()`. The contents as follows:
1. **`renv/`** implements local dependency management.
2. **`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](https://www.swisstopo.admin.ch/en/geodata/height/alti3d.html);
- `streams/`, a directory that defines stream geometries (created manually via https://map.geo.admin.ch/) and associated characteristics; <br/>
3. **`data/`** contains processed data and results:
- `fish.rds` is the processed `fish` dataset, from `process_data_fish.R` (see below);
- `distances-to-lake.rds`, `migrants.rds`, `prop_ss.rds` and `prop_sss.rds` are supporting datasets generated by data processing scripts (see below);
- `inst/` contains [RStudio](https://www.rstudio.com/) [Project](https://r4ds.had.co.nz/workflow-projects.html)-management files generated by [`dv`](https://github.com/edwardlavender/dv):
- `tree.rds` is a record of the project directory tree (as generated by `dv::use_template_tree()` in `dev/01-dev.R`, see below); <br/>
4. **`R/`** contains scripts for data processing and analysis:
- `define_*` scripts define global parameters and functions:
- `define_global_param.R` defines global parameters;
- `define_helpers.R` defines helper functions;
- `get_data*` scripts get raw datasets:
- `get_data.R` copies raw datasets into this Project;
- `process_*` scripts implement data processing:
- `process_data_spatial.R` processes spatial datasets (namely, stream geometries), to define distances along streams to sampling sections and related variables;
- `process_data_fish.R` processes the fish data used for analysis;
- `analyse_*` scripts analyse the data and produce figures:
- `analyse_data.R` produces summary statistics;
- `analyse_p1` analyses 'Prediction 1' (females, and especially small females, should be more likely to undertake migration than males);
- `analyse_p2` analyses 'Prediction 2' (females should migrate earlier than equivalently sized males); <br/>
5. **`dev/`** contains project-management scripts.
- `01-dev.R` and `02-clone.R` are standard [`dv`](https://github.com/edwardlavender/dv) scripts:
- `01-dev.R` records project set up and development;
- `02-clone.R` is used to clone the project (see 'Instructions');
6. **`fig/`** contains figures.
7. **`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.
# Instructions
Follow the steps described below to clone the project and reproduce the workflow.
1. **Clone the project** via GitHub. Follow the instructions in `dev/02-clone.R` to install project packages and create directories:
- **Packages.** Open `dev/02-clone.R` to use [`renv`](https://rstudio.github.io/renv/articles/renv.html) to regenerate the local project library. Packages can also be manually reinstalled via `02-clone.R`. (However, note that package versions may differ in this case.)
- **Directories.** Rebuild the project directory tree, via `dv::use_template_proj()` and `dv::use_template_tree()`.
2. **Source (raw) data** via the authors and/or links provided.
3. **Define global parameters** via `define_global_param.R` and `define_helpers.R`.
4. **Process raw data** via `process_*` scripts.
5. **Implement analysis** via `analyse_*` scripts.
# Citation
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
------------------------------------------------------------------------