diff options
author | Ken Kellner <ken@kenkellner.com> | 2022-12-02 09:41:16 -0500 |
---|---|---|
committer | Ken Kellner <ken@kenkellner.com> | 2022-12-02 15:48:26 -0500 |
commit | 09d2f9650cc7250125de11caa7f268b1dd42a2d1 (patch) | |
tree | 971e055115e407e0bc870191c57f924233ef63d3 | |
parent | 3f9a6bf604739830ff2ebd9598cd8b72b421c969 (diff) |
Add docker and README
-rw-r--r-- | Dockerfile | 38 | ||||
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | README.md | 15 | ||||
-rw-r--r-- | unmarked_Paper_Analysis.Rmd | 4 |
4 files changed, 63 insertions, 2 deletions
diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1d0f46b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +# Start with R version 4.2.2 +FROM rocker/r-ver:4.2.2 + +# Install some linux libraries that R packages need +RUN apt-get update && apt-get install -y \ + pandoc \ + libcurl4-openssl-dev \ + libfontconfig1-dev \ + libssl-dev \ + cmake \ + libxml2-dev \ + libxt6 + +# Set renv version 0.15.5 +ENV RENV_VERSION 0.15.5 + +# Install renv +RUN Rscript -e "install.packages('http://cran.r-project.org/src/contrib/Archive/renv/renv_${RENV_VERSION}.tar.gz', repos=NULL, type='source')" + +# Create a working directory +WORKDIR /unmarked-paper + +# Install all R packages specified in renv.lock +COPY renv.lock renv.lock +RUN Rscript -e 'renv::restore()' + +# Copy necessary files +COPY unmarked_Paper_Analysis.Rmd unmarked_Paper_Analysis.Rmd +COPY acfl_roanoke_river.csv acfl_roanoke_river.csv + +# Run analysis +RUN Rscript -e "rmarkdown::render('unmarked_Paper_Analysis.Rmd')" + +# Copy other files +COPY README.md README.md + +# Default to bash terminal when running docker image +CMD ["bash"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2f9dafe --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +docker: + docker image build -t unmarked-paper . + $(eval ID = $(shell docker create unmarked-paper)) + mkdir -p docker-output + rm -f docker-output/* + docker cp $(ID):/unmarked-paper/unmarked_Paper_Analysis.html docker-output/ + docker cp $(ID):/unmarked-paper/Figure_4.tiff docker-output/ + docker rm -v $(ID) diff --git a/README.md b/README.md new file mode 100644 index 0000000..3b725ca --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# unmarked-paper + +Analysis code for Kellner KF, et al. "The unmarked R package: Twelve years of advances in occurrence and abundance modeling in ecology". + +This analysis is fully reproducible using the following steps. + +1. Copy the data file `acfl_roanoke_river.csv` into this directory. +2. Install the `renv` package, e.g. with `install.packages('renv')`. +3. Run `renv::restore()` in this directory. This downloads and locally installs the exact versions of the R packages specified in the `renv.lock` file (it should not affect your existing R package library). +4. Compile the Rmarkdown document by running `rmarkdown::render("unmarked_Paper_Analysis.Rmd")`. As part of this process, output will be tested to make sure it matches expected results. + +This will yield two files: an HTML file with the analysis results, and a TIFF image (Figure 4 in the paper). + +Alternatively you can build the Docker image by running `make docker` in this directory at the command line, assuming you have the appropriate software installed. +In this case, after the Docker image is built the two resulting output files will be copied into a new `docker-output` directory. diff --git a/unmarked_Paper_Analysis.Rmd b/unmarked_Paper_Analysis.Rmd index 8ae3168..ada0ff5 100644 --- a/unmarked_Paper_Analysis.Rmd +++ b/unmarked_Paper_Analysis.Rmd @@ -409,7 +409,7 @@ stopifnot(pct_decline_plant == 7.0) pct_decline_plant ``` -## Build Figure 5 +## Build Figure 4 Predicted abundance over time by habitat: @@ -441,7 +441,7 @@ ggplot(data=pr, aes(x=Year+2005, y=Predicted)) + Save plot to file: ```{r} -tiff("Figure_5.tiff", height=5, width=7, units='in', res=300, compression='lzw') +tiff("Figure_4.tiff", height=5, width=7, units='in', res=300, compression='lzw') ggplot(data=pr, aes(x=Year+2005, y=Predicted)) + geom_point(data=pr_point, aes(col=Habitat), alpha=0.2) + geom_ribbon(aes(ymin=lower, ymax=upper, fill=Habitat), alpha=0.2) + |