traitecoevo / growth_trajectories

Code for reproducing http://doi.org/10.1101/083451
4 stars 2 forks source link

How functional traits influence plant growth and shade tolerance across the life-cycle

This repository contains code needed to reproduce the article:

Falster DS, Duursma R, FitzJohn R (2018) How functional traits influence plant growth. Proceedings of the National Academy of Sciences USA doi: 10.1073/pnas.1714044115

also available as a preprint at

Falster DS, Duursma R, FitzJohn R (2016) Growth trajectories: how functional traits influence plant growth. bioRxiv: 083451. 10.1101/083451

The idea for this paper came from a presentation at Intecol 2013 in London:

Falster, Daniel (2013): Growth trajectories: a new way of understanding the influence of traits on plant growth. 10.6084/m9.figshare.775379

Instructions

The code included should enabled you to recreate nearly-all the figures from the paper and the supplementary material.

I say "nearly-all" because the code to reproduce figures S1-S2 may no longer run, depending on what version of R and rstan you have installed. These figures were generated by fitting models using the rstan package. Frequent and substantial changes in the rstan package since the code was developed in 2016 mean it no longer compiles and runs, as it did back then. For posterity sake, the original code is included, but I have separated out figures S1-S2 as optional targets in the build.

Reproducing the other figures will take < 5min, once you have the correct packages installed.

Installing relevant software

All analyses were done in R. You need to download this repository, and then open an R session with working directory set to the root of the project.

Remake

To compile the figures figures and supplementary material we use the remake package for R. You can install remake using the devtools package (run install.packages("devtools") to install devtools if needed):

devtools::install_github("richfitz/storr", dependencies=TRUE)
devtools::install_github("richfitz/remake", dependencies=TRUE)

Plant

The analysis is based heavily on the plant package for R. To be guaranteed of recreating the figures, make sure you install v1.1.0, as follows. You must be using R 3.3.0 or newer. At this stage the package is not on CRAN. You're options for installing are described below.

Installation requires a C++11 compatible C compiler (OSX >= 10.10/Yosemite satisfies this, as do standard linux Ubuntu 12.04 and 14.04). On Windows machines you will need to install Rtools.

The plant package can be installed direct from github using the devtools package. plant also requires the packages loggr and RcppR6 packages. Install those with

devtools::install_github("smbache/loggr", dependencies=TRUE)
devtools::install_github("richfitz/RcppR6", dependencies=TRUE)

Then install version 1.1.0 of plant:

devtools::install_github("traitecoevo/plant", ref = "v1.1.0", dependencies=TRUE)

The Biomass and Allometry Database

Figure S2 uses data from the Biomass and Allometry Database. Access to that dataset is obtained via installing the baad.data package:

devtools::install_github("richfitz/datastorr")
devtools::install_github("traitecoevo/baad.data")

Other

We use a number of other packages, which can be easily installed by remake if they are missing:

remake::install_missing_packages()

Finally, compiling the figure 1 and the paper requires a reasonably complete LaTeX installation (e.g. MacTeX for OSX or MikTex for windows). The LaTeX compilation will depend on a few packages from CTAN, make sure to allow automatic package installation by your LaTeX distribution.

Recreating the figures

To generate all figures run:

remake::make()

To make only one of the figures, run a command like

remake::make("output/main/lcp_schematic.pdf")

The list of targets can be gleaned from the file remake.yml.

If you find remake confusing and prefer to run plain R, checkout out the file analysis.R for instructions in plain old vanilla R.