Skip to contents

This script takes the checked fish data from the previous workflow steps, visualises the data and exports it into a format suitable for modelling. The exploratory visualisation of the data allows for trends and patterns in the raw data to be investigated.

R set up

Load the necessary libraries.

Set the study name.

name <- "example-bruv-workflow"

Read in the data

Load and format the metadata.

metadata.bathy.derivatives <- readRDS(here::here(paste0("r-workflows/data/tidy/", name, "_metadata-bathymetry-derivatives.rds"))) %>%
  glimpse()
## Rows: 32
## Columns: 22
## $ campaignid                  <chr> "2023-03_SwC_stereo-BRUVs", "2023-03_SwC_s…
## $ sample                      <chr> "35", "5", "26", "23", "29", "4", "32", "3…
## $ date_time                   <chr> "14/03/2023 23:36", "14/03/2023 23:49", "1…
## $ location                    <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ site                        <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ depth                       <chr> "39.6", "42.7", "36", "41", "42.6", "45", …
## $ successful_count            <chr> "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", …
## $ successful_length           <chr> "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", …
## $ successful_habitat_forward  <chr> "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", …
## $ successful_habitat_backward <chr> "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", …
## $ x                           <dbl> 114.9236, 114.9292, 114.9284, 114.9190, 11…
## $ y                           <dbl> -34.13155, -34.12953, -34.12729, -34.12832…
## $ longitude_dd                <dbl> 114.9236, 114.9292, 114.9284, 114.9190, 11…
## $ latitude_dd                 <dbl> -34.13155, -34.12953, -34.12729, -34.12832…
## $ ID                          <dbl> 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73…
## $ mbdepth                     <dbl> -34.97151, -36.35807, -40.68553, -38.25594…
## $ slope                       <dbl> 0.146843375, 0.812689749, 0.694289634, 0.4…
## $ aspect                      <dbl> 209.89577, 62.41434, 40.87387, 294.10675, …
## $ TPI                         <dbl> 0.42153454, 2.39535522, -0.67607403, 0.476…
## $ TRI                         <dbl> 0.75557327, 3.29823494, 2.39221191, 1.8367…
## $ roughness                   <dbl> 2.21119308, 8.36493301, 8.36493301, 5.3012…
## $ detrended                   <dbl> -5.6631737, -7.0394716, -11.2637815, -8.69…

Load and format the habitat data. Here we create a ‘reef’ column that consists of reef-forming habitat found in the study area, which will be used in subsequent fish modelling scripts.

habitat <- readRDS(here::here(paste0("r-workflows/data/tidy/", name, "_tidy-habitat.rds"))) %>%
  dplyr::mutate(number = number / total_points_annotated) %>%
  dplyr::select(campaignid, sample, longitude_dd, latitude_dd, depth, mbdepth, slope, aspect, tpi, tri, roughness, detrended, habitat, number, mean_relief, sd_relief) %>%
  pivot_wider(names_from = habitat, values_from = number, values_fill = 0) %>%
  CheckEM::clean_names() %>%
  dplyr::mutate(reef = consolidated_hard + macroalgae + seagrasses + sessile_invertebrates) %>%           
  dplyr::select(-c(consolidated_hard, macroalgae, seagrasses, sessile_invertebrates, unconsolidated_soft)) %>%
  glimpse()
