Details

This is an R Markdown document.

Dissertation Research: The purpose of this analysis is to identify SNPs that are spatially informative. The best way to do this would be to run simulations to test combinations of SNPs and generate error and AIC/BIC statistics for each combination. However, we don’t have the sampling for this. We have to make the best educated guess with the samples we have and the calculations we can prepare.

Approach:

The bioinformatics code and methods are in my online notebook and in my drylab notes.

This document will show the Fst partitions.

#load packages
library(rgdal) # used to read world map data
library(rgeos) # to fortify without needing gpclib
library(maptools)
library(ggplot2)
library(scales) # for formatting ggplot scales with commas
library(gridExtra)
library(maps)
library(RColorBrewer)
library(reshape)
library(ggrepel)

Including Plots

# Data from http://thematicmapping.org/downloads/world_borders.php.
# Direct link: http://thematicmapping.org/downloads/TM_WORLD_BORDERS_SIMPL-0.3.zip
# Unpack and put the files in a dir 'data'

worldMap <- readOGR(dsn="TM_WORLD_BORDERS-0.3.shp", layer="TM_WORLD_BORDERS-0.3")
## OGR data source with driver: ESRI Shapefile 
## Source: "TM_WORLD_BORDERS-0.3.shp", layer: "TM_WORLD_BORDERS-0.3"
## with 246 features
## It has 11 fields
## Integer64 fields read as strings:  POP2005
# Change "data" to your path in the above!
worldMap.fort <- fortify(worldMap, region = "ISO3")
# Fortifying a map makes the data frame ggplot uses to draw the map outlines.
# "region" or "id" identifies those polygons, and links them to your data. 
# Look at head(worldMap@data) to see other choices for id.
# Your data frame needs a column with matching ids to set as the map_id aesthetic in ggplot. 
idList <- worldMap@data$ISO3
# "coordinates" extracts centroids of the polygons, in the order listed at worldMap@data
centroids.df <- as.data.frame(coordinates(worldMap))
names(centroids.df) <- c("Longitude", "Latitude")  #more sensible column names
# This shapefile contained population data, let's plot it.
popList <- worldMap@data$POP2005

pop.df <- data.frame(id = idList, centroids.df)

ec.p.bo<-read.csv("20170724_mapping.csv",header=1)

basic<-ggplot(pop.df, aes(map_id = id)) + 
  geom_map(fill="white",colour= "black", map = worldMap.fort) +
  expand_limits(x = worldMap.fort$long, y = worldMap.fort$lat) +
  coord_equal(xlim = c(-80,-66), ylim = c(-16,0)) + #let's view South America
  theme_bw()+ theme(
    legend.title = element_blank(),
    panel.grid.major = element_blank(),
    panel.grid.minor = element_blank(),
    plot.title = element_text(size = 10),
    axis.title.x = element_blank(),
    axis.title.y = element_blank(),
    legend.background = element_blank())

#nvs
lat<-basic +geom_point(data=ec.p.bo, aes(map_id=NA,long, lat, color=nvs), size = 3)+
  theme(legend.position = c(.85,.85))+
  scale_color_manual(values= c("dodgerblue","goldenrod"),
                     labels=c("North", "South"))+
  ggtitle("Latitude")+ylab("Latitude")

#elev.lvh
elevation<-basic +geom_point(data=ec.p.bo, aes(map_id=NA,long, lat, color=elev.lvh), size = 3)+
  theme(legend.position = c(.85,.85))+
  scale_color_manual(values= c("dodgerblue","goldenrod"),
                     labels=c("High", "Low"))+
  ggtitle("Elevation")

fsts<-read.csv("20170725_mapping_clim.csv",header=1)

temperature<-basic +geom_point(data=fsts, aes(map_id=NA,long, lat, color=t.group), size = 3)+
  theme(legend.position = c(.85,.85))+
  scale_color_manual(values= c("dodgerblue","goldenrod","grey50"),
                     labels=c("High", "Moderate","Low"))+
  ggtitle("Temperature")+xlab("Longitude")+ylab("Latitude")
precipitation<-basic +geom_point(data=fsts, aes(map_id=NA,long, lat, color=p.group), size = 3)+
  theme(legend.position = c(.85,.85))+
  scale_color_manual(values= c("dodgerblue","goldenrod","grey50"),
                     labels=c("High", "Moderate","Low"))+
  ggtitle("Precipitation")+xlab("Longitude")
grid.arrange(lat,elevation,temperature,precipitation,ncol=2)