Landscape Genetic Data Analysis with R
Getting Started
1
Introduction
1.1
How to use this Book
1. Book Structure
2. Find what is relevant for you
3. Course R package ‘LandGenCourse’
1.2
List of R Packages by Vignette
2
Review of R Skills
2.1
Basic R Programming
1. Overview
2. Data Types
3. Data Containers
4. Programming
2.2
R Graphics
1. Overview
2. Univariate plots
3. Bivariate plots
4. Advanced plotting
2.3
Further R resources
3
GitHub for Group Projects
3.1
Why use GitHub?
1. Goals
2. Watch course video: Version Control 101
3. Preview slides
4. Next steps
3.2
Installation
1. Goals
3.2.1
2. How to get GitHub and GitKraken for free
3. Happy Git with R
4. Video tutorials: installation
5. Joining your group’s project on GitHub
6. Setting up a group repo
7. Next steps
3.3
Workflows
1. Goals
2. Step-by-step tutorials
3. Further resources
Basic Topics
4
Week 1: Importing Genetic Data
4.1
View Course Video
1. Embedded Video
2. Preview Slides
4.2
Interactive Tutorial 1
1. List of R commands covered this week
2. General Instructions
4.3
Worked Example
1. Overview of Worked Example
2. Import data from .csv file
3. Create ‘genind’ Object
4. View information stored in ‘genind’ object
5. Import data with ‘gstudio’ package
6. Importing SNP data
4.4
R exercise Week 1
5
Week 2: Spatial Data
5.1
View Course Video
1. Embedded Video
2. Preview Slides
5.2
Interactive Tutorial 2
1. List of R commands covered this week
2. General Instructions
5.3
Worked Example
1. Overview of Worked Example
2. Import site data from .csv file
3. Display raster data and overlay sampling locations, extract data
4. Calculate landscape metrics
5. Sample landscape metrics within buffer around sampling locations
5.4
R Exercise Week 2
5.5
Bonus: ‘sf’ and ‘terra’
1. Overview
2. Import and export ESRI shapefiles
3. Compatibility with
sp
and
raster
objects
4. Plotting spatial data with
tmap
5. Plot a categorical map with predefined color scheme
6
Week 3: Genetic Diversity
6.1
View Course Video
1. Embedded Video
Video, Part 1
Video, Part 2
Preview Slides
6.2
Interactive Tutorial 3
1. List of R commands covered this week
2. General Instructions
6.3
Worked Example
6.4
R Exercise Week 3
7
Week 4: Metapopulations
7.1
View Course Video
1. Embedded Video
Video, Part 1
Video, Part 2
Preview Slides
7.2
Interactive Tutorial 4
1. List of R commands covered this week
2. General Instructions
7.3
Worked Example
1. Overview of Worked Example
2. Spatial distribution of genetic structure
3. What determines genetic differentiation among sites?
4. What determines genetic diversity?
5. Are genetic differentiation and diversity related?
6. Effect of recent extinction events
7.4
R Exercise Week 4
8
Week 5: Spatial Statistics
8.1
View Course Video
1. Embedded Video
Preview Slides
8.2
Interactive Tutorial 5
1. List of R commands covered this week
2. General Instructions
8.3
Worked Example
1. Overview of Worked Example
2. Data import and manipulation
3. Calculate genetic distances
4. Perform a Mantel test to test for IBD
5. Create Mantel correlogram for genetic data
6. Specify spatial weights and calculate Moran’s I
8.4
R Exercise Week 5
9
Week 6: Quantitative Genetics
9.1
View Course Video
1. Embedded Video
Video, Part 1
Video, Part 2
Preview Slides
9.2
Interactive Tutorial 6
1. List of R commands covered this week
2. General Instructions
9.3
Worked Example
1. Overview of Worked Example
2. Estimate genetic and non-genetic variance components from a common garden experiment
3. Estimate trait heritability
4. Compare
\(Q_{st}\)
to
\(F_{st}\)
measured from SNP data
5. Assess correlation between trait and environment
R Exercise Week 6
10
Week 7: Spatial Linear Models
10.1
View Course Video
1. Embedded Video
Video, Part 1
Video, Part 2
Preview Slides
10.2
Interactive Tutorial 7
1. List of R commands covered this week
2. General Instructions
10.3
Worked Example
1. Overview of Worked Example
2. Explore data set
3. Test regression residuals for spatial autocorrelation
4. Fit models with spatially correlated error (GLS) with package ‘nlme’
5. Fit spatial simultaneous autoregressive error models (SAR)
6. Spatial filtering with MEM using package ‘spmoran’
7. Fit spatially varying coefficients model with package ‘spmoran’
Model with PatchSize and IBR
Model with IBR only
8. Conclusions
10.4
R Exercise Week 7
10.5
Bonus: Si index
1. Overview of Bonus Materials
2. Import ecological distance matrices
3. Optimize the scaling parameter alpha
4. Calculate Hanski’s index Si with source patch parameters
11
Week 8: Simulation Experiments
11.1
View Course Video
1. Embedded Video
Video, Part 1
Video, Part 2
Preview Slides
11.2
Interactive Tutorial 8
1. List of R commands covered this week
2. General Instructions
11.3
Worked Example
1. Overview of Worked Example
2. Initialize a landscape
3. Define simulation parameters
4. Run simulations and analyze results
5. Run simulator using a previously defined parameter set
11.4
R Exercise Week 8
11.5
Bonus: Efficient R
Advanced Topics
12
Week 9: Population Structure
12.1
Worked Example
1. Overview of Worked Example
2. Simulated data: 2-island model
3. Simulated data: 2-island model with admixture
4. Empirical data: Threespine sticklebacks
13
Week 10: Landscape Resistance
13.1
Worked Example
1. Overview of Worked Example
2. Explore the data set
3. Setting cost values and calculating conductance
4. Convert conductance into effective distance
5. Create cost-distance matrices
6. How does changing resolution affect these metrics?
7. References
13.2
Bonus: ‘radish’ tutorial
1. Overview of Bonus Materials
2. Import data
3. Basic model fitting
4. Advanced modeling topics
5. Summary
6. References
14
Week 11: Detecting Adaptation
14.1
Worked Example
1. Overview of Worked Example
2. Import and prepare the data
3. Latent Factor Mixed Models (LFMM): a univariate GEA
4. Redundancy Analysis (RDA): a multivariate GEA
5. Compare LFMM and RDA candidates
6. A quick note on controlling for population structure in RDA
7. References
15
Week 12: Model Selection
15.1
Worked Example
1. Overview of Worked Example
2. Fitting candidate models
3. Your turn to test additional hypotheses!
4. Nested model (NMLPE) for hierarchical sampling designs
5. References
16
Week 13: Gravity Models
16.1
Worked Example
1. Overview of Worked Example
2. Setup
3. Wetland complex data preparation
4. Wetland field-data preparation
5. Saturated Graph
6. Spatial model data prepration
7. Gravity model
17
Week 14: Contemporary Gene Flow
17.1
Worked Example
1. Overview
2. Import Genotypes
3. Pollen pool genetic structure
4. Paternity analysis
5. Linking paternity to ecological variables
6. References
Published with bookdown
Landscape Genetic Data Analysis with R
2.3
Further R resources
Links to some excellent external resources:
Applied Population Genetics
bz Rodney Dyer
Efficient R Programming
by Colin Gillespie and Robin Lovelace