## Rows: 32
## Columns: 15
## $ campaignid   <chr> "2023-03_SwC_stereo-BRUVs", "2023-03_SwC_stereo-BRUVs", "…
## $ sample       <chr> "35", "5", "26", "23", "29", "4", "32", "37", "3", "2", "…
## $ longitude_dd <dbl> 114.9236, 114.9292, 114.9284, 114.9190, 114.9105, 114.911…
## $ latitude_dd  <dbl> -34.13155, -34.12953, -34.12729, -34.12832, -34.12296, -3…
## $ depth        <chr> "39.6", "42.7", "36", "41", "42.6", "45", "44.4", "46.1",…
## $ mbdepth      <dbl> -34.97151, -36.35807, -40.68553, -38.25594, -39.91339, -4…
## $ slope        <dbl> 0.146843375, 0.812689749, 0.694289634, 0.444838455, 0.322…
## $ aspect       <dbl> 209.89577, 62.41434, 40.87387, 294.10675, 307.15484, 319.…
## $ tpi          <dbl> 0.42153454, 2.39535522, -0.67607403, 0.47694588, 0.875010…
## $ tri          <dbl> 0.75557327, 3.29823494, 2.39221191, 1.83670998, 1.3206706…
## $ roughness    <dbl> 2.21119308, 8.36493301, 8.36493301, 5.30128479, 3.3831062…
## $ detrended    <dbl> -5.6631737, -7.0394716, -11.2637815, -8.6934719, -9.84557…
## $ mean_relief  <dbl> 3.034483, 3.900000, 4.000000, 3.555556, 4.000000, 3.76190…
## $ sd_relief    <dbl> 1.1174831, 0.4472136, 0.0000000, 0.8555853, 0.0000000, 0.…
## $ reef         <dbl> 0.9298246, 1.0000000, 1.0000000, 1.0000000, 1.0000000, 1.…

Load length of maturity data. The maturity dataset is loaded when the package is installed.

maturity.mean <- maturity %>%
  dplyr::group_by(family, genus, species, sex) %>%
  dplyr::slice(which.min(l50_mm)) %>%
  ungroup() %>%
  dplyr::group_by(family, genus, species) %>%
  dplyr::summarise(l50 = mean(l50_mm)) %>%
  ungroup() %>%
  glimpse()
## `summarise()` has grouped output by 'family', 'genus'. You can override using
## the `.groups` argument.
## Rows: 42
## Columns: 4
## $ family  <chr> "Arripidae", "Berycidae", "Carangidae", "Carangidae", "Carchar…
## $ genus   <chr> "Arripis", "Centroberyx", "Pseudocaranx", "Seriola", "Carcharh…
## $ species <chr> "truttaceus", "gerrardi", "spp", "hippos", "obscurus", "plumbe…
## $ l50     <dbl> 600.0, 266.0, 310.0, 831.0, 2540.0, 1360.0, 670.0, 400.0, 466.…

Load and format count data, and transform this into total abundance and species richness. These two response variables will be used in subsequent fish modelling scripts.

tidy.count <- readRDS(here::here(paste0("r-workflows/data/staging/", name, "_complete-count.rds"))) %>%
  dplyr::group_by(campaignid, sample, scientific) %>%
  dplyr::summarise(count = sum(count)) %>%
  pivot_wider(names_from = "scientific", values_from = count, values_fill = 0) %>%
  dplyr::ungroup() %>%
  dplyr::mutate(total_abundance = rowSums(.[, 3:(ncol(.))], na.rm = TRUE), species_richness = rowSums(.[, 3:(ncol(.))] > 0)) %>% 
  dplyr::select(campaignid, sample, total_abundance, species_richness) %>%
  pivot_longer(cols = c("total_abundance", "species_richness"), names_to = "response", values_to = "number") %>%
  dplyr::left_join(habitat) %>%
  glimpse()
## `summarise()` has grouped output by 'campaignid', 'sample'. You can override
## using the `.groups` argument.
## Joining with `by = join_by(campaignid, sample)`
## Rows: 188
## Columns: 17
## $ campaignid   <chr> "2022-05_PtCloates_stereo-BRUVS", "2022-05_PtCloates_ster…
## $ sample       <chr> "1", "1", "11", "11", "12", "12", "13", "13", "14", "14",…
## $ response     <chr> "total_abundance", "species_richness", "total_abundance",…
## $ number       <dbl> 42, 8, 19, 8, 27, 13, 20, 10, 7, 6, 45, 13, 38, 12, 61, 1…
## $ longitude_dd <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
## $ latitude_dd  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
## $ depth        <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
## $ mbdepth      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
## $ slope        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
## $ aspect       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
## $ tpi          <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
## $ tri          <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
## $ roughness    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
## $ detrended    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
## $ mean_relief  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
## $ sd_relief    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
## $ reef         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…

Load and format length data.

