knitr::opts_chunk$set(echo = TRUE) devtools::load_all()
In this page, I'll show a how to generate mock thermal-performance data (TPD) at different levels of complexity and present how it looks when plotted. I'll start at the individual level and from there I'll expand to the population and multiple populations level
As part of this package I have developed a function called gen_tpd
(generate thermal-performance data). This function intakes basic TPTs and together with some of other specifications, generates a data set similar to that which could be obtained from a lizard in the field. The objective of developing this tool is to have real-world-like data to test models and perform simulations. I'll first show an example and then explain more in detail how it works and what it provides:
ind_tpd <- gen_tpd( Topt = 25, CTmax = 30, CTmin = 20, Pmax = 10, Pmin = 0, Error = 2, Samples = 10, Degree = 3) ind_tpd
ggplot(data = ind_tpd, aes(x = Tm, y = P)) + geom_point(size = 2) + labs(x = "Temperature", y ="PIT") + theme_classic()
As seen above gen_tpd
intakes the following arguments:
Topt
: The thermal optimum, i.e. the temperature at which maximal performance capacity ($P_{max}$) is reached.
CTmax
& CTmin
: The critical thermal max & min, i.e. the temperature extremes at which performance is minimal. It is important to point out that these two values can be different since a TPC doesn't need to be symmetric around the optimum.
Pmax
: The maximal performance capacity.
Pmin
: The minimal performance capacity. In most cases this is considered zero but I leave it as changeable just in case.
Error
: The amount of noise or error that should be introduced into the data. This allows the data generated by this function to be different every time you use it. Error
is measured in units of standard deviation.
Samples
: The number of samples generated
Degree
: The degree of the polynomial regression of the curve from which the samples should be taken.
Using this parameters the function generates a simple data set with two columns:
Tm
: A vector of temperatures. This values are taken round and in specific intervals, mirroring an experimental measurement.
P
: A vector of performance values, representing the values of a fitness-indicator trait.
As an extension of gen_tpd
, this package also includes the function gen_pop_tpd
to generate TP data at a population level. gen_pop_tpd
following the same logic but includes a new input; N
, which is the number of individuals that should be generated. Additionally, the output also includes an ID
column with randomly generated unique names for each individual (see function gen_id
for how they are made). I'll show an example:
pop_tpd <- gen_pop_tpd( N = 15, Topt = 25, CTmax = 30, CTmin = 20, Pmax = 10, Pmin = 0, Error = 0.5, Samples = 20, Degree = 3)
ggplot(data = pop_tpd, aes(x = Tm, y = P)) + geom_point(aes(colour = factor(ID))) + theme_classic() + labs( x = "Temperature", y = "PIT", colour = "Individual ID")
And finally, gen_pop_tpd
can be used to generate data for multiple populations. As an example I'll generate two populations with distinct TPC shapes on opposite extremes of a Specialist-Generalist trade-off (SGT). First I'll generate data for the Mediterranean island of Menorca where seasonality would push selection towards generalist phenotypes. Second, I'll generate data for the island of Eleuthera in the Bahamas, where, in comparison, lizards should be have evolved to have a more generalist-like TPC:
menorca <- gen_pop_tpd( N = 12, Topt = 18, CTmax = 30, CTmin = 9, Pmax = 5, Pmin = 0, Error = 1, Samples = 10, Degree = 3) eleuthera <- gen_pop_tpd( N = 15, Topt = 28, CTmax = 32, CTmin = 25, Pmax = 10, Pmin = 0, Error = 1, Samples = 10, Degree = 3)
menorca <- menorca %>% mutate( I = rep("Menorca", nrow(menorca))) eleuthera <- eleuthera %>% mutate ( I = rep("Eleuthera", nrow(eleuthera))) isl_tpd <- rbind(menorca, eleuthera) ggplot(data = isl_tpd, aes(x = Tm, y = P)) + geom_point(aes(colour = factor(I))) + theme_classic() + theme(legend.position = "top") + labs( x = "Temperature", y = "Fitness-indicator trait (Performance)", colour = "Island")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.