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

Generate Individual TPD

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:

Using this parameters the function generates a simple data set with two columns:

Generate Population TPD

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")

Generate Multiple Population TPD

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")


ggcostoya/tpcurves2 documentation built on Jan. 1, 2021, 2:19 a.m.