Skip to content

R code supporting Lavender et al. (in prep). patter: particle algorithms for animal tracking in R and Julia.

Notifications You must be signed in to change notification settings

edwardlavender/patter-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple demonstration of the patter package

Edward Lavender*

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

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

Introduction

This repository contains methods, written in R and organised as an RStudio Project, for Lavender et al. (in prep). patter: particle algorithms for animal tracking in R and Julia. In this project, we simulate animal tracking data and apply particle filtering and smoothing algorithms to reconstruct patterns of space use. The code forms a basic worked example of the patter R package.

Description

Dependencies

The project was built in R (version 4.3.1) in RStudio and implements local dependency management using renv. This manages the installation of the dv package (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).

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. renv/ implements local dependency management.

  2. data/ contains data:

    • spatial/ contains spatial datasets (sourced from patter-flapper);
    • data.table/, filter/, smoother/, sim/ and ud/ contain script outputs;
    • 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 (as generated by dv::use_template_tree() in dev/01-dev.R, see below);
  3. R/ contains scripts for data preparation, simulation and analysis:

    • preparation.R prepares spatial dataset(s);
    • workflow.R simulates and analyses animal tracking datasets;
    • figs.R produces manuscript figures;
  4. src/ contains helper (R) functions.

  5. Julia/ contains a Julia project.

    • This is set up by patter;
  6. 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’);
  7. fig/ contains figures.

  8. doc/ contains supporting documents.

Note that the 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. 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. If required, patter is available here.
    • Directories. Rebuild the project directory tree, via dv::use_template_proj() and dv::use_template_tree().
  2. Source (raw) data via the links provided (or the authors).

  3. Implement workflow via R scripts.

Citation

Lavender et al. (in prep). patter: particle algorithms for animal tracking in R and Julia.

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.