DOI: 10.5061/dryad.83bk3j9zk
title: Data from: Fitness surfaces and local thermal adaptation in Drosophila along a latitudinal gradient

description: Local adaptation is commonly cited to explain species distribution, but
 how fitness varies along continuous geographical gradients is not well
 understood. Here we combine thermal biology and life-history theory to
 demonstrate that Drosophila populations along a 2,500 km latitudinal cline
 are adapted to local conditions. We measured how heat tolerance and
 viability rate across 8 populations vary with temperature in the
 laboratory, and then simulated their expected cumulative Darwinian fitness
 employing high-resolution temperature data from their 8 collection sites.
 Simulations indicate a trade-off between annual survival and cumulative
 viability, as both mortality and the recruitment of new flies are
 predicted to increase in warmer regions. Importantly, populations are
 locally adapted and exhibit the optimal combination of both traits to
 maximize fitness where they live. In conclusion, our method is able to
 reconstruct fitness surfaces employing empirical life-history estimates
 and reconstructs peaks representing locally adapted populations, allowing
 to study geographic adaptation in silico.
description: # Fitness surfaces and local thermal adaptation in Drosophila along a
 latitudinal gradient Alruiz JM, Peralta-Maraver I, Cavieres<sup>
 </sup>G, Bozinovic F, Rezende EL. *Ecology Letters*
 [https://doi.org/10.5061/dryad.83bk3j9zk](https://doi.org/10.5061/dryad.83bk3j9zk) ## Description of the data and file structure The attached files contain the data and R code to replicate the analyses and figures presented in the paper, including those from the Supplementary Material. It should be noted that the code routine to obtain the thermal tolerance estimates requires around 4 hours to complete. For this reason, processed thermal tolerance and viability data are provided in "tolerance.RData" and "viability.RData". Note that missing values in all data files have been filled as "NA" **CODE (7 files in total)** **1\. code\_manuscript\.R:** R script to replicate analyses and figures in the paper and Supplementary Material, including Table 1 and Figures 1, 2, 3, and 4. **2\. Functions\_performance\_curve\.R**: Extra functions to fit thermal performance curves based on Rezende & Bozinovic (2019). **3\. Functions\_tolerance\_landscape\.R**: Extra functions to get temperature survival using thermal landscapes and dynamic models from Rezende et al. (2020). **4\. viability\_assembly\.R**: R script to assemble viability data prior to analysis. This code generates the file "viability.RData". **5\. thermal\_tolerance\_assembly\.R**: R script to assemble temperature mortality data prior to analysis. This code generates the file "thermal\_tolerance.RData". **6\. code\_supplementary\_figs\.R**: R script to replicate Supplementary Figures S1, S2, S3, S6, and S7. [The following code files are used to replicate the analysis by using a different thermal performance curve model. Here, we prepare the code to use the *modifiedgaussian\_2006* model from the rTPC package (Padfield et al., 2021; R Core team, 2023). However, any other model can be accommodated.] **7\. viability\_modifiedgaussian\_assembly\.R**: R script to assemble viability data using the *modifiedgaussian\_2006* model, prior to analysis. This code generates the file "viability\_modifiedgaussian.RData". **8\. extra\_code\_FigS5:** R script to replicate analyses using *modifiedgaussian\_2006* model to fit thermal performance curves and Figure S5. *** **DATA (6 files in total)** **9\. Viability\_dataset\.xlsx**: Comprises raw data on egg-to-adult viability data. Columns: * ttrial: trial temperature in celsius degree * pop: population * vial: (container with the culture medium and the 20 eggs) * pdate: date the eggs were laid in the vials for the trial temperatures (day/month/year) * edate: date the eggs hatched * days: days between edate and pdate * ne: number of viable adults that hatched from the eggs **10\. Thermal\_tolerance\_dataset\.xlsx**: Comprises raw data on thermal tolerance data. Columns: * treat: experimental treatment (heat-adapted flies) * block: experimental block * ttrial: trial temperature in Celsius degrees * sp: species * pop: population of origin * date: sampling date (DD.MM.YYYY) * lat: latitude coordinate of the origin population * lon: longitude coordinate of the origin population * tmean: average temperature of the origin population in Celsius degrees * tmax: maximum temperature of the origin population in Celsius degrees * tmin: minimum temperature of the origin population in Celsius degrees * sex: sex of the individual studied * vial: vial number from which the study individual originated * min: minutes of exposure * sec: seconds of exposure * tacc: acclimation temperature <br> **11\. Temp\_2018\_2020\.csv:** Time series of temperature from 2018 to 2020 for the study populations. Columns include date and time values, as well as the temperature for each sampled population: "Arica", "Copiapo", "La Serena", "Santiago", "Talca", "Chillan", "Temuco", and "Puerto Montt". **12\. tolerance\.RData:** Fitted tolerance landscapes of thermal tolerance for each population. By using this code, users can replicate the paper's analysis without enduring a 4-hour processing wait. **13\. viability\.RData:** Fitted Thermal Performance Curves for each population using the model from Rezende & Bozinovic (2019). **14\. viability\_modifiedgaussian\.RData:** Fitted Thermal Performance Curves for each population using *modifiedgaussian\_2006* model from rTPC package. **References:** * Padfield, D., O'Sullivan, H., & Pawar, S. (2021). rTPC and nls multstart: a new pipeline to fit thermal performance curves in R. *Methods in Ecology and Evol*ution 12, 1138-1143. * Rezende EL, Bozinovic F. (2019). Thermal performance across levels of biological organization. *Philosophical Transactions of the Royal Society B*, *374*, 20180549. * Rezende, E. L., Bozinovic, F., Szilágyi, A., & Santos, M. (2020). Predicting temperature mortality and selection in natural Drosophila populations. *Science*, 369, 1242-1245. * R Core Team. (2023). R: A language and environment for statistical comput‐ ing. Vienna, Austria: R Foundation for Statistical Computing. http:// [www.R–project.org](http://www.xn--rproject-sn3d.org/)