Admixture maps in R for Dummies

Before we get started, I’d like to point everyone to an excellent tutorial here by Kim Gilbert on making maps in R. I have been grappling with overlaying admixture plots, and migration routes on top of maps recently, and thought I’d put together a quick tutorial on that.
What you will need:

  1. GPS coordinates

    Eg. gps.data

    ID,Lat,Lon
    1,33.72,-94.40
    2,34.1682185,-111.930907
    3,37.2718745,-119.2704153
    

  2. Admixture proportions – these are routinely printed out as the “Q” matrix by STRUCTURE, and in a file suffixed with a “Q” by ADMIXTURE. I added a column with sample sizes to this, to proportionately resize the admixture pies.

    Eg. admixprops.data

    K1,K2,Num
    0.836601,0.163399,12
    0.565904,0.434096,16
    0.508735,0.491265,18
    0.111114,0.888886,9
    

  3. maps() and plotrix() packages in R

#Initialize packages
library(maps)
library(plotrix)
gps<-read.csv(“gps.data”,header=TRUE) #Read input files
admix<-read.csv(“admixprops.data”,header=TRUE)
map(”state”) #Plot maps
map.axes() #Add axes
points(gps$Lon, gps$Lat,
cex = admix$Num/5, col=’red’, pch=19) #To add just points
for (x in 2:nrow(gps)) { #To add arrows for migration models
arrows(gps$Lon[1],gps$Lat[1],gps$Lon[x],
gps$Lat[x],lty=”dashed”,code=2)
} #To add admixture plots – here I used K = 2.
for (x in 1:nrow(gps)) { floating.pie(gps$Lon[x],gps$Lat[x], #You can modify your loop to reflect this
c(admix$K1[x],admix$K2[x]),radius=admix$Num[x]/8,
col=c("red","blue") }

usa-tut1 usa-tut2

And voila! What took me four lines of code in R, involved days of learning ArcGIS to do the same thing (not to undermine the way cooler things that you can do with ArcGIS). I’ve been playing around with adding a phylogenetic tree to the admixture map as well using the ape package – more to come on this soon!

Share

About Arun Sethuraman

I am a computational biologist, and I build statistical models and tools for population genetics. I am particularly interested in studying the dynamics of structured populations, genetic admixture, and ancestral demography.
This entry was posted in howto, population genetics, R, software, STRUCTURE and tagged , . Bookmark the permalink.