setwd("~/Desktop/inPrep/pew/github/erp/Rmd")

Consumption of forage fish in Ecosim

This is an R Markdown document for the visualization of outputs from the Ecosim component of Ecopath with Ecosim (EwE) models of Northeast Atlantic regional seas. Models used in this work include those covering the extent of:

  1. The Irish Sea (ICES VIIa),
  2. The West Coast of Scotland (VIa),
  3. The Greater North Sea (IVa, IVb, IVc),
  4. The Northern North Sea (IVa),
  5. The Norwegian Sea and Barents Sea (Ia, Ib, IIa, IIb)

Ecosim components for all of the above models were available for this study. From these models, we have extracted the estimated consumption (tonnes per km-2) of forage fish over time. This analysis provides an overview of the ecosystem role of species in the available ecosystem models and enables regional comparison of forage fish consumption across ecosystems.

# Create a list of dataframes
dataframes <- list(
  Irish_Sea = Irish,
  Northern_North_Sea = NNorthSea,
  Norwegian_and_Barents_Seas = NorBar,
  North_Sea = NorthSea,
  West_Coast_of_Scotland = WCofS
)

# Extract unique column names from all dataframes to help build custom legend
all_columns <- unique(unlist(lapply(dataframes, colnames)))

# Create a color palette for the unique columns using viridis
num_unique_columns <- length(all_columns)
color_palette <- viridis(num_unique_columns)

# Create a named vector mapping column names to colors so that they match across plots
column_color_mapping <- setNames(color_palette, all_columns)
column_color_mapping[5]<-'light grey'

# Create a list to store the ggplot objects
plot_list <- list()

# Loop through each ecosystem dataframe and create a stacked area plot for forage fish consumption
for (df_name in names(dataframes)) {
  df <- dataframes[[df_name]]
  
  # Reshape the data from wide to long format
  df_long <- df %>% 
    pivot_longer(cols = -Year, names_to = "Variable", values_to = "Value")
  
  # Create the stacked area plot
  p <- ggplot(df_long, aes(x = Year, y = Value, fill = Variable)) +
    geom_area() +
    scale_fill_manual(values = column_color_mapping) +  # Use the predefined colors
    labs(title = gsub("_"," ",df_name), y=expression(Consumption~(tonnes~per~km^2))) +
    theme_minimal() +
    theme(legend.position = "none")  # Remove individual legends so we can add a common legend later
  plot_list[[df_name]] <- p
}

# Arrange the plots in a grid
grid_plot_without_legend <- cowplot::plot_grid(plotlist = plot_list, ncol = 2)

# Remove "Year" from the list of all columns
all_columns <- all_columns[all_columns != "Year"]

# Create a custom legend using the species column names
custom_legend <- cowplot::get_legend(
  ggplot() +
    geom_point(aes(x = 0, y = 0, color = all_columns), size = 4) +
    scale_color_manual(values = column_color_mapping[all_columns]) +
    labs(color = NULL) +  # Remove the legend key title
    theme_void() +
    theme(legend.title = element_blank())
)

plot_list[[6]]<-custom_legend

# Add a single legend at the bottom of the combined grid
combined_grid <- cowplot::plot_grid(
  cowplot::plot_grid(plotlist = plot_list, ncol = 2)
)

# Print the combined grid with a single legend at the bottom
print(combined_grid)
Figure 1. Consumption of forage fish in North East Atlantic ecosystems across time. Estimates of total consumption come from the time-dynamic Ecosim components of Ecopath with Ecosim models.

Figure 1. Consumption of forage fish in North East Atlantic ecosystems across time. Estimates of total consumption come from the time-dynamic Ecosim components of Ecopath with Ecosim models.

ggsave("../outputs/figs/Ecosim_consumption.png", combined_grid, height = 8, width = 6,dpi = 500)

Estimates of natural mortality for Mackerel

Our study uses Mackerel as a casestudy for the development of pragmatic ecological reference points. EwE provides estimates of natural mortality linked to the consumption of mackerel by predators (consumption/biomass). Three of the ecosystem models listed above meet the requirements to extract this information for mackerel. These requirements are: 1) Mackerel is included as a single species functional group, and 2) Ecosystem models have an Ecosim component fitted to observation data. Models available for this portion of the analysis include:

  1. The Greater North Sea (IVa, IVb, IVc),
  2. The Northern North Sea (IVa),
  3. The Norwegian Sea and Barents Sea (Ia, Ib, IIa, IIb)
# Reshape the mackerel M data from wide to long format
MackerelM_long <- gather(MackerelM, key = "Variable", value = "Value", -Year)

MackerelM_long$Variable <- gsub('NorBar', 'Norwegian and Barents Seas', MackerelM_long$Variable)
MackerelM_long$Variable <- gsub('WCofS', 'West coast of Scotland', MackerelM_long$Variable)
MackerelM_long$Variable <- gsub('North.Sea', 'North Sea', MackerelM_long$Variable)

# Plot the annual natural mortality from available Ecosim models
Mac_M<-ggplot(MackerelM_long, aes(x = Year, y = Value, color = Variable)) +
  geom_line() +
  labs(x = "Year", y = "Predation mortality (M2)", color = "Ecosystem model") +
  scale_color_viridis_d(option = "D", begin = 0.2, end = 0.8) +
  geom_hline(yintercept = 0.15, linetype = "dashed", color = "black") +
  theme_minimal() +
  theme(panel.background = element_rect(fill = "white", color = "black"))

ggsave("../outputs/figs/Mac_M.png", Mac_M, dpi = 500, height = 2, width=6)
Mac_M
Figure 5. Natural mortality (M) estimates for Mackerel from ecosystem models of the Norwegian and Barents Seas (NorBar), West Coast of Scotand (WCofS) and North Sea. The dashed horizontal line at M=0.15 represents the assumed M in the ICES stock assessment for North Atlantic mackerel.

Figure 5. Natural mortality (M) estimates for Mackerel from ecosystem models of the Norwegian and Barents Seas (NorBar), West Coast of Scotand (WCofS) and North Sea. The dashed horizontal line at M=0.15 represents the assumed M in the ICES stock assessment for North Atlantic mackerel.