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


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

2. Admixture proportions

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.


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

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

#Initialize packages

gps <- read.csv(“”,header=TRUE) #Read input files
admix <- read.csv(“”,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
} #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
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!

This entry was posted in howto, population genetics, R, software, STRUCTURE and tagged , . Bookmark the permalink.