Last updated: 2021-07-13
Checks: 6 1
Knit directory: foodweb-theory/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
The R Markdown file has unstaged changes. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish
to commit the R Markdown file and build the HTML.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20200205)
was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version 7ba99a7. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish
or wflow_git_commit
). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .Rhistory
Ignored: .Rproj.user/
Untracked files:
Untracked: analysis/rosenzweig-macarthur.Rmd
Untracked: code/Models.R
Untracked: figures/
Untracked: temp/
Unstaged changes:
Modified: analysis/index.Rmd
Modified: analysis/references.bib
Modified: analysis/temperature-GxE-consumers.Rmd
Deleted: analysis/temperature-dependence.Rmd
Modified: code/Consumer_Resource_Functions.R
Modified: code/identify_steady_state.R
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were made to the R Markdown (analysis/temperature-GxE-consumers.Rmd
) and HTML (docs/temperature-GxE-consumers.html
) files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view the files as they were in that past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
html | 82fbf95 | mabarbour | 2020-10-15 | Build site. |
Rmd | d19252f | mabarbour | 2020-10-15 | GxE analysis of temperature. |
I analyze a continuous time model of a consumer-resource interaction. The resource exhibits logistic growth and the consumer has a type 1 functional response:
\[\frac{dR}{dt}=R(r-\frac{rR}{K}-aC)\] \[\frac{dC}{dt}=C(eaR-m)\]
The following ecological rates govern the dynamics of this model:
r = intrinsic growth rate of resource at low densities
K = carrying capacity of resource
a = attack rate of consumer on the resource
e = conversion efficiency of resources into consumers
m = mortality rate of consumer
I consider these ecological rates as the phenotypes of the consumer and resource. For my initial exploration, I’m going to keep things simple and focus on G\(\times\)E effects of consumers, but I also model the effects of E on resources. I’m also going to link phenotypic change to selection, fitness, and stability.
Following the framework of Gilbert et al. (2014), I assume that the temperature dependence of consumer and resource phenotypes can be modelled as Boltzmann-Arrhenius equations. I focus here on temperature because of its well known influence on consumer and resource phenotypes, and its predictable response to climate change. I also use the biological plausible parameter values that Gilbert et al. (2014) provide in Table 1 and Figure 3 of their paper. I explore the effects of temperature across a gradient from 5-30\(^\circ\)C.
To get a sense for how genotype-by-environment interactions (G\(\times\)E) in consumers might alter these dynamics, I created two different genotypes (A and B). These genotypes have the same “initial” phenotype, which I setup at 15\(^\circ\)C. This choice of temperature was arbitrary and I chose it to follow Fig. 3 of Gilbert et al. (2014). I would argue this represents the effect of genotype (G) as it affects the “intercept” of the phenotype. To simulate a G\(\times\)E effect, I adjusted the activation energy of the temperature relationship (i.e., the slope) assuming a linear tradeoff between genotypes. With these two genotypes, I can visualize G effects (comparing at 15\(^\circ\)C), E effects (mean phenotype change with temperature), and G\(\times\)E effects (different slopes of each genotype).
# parameters from Gilbert et al. 2014 and Osmond et al. 2017
E_vC_mean <- 0.46
E_tradeoff <- 0.2
E_vC_A <- E_vC_mean - E_tradeoff
E_vC_B <- E_vC_mean + E_tradeoff
# Genotype A
a_seq <- a_scaling(a0 = a0(a_base = 0.1, v0_C = 1, v0_R = 1,
E_vC = E_vC_A, E_vR = 0.46,
T_C = C_to_K(15), T_R = C_to_K(15)),
v0_C = 1, v0_R = 1, E_vC = E_vC_A, E_vR = 0.46,
T_C = C_to_K(Temp_seq), T_R = C_to_K(Temp_seq))
# Genotype B
a_seq2 <- a_scaling(a0 = a0(a_base = 0.1, v0_C = 1, v0_R = 1,
E_vC = E_vC_B, E_vR = 0.46,
T_C = C_to_K(15), T_R = C_to_K(15)),
v0_C = 1, v0_R = 1, E_vC = E_vC_B, E_vR = 0.46,
T_C = C_to_K(Temp_seq), T_R = C_to_K(Temp_seq))
E_m_mean <- 0.45
# using same tradeoff
E_m_A <- E_m_mean - E_tradeoff
E_m_B <- E_m_mean + E_tradeoff
m_seq <- m_scaling(m0 = m0(m_base = 0.6, E_m = E_m_A, T = C_to_K(15)),
E_m = E_m_A,
T = C_to_K(Temp_seq))
m_seq2 <- m_scaling(m0 = m0(m_base = 0.6, E_m = E_m_B, T = C_to_K(15)),
E_m = E_m_B,
T = C_to_K(Temp_seq))
According to Peters (1983), conversion efficiency e is independent of temperature, so I set e=0.15 as in Fig. 3 of Gilbert et al. (2014).
For resources, I only modelled well known effects of warming.
# Genotype A
r_seq <- r_scaling(r0 = r0(r_base = 2, E_B = 0.32, T = C_to_K(15)),
E_B = 0.32,
T = C_to_K(Temp_seq))
# Genotype A
K_seq <- K_scaling(K0 = K0(K_base = 100, E_B = 0.32, E_S = 0.9, T = C_to_K(15)),
E_B = 0.32,
E_S = 0.9,
T = C_to_K(Temp_seq))
To answer this question, I have to understand how a small change in the phenotype alters the mean fitness (\(\bar{W}\)) of the consumer or resource population (i.e. directional selection). Importantly, both consumer and resource fitness are density-dependent:
\[\bar{W_R}=\frac{1}{R}\frac{dR}{dt}=r-\frac{r}{K}R-aC\] \[\bar{W_C}=\frac{1}{C}\frac{dR}{dt}=eaR-m\]
To make things easier, I assume the consumer and resource dynamics are at an equilibrium and use these values to to estimate selection on each phenotype. Note that I only assess selection acting on the consumer, since I’m primarily interested in the consequences of G\(\times\)E.
Now I can plot both the G\(\times\)E effects of temperature, but also how these G\(\times\)E alters natural selection:
Version | Author | Date |
---|---|---|
82fbf95 | mabarbour | 2020-10-15 |
I’m going to examine how temperature alters the invasion fitness of genotypes A and B. To do this, I need to be able to assess whether Genotype B, e.g., has higher fitness when Genotype A is at equilibrium, and vice versa. But since there phenotypes are different, I need to compare their total phenotype at a particular temperature.
Version | Author | Date |
---|---|---|
82fbf95 | mabarbour | 2020-10-15 |
I can also look at how the G\(\times\)E effects of temperature alter the stability of the consumer-resource interactions:
Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
"none")` instead.
Version | Author | Date |
---|---|---|
82fbf95 | mabarbour | 2020-10-15 |
While we still observe a typical stability pattern with temperature (explained in detail in Gilbert et al. 2014), we see that G\(\times\)E effects can switch which genotypes confer greater stability depending on temperature.
sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.7 LTS
Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] cowplot_1.1.1 forcats_0.5.1 stringr_1.4.0 dplyr_1.0.7
[5] purrr_0.3.4 readr_1.4.0 tidyr_1.1.3 tibble_3.1.2
[9] ggplot2_3.3.5 tidyverse_1.3.1 rootSolve_1.8.2.2 deSolve_1.28
[13] workflowr_1.6.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.6 lubridate_1.7.10 assertthat_0.2.1 rprojroot_2.0.2
[5] digest_0.6.27 utf8_1.2.1 R6_2.5.0 cellranger_1.1.0
[9] backports_1.2.1 reprex_2.0.0 evaluate_0.14 highr_0.9
[13] httr_1.4.2 pillar_1.6.1 rlang_0.4.11 readxl_1.3.1
[17] rstudioapi_0.13 whisker_0.4 jquerylib_0.1.4 rmarkdown_2.9
[21] labeling_0.4.2 munsell_0.5.0 broom_0.7.8 compiler_4.1.0
[25] httpuv_1.6.1 modelr_0.1.8 xfun_0.24 pkgconfig_2.0.3
[29] htmltools_0.5.1.1 tidyselect_1.1.1 viridisLite_0.4.0 fansi_0.5.0
[33] crayon_1.4.1 dbplyr_2.1.1 withr_2.4.2 later_1.2.0
[37] grid_4.1.0 jsonlite_1.7.2 gtable_0.3.0 lifecycle_1.0.0
[41] DBI_1.1.1 git2r_0.28.0 magrittr_2.0.1 scales_1.1.1
[45] cli_3.0.0 stringi_1.6.2 farver_2.1.0 fs_1.5.0
[49] promises_1.2.0.1 xml2_1.3.2 bslib_0.2.5.1 ellipsis_0.3.2
[53] generics_0.1.0 vctrs_0.3.8 tools_4.1.0 glue_1.4.2
[57] hms_1.1.0 yaml_2.2.1 colorspace_2.0-2 rvest_1.0.0
[61] knitr_1.33 haven_2.4.1 sass_0.4.0