Skip to content

SNARL1/sierra-reintroduction-cmr

Repository files navigation

sierra-reintroduction-cmr

DOI

Maxwell B. Joseph and Roland A. Knapp

This repository contains models and data to understand how the amphibian chytrid fungus Batrachochytrium dendrobatidis and climatic conditions drive population dynamics of Sierra Nevada yellow-legged frogs. It combines a capture mark-recapture model with a joint model for Bd/host dynamics that accomodates known introductions of hosts. This is associated with the paper Disease and climate effects on individuals drive post-reintroduction population dynamics of an endangered amphibian. This repo is maintained by Max Joseph (maxwell.b.joseph (at) colorado.edu).

Reproducing the analysis

Hardware requirements

We recommend a machine with at least 60 GB of RAM. We used an EC2 r4.2xlarge instance on Amazon Web Services.

Software dependencies

We ran the analysis with GNU Make, R, and the following R packages (see R/load-deps.R):

You will also need pandoc and a LaTeX installation to compile the paper.

We used the following R version and OS:

R version 3.4.2 (2017-09-28) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 16.04.3 LTS

Docker instructions

If you don't want to bother with a local installation, the software requirements have been wrapped in a Docker image (see Dockerfile for the source code). To run the Docker container, first install Docker if necessary then run:

docker run -d -e PASSWORD=yourpassword -p 8787:8787 mbjoseph/sierra-reintroduction-cmr

This will launch an RStudio server on port 8787. If running locally navigate to http://localhost:8787, and if running on AWS replace localhost with the Public DNS (IPv4) of your EC2 instance, ensuring that the security group allows inbound access to port 8787. Once at the login prompt, you can log in with username rstudio, and the password provided in your call to docker run (e.g., yourpassword in the example above). If you are running a cloud instance that allows inbound access from all IP addresses, use the terminal program passwd to change the password to something better.

If the Terminal pane in RStudio is not working (a known bug), select Tools > Global Options... > Terminal, and uncheck the "Connect with WebSockets" option, then click Apply and OK. Then you should be able to open a new terminal in the terminal pane: Terminal > New Terminal.

Running the code

We have wrapped the workflow in a GNU Make command. To reproduce the analysis, in a terminal, cd into the sierra-reintroduction-cmr directory and type make to clean the data, fit models, create plots, and then generate a final pdf of the paper:

cd sierra-reintroduction-cmr
make

This should generate a PDF of the manuscript called main.pdf in a few hours.

Analysis description

The GNU Make program orchestrates the following:

  1. Data cleaning: data from Alpine and Subalpine are cleaned using the clean-*-data.R scripts, generating alpine.RData and subalpine.RData

  2. Model fitting: those RData files are used as input to a Stan model, stan/uncertain-state.stan, to estimate parameters and save model fits alpine_fit.rds and subalpine_fit.rds

  3. Visualization: all of the figures are generated by running R scripts prefixed by plot*, e.g., R/plot-detection-effects.R, R/plot-transitions.R. All relationships between generated figures and scripts are defined in the Makefile.

  4. Compiling the RMarkdown manuscript: after all figures are generated, main.Rmd is used to generate an intermediate tex file and a final pdf of the manuscript.

About the data

See the README file in the data directory (data/README.md) for a description of the data.

About

Data and code for the article: Disease and climate effects on individuals jointly drive post-reintroduction population dynamics of an endangered amphibian

Resources

License

Stars

Watchers

Forks

Packages

No packages published