Skip to content

Commit 23cce97

Browse files
committed
revision update
1 parent 9c3ef83 commit 23cce97

7 files changed

+14
-35
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ Model study 3 is the **Case study**, which is used to estimate possible 87Sr/86S
1414
The "data" folder contains both data used in this study, and published data from [Wooller et al., (2021)](https://www.science.org/doi/abs/10.1126/science.abg1134) for the case studies.
1515

1616
## Software requirements
17-
The code is developed in R (ver. 4.0.5) calling the standalone JAGS (Just Another Gibbs Sampler) program, which is required before the code can be run. The JAGS program can be downloaded via [this link](https://sourceforge.net/projects/mcmc-jags/). Please make sure to download the version that is appropriate for your operating system.
17+
The code was developed in R (ver. 4.0.5) calling the standalone JAGS (Just Another Gibbs Sampler) program, which is required before the code can be run. The JAGS program can be downloaded via [this link](https://sourceforge.net/projects/mcmc-jags/). Please make sure to download the version that is appropriate for your operating system.
1818

1919
To call JAGS from RStudio, the R packages "rjags" and "R2jags" are also required.
2020

2121
Other R packages specified in the file headers help to visualize data.
2222

2323
## Related Publication
24-
This version of the code is for peer review only, and is subject to major updates.
24+
Yang et al., (in revision), BITS: a Bayesian Isotope Turnover and Sampling model for strontium isotopes in proboscideans and its potential utility in movement ecology, Methods in Ecology and Evolution.
2525

2626
## How to cite this software
2727
Yang, D. (2023), BITS: a Bayesian Isotope Turnover and Sampling model. https://github.com/SPATIAL-Lab/BITS

code/2 Driver Sr turnover.R

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ library(EnvStats)
1010

1111
source("code/1 Helper functions.R")
1212

13-
plot.col<-viridis(7)
14-
15-
setwd("C:/Users/ydmag/Google Drive/U of U/Elephant movement/Sr-in-ivory")
16-
1713
####The one pool model is only used in sensitivity test in the supporting information#####
1814

1915
misha.raw <- read.csv("data/Misha raw.csv")
@@ -45,7 +41,7 @@ plot(n.avg.misha.50.dist, n.avg.misha.50.sr, main="50 pt average",
4541
lines(n.avg.misha.50.dist, n.avg.misha.50.sr)
4642
hist(n.sd.misha.50.sr)
4743

48-
##################2 pool turnover with 50 pt average (excursion rmv)################
44+
################## 2 pool turnover with 50 pt average (excursion rmv) ################
4945
###prep data###
5046
ind.remv.50 <- which(n.avg.misha.50.dist > 17000 & n.avg.misha.50.dist < 17500 & n.avg.misha.50.sr < 0.7075)
5147
ind.remv.50 #36 37 38 39
@@ -57,7 +53,7 @@ n.avg.misha.50.sr.rmv <- n.avg.misha.50.sr[index.50.anom.remv]
5753
n.sd.misha.50.sr.rmv <- n.sd.misha.50.sr[index.50.anom.remv]
5854

5955

60-
#######This is the version used in the article, constraint on parameter b######
56+
####### This is the version used in the article, constraint on parameter b ######
6157
R.sd.mea <- n.sd.misha.50.sr.rmv
6258
dist.mea <- n.avg.misha.50.dist.rmv
6359
R.mea <- n.avg.misha.50.sr.rmv
@@ -161,5 +157,3 @@ MCMC.CI.pool.ratio$CI_high
161157
post.misha.pc2p3.Rin.89<- MCMC.CI.bound(post.misha.pc2p3$BUGSoutput$sims.list$Rin, 0.89)
162158
#calculate the mean of intake after switch
163159
intake.af <- mean(post.misha.pc2p3.Rin.89[[1]][90:750])
164-
165-

code/3 Driver Sr intake model.R

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ library(MASS)
88
library(viridisLite)
99
library(EnvStats)
1010

11-
12-
plot.col<-viridis(7)
13-
14-
setwd("C:/Users/ydmag/Google Drive/U of U/Elephant movement/Sr-in-ivory")
15-
1611
#adding the model component of food and water mixture as intake#
1712
intake <- read.csv("data/intake.csv")
1813
intake$Sr_conc
@@ -113,6 +108,7 @@ save(post.misha.intake, file = "out/post.misha.intake.RData")
113108

114109
post.misha.intake$BUGSoutput$summary
115110

111+
#save MAP estimate and HDI
116112
w.intake.map <- map_estimate(post.misha.intake$BUGSoutput$sims.list$w.contrib[,1])
117113
w.intake.hid <- hdi(post.misha.intake$BUGSoutput$sims.list$w.contrib[,1],0.89)
118114
w.intake.hid[2]

code/4 Driver inversion fidelity test.R

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ library(EnvStats)
1010

1111
source("code/1 Helper functions.R")
1212

13-
plot.col<-viridis(7)
14-
15-
setwd("C:/Users/ydmag/Google Drive/U of U/Elephant movement/Sr-in-ivory")
16-
17-
############################# inversion of Misha using params#######
13+
############################# inversion of Misha using parameters #######
1814
R.sd.mea <- n.sd.misha.50.sr.rmv
1915
dist.mea <- n.avg.misha.50.dist.rmv
2016
R.mea <- n.avg.misha.50.sr.rmv

code/5 Driver inversion case study mammoth.R

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,15 @@ library(EnvStats)
1010

1111
source("code/1 Helper functions.R")
1212

13-
plot.col<-viridis(7)
14-
15-
setwd("C:/Users/ydmag/Google Drive/U of U/Elephant movement/Sr-in-ivory")
16-
17-
####invterting laser abalition data from Wooller et al., 2021####
13+
#### invterting laser abalition data from Wooller et al., 2021 ####
1814
Wooller <- read.csv("data/Wooller_Data_S3.csv")
1915

2016
Wooller.sr <- Wooller$Sr_Seg01
2117

2218
#dist is in cm, convert to micron
2319
wooller.micron <- Wooller$Dist_Seg01*10000
2420

25-
#foward model simulating micromill results (500 micron band)
21+
#forward model simulating micromill results (500 micron band)
2622
mm.bwidth <- 500 #microns
2723
index.wooller.dist<- ceiling(wooller.micron/mm.bwidth) #this is about the same as averaging per 100 data points!
2824

@@ -45,7 +41,7 @@ for(i in 1:mm.sim.n){
4541

4642
plot(mm.sim.avg.Wooller.dist, mm.sim.avg.Wooller.sr,type="l")
4743

48-
######ivory extension rate Wooller et al 2021####
44+
######tusk dentine extension rate Wooller et al 2021####
4945
wooller.COSr<-read.csv("data/Wooller_isotope_data.csv")
5046

5147
wooller.rate <- rep(NA,27)
@@ -80,7 +76,7 @@ plot(sub.mm.sim.avg.dist, sub.mm.sim.avg.sr, type="l",
8076
#back to raw data, which is in the dist
8177
Wooller.sub.raw <- subset(Wooller, (wooller.micron> min(sub.mm.sim.avg.dist -250)) & (wooller.micron< 250 + max(sub.mm.sim.avg.dist)))
8278

83-
########################inversion with precision 1e-7########
79+
######################## inversion with precision 1e-7 ########
8480
Ivo.rate.mean <- mean.wooller.rate #microns per day
8581
Ivo.rate.sd <- sd.wooller.rate
8682

code/7 Driver sensitivity tests.R

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ library(EnvStats)
1010

1111
source("code/1 Helper functions.R")
1212

13-
plot.col<-viridis(7)
14-
plot.col.6<-inferno(6)
15-
16-
setwd("C:/Users/ydmag/Google Drive/U of U/Elephant movement/Sr-in-ivory")
13+
#set plot colors
14+
plot.col <- viridis(7)
15+
plot.col.6 <- inferno(6)
1716

1817
#####################################################################################
1918
################################ Section 1 ################################
@@ -702,7 +701,7 @@ lines(density(post.misha.inv2p.tsrwca$BUGSoutput$sims.list$a),col="red")
702701
plot(density(post.misha.inv2p.tsrwca$BUGSoutput$sims.list$Rin.m.cps.ac)) #autocorrelation is weak
703702

704703
###################################################################################################
705-
##############case study: Mammoth##############
704+
############## case study: Mammoth ##############
706705
######Mammoth inversion with normal per step error: tsrw ########
707706

708707
Ivo.rate.mean <- mean.wooller.rate #microns per day

code/9 Plots supporting information.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ library(zoo)
1111

1212
plot.col<-viridis(7)
1313

14-
setwd("C:/Users/ydmag/Google Drive/U of U/Elephant movement/Sr-in-ivory")
15-
1614
source("code/1 Helper functions.R")
1715

1816
####supplementary figures######

0 commit comments

Comments
 (0)