lengths <- readRDS(here::here(paste0("r-workflows/data/staging/", name, "_complete-length.rds"))) %>%
  # dplyr::mutate(depth = as.numeric(depth)) %>%                      
  left_join(habitat) %>%
  left_join(maturity.mean) %>%
  dplyr::mutate(number = 1) %>%
  glimpse()
## Joining with `by = join_by(campaignid, sample, depth)`
## Joining with `by = join_by(family, genus, species)`
## Rows: 23,119
## Columns: 35
## $ campaignid                  <chr> "2022-05_PtCloates_stereo-BRUVS", "2022-05…
## $ sample                      <chr> "1", "1", "1", "1", "1", "1", "1", "1", "1…
## $ family                      <chr> "Acanthuridae", "Acanthuridae", "Acanthuri…
## $ genus                       <chr> "Naso", "Naso", "Naso", "Albula", "Aplodac…
## $ species                     <chr> "brachycentron", "fageni", "hexacanthus", …
## $ length_mm                   <dbl> NA, NA, NA, NA, NA, NA, NA, 336.7789, 324.…
## $ number                      <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
## $ range                       <chr> NA, NA, NA, NA, NA, NA, NA, "3775.30808", …
## $ rms                         <chr> NA, NA, NA, NA, NA, NA, NA, "11.10507", "1…
## $ precision                   <chr> NA, NA, NA, NA, NA, NA, NA, "21.13063", "9…
## $ date_time                   <chr> "2022-05-22T10:03:24+08:00", "2022-05-22T1…
## $ location                    <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ site                        <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ depth                       <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ successful_count            <chr> "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", …
## $ successful_length           <chr> "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", …
## $ successful_habitat_forward  <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ successful_habitat_backward <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ zone_type                   <chr> "National Park Zone (IUCN II)", "National …
## $ status                      <chr> "No-take", "No-take", "No-take", "No-take"…
## $ marine_region               <chr> "North-west", "North-west", "North-west", …
## $ scientific                  <chr> "Acanthuridae Naso brachycentron", "Acanth…
## $ longitude_dd                <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ latitude_dd                 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ mbdepth                     <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ slope                       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ aspect                      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ tpi                         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ tri                         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ roughness                   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ detrended                   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ mean_relief                 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ sd_relief                   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ reef                        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ l50                         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…

Format data for visualisation and modelling

Filter length data to only include ‘indicator species’. In our case study, these are three species that have been defined as bioregional-scale demersal fish indicators by the West Australian Department of Primary Industries and Regional Development. If there is no equivalent in your study area, we suggest using ecologically-relevant and highly-targeted species.

indicator.species <- lengths %>%
  dplyr::mutate(scientific = paste(genus, species, sep = " ")) %>%
  dplyr::filter(scientific %in% c("Choerodon rubescens", "Chrysophrys auratus", "Glaucosoma hebraicum")) %>%
  glimpse()
## Rows: 330
## Columns: 35
## $ campaignid                  <chr> "2022-05_PtCloates_stereo-BRUVS", "2022-05…
## $ sample                      <chr> "1", "1", "1", "11", "11", "11", "12", "12…
## $ family                      <chr> "Glaucosomatidae", "Labridae", "Sparidae",…
## $ genus                       <chr> "Glaucosoma", "Choerodon", "Chrysophrys", …
## $ species                     <chr> "hebraicum", "rubescens", "auratus", "hebr…
## $ length_mm                   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ number                      <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
## $ range                       <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ rms                         <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ precision                   <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ date_time                   <chr> "2022-05-22T10:03:24+08:00", "2022-05-22T1…
## $ location                    <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ site                        <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ depth                       <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ successful_count            <chr> "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", …
## $ successful_length           <chr> "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", …
## $ successful_habitat_forward  <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ successful_habitat_backward <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ zone_type                   <chr> "National Park Zone (IUCN II)", "National …
## $ status                      <chr> "No-take", "No-take", "No-take", "No-take"…
## $ marine_region               <chr> "North-west", "North-west", "North-west", …
## $ scientific                  <chr> "Glaucosoma hebraicum", "Choerodon rubesce…
## $ longitude_dd                <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ latitude_dd                 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ mbdepth                     <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ slope                       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ aspect                      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ tpi                         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ tri                         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ roughness                   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ detrended                   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ mean_relief                 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ sd_relief                   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ reef                        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ l50                         <dbl> 310.5, 379.0, 352.0, 310.5, 379.0, 352.0, …

