README

Data and analyses for the paper titled:
Plasticity contributes to a fine-scale depth gradient in sticklebacks’ visual system

by Thor Veen, Chad Brock, Diana Rennison and Daniel Bolnick

in Molecular Ecology


This repository contains the raw data files and the R code to reproduce all the statistical analyses and figures in the paper and supplementary material.
The R code is explained in comments in the text. Start by reading the main.R as this is the starting point.
In brief:
•main.R 	starting point of analyses and explanation of other .R files

•figures.R code needed to make all the figures

•functions.R custom functions used throughout the different script files

•opsin.gradient.R 
-analyses to calculate opsin expression along the gradient, both untransformed and transformed (figure 1, table 1 + 2, suppl. mat table 2 + 3)  
- difference in absorbance of individual at either extreme of the gradient based on the linear model (figure 2)

•irradiance.gradient.R change of light environment along the depth gradient (section ‘Changes in irradiance’ in main text)

•opsin.experiment.R
-opsin expression differences between two treatments (figure 3, table 3, suppl. mat table 4)
-absorbance differences between two treatments (bootstrap p values in main text, figure 4
-plasticity analysis for males (figure 5 and table 4 in the main text)

•irradiance.experiment.R
-compared the differences in irradiance between the cages to see if it differs using bootstrapping (Online Supplementary Material 1 
-find the best match between irradiance in each treatment with irradiance at a specific depth along the natural gradient (Online Supplementary Material Figure 2)


The data files are in the folder “data’ which has the following files and subfolder:
files:
•data.opsin.csv
Condition 	unique number for each opsin sample
IndivName	name for each individual sample which can be used to trace it back to its cage or control status
X	dummy column, not used
SWS1	proportional expression 
SWS2	proportional expression 
RH2	proportional expression 
LWS	proportional expression 

•opsin.control.cvs
IndivName	name for each individual sample which can be used to trace it back to its cage or control status. In this file there are only control individuals
SWS1	proportional expression 
SWS2	proportional expression 
RH2	proportional expression 
LWS	proportional expression 
gender	gender, in this case all males
date	the date
time.caught	the time the individual was caught
depth	the depth in meters of capture

Folders
•irradianceCages
all the irradiance data taken within the cages. This is linked with ‘expIrradCages.csv’ in the metaData folder for meta data.

•postSeasonIrr
Irradiance data taken at the end of the experiment along the depth gradient. 
This is linked with ‘naturalIrradGradient.csv’ in the metaData folder for meta data.

•metaData	meta data with various data used
-cal_coeffs_2015.csv
irradiance from the reference lamp. Each row is irradiance for integration times. Rows increase in steps of 1 nm per row.

-control.fish
FishID		unique number to trace individuals cage/control and gender (M or F)
gender		gender, in this case all males
snorkeler	initial of snorkeler who captured the individual
date		the date
time.caught	the time the individual was caught
depth		the depth in meters of capture
mass		mass in grams
SL		standard length in cm
note.col 	note of activity near the nest or state of nesting

- experimental.fish.csv
IDcom		identification number
IndivName 	unique number to trace individuals cage/control and gender (M or F)
FishID		cage number
timing		timing of sampling, all post in this case
gender		gender
fish.order	whether it was in the cage from the start (1) or a replacement (2)
retrap		whether the individual was trapped in the cage or not (no mean 			individual was dead or escaped)
date.post	date retrapped   
date.pre	date when put into cage
depth 		the depth in meters of capture
mass		mass in grams
SL		standard length in cm
time.in.cage	time individual spend in the cage in days (date.post - date.pre)

- expIrradCages.csv
cage 		cage in which irradiance was measured, corresponds to end number of 			irradiance file (e.g. 1 -> Postcage_Cont001.SSM)
file.name	number of file, corresponds to end number of 						irradiance file (e.g. 1 -> Postcage_Cont001.SSM)
time		time of day
orientation	orientation of probe, catching up-side-downwelling light
position.surface	whether probe is above, just below the water or at the bottom 		of the cage
integr.time.sec		integration time in seconds
date		the date
note		notes added linked to the measurements

- naturalIrradGradient.csv
location	one of three location along the shore 
file.name	matches names of files in postSeasonIrr folder
time		time of day 
orientation	orientation of probe, catching up-side-downwelling light
integr.time.sec		integration time in seconds
position.surface	whether probe is above, just below the water or at the bottom 		of the cage
date		the date
note		notes added linked to the measurements

