NMFS Trawl Data

trawl.data<-survdat %>%
  select(ID, EST_YEAR,SEASON, STRATUM, DECDEG_BEGLAT,DECDEG_BEGLON,
         SVSPP, COMNAME, CATCHSEX,BIOMASS, AVGDEPTH, ABUNDANCE) %>%
  filter(STRATUM >= 01010 & STRATUM <= 01760) %>%
  filter(STRATUM!=1310 & STRATUM!=1320 & STRATUM!=1330 & STRATUM!=1350 &
           STRATUM!=1410 & STRATUM!=1420 & STRATUM!=1490) %>%
  filter(SEASON == "SPRING" | SEASON == "FALL") %>%
  filter(EST_YEAR >= 1970 & EST_YEAR < 2018) %>%
  filter(!is.na(BIOMASS))

Generate template of all sampling occasions by selecting duplicate cases by ID, EST_YEAR, SEASON, STRATUM, and AVGDEPTH.

template<-trawl.data %>%
  distinct(ID, EST_YEAR, SEASON, STRATUM, AVGDEPTH,.keep_all = TRUE) %>%
  select(ID, EST_YEAR, SEASON, STRATUM,DECDEG_BEGLAT,DECDEG_BEGLON,AVGDEPTH)

Summarize biomass for each spp in each sample

samples<-trawl.data %>%
  distinct(ID, SVSPP, CATCHSEX,.keep_all = TRUE)

samples.biomass<-samples %>%
  group_by(ID,SVSPP) %>%
  summarise(BIOMASS = sum(BIOMASS))

Calculate center lat/long.

trawl.spp<-sort(unique(samples$SVSPP))
year <- seq(1970, 2017)
center7017 <- data.frame()

for (s in 1:length(trawl.spp)){ # loop for species
  
  spp.sub <- samples[samples$SVSPP==trawl.spp[s],]   # subset data for species
  
 
  for (y in 1:length(year)){  # loop for years
    
    spp.yr<- spp.sub[spp.sub$EST_YEAR == year[y], ]    # subset data for time
    
    biomass.total.year <- sum(spp.yr$BIOMASS)
    
    center.lat <- sum(spp.yr$DECDEG_BEGLAT*(spp.yr$BIOMASS/biomass.total.year))
    center.lon <- sum(spp.yr$DECDEG_BEGLON*(spp.yr$BIOMASS/biomass.total.year))
    center7017[(s-1)*(length(year))+y, 1]<- trawl.spp[s]
    center7017[(s-1)*(length(year))+y, 2]<- year[y]
    center7017[(s-1)*(length(year))+y, 3] <- center.lat
    center7017[(s-1)*(length(year))+y, 4] <- center.lon
    
    colnames(center7017)<- c("SVSPP","YEAR","CENTER_LAT", "CENTER_LON")
  }
  
}

Screen species.

screen7017 <- data.frame()

for (s in 1:length(trawl.spp)){ # loop for species
  spp.sub <- center7017[center7017$SVSPP==trawl.spp[s],] 
  count<-nrow(spp.sub[spp.sub$CENTER_LAT<=1,])  #THIS INDICATES YEARS IN WHICH THEY WEREN'T OBSERVED
  screen7017[s, 1]<- trawl.spp[s]
  screen7017[s, 2]<- count
  
  colnames(screen7017)<- c("SVSPP","MISSING_YRS")
}

nearfull7017<-screen7017[screen7017$MISSING_YRS==0,]

ts7017<-merge(center7017,nearfull7017,by="SVSPP",all.x=FALSE)
names<-unique(trawl.data[,c('SVSPP', 'COMNAME')])
ts7017<-merge(ts7017,names, by="SVSPP",all.y=FALSE)
ts7017<-ts7017[with(ts7017,order(SVSPP, YEAR)),]

Plot ts of faster moving species center.

##  1970s  1980s  1990s  2000s  2010s   NA's 
## 321957 294232 323834 565113  54704 300924
seasonscols = c("#fec44f","#3182bd")
a<-trawl.data %>%
  group_by(EST_YEAR, SEASON) %>%
  summarise(n = n()) %>%
  ggplot(aes(EST_YEAR,n)) +  geom_bar(stat = "identity",aes(fill = SEASON)) + theme_bw() +
  labs(x = "Year",y = "Number of tows per year")  + theme(legend.position = "bottom") + 
  scale_fill_manual(values = seasonscols) + theme(panel.grid = element_blank()) + 
  theme(axis.text.x = element_text(size = 13),axis.text.y = element_text(size = 13),axis.title = element_text(size = 16))

b<-trawl.data %>%
  group_by(EST_YEAR, SEASON) %>%
  summarise(n = n(),sum = sum(BIOMASS)) %>%
  ggplot(aes(EST_YEAR,sum)) +  geom_bar(stat = "identity",aes(fill = SEASON)) + theme_bw() +
  labs(x = "Year",y = "Total biomass caught") + theme(legend.position = "none") +
  scale_fill_manual(values = seasonscols) + theme(panel.grid = element_blank()) + 
  theme(axis.text.x = element_text(size = 13),axis.text.y = element_text(size = 13),axis.title = element_text(size = 16))

c<-trawl.data %>%
  group_by(EST_YEAR, SEASON) %>%
  summarise(n = n(),sum = sum(BIOMASS),pertow = sum/n) %>%
  ggplot(aes(EST_YEAR,pertow)) +  geom_bar(stat = "identity",aes(fill = SEASON)) + theme_bw() +
  labs(x = "Year",y = "Biomass per tow") + theme(legend.position = "none") +
  scale_fill_manual(values = seasonscols) + theme(panel.grid = element_blank()) + 
  theme(axis.text.x = element_text(size = 13),axis.text.y = element_text(size = 13),axis.title = element_text(size = 16))

lay <- rbind(c(1,1,1,2,2),
             c(1,1,1,3,3))
gs = list(a,b,c)
finalfig<-grid.arrange(grobs = gs, layout_matrix = lay)

#ggsave(finalfig,width=11, height=8.5, file = paste(shared.path, "Mills Lab/Projects/Pew_project/Leading-Trailing_Edge_Project/Temp_Figures/trawlNs.pdf",sep = ""))

Distribution by species/decade

Create figures (biomass by latitude over decades, biomass weighted density by decade, and slope of center, leading, trailing edge).

Top plot: This barplot (not histogram) illustrates the relationship between latitude and biomass over time. This does not only include center of biomass, but latitude for all catch by species over each decade. I used a color scale to define the center 50% of the data, as well as the 80, 85, 90, and 95 percentiles.

Bottom left: This ggridge shows the biomass weighted density by decade. This is more like a histogram (counts), but I weighted it by biomass so it is more representative of actual catch.

Bottom right: In this figure, the points represent the annual center of biomass, the black line is the lm of center of biomass latitude ~ year (with the 99% CI of the lm). The dark grey dashed line represents the IQR of the species’ latitude distribution. The light grey dashed line represents mean plus and minus two standard deviations

Quartiles and standard deviations were calculated by using the summarize function from the FSA package in R on the lm of (lat ~ year) for each species (all data, not just center).

The dashed lines are a lm for q1.lat~year, q3.lat~year, and so on.

Potential “edges” by year