Create a unique list of the samples per campaign, to fill the zeroes back into processed length data.

metadata.length <- lengths %>%
  distinct(campaignid, sample, status) %>%
  glimpse()
## Rows: 94
## Columns: 3
## $ campaignid <chr> "2022-05_PtCloates_stereo-BRUVS", "2022-05_PtCloates_stereo…
## $ sample     <chr> "1", "11", "12", "13", "14", "15", "16", "17", "18", "19", …
## $ status     <chr> "No-take", "No-take", "No-take", "No-take", "No-take", "No-…

Create a dataframe of the indicator species greater than length of maturity.

greater.mat <- indicator.species %>%
  dplyr::filter(length_mm > l50) %>%
  dplyr::group_by(campaignid, sample) %>%
  dplyr::summarise(number = sum(number)) %>%
  ungroup() %>%
  right_join(metadata.length) %>%
  dplyr::mutate(number = ifelse(is.na(number), 0, number)) %>%
  dplyr::mutate(response = "greater than Lm") %>%
  left_join(habitat) %>%
  dplyr::glimpse()
## `summarise()` has grouped output by 'campaignid'. You can override using the
## `.groups` argument.
## Joining with `by = join_by(campaignid, sample)`
## Joining with `by = join_by(campaignid, sample)`
## Rows: 94
## Columns: 18
## $ campaignid   <chr> "2023-03_SwC_stereo-BRUVs", "2023-03_SwC_stereo-BRUVs", "…
## $ sample       <chr> "15", "17", "19", "23", "24", "26", "29", "3", "31", "32"…
## $ number       <dbl> 1, 1, 8, 3, 2, 3, 4, 1, 4, 6, 1, 3, 1, 2, 4, 2, 6, 1, 13,…
## $ status       <chr> "No-take", "No-take", "No-take", "No-take", "No-take", "N…
## $ response     <chr> "greater than Lm", "greater than Lm", "greater than Lm", …
## $ longitude_dd <dbl> 114.8444, 114.8576, 114.7822, 114.9190, 114.8485, 114.928…
## $ latitude_dd  <dbl> -34.08478, -34.09635, -34.12047, -34.12832, -34.11789, -3…
## $ depth        <chr> "45.3", "43.3", "73.6", "41", "45.6", "36", "42.6", "46.7…
## $ mbdepth      <dbl> -44.29804, -42.74676, -71.60112, -38.25594, -44.23959, -4…
## $ slope        <dbl> 0.108975978, 0.008719478, 0.880997142, 0.444838455, 0.103…
## $ aspect       <dbl> 264.03427, 30.76545, 262.35388, 294.10675, 257.20307, 40.…
## $ tpi          <dbl> -0.19527912, 0.02505112, 1.04176044, 0.47694588, 0.042278…
## $ tri          <dbl> 0.34487247, 0.03473282, 2.80258274, 1.83670998, 0.3347983…
## $ roughness    <dbl> 0.91366196, 0.09923935, 9.01136017, 5.30128479, 1.2933082…
## $ detrended    <dbl> -0.2281526, -3.1375041, 17.9911461, -8.6934719, 2.9724391…
## $ mean_relief  <dbl> 2.518519, 3.333333, 2.583333, 3.555556, 3.360000, 4.00000…
## $ sd_relief    <dbl> 0.8024180, 0.9128709, 0.5036102, 0.8555853, 0.4898979, 0.…
## $ reef         <dbl> 0.8292683, 1.0000000, 0.9493671, 1.0000000, 1.0000000, 1.…

Create a dataframe of the indicator species smaller than length of maturity.

smaller.mat <- indicator.species %>%
  dplyr::filter(length_mm < l50) %>%
  dplyr::group_by(campaignid, sample) %>%
  dplyr::summarise(number = sum(number)) %>%
  ungroup() %>%
  right_join(metadata.length) %>%
  dplyr::mutate(number = ifelse(is.na(number), 0, number)) %>%
  dplyr::mutate(response = "smaller than Lm") %>%
  left_join(habitat) %>%
  dplyr::glimpse()
