library(EcotaxaTools)
<- ecopart_example |>
tricho_only mod_zoo(names_keep, keep_names = 'Trichodesmium', keep_children = T) |>
add_zoo(names_to, col_name = 'name', new_names = 'Trichodesmium', suppress_print = T) |>
add_zoo(func = biovolume, col_name = 'biovol', shape = 'ellipsoid',
pixel_mm = unique(ecopart_example$meta$acq_pixel)) |>
uvp_zoo_conc(func_col = 'biovol', func = sum, breaks = seq(0,400,25))
<- tricho_only[[1]] |>
tricho_c1 bin_format() #get cast 1 only
## Calculate trapzoidal integration
= trap_integrate(x = tricho_c1$mp, y = tricho_c1$conc_m3,
intg_tricho min_x = 0, max_x = 400)
Depth-integration
Zooplankton concentration can be depth-integrated following either bin_taxa()
or uvp_zoo_conc()
. In EcotaxaTools, I provide a method for trapezoidal integration. This approach will use linear interpolation of the zooplankton concentration between mid-points of each depth bin. The core function is trap_integrate()
which passes arguments to a linear interpolation function lin_interp()
and to the base integrate()
function. At times, integrate()
will return errors from processing/accuracy. These can be circumvented by increaseing the number of subdivisions with subdivision (default is set to 100, typically I’ll increase to 1000L) or by increasing the rel.tol. By default rel.tol is set to .Machine$double.eps^25
and tolerance can be increased by changing that exponent.
There are a few ways to apply the integration tools:
Integrating a single dataframe and one species:
If there is a single zoo_df
, and a single species, then the user must specify the columns manually. For example, if you were only interested in the Trichodesmium integrated biovolume from a single cast:
Integrating mutliple species in a dataframe:
For multiple taxa, the integrate_all()
will apply trap_integrate()
for each unique taxa. This function also has an option for formatting, if bin_format()
has yet to be applied. A list of integration dataframes for each taxa will be returned. To collapse this into a single df, use intg_to_tib()
. For example, if you were interested in the integrated abundance of all crustaceans:
<- ecopart_example |>
crustacea_conc mod_zoo(names_keep, keep_names = 'Crustacea', keep_children = T) |>
uvp_zoo_conc(breaks = seq(0,1200,100))
<- crustacea_conc[[1]]
crustacea_c1 <- integrate_all(crustacea_c1, need_format = T)
intg_crustacea |>
intg_crustacea intg_to_tib()
# A tibble: 2 × 2
taxa intg
<chr> <dbl>
1 Copepoda 189.
2 Eumalacostraca 324.
Integrating multiple taxa across several casts
Most useful for incorporation with the UVP / ecopart_obj
framework would be to include integrate_all()
with a lapply()
. For example, using the crustacea_conc from the previous example:
|>
crustacea_conc lapply(integrate_all, need_format = T) |>
lapply(intg_to_tib) |>
list_to_tib('cast')
# A tibble: 91 × 3
taxa intg cast
<chr> <dbl> <chr>
1 Copepoda 189. bats361_ctd1
2 Eumalacostraca 324. bats361_ctd1
3 Copepoda 1278. bats361_ctd2
4 Crustacea 43.6 bats361_ctd2
5 Eucalanidae 201. bats361_ctd2
6 Eumalacostraca 24.2 bats361_ctd2
7 Ostracoda 248. bats361_ctd2
8 Copepoda 1093. bats361_ctd3
9 Eucalanidae 430. bats361_ctd3
10 Eumalacostraca 80.4 bats361_ctd3
# … with 81 more rows