knitr::opts_chunk$set(echo = F)

SatTagSim

SatTagSim is a package for R statistical software designed to produce spatial and temporally explicit simulations and movement summaries of fish based on electronic tagging results. The movement simulation is based on an advection diffusion framework and includes environmental constraints which may be tailored to those of the study organism. The primary product of the package are sets of movement matrices that summarize population level movement between discrete areas of the ocean. These matrices are designed to be used in a variety of spatially explicit operational and stock assessment models and management strategy evaluations.

Installation

library(devtools)
install_github('galuardi/SatTagSim', subdir = 'develop2024')

Tag Data

Data required for using this package are estimated tracks and associated uncertainty parameters, typical of those generated by state space geolocation models. An example dataset of 31 Atlantic bluefin tuna, tagged off Nova Scotia, Canada [@galuardi2010], are included in this package.

library(SatTagSim)
library(rworldmap)
library(rworldxtra)
library(tidyverse)
library(sf)
data(box7)
data(box11)
data(rmask)
data(nsfish)
data(myramps)

myworld =  rworldmap::getMap(resolution  =  'high') %>% 
  sf::st_as_sf()

cols = c(month.colors[,2])
names(cols) = month.colors[,1]

seasons  =  c("Winter", "Spring", "Summer", "Fall")
nsfish = nsfish  %>% 
sf::st_as_sf() %>% 
mutate(seas = case_when(Month %in% c(1,2,3) ~ 'Winter'
,Month%in%c(4,5,6)  ~'Spring'
,Month%in%c(7,8,9)  ~ 'Summer'
,Month%in%c(10,11,12)  ~'Fall'
)) %>% 
mutate(Month = as.factor(Month), seas = as.factor(seas))


lpts  =  coordinates(box11)
lpts[4,2]  =  35
lpts[9,]  =  c(-25, 25)

nsfish %>% 
  st_set_crs(4326) %>% 
ggplot()+
  geom_sf(aes(col = Month))+
  scale_color_manual(values = cols, aesthetics = c("colour", "fill"), na.value = NA)+
  geom_sf(myworld, mapping = aes(), fill = 'grey90', col = 'grey50')+
    geom_sf(box11 %>%  sf::st_as_sf(), mapping = aes(), col = 'salmon', lwd = 1, fill = 'transparent')+
    # geom_text(data = box11@data, inherit.aes = F, mapping = aes(rep(coordinates(box11)[,1],4), rep(coordinates(box11)[,2],4)), cex = 8, label =  rep(box11@data$ID, 4), col = 'darkred')+
   geom_text(data = box11@data, inherit.aes = F, mapping = aes(rep(lpts[,1],1), rep(lpts[,2],1)), cex = 8, label =  rep(box11@data$ID, 1), col = 'darkred')+
    coord_sf(xlim = c(-100, 40), ylim = c(0, 70), crs = NULL, datum = sf::st_crs(4326)) +
  xlab('')+
  ylab('')+
  theme(strip.text.x = element_text(size = 12), strip.text.y = element_text(size = 12))+
  theme_bw()

Simulations

The primary goal of simualtion from electronic tag data is to gain population level inferences from individual information. Population level information is typically more usful for assessment and management applications while indivudal data are more usful for biologically focused study.

Simulations are produced using advection and diffusion parameters, typically estimated from Kalman filter geolocation estimation [@sibert2003]. The concept was illustrated in [@sibert2006].

simex = simdat[[12]]

simex = simex  %>% 
  dplyr::rename('lon' = 'lon,') %>% 
sf::st_as_sf(coords = c('lon', 'lat')) %>% 
mutate(seas = case_when(Month %in% c(1,2,3) ~ 'Winter'
,Month%in%c(4,5,6)  ~'Spring'
,Month%in%c(7,8,9)  ~ 'Summer'
,Month%in%c(10,11,12)  ~'Fall'
)) %>% 
mutate(Month = as.factor(Month), seas = as.factor(seas))

simex %>% 
  sf::st_set_crs(4326) %>% 
ggplot()+
  geom_sf(aes(col = Month))+
  scale_color_manual(values = cols, aesthetics = c("colour", "fill"), na.value = NA)+
  geom_sf(myworld, mapping = aes(), fill = 'grey90', col = 'grey50')+
  coord_sf(xlim = c(-100, -15), ylim = c(10, 50), crs = NULL, datum = sf::st_crs(4326) )+
      geom_sf(box11 %>%  sf::st_as_sf(), mapping = aes(), col = 'salmon', lwd = 1, fill = 'transparent')+
    # geom_text(data = box11@data, inherit.aes = F, mapping = aes(rep(coordinates(box11)[,1],4), rep(coordinates(box11)[,2],4)), cex = 8, label =  rep(box11@data$ID, 4), col = 'darkred')+
   geom_text(data = box11@data, inherit.aes = F, mapping = aes(rep(lpts[,1],1), rep(lpts[,2],1)), cex = 8, label =  rep(box11@data$ID, 1), col = 'darkred')+
    coord_sf(xlim = c(-100, -45), ylim = c(20, 50), crs = NULL, datum = sf::st_crs(4326)) +
  xlab('')+
  ylab('')+
  theme(strip.text.x = element_text(size = 12), strip.text.y = element_text(size = 12))+
  theme_bw()

Movement Matrices

A key output of this package are Markovian movement matrices. These matrices indicate percentages of simulated fish that moved between starting and ending areas during seasonal time steps.

data('sim_example')
msims  =  500 # simulations to be started in each month
npmon  =  4 # number of simulation steps per month.
nyears  =  2 # number of years to simulate for each track
nreps  =  167 # number of replicates for variance calculation
sstol  =  2   # number of suitable months for each daily simulation step
datbox  =  get.first.box(simdat, 2000, box11, seas.len  =  npmon*3) # season length is number per month*3
boxtrans  =  get.trans.prob(datbox, nyears = 100, adims  =  c(11, 11,4), perc  =  T)

seasons  =  c("Winter", "Spring", "Summer", "Fall")
names(boxtrans)  =  seasons

plot.boxtrans(boxtrans, text.size = 2.5, strip.text = 12, axis.text = 12, text.col = 'black', palette = 'Greens')

Vignette

SatTagSim includes a vignette outlining all steps in a typical simulation run. To facilitate knitting, and example simulation result is included in the package datasets. At the time of writing, the vignette should knit, but it is better for a new user to step through the vignette. The setup of summary movement parameters from tag data, for example, is quire involved. The package has not been tested on a Mac either. Linux is lovely though.

Other Data in SatTagSim

References



galuardi/SatTagSim documentation built on Oct. 22, 2024, 10:18 a.m.