## `summarise()` has grouped output by 'campaignid'. You can override using the
## `.groups` argument.
## Joining with `by = join_by(campaignid, sample)`
## Joining with `by = join_by(campaignid, sample)`
## Rows: 94
## Columns: 18
## $ campaignid   <chr> "2023-03_SwC_stereo-BRUVs", "2023-03_SwC_stereo-BRUVs", "…
## $ sample       <chr> "26", "4", "7", "1", "11", "12", "13", "14", "15", "16", …
## $ number       <dbl> 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ status       <chr> "No-take", "No-take", "No-take", "No-take", "No-take", "N…
## $ response     <chr> "smaller than Lm", "smaller than Lm", "smaller than Lm", …
## $ longitude_dd <dbl> 114.9284, 114.9112, 114.7854, NA, NA, NA, NA, NA, NA, NA,…
## $ latitude_dd  <dbl> -34.12729, -34.11597, -34.09623, NA, NA, NA, NA, NA, NA, …
## $ depth        <chr> "36", "45", "62.7", NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
## $ mbdepth      <dbl> -40.68553, -42.80315, -60.38860, NA, NA, NA, NA, NA, NA, …
## $ slope        <dbl> 0.69428963, 0.04543667, 0.11543757, NA, NA, NA, NA, NA, N…
## $ aspect       <dbl> 40.87387, 319.32290, 319.71953, NA, NA, NA, NA, NA, NA, N…
## $ tpi          <dbl> -0.6760740, 0.1713285, 0.0789628, NA, NA, NA, NA, NA, NA,…
## $ tri          <dbl> 2.3922119, 0.2051287, 0.3780084, NA, NA, NA, NA, NA, NA, …
## $ roughness    <dbl> 8.3649330, 0.5424461, 1.6087303, NA, NA, NA, NA, NA, NA, …
## $ detrended    <dbl> -11.26378, -12.73950, 19.98986, NA, NA, NA, NA, NA, NA, N…
## $ mean_relief  <dbl> 4.000000, 3.761905, 3.000000, NA, NA, NA, NA, NA, NA, NA,…
## $ sd_relief    <dbl> 0.0000000, 0.4364358, 0.0000000, NA, NA, NA, NA, NA, NA, …
## $ reef         <dbl> 1, 1, 1, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …

Join the two datasets.

tidy.length <- bind_rows(greater.mat, smaller.mat) %>%
  glimpse()
## Rows: 188
## Columns: 18
## $ campaignid   <chr> "2023-03_SwC_stereo-BRUVs", "2023-03_SwC_stereo-BRUVs", "…
## $ sample       <chr> "15", "17", "19", "23", "24", "26", "29", "3", "31", "32"…
## $ number       <dbl> 1, 1, 8, 3, 2, 3, 4, 1, 4, 6, 1, 3, 1, 2, 4, 2, 6, 1, 13,…
## $ status       <chr> "No-take", "No-take", "No-take", "No-take", "No-take", "N…
## $ response     <chr> "greater than Lm", "greater than Lm", "greater than Lm", …
## $ longitude_dd <dbl> 114.8444, 114.8576, 114.7822, 114.9190, 114.8485, 114.928…
## $ latitude_dd  <dbl> -34.08478, -34.09635, -34.12047, -34.12832, -34.11789, -3…
## $ depth        <chr> "45.3", "43.3", "73.6", "41", "45.6", "36", "42.6", "46.7…
## $ mbdepth      <dbl> -44.29804, -42.74676, -71.60112, -38.25594, -44.23959, -4…
## $ slope        <dbl> 0.108975978, 0.008719478, 0.880997142, 0.444838455, 0.103…
## $ aspect       <dbl> 264.03427, 30.76545, 262.35388, 294.10675, 257.20307, 40.…
## $ tpi          <dbl> -0.19527912, 0.02505112, 1.04176044, 0.47694588, 0.042278…
## $ tri          <dbl> 0.34487247, 0.03473282, 2.80258274, 1.83670998, 0.3347983…
## $ roughness    <dbl> 0.91366196, 0.09923935, 9.01136017, 5.30128479, 1.2933082…
## $ detrended    <dbl> -0.2281526, -3.1375041, 17.9911461, -8.6934719, 2.9724391…
## $ mean_relief  <dbl> 2.518519, 3.333333, 2.583333, 3.555556, 3.360000, 4.00000…
## $ sd_relief    <dbl> 0.8024180, 0.9128709, 0.5036102, 0.8555853, 0.4898979, 0.…
## $ reef         <dbl> 0.8292683, 1.0000000, 0.9493671, 1.0000000, 1.0000000, 1.…

