###Copy and paste this script into the R console on your computer. It will be compatible with Windows, Mac, and Linux. ###All sentences beginning with "###" will be invisible to the software, and will caption and describe each step of the analysis and figures for [CITATION] ###Erase everything that comes before rm(list = ls(all = TRUE)) ###Compatibility if(.Platform$OS.type=="windows") { quartz<-function() windows() } ###This script was run in R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" ###IMPORTANT NOTE: R uses packages to facilitate the analysis of data and production of figures. If you do not have the gridExtra, vcd, siar, or ggplot2 packages installed, the following three lines of text will do it for you - all you have to do is delete the "###" that precedes the commands ###The command below will bring up a list of download sites. Pick one closest to you to speed up the download process ###chooseCRANmirror() ###The script below will then install the gridExtra package (for stacking plots), vcd package (needed for Bayesian mixing model), siar package (for running Bayesian analysis) and ggplot2 (for generating data plots) ###Note: Installation of packages may take up to an hour, depending upon the speed of your internect connection. ###install.packages("gridExtra", dependencies = TRUE) ###install.packages("vcd", dependencies = TRUE) ###install.packages("ggplot2", dependencies = TRUE) ###install.packages("siar", dependencies = TRUE) ###Note: Siar works best in R Studio ###Activate the packages library(ggplot2) library(gridExtra) library(vcd) library(siar) ############### ###Strontium#### ############### ###Load Data source <- read.csv(file="http://bleedrake.com/chacostrontium/treesource.csv") source.species <- read.csv(file="http://bleedrake.com/chacostrontium/chacotreespecies.csv") chaco <- read.csv(file="http://bleedrake.com/chacostrontium/chacotrees.csv") corn <- read.csv(file="http://bleedrake.com/chacostrontium/cornallstrontium.csv") corn.for.plot <- read.csv(file="http://bleedrake.com/chacostrontium//cornforplot.csv") corn.sources <- read.csv(file="http://bleedrake.com/chacostrontium/cornsource.csv") ###Look at just Chaco Strontium just.chaco <- read.csv(file="http://bleedrake.com/chacostrontium/allchacostrontium.csv") ################### ###Define Sources### ################## ###Source Probability chaco.strontium <- subset(source$X87.Sr.86.Sr, source$Site.Name=="Chaco Canyon Soil") upper.rio.chaco <- subset(source$X87.Sr.86.Sr, source$Site.Name=="Upper Rio Chaco Soils") san.mateo <- subset(source$X87.Sr.86.Sr, source$Site.Name=="San Mateo Mountains") chuska <- subset(source$X87.Sr.86.Sr, source$Site.Name=="Chuska Mountains") hosta.butte <- subset(source$X87.Sr.86.Sr, source$Site.Name=="Hosta Butte") la.plata <- subset(source$X87.Sr.86.Sr, source$Site.Name=="La Plata Mountains") cuba.mesa <- subset(source$X87.Sr.86.Sr, source$Site.Name=="Cuba Mesa") san.pedro <- subset(source$X87.Sr.86.Sr, source$Site.Name=="San Pedro Mountains") pueblo.bonito <- subset(chaco$X87.Sr.86.Sr, chaco$ Site..=="Pueblo Bonito") pueblo.del.arroyo <- subset(chaco$X87.Sr.86.Sr, chaco$ Site..=="Pueblo del Arroyo") chetro.ketl <- subset(chaco$X87.Sr.86.Sr, chaco$ Site..=="Chetro Ketl") great.houses <- c(pueblo.bonito, pueblo.del.arroyo, chetro.ketl) pinus <- subset(chaco$X87.Sr.86.Sr, chaco$Taxa=="Pinus") abies <- subset(chaco$X87.Sr.86.Sr, chaco$Taxa=="Abies") picea <- subset(chaco$X87.Sr.86.Sr, chaco$Taxa=="Picea") ###Maize chaco.gh.maize <- subset(corn$X87Sr.86Sr, corn$Site=="Chaco Great House Corn") chaco.ss.maize <- subset(corn$X87Sr.86Sr, corn$Site=="Chaco Smaller Site Corn") aztec.maize <- subset(corn$X87Sr.86Sr, corn$Site=="Aztec Ruin Corn") newcomb.maize <- subset(corn$X87Sr.86Sr, corn$Site=="Newcomb Corn") mcelmo.soil <- subset(corn$X87Sr.86Sr, corn$Site=="McElmo Dome Soil") mesa.verde.soil <- subset(corn$X87Sr.86Sr, corn$Site=="Mesa Verde Soil") aztec.soil <- subset(corn$X87Sr.86Sr, corn$Site=="Aztec Ruin Soil") salmon.soil <- subset(corn$X87Sr.86Sr, corn$Site=="Salmon Ruin Soil") la.plata.soil <- subset(corn$X87Sr.86Sr, corn$Site=="La Plata Soil") totah.soil <- subset(corn$X87Sr.86Sr, corn$Site=="Totah Soil") mid.chinle.soil <- subset(corn$X87Sr.86Sr, corn$Site=="Middle Chinle Soil") chuska.slope.soil <- subset(corn$X87Sr.86Sr, corn$Site=="Chuska Slope Soil") upper.chaco.soil <- subset(corn$X87Sr.86Sr, corn$Site=="Upper Rio Chaco Soil") chaco.canyon.soil <- subset(corn$X87Sr.86Sr, corn$Site=="Chaco Canyon Soil") defiance.soil <- subset(corn$X87Sr.86Sr, corn$Site=="Defiance Plateau Soil") lobo.mesa.soil <- subset(corn$X87Sr.86Sr, corn$Site=="Lobo Mesa Soil") rio.puerco.soil <- subset(corn$X87Sr.86Sr, corn$Site=="Western Rio Puerco Soil") red.mesa.soil <- subset(corn$X87Sr.86Sr, corn$Site=="Red Mesa Soil") little.colorado.soil <- subset(corn$X87Sr.86Sr, corn$Site=="Upper Little Colorado Soil") dinetah.soil <- subset(corn$X87Sr.86Sr, corn$Site=="Dinetah Soil") la.plata.soil <- subset(corn$X87Sr.86Sr, corn$Site=="La Plata Soil") san.juan.soil <- subset(corn$X87Sr.86Sr, corn$Site=="Northwestern San Juan River Tributary Soil") chaco.watershed <- subset(corn$X87Sr.86Sr, corn$Site=="Chaco Watershed") pre.1140.maize <- subset(corn.for.plot$X87Sr.86Sr, corn.for.plot$Time=="Pre 1140 Maize") post.1140.maize <- subset(corn.for.plot$X87Sr.86Sr, corn.for.plot$Time=="Post 1140 Maize") historic.maize <- subset(corn$X87Sr.86Sr, corn$Time=="Historic") ######################## ####Define Data for Test#### ####################### pueblo.bonito.matrix <- matrix(pueblo.bonito, ncol = 1, nrow = 39) pueblo.del.arroyo.matrix <- matrix(pueblo.del.arroyo, ncol = 1, nrow = 24) chetro.ketl.matrix <- matrix(chetro.ketl, ncol = 1, nrow = 34) chaco.timber.matrix <- matrix(great.houses, ncol=1, nrow=97) chaco.gh.maize.matrix <- matrix(chaco.gh.maize, ncol=1, nrow = 11) chaco.ss.maize.matrix <- matrix(chaco.ss.maize, ncol=1, nrow = 26) aztec.maize.matrix <- matrix(aztec.maize, ncol=1, nrow=10) newcomb.maize.matrix <- matrix(newcomb.maize, ncol=1, nrow=16) pre.1140.matrix <- matrix(pre.1140.maize, ncol=1, nrow=7) post.1140.matrix <- matrix(post.1140.maize, ncol=1, nrow=33) historical.matrix <- matrix(historic.maize, ncol=1, nrow=6) abies.matrix <- matrix(abies, ncol=1, nrow=32) picea.matrix <- matrix(picea, ncol=1, nrow=14) pinus.matrix <- matrix(pinus, ncol=1, nrow=51) all.taxa <- c(abies, picea, pinus) pinus.n <- rep("Pinus", 51) abies.n <- rep("Abies", 32) picea.n <- rep("Picea", 14) all.taxa.n <- c(abies.n, picea.n, pinus.n) tree.species.data.frame <- data.frame(all.taxa.n, all.taxa) colnames(tree.species.data.frame) <- c("Taxa", "Sr") tree.species.matrix <- as.matrix(tree.species.data.frame) chaco.strontium.mean <- mean(chaco.strontium) san.mateo.mean <- mean(san.mateo) chuska.mean <- mean(chuska) hosta.butte.mean <- mean(hosta.butte) la.plata.mean <- mean(la.plata) cuba.mesa.mean <- mean(cuba.mesa) san.pedro.mean <- mean(san.pedro) mcelmo.soil.mean <- mean(mcelmo.soil) mesa.verde.soil.mean <- mean(mesa.verde.soil) aztec.soil.mean <- mean(aztec.soil) salmon.soil.mean <- mean(salmon.soil) la.plata.soil.mean <- mean(la.plata.soil) totah.soil.mean <- mean(totah.soil) mid.chinle.soil.mean <- mean(mid.chinle.soil) chuska.slope.soil.mean <- mean(chuska.slope.soil) upper.chaco.soil.mean <- mean(upper.chaco.soil) chaco.canyon.soil.mean <- mean(chaco.canyon.soil) defiance.soil.mean <- mean(defiance.soil) lobo.mesa.soil.mean <- mean(lobo.mesa.soil) rio.puerco.soil.mean <- mean(rio.puerco.soil) red.mesa.soil.mean <- mean(red.mesa.soil) little.colorado.soil.mean <- mean(little.colorado.soil) dinetah.soil.mean <- mean(dinetah.soil) san.juan.soil.mean <- mean(san.juan.soil) chaco.watershed.mean <- mean(chaco.watershed) chaco.strontium.sd <- sd(chaco.strontium) san.mateo.sd <- sd(san.mateo) chuska.sd <- sd(chuska) hosta.butte.sd <- sd(hosta.butte) la.plata.sd <- sd(la.plata) cuba.mesa.sd <- sd(cuba.mesa) san.pedro.sd <- sd(san.pedro) mcelmo.soil.sd <- sd(mcelmo.soil) mesa.verde.soil.sd <- sd(mesa.verde.soil) aztec.soil.sd <- sd(aztec.soil) salmon.soil.sd <- sd(salmon.soil) la.plata.soil.sd <- sd(la.plata.soil) totah.soil.sd <- sd(totah.soil) mid.chinle.soil.sd <- sd(mid.chinle.soil) chuska.slope.soil.sd <- sd(chuska.slope.soil) upper.chaco.soil.sd <- sd(upper.chaco.soil) chaco.canyon.soil.sd <- sd(chaco.canyon.soil) defiance.soil.sd <- sd(defiance.soil) lobo.mesa.soil.sd <- sd(lobo.mesa.soil) rio.puerco.soil.sd <- sd(rio.puerco.soil) red.mesa.soil.sd <- sd(red.mesa.soil) little.colorado.soil.sd <- sd(little.colorado.soil) dinetah.soil.sd <- sd(dinetah.soil) san.juan.soil.sd <- sd(san.juan.soil) chaco.watershed.sd <- sd(chaco.watershed) mean.sources <- c(san.mateo.mean, chuska.mean, hosta.butte.mean, la.plata.mean, cuba.mesa.mean, san.pedro.mean, mesa.verde.soil.mean, aztec.soil.mean, salmon.soil.mean, la.plata.soil.mean, totah.soil.mean, mid.chinle.soil.mean, chuska.slope.soil.mean, upper.chaco.soil.mean, chaco.canyon.soil.mean, defiance.soil.mean, lobo.mesa.soil.mean, rio.puerco.soil.mean, red.mesa.soil.mean, little.colorado.soil.mean, dinetah.soil.mean, san.juan.soil.mean) sd.sources <- c(san.mateo.sd, chuska.sd, hosta.butte.sd, la.plata.sd, cuba.mesa.sd, san.pedro.sd, mesa.verde.soil.sd, aztec.soil.sd, salmon.soil.sd, la.plata.soil.sd, totah.soil.sd, mid.chinle.soil.sd, chuska.slope.soil.sd, upper.chaco.soil.sd, chaco.canyon.soil.sd, defiance.soil.sd, lobo.mesa.soil.sd, rio.puerco.soil.sd, red.mesa.soil.sd, little.colorado.soil.sd, dinetah.soil.sd, san.juan.soil.sd) names.sources <- c("SanMateoMountains", "ChuskaMountains", "HostaButte", "LaPlataMountains", "CubaMesa", "SanPedroMountains", "MesaVerdeSoil", "AztecSoil", "SalmonSoil", "LaPlataSoil", "TotahSoil", "MiddleChinleSoil", "ChuskaSlopeSoil", "UpperRioChacoSoil", "ChacoCanyonSoil", "DefiancePlateauSoil", "LoboMesaSoil", "RioPuercoSoil", "RedMesaSoil", "LittleColoradoSoil", "DinetahSoil", "NorthwestSanJuanRiverTributarySoil") sources <- data.frame(names.sources, mean.sources, sd.sources) colnames(sources) <- c("Sources", "Mean.SR/SR", "SD.SR/SR") ###TREES tree.mean.sources <- c(san.mateo.mean, chuska.mean, hosta.butte.mean, la.plata.mean, cuba.mesa.mean, san.pedro.mean, chaco.watershed.mean, aztec.soil.mean) tree.sd.sources <- c(san.mateo.sd, chuska.sd, hosta.butte.sd, la.plata.sd, cuba.mesa.sd, san.pedro.sd, chaco.watershed.sd, aztec.soil.sd) tree.names.sources <- c("SanMateoMountains", "ChuskaMountains", "HostaButte", "LaPlataMountains", "CubaMesa", "SanPedroMountains", "ChacoWatershed", "AztecSoil" ) tree.sources <- data.frame(tree.names.sources, tree.mean.sources, tree.sd.sources) colnames(sources) <- c("Sources", "Mean.SR/SR", "SD.SR/SR") ###Soils soil.mean.sources <- c(aztec.soil.mean, salmon.soil.mean, la.plata.soil.mean, chuska.slope.soil.mean, lobo.mesa.soil.mean, red.mesa.soil.mean, san.juan.soil.mean, chaco.watershed.mean) soil.sd.sources <- c( aztec.soil.sd, salmon.soil.sd, la.plata.soil.sd, chuska.slope.soil.sd, lobo.mesa.soil.sd, red.mesa.soil.sd, san.juan.soil.sd, chaco.watershed.sd) soil.names.sources <- c( "AztecSoil", "SalmonSoil", "LaPlataSoil","ChuskaSlopeSoil", "LoboMesaSoil", "RedMesaSoil", "NorthwestSanJuanRiverTributarySoil", "ChacoWatershed") soil.sources <- data.frame(soil.names.sources, soil.mean.sources, soil.sd.sources) colnames(soil.sources) <- c("Sources", "Mean.SR/SR", "SD.SR/SR") ############# ###Figure 3### ############ ###Plot Corn sources quartz() corn.source.plot <- ggplot(corn.sources, aes(X87Sr.86Sr, fill = Site, colour=Site)) + geom_vline(aes(xintercept= 0.70943), linetype=2, alpha=.6) + geom_density(alpha=0.5) + labs(fill="Corn Strontium Ratio Key", colour = "Corn Strontium Ratio Key") + theme_bw() + scale_x_continuous(breaks=seq(from= 0.708, to= 0.715, by= 0.001), limits = c(0.708, 0.715)) + ylab("Density")+ xlab(expression(paste(""^87*'Sr/'^86*'Sr Ratio'))) + opts(axis.text.x = theme_text(size=15)) + opts(axis.text.y = theme_text(size=15)) + opts(axis.title.x = theme_text(size=20)) + opts(axis.title.y = theme_text(size=20, angle=90)) + opts(plot.title=theme_text(size=30)) corn.source.plot ###Plot Corn quartz() corn.plot <- ggplot(corn.for.plot, aes(X87Sr.86Sr, fill = Time, colour = Time)) + geom_vline(aes(xintercept= 0.70943), linetype=2, alpha=.6) + geom_density(alpha=0.5) + labs(fill="Corn Strontium Ratio Key", colour = "Corn Strontium Ratio Key") + theme_bw() + scale_x_continuous(breaks=seq(from= 0.708, to= 0.715, by= 0.001), limits = c(0.708, 0.715)) + scale_y_continuous(limits = c(0, 1200)) + xlab("") + ylab("Density")+ opts(axis.text.x = theme_text(size=15)) + opts(axis.text.y = theme_text(size=15)) + opts(axis.title.x = theme_text(size=20)) + opts(axis.title.y = theme_text(size=20, angle=90)) + opts(plot.title=theme_text(size=30)) corn.plot ###SidebySidePlot quartz() sidebysideplot <- grid.arrange(corn.plot, corn.source.plot, nrow=2) ############### ###Figure 4a-c### ############### pre.1140.out <- siarmcmcdirichletv4(pre.1140.matrix, soil.sources) pre.1140.out <- pre.1140.out$output pre.1140.smalls <- subset(pre.1140.out, select=c(ChuskaSlopeSoil, ChacoWatershed, AztecSoil)) quartz() pre.1140.t <- ternaryplot(pre.1140.smalls, main = "Pre-1140 A.D.") post.1140.out <- siarmcmcdirichletv4(post.1140.matrix, soil.sources) post.1140.out <- post.1140.out$output post.1140.smalls <- subset(post.1140.out, select=c(ChuskaSlopeSoil, ChacoWatershed, AztecSoil)) quartz() post.1140.t <- ternaryplot(post.1140.smalls, main = "Post-1140 A.D.") historical.out <- siarmcmcdirichletv4(historical.matrix, soil.sources) historical.out <- historical.out $output historical.smalls <- subset(historical.out, select=c(ChuskaSlopeSoil, ChacoWatershed, AztecSoil)) quartz() historical.t <- ternaryplot(historical.smalls, main = "Historic") ############### ###Figure 6a-c### ############### pinus.out <- siarmcmcdirichletv4(pinus.matrix, tree.sources) pinus.out <- pinus.out$output pinus.smalls <- subset(pinus.out, select=c(ChuskaMountains, ChacoWatershed, SanMateoMountains)) quartz() pinus.t <- ternaryplot(pinus.smalls, main = "Ponderosa Pine") picea.out <- siarmcmcdirichletv4(picea.matrix, tree.sources) picea.out <- picea.out$output picea.smalls <- subset(picea.out, select=c(ChuskaMountains, ChacoWatershed, SanMateoMountains)) quartz() picea.t <- ternaryplot(picea.smalls, main = "Spruce") abies.out <- siarmcmcdirichletv4(abies.matrix, tree.sources) abies.out <- abies.out$output abies.smalls <- subset(abies.out, select=c(ChuskaMountains, ChacoWatershed, SanMateoMountains)) quartz() abies.t <- (ternaryplot(abies.smalls, main = "Fir")) ############# ###Figure 8### ############ ###Plot Just Chaco quartz() source.plot <- ggplot(just.chaco, aes(X87Sr.86Sr, fill = Site, colour = Site)) + geom_vline(aes(xintercept= 0.70943), linetype=2, alpha=.6) + geom_density(alpha=0.5) + labs(fill="Chaco Strontium Ratio Key", colour="Chaco Strontium Ratio Key") + theme_bw() + scale_x_continuous(breaks=seq(from= 0.704, to= 0.718, by= 0.002)) + xlab("") + ylab("Density")+ xlab(expression(paste(""^87*'Sr/'^86*'Sr Ratio'))) + opts(axis.text.x = theme_text(size=15)) + opts(axis.text.y = theme_text(size=15)) + opts(axis.title.x = theme_text(size=20)) + opts(axis.title.y = theme_text(size=20, angle=90)) + opts(plot.title=theme_text(size=30)) source.plot ####Figures 4 and 6d-f can be generated using the siarmenu() (siar 4.2) command and 1) selecting the appropriate samplematrix, 2) the appropriate data frame and not choosing any correct mean/standard deviation or concentration dependence mean/standard deviation, 3) analyzing a single group for 1000000 iterations (with 400000 burnins), 4) plot a traditional (isosource) plot for all sources on one graph. ###Tables 2 and 4 can be generated using the siarmenu() (siar 4.2) command and after loading in data following the above steps, selecting 8) Summary information and convergence diagnostics ###Data Sources: ###English NB, Betancourt JL, Dean JS, Quade J. (2001) Strontium isotopes reveal distant sources of architectural timber in Chaco Canyon, New Mexico. Proc Natl Acad Sci 98: 11891-11896. ###Benson L, Cordell L, Vincent K, Taylor H, Stein J, Farmer LG, Futa K (2003) Ancient maize from Chacoan Great Houses: Where was it grown? Proc Natl Acad Sci 100: 13111-13115 ###Reynolds AC, Betancourt JL, Quade J, Patchett PJ, Dean JS, Stein J. (2005) 87Sr/86Sr sourcing of ponderosa pine used at Anasazi great house construction in Chaco Canyon, New Mexico. J of Arch Sci 32: 1061-1075. ###Benson LV, Stein JR, Taylor HE. (2009) Possible sources of archaeological maize found in Chaco Canyon and Aztec Ruin, New Mexico. J Archaeol Sci 36: 387-407. ###Benson LV. (2010) Who provided maize to Chaco Canyon after the mid-12th century drought? J of Arch Sci 37: 621-629 ###Method Sources: ####Newsome SD, Martinez del Rio C, Bearhop S, Phillips DL. (2007) A niche for isotopic ecology. Frontiers in Ecology and the Environment 5(8): 429-436. ###Parnell AC, Inger R, Bearhop S, Jackson AL. (2010) Source partitioning using stable isotopes: coping with too much variation. PLoS One 5(3): e9672. ###Parnell A, Jackson A. (2013) SIAR: Stable isotope analysis in R. R package version 4.2. http://CRAN.R-project.org/package=siar. ###Phillips DL. (2012) Converting isotope values to diet composition: the use of mixing models. Journal of Mammalogy 93(2): 342-352. ###Phillips, DL, Gregg, JW. (2001) Uncertainty in source partitioning using stable isotopes. Oecologia, 127(2): 171-179.