#R code to make the map, delta K, and IMa2 plot for Hamm et al. 2013 - Journal of Heredity #Map code map(database='state', region=c('maine', 'new hampshire', 'vermont', 'massachusetts', 'delaware', 'rhode island', 'connecticut', 'new york', 'new jersey', 'pennsylvania', 'west virginia', 'virginia', 'maryland', 'north carolina', 'south carolina', 'georgia', 'florida', 'alabama', 'mississippi', 'tennessee', 'kentucky', 'ohio', 'indiana', 'michigan', 'illinois', 'wisconsin'), lwd=1.5, resolution=0) #map.axes() #axis(1, at=c(-90, -85, -80, -75, -70), lab=expression(-90, -85, -80, -75, -70)) #axis(2, at=c(25, 30, 35, 40, 45), lab=expression(25, 30, 35, 40, 45)) map.scale(-79.5, relwidth=0.25, metric=T, ratio=F, cex=1.2) points(-85.7, 42.2, pch=16, cex=2) points(-85.3, 41.4, pch=16, cex=2) points(-81, 36.92, pch=16, cex=2)#VA points(-80, 35.7, pch=16, cex=2)#NC points(-87.4, 33.3, pch=16, cex=2)#AL points(-88.6, 34.62, pch=16, cex=2)#MS points(-81.5, 40.5, cex=2, pch=16, col='dark grey') points(-74.6, 40.5, pch=16, cex=2, col='dark grey') points(-88.32, 42.9, cex=2, pch=16, col='dark grey') legend(-75, 37, legend=c('Extant', 'Extirpated'), pch=16, pt.cex=2, col=c('black', 'dark grey'), bty='n', cex=1.2) #deltaK code, the rest of the figure was made in Photoshop p9 <- read.csv('~/Desktop/MSB_p9.csv', header=T) par(mar=c(4,7.5,4,4), xaxs='i', yaxs='i') plot(p9$K, p9$A_C, type='l', lty=4, lwd=5, ylab= '', xlab='# Clusters', frame.plot=F, ylim=c(0, 2500), cex.lab=2.5, las=1, cex.axis=2) lines(p9$K, p9$NA_U, type='l', lty=1, lwd=4) lines(p9$K, p9$A_U, type='l', lty=3, lwd=5) legend(5.5, 1800, legend=c('A C', 'A U', 'N U'), lwd=5, lty=c(4, 1, 3), bty='n', cex=2.5) mtext(expression(paste(Delta, italic('K'))), side=2, cex=2.5, line=5) #code to make the IMa2 posteriors plot #MSB 9h SFS - MSB MSB9h <- read.csv('MSB_IM_9h.csv', header=T) str(MSB9h) head(MSB9h) tail(MSB9h) #File MSB_IM_11 compares MSB (P0) to VA (P1) MSB11m <- read.csv('MSB_IM_11m.csv', header=T) str(MSB11m) head(MSB11m) tail(MSB11m) #MSB 14a MSB - AL/MS MSB14a <- read.csv('MSB_IM_14a.csv', header=T) head(MSB14a) str(MSB14a) tail(MSB14a) #File MSB_IM_10 has SFS (P0) and AL/MS (P1) MSB10j <- read.csv('IM_10j.csv', header=T) str(MSB10j) head(MSB10j) tail(MSB10j) #This file compares VA to MS/AL MSB12n <- read.csv('MSB_IM_12n.csv', header=T) str(MSB12n) head(MSB12n) tail(MSB12n) #MSB13d SFS - VA MSB13d <- read.csv('MSB_IM13d.csv', header=T) str(MSB13d) head(MSB13d) tail(MSB13d) ########################### #NORMALIZED CURVES n9h <- 125 nMSB9h <- (MSB9h$P/n9h) n10j <- 100 nMSB10j <- (MSB10j$P/n10j) n13d <- 125 nMSB13d <- (MSB13d$P/n13d) n14a <- 125 nMSB14a <- (MSB14a$P/n14a) par(mar=c(1,5,0,1)) #X1 X2 Y1 Y2 par(fig=c(0,1,0.5,0.9), new=T) plot.new() plot(MSB9h$t0, nMSB9h, xlim=c(0,0.4), ylim=c(0,0.25), las=1, type='l', lwd=4, lty=1, ylab='', xlab='', bty='l') lines(MSB11m$t0, nMSB11m, type='l', lwd=4, lty=3)#MSB-VA lines(MSB14a$t0, nMSB14a, type='l', lwd=4, lty=6)#MSB-AL/MS legend('topright', legend=c('MI/IN - NC', 'MI/IN - VA', 'MI/IN - AL/MS'), lwd=4, lty=c(1, 3, 6), bty='n', cex=1.3) mtext(expression(paste(bold('(A)'))), side=3, cex=2, adj=0) par(fig=c(0, 1, 0.1, 0.4), new=T) plot.new() plot(MSB10j$t0, nMSB10j, xlim=c(0,0.4), ylim=c(0,0.5), las=1, type='l', lwd=4, lty=1, ylab='', xlab='', bty='l')#SFS-AL/MS lines(MSB12n$t0, nMSB12n, type='l', lwd=4, lty=2)#VA-AL/MS lines(MSB13d$t0, nMSB13d, type='l', lwd=4, lty=3)#SFS-VA legend('topright', legend=c('NC - AL/MS', 'VA - AL/MS', 'NC - VA'), lty=c(1, 3, 2), lwd=4, bty='n', cex=1.3) mtext(expression(paste(bold('(B)'))), side=3, cex=2, adj=0) mtext('Posterior Probability', side=2, outer=T, adj=0.47, line=-2, cex=2) mtext(expression(paste(bold(italic('t')))), side=1, line=2.7, cex=2) par(fig=c(0.25, 0.65, 0.25, 0.4), new=T) plot.new() plot(MSB13d$t0, nMSB13d, type='l', ylim=c(0, 0.006), xlim=c(0, 1), las=1, lwd=4, lty=3, ylab='', xlab='', xaxt='n', yaxt='n', bty='l') axis(2, at=c(0, 0.002, 0.004, 0.006), lab=expression(0, 0.002, 0.004, 0.006), las=1) axis(1, at=c(0, 0.25, 0.5, 0.75, 1.0), lab=expression(0, '.025', '.05', '.075', 0.1))