Visualise the fish count data

Filter the count (maxn) data to only include one response. In this example the count metrics included are total abundance and species richness.

response.name <- 'total_abundance'

overzero <-  tidy.count %>% 
  filter(response %in% response.name & number > 0) 

equalzero <- tidy.count %>% 
  filter(response %in% response.name & number == 0)

Visualise the count data as a bubble plot. White bubbles represent zeroes and the size of blue bubbles represents abundance.

bubble.plot <- leaflet(data = tidy.count) %>%                     
  addTiles() %>%                                                    
  addProviderTiles('Esri.WorldImagery', group = "World Imagery") %>%
  addLayersControl(baseGroups = c("Open Street Map", "World Imagery"), options = layersControlOptions(collapsed = FALSE))

if (nrow(overzero)) {                                               
  bubble.plot <- bubble.plot %>%
    addCircleMarkers(data = overzero, lat = ~ latitude_dd, lng = ~ longitude_dd, radius = ~ number / 10, fillOpacity = 0.5, stroke = FALSE, label = ~ as.character(sample))}
## Warning in validateCoords(lng, lat, funcName): Data contains 62 rows with
## either missing or invalid lat/lon values and will be ignored
if (nrow(equalzero)) {                                            
  bubble.plot <- bubble.plot %>%
    addCircleMarkers(data = equalzero, lat = ~ latitude_dd, lng = ~ longitude_dd, radius = 2, fillOpacity = 0.5, color = "white", stroke = FALSE, label = ~ as.character(sample))}
bubble.plot

Visualise the fish length data

Filter the length data to only include one response. In this example the length metrics included are indicator species greater than and smaller than the length of maturity.

response.name <- 'greater than Lm'

overzero <-  tidy.length %>% 
  filter(response %in% response.name & number > 0) 

equalzero <- tidy.length %>% 
  filter(response %in% response.name & number == 0)

Visualise the count data as a bubble plot. White bubbles represent zeroes and the size of blue bubbles represents abundance.

bubble.plot <- leaflet(data = tidy.length) %>%                     
  addTiles() %>%                                                    
  addProviderTiles('Esri.WorldImagery', group = "World Imagery") %>%
  addLayersControl(baseGroups = c("Open Street Map", "World Imagery"), options = layersControlOptions(collapsed = FALSE))

if (nrow(overzero)) {                                               
  bubble.plot <- bubble.plot %>%
    addCircleMarkers(data = overzero, lat = ~ latitude_dd, lng = ~ longitude_dd, radius = ~ number + 3, fillOpacity = 0.5, stroke = FALSE, label = ~ as.character(sample))}

if (nrow(equalzero)) {                                            
  bubble.plot <- bubble.plot %>%
    addCircleMarkers(data = equalzero, lat = ~ latitude_dd, lng = ~ longitude_dd, radius = 2, fillOpacity = 0.5, color = "white", stroke = FALSE, label = ~ as.character(sample))}
## Warning in validateCoords(lng, lat, funcName): Data contains 62 rows with
## either missing or invalid lat/lon values and will be ignored
bubble.plot

Save tidy datasets for modelling

Save count response data (total abundance and species richness).

saveRDS(tidy.count, file = here::here(paste0("r-workflows/data/tidy/", name, "_tidy-count.rds")))

Save length response data (indicator species greater than and smaller than the length of maturity).

saveRDS(tidy.length, file = here::here(paste0("r-workflows/data/tidy/", name, "_tidy-length.rds")))