Skip to content

edwardlavender/patter-flapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Animal tracking with particle algorithms for conservation

Edward Lavender*

Project Status: Active – The project has reached a stable, usable state and is being actively developed.

*This repository is maintained by Edward Lavender (edward.lavender@eawag.ch).

Introduction

This repository reconstructs movement patterns of a Critically Endangered elasmobranch in a passive acoustic telemetry system. In 2016–17, we tagged flapper skate (Dipturus intermedius) with acoustic and archival tags in a Marine Protected Area (MPA) off the west coast of Scotland as part of the Movement Ecology of Flapper Skate (MEFS) project. In 2023, we developed a process-based framework for reconstructing movement patterns and patterns of space use, motivated by our work in this system (Lavender et al., 2023). More recently, we refined this framework, formalising the methodology in the language of state-space modelling, with model inference implemented using particle algorithms (Lavender et al., 2024). We developed the patter package to support its application (Lavender et al., 2024). The package is implemented in R and wraps a high-performance Julia backend. In this repository, we apply the methodology to reconstruct movements, patterns of space use and residency exhibited by tagged individuals in relation to the management zones within the MPA.

Methods are written in R and organised as an RStudio Project. Key elements of the workflow include:

  • Data processing. We collate data from tagged animals and process data as required by the patter package.
  • Simulations. We conduct a simulation-based analysis to evaluate algorithm performance, sensitivity and reproducibility.
  • Real-world analyses. We analyse real-world movement patterns from tagged flapper skate.

Description

Dependencies

The project was built in R (version 4.4.2) in RStudio and implements local dependency management using renv.

Directories

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:

  1. data-raw/ contains ‘raw’ data:

    • bathymetry/ contains bathymetry data for the study area, from Howe et al. (2015), Admiralty and Digimap;
    • boundaries/ contains boundaries of the study site, from process-data-spatial-*.R;
    • coast/ contains coastline data, from Digimap;
    • movement/ contains raw movement datasets, from the MEFS project and Skatespotter;
    • mpa/ contains MPA boundary data, from J. Thorburn;
  2. data/ contains processed data and results:

    • graphics/ contains graphical settings (recorded by scripts);
    • input/ contains algorithm inputs;
    • inst/ contains RStudio Project-management files generated by dv:
      • dependencies.rds is a list of dependencies;
      • session-info.rds is a record of information about the R Session;
      • tree.rds is a record of the project directory tree;
    • output/ contains algorithm outputs;
    • spatial/ contains processed spatial datasets (see process-data-spatial-*.R);
  3. dev/ contains project-management scripts.

    • 01-dev.R and 02-clone.R are standard dv scripts:
      • 01-dev.R records project set up and development;
      • 02-clone.R is used to clone the project (see ‘Instructions’);
      • *-cluster-*.R scripts support local cluster setup and management;
  4. bin/ contains bash scripts.

  5. R/ contains R scripts for data processing and analysis:

    • process-* scripts implement data processing:
      • process-data-spatial-*.R scripts process spatial data;
      • process-data-mefs-*.R scripts process MEFS data;
    • explore-* scripts implement data exploration;
      • explore-data-mefs-*.R scripts explore the MEFS data;
    • formulate-models.R formulates models;
    • simulate algorithms.R runs simulations;
    • prepare-*.Rscripts prepare real-world analyses:
      • prepare-runs prepares iteration datasets;
      • prepare-xinit-*.R prepares initial locations;
    • run-* scripts run real-world analyses:
      • run-coa.R runs the COA algorithm;
      • run-rsp.R runs the RSP algorithm;
      • run-patter-trials.R trials patter’s algorithms;
      • run-patter.R - runs patter’s algorithms
      • run-patter-reanalysis.R runs a reanalysis;
      • synthesis.R synthesises results from real-world analyses;
  6. src/ contains supporting R functions.

  7. renv/ implements local dependency management.

  8. Julia/ houses the Julia project.

  9. fig/ contains figures.

  10. doc/ contains supporting documents.

Note that the data-raw/, data/ (except data/inst/), fig/ and doc directories are not provided in the online version of this repository.

Instructions

Follow the steps described below to clone the project and reproduce the workflow.

  1. Contact us. Please get in touch if you would like to reproduce the workflow in full. We are unable to publish all raw datasets openly here due to copyright and third-party restrictions. Digimap datasets are subject to copyright restrictions and acoustic and archival belong to NatureScot and Marine Scotland Science. In addition, in this project, acoustic and archival data were sourced from the MEFS R package, which requires authentication for access.

  2. Clone the project via GitHub. Follow the instructions in dev/02-clone.R to install packages and directories:

    • Packages. Work through dev/02-clone.R to use renv to regenerate the local project library. Packages can also be manually reinstalled via 02-clone.R. Contact us for the development versions of R and Julia libraries. Authentication is required for MEFS.
    • Directories. Rebuild the project directory tree, via dv::use_template_proj() and dv::use_template_tree().
  3. Source project files (namely, raw data) from the authors.

  4. Implement scripts in the order provided.

  5. Warnings:

    • patter routines. We continued to revise the patter package during the development of this repository, so some routines may no longer work with the recorded package version.
    • Clusters. Selected routines were designed for specific clusters and may require adaptation for other machines.

References

Howe, J. et al. (2014). The seabed geomorphology and geological structure of the Firth of Lorn, western Scotland, UK, as revealed by multibeam echo-sounder survey. Earth and Environmental Science Transactions of the Royal Society of Edinburgh, 105(4), 273–284. https://doi.org/10.1017/S1755691015000146

Lavender, E. et al. (2023). An integrative modelling framework for passive acoustic telemetry. Methods in Ecology and Evolution, 14, 2626–2638. https://doi.org/10.1111/2041-210X.14193

Lavender, E. et al. (2024a). Particle algorithms for animal movement modelling in autonomous receiver networks. bioRxiv, https://doi.org/10.1101/2024.09.16.613223

Lavender, E. et al. (2024b). patter: particle algorithms for animal tracking in R and Julia. bioRxiv, https://doi.org/10.1101/2024.07.30.605733

Citation

Lavender, E., Scheidegger, A., Albert, C., Biber, S. W., Brodersen, J., Aleynik, D., Cole, G., Dodd, J., Wright, P. J., Illian, J., James, M., Smout, S., Thorburn, J., & Moor, H. (2025). Animal tracking with particle algorithms for conservation. bioRxiv. https://doi.org/10.1101/2025.02.13.638042

Code of conduct

Please note that this project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.