DOI: 10.5061/dryad.5x69p8d30
title: Data from: Genomic signatures of spatially divergent selection at clownfish range margins

description: Understanding how evolutionary forces interact to drive patterns of
 selection and distribute genetic variation across a species’ range is of
 great interest in ecology and evolution, especially in an era of global
 change. While theory predicts how and when populations at range margins
 are likely to undergo local adaptation, empirical evidence testing these
 models remains sparse. Here, we address this knowledge gap by
 investigating the relationship between selection, gene flow, and genetic
 drift in the yellowtail clownfish, Amphiprion clarkii, from the core to
 the northern periphery of the species range. Analyses reveal low genetic
 diversity at the range edge, gene flow from the core to the edge, and
 genomic signatures of local adaptation at 56 Single Nucleotide
 Polymorphisms (SNPs) in 25 candidate genes, most of which are
 significantly correlated with minimum annual sea surface temperature.
 Several of these candidate genes play a role in functions that are
 up-regulated during cold stress, including protein turnover, metabolism,
 and translation. Our results illustrate how spatially divergent selection
 spanning the range core to the periphery can occur despite the potential
 for strong genetic drift at the range edge and moderate gene flow from the
 core populations. 
description: Data and scripts for the analyses in "Genomic signatures of
 spatially divergent selection at clownfish range margins," which
 identifies the population structure and signatures of selection in
 populations of <em>Amphiprion clarkii</em> (the yellowtail
 clownfish) across the northern half of its range.
 <strong>Data</strong>
 A list of the files either read into R scripts or copied to
 Amarel for analyses. There are also files containing metadata and general
 output files. <em>Files generated by scripts are not included, with
 a few exceptions.</em>
 <strong>Aclarkii_metadata.csv</strong><br> This
 file contains metadata for the 25 clownfish used in the main analyses.
 Data include the individual ID used for sequencing, capture location (site
 name, latitude, and longitude), collector name, capture date, dissection
 method, sea surface salinity data at collection location (mean, minimum,
 maximum, range, and variation), and sea surface temperature data at
 collection location (mean, minimum, maximum, range, and variation). For
 some individuals, the standard length (mm), time of collection, time of
 incubation, time of dissection, and time spent in the freezer are also
 recorded.
 <strong>Aclarkii_ref_transcriptome.fa</strong><br> Fasta file containing the reference sequences that reads from each individual were mapped to. <strong>allele_freqs_all.xlsx</strong><br> This file contains the non-polarized allele frequencies for every SNP at each sampling site. The file contains four sheets. The first sheet (allele_freqs_all) contains the allele frequency for all SNPs in all sampling sites and contains 4 columns. The first column contains the contig & bp (separated by "_") for each SNP. The second column contains the population ID and the third column indicates whether or not the SNP is an outlier. Columns five & six contain the unfolded and folded allele frequency, respectively. Sheets 2-4 (allele_freqs_J_noout, etc.) contain the allele frequencies for only non-outlier SNPs in a given population. In these sheets, columns 1-4 contain the same information as the first sheet. Columns 5-6 contain the allele count and folded allele count, respectively. This file is used to create site frequency spectra for Stairway Plot analyses. <strong>annotations_combined.xlsx</strong><br> This file contains the functional and structural annotations for every outlier SNP. The first column is the contig each SNP is found on, and the second column is the bp position of the SNP. Columns 3 & 4 are the reference and alternate allele, respectively. Column 5 contains the gene name (if available), while column 6 contains the name of the protein coded by the gene. Column 7 contains the molecular function GO annotation and column 8 contains the biological process GO annotation. Column 9 is the structural annotation from SnpEff. Columns 10-14 are the Bayes Factor (deciban units) output from BayPass for sea surface salinity mean, sea surface temperature (SST) mean, SST minimum, SST maximum, and latitude, respectively. Column 15 is the XtX value from BayPass. <strong>apcl.est</strong><br> est file that contains the prior distributions for each parameter estimated in the *fastsimcoal2* model. This file, along with <strong><em>apcl.tpcl</em></strong>, is read into <em>fastsimcoal2</em>. <strong>apcl_raw_bestlhoods.csv</strong><br> This file contains the parameter estimates & maximum likelihood (ML) from each of the 50 <em>fastsimcoal2 </em>replicate runs with the observed multi-dimensional site frequency spectrum. The first column contains the run number (1-50). Columns 2-7 contain the parameter estimates for each parameter estimated by the model (POPONE = effective population size (<em>N<sub>e</sub></em>) for Japan, POPTWO = <em>N<sub>e</sub></em> for Philippines, POPTHREE = <em>N<sub>e</sub></em> for Indonesia, DISPONE = Japan-Philippines migration rate, DISPTWO = Philippines-Indonesia migration rate, TDIVTWO = time (backwards in generations) of Philippines-Indonesia population split). Columns 8 & 9 contain the estimated ML and observed ML, respectively. <strong>apcl.tpl</strong><br> tpl file that contains the model structure (sampling scheme information, number/types of demographic events, etc.) for <em>fastsimcoal2</em>. This file, along with <em><strong>apcl.est</strong></em>, is read into <em>fastsimcoal2</em>. <strong>Contig_length.csv</strong><br> This file contains the length of each contig that contains a SNP. The first column is the contig name and the second column is the length of the contig (bp). This file is read into <em><strong>pi.R.</strong></em> <strong>fsc_maxLhood_CI_summary.csv</strong><br> This file contains the parameter values & maximum likelihood (ML) from the best ML run for each bootstrapped SFS from <em>fastsimcoal2</em>. Columns 1-6 contain the parameter estimates for each parameter estimated by the model (POPONE = effective population size (<em>N<sub>e</sub></em>) for Japan, POPTWO = <em>N<sub>e</sub></em> for Philippines, POPTHREE = <em>N<sub>e</sub></em> for Indonesia, DISPONE = Japan-Philippines migration rate, DISPTWO = Philippines-Indonesia migration rate, TDIVTWO = time (backwards in generations) of Philippines-Indonesia population split). Columns 7 & 8 contain the estimated ML and observed ML, respectively. This file is read into <strong><em>fsc_CIs.R</em>.</strong> <strong>output.hicov2.snps.only.mac2.vcf</strong><br> VCF file that contains all SNPs that passed all bioinformatic filters. This file is read into <em><strong>Fst_script.R</strong></em> and is used for most upstream analyses. <strong>polarized_allele_freqs.csv</strong><br> This file contains the polarized allele frequencies for every SNP at each sampling site. The first column contains the contig & bp (separated by "_") for each SNP. The second column contains the polarized allele frequency (polarized to Japan). The third column indicates whether or not the SNP is an outlier and the fourth column contains the population ID.  This file is read into <em><strong>Allele Freq Line Plots.R</strong></em>. <strong>relatedness_input_mac2.txt</strong><br> This file contains the genotype information for every SNP. The first column contains the population ID and individual ID (separated by "_"). A population ID of JJ indicates Japan, NN indicates Indonesia, and PP indicates the Philippines. Columns 2-8425 are SNPs (each SNP has 2 columns) and contain values of 100-130 to indicate which nucleotide a particular individual has (A=100, T=110, G=120, C=130). This file is read into <em><strong>relatedness.R</strong></em>. <strong>STRUCTURE_mac2.str</strong><br> This file is formatted for input into the program STRUCTURE. It contains 4212 SNPs across all 25 clownfish. The column contains the fish ID (each individual has two rows). The second column contains the population ID. Columns 3-4215 are SNPs and contain values of 1-4 to indicate which nucleotide a particular individual has (A=1, T=2, G=3, C=4). This file is read into <em><strong>RDA.R</strong></em> and used for some STRUCTURE analyses.<br>   <strong>R Scripts</strong> A list of the R scripts. If the input files for a script were created by running code and/or calling programs on a remote workstation, details on the code used can be found in the <strong>Upstream Analyses</strong> section. <strong>Allele Freq Line Plots.R</strong><br> This script creates polarized allele frequency plots (outlier and non-outlier). <strong>BF Correlation Plots.R</strong><br> This script reads in a .csv file of Bayes Factors and XtX values outputted by BayPass and creates correlation plots by environmental variables. <strong>Bootstrap_forSFS.R</strong><br> This script creates bootstrapped VCF files. These files can then be read into <em>easySFS.py</em> to create bootstrapped SFS for reading into <em>fastsimcoal2 </em>and calculating the 95% confidence intervals. <strong>Diversity_Script.R</strong><br> This script calculates <em>H<sub>o</sub></em>, <em>H<sub>e,</sub></em> and <em>F</em><em><sub>is</sub> </em>from the allele frequencies. <strong>ECDFS for Sim v Real BFs.R</strong><br> This script contains code for Mann-Whitney U-tests and plots of empirical cumulative distribution functions for Bayes Factors from raw data and permuted data. <strong>fsc_CIs.R</strong><br> This script reads in the parameter estimates from the best maximum likelihood run for each bootstrapped SFS from <em>fastsimcoal2</em> and calculates the 95% confidence intervals.  <strong>Fst_script.R</strong><br> This script calculates the per-SNP <em>F<sub>st</sub> </em>and the site pairwise <em>F<sub>st </sub></em>values from the VCF. <strong>PCAs.R</strong><br> This script reads in eigenvector information from plink and creates PCA plots. <strong>pi.R</strong><br> This script reads in the .csv files containing the site pi output from VCFtools and calculates the mean (+ bootstrapped 95% confidence interval) for pi in each site and with all sites pooled. <strong>Pull_BFs.R</strong><br> This script reads in raw <strong><em>summary_betai.txt</em></strong> files from BayPass and reorganizes them into one .csv file for easier downstream analysis. It also pulls out candidate SNPs.  <strong>RDA.R</strong><br> This script runs a redundancy analysis (RDA), creates bi-plots for visualization, and identifies outliers from RDA using two different methods. <strong>relatedness.R</strong><br> This script calculates the pairwise relatedness (point estimates for all possible pairs, mean within-site relatedness, and 95% confidence interval for within-site relatedness). <strong>STRUCTURE_script.R</strong><br> This script reads in STRUCTURE output files, runs CLUMPP, and creates output plots for visualization of STRUCTURE results. It also creates maximum likelihood (ML) and Evanno method plots to identify the "best" value of K. <strong>TajimaD_script.R</strong><br> This script reads in the .csv files containing Tajima's <em>D</em> output from VCFtools and calculates the mean (+ standard error) Tajima's <em>D</em> in each site and with all sites pooled. It also contains code for Mann-Whitney U-tests and plots of empirical cumulative distribution functions (outlier vs. all transcripts). <strong>TD_v_pi.R</strong><br> This script creates plots of Tajima's <em>D </em>v. pi for each sampling site and for all sampling sites pooled. <strong>Write Simulation Pop Data for BayPass.R</strong><br> This script creates permuted datasets to run in BayPass and create distributions of Bayes Factors under the null hypothesis (no association between allele frequencies and environmental factors).  <strong>Write_Sim_Data_Het_CIs.R</strong><br> This script writes simulation populations and bootstraps them to create the 95% confidence intervals for <em>H<sub>o</sub></em>, <em>H<sub>e,</sub></em> and <em>F</em><em><sub>is</sub></em>. <strong>XtX_Calibration.R</strong><br> This script contains modified code from Gautier (2015) to create pseudo-observed datasets (PODs) to generate 95% significance thresholds for XtX values. Once the PODs are run in BayPass, it also contains modified code to calculate the XtX significance cut-off.<br>   <strong>Upstream Analyses</strong> This directory contains the code for upstream analyses that create the input files for some of the R scripts. All scripts are written to be run on Amarel, Rutger's high-performance computing cluster.  <strong>BayPass_upstream.md</strong><br> This file contains code for running BayPass. It creates input files for <em><strong>Pull_BFs.R</strong></em> & <em><strong>XtX_Calibration</strong>.R</em> and takes input files from <em><strong>Write Simulation Pop Data for BayPass.R</strong></em>. <strong>Fastsimcoal2_upstream.md</strong><br> This file contains code for running <em>fastsimcoal2</em>. It also contains information on how to create SFS with <em>easySFS.py</em>. It creates best point estimates for demographic parameters and input files for <strong><em>fsc_CIs.R</em></strong>. <strong>PCA_upstream.md</strong><br> This file contains code for running plink to generate eigenvalue and eigenvector inputs for PCAs. It creates input files for <em><strong>PCAs.R</strong></em>. <strong>pi_upstream.md</strong><br> This file contains code for calculating site-pi using VCFtools. It creates input files for <em><strong>pi.R</strong></em> & <strong><em>TD_v_pi.R</em></strong>. <strong>StairwayPlot_upstream.md</strong><br> This file contains code for running Stairway Plot v.2. It creates figures with estimates of demographic histories for each sampling site. <strong>STRUCTURE_upstream.md</strong><br> This file contains code for running STRUCTURE. It creates input files for <em><strong>STRUCTURE_script.R</strong></em>. <strong>TajimasD_upstream.md</strong><br> This file contains code for running SnpEff and calculating Tajima's <em>D </em>using VCFtools. It also contains information on how mapping to <em>Amphiprion frenatus</em> was done. It creates input files for <strong><em>TajimaD_script.R</em></strong> & <em><strong>TD_v_pi.R</strong></em>.<br>