Introduction

The fishflux package provides a tool to model fluxes of C (carbon), N (nitrogen) and P (phosphorus) in fishes. It combines basic principles from elemental stoichiometry and metabolic theory. The package offers a user-friendly interface to apply the model. fishflux is ideal for fish ecologists wishing to predict ingestion, egestion and excretion to study fluxes of nutrients and energy.

Main assets:

  • Provides function to model fluxes of Carbon, Nitrogen and Phosphorus for fishes
  • Allows for the estimation of uncertainty, dpending on the uncertainy of the input parameters
  • Provides some functions to help find parameters as inputs for the model
  • Provides functions to extract and illustrate results

Installing and loading fishflux

fishflux uses Markov Chain Monte Carlo simulations provided by stan. Therefore, the first step is to install rstan. It’s important to closely follow all the steps described on the page depending on your operating system.

GitHub

The best way to install the latest development version of fishflux is to install it from GitHub.

install.packages("devtools")
devtools::install_github("nschiett/fishflux", dependencies = TRUE) # if errors are returned, try adding `args = "--preclean"` to `install_github`
library(fishflux)

CRAN

fishflux will be available on CRAN in the future:

Downloaded package file

Another option is to download the source file available on GitHub here.

install.packages(path_to_fishflux_file, repos = NULL, type = "source")
library(fishflux)

How to use fishflux?

fishflux is designed to follow three simple steps:

  • Find the right input parameters
  • Run the model simulation with those input parameters
  • Plot the model results and check sensitivity

Input parameters

Before running the model, the parameters have to be specified. Below, there is a table showing all parameters needed to run the model simulation. fishflux provides several functions to find some of these parameters, but note that others have to be provided by the user at this stage. Ideally, all parameters should also have a standard deviation, so that their uncertainty can be reflected in the model predictions

. Overview of inputs, including input parameters, to be specified by the user of the model. k indicates c, n or p. VBGC = von Bertalanffy growth curve.
Symbol Description Unit
ak Element-specific assimilation efficiency _
lt Total length of individual cm
linf Asymptotic adult length (VBGC) cm
κ Growth rate parameter (VBGC) yr − 1
t0 Age at settlement (VBGC) yr
lwa Parameter length-weight relationship g cm − 1
lwb Parameter length-weight relationship _
Qk Element-specific body content percentage %
f0 Metabolic normalisation constant independent of body mass g Cg − αd − 1
alpha Mass-scaling exponent _
theta Activity scope _
v Environmental temperature C
h trophic level _
r Aspect ratio of caudal fin _
F0nz Mass-specific turnover rate of N g Ng − 1d − 1
F0pz Mass-specific turnover rate of P g Pg − 1d − 1
mdw Ratio of dry mass and wet mass of fish _
Dk Elemental stoichiometry of diet %

A good place to start is checking if you are using the correct scientific name of your species of interest. The function name_errors will tell you if the species name is correct. This function can be useful, especially when working with larger databases.

# example
fishflux::name_errors("Zebrazoma scopas")
#> Inaccurate species names found:
#> [1] "Zebrazoma scopas"

Once the species names are verified and/or corrected we can continue with specifying some parameters.

The find_lw function searches FishBase to find length-weight relationship parameters lw_a and lw_b extracted from Froese and Pauly (2018).

# example
fishflux::find_lw("Zebrasoma scopas", mirror = "se")
#>            species   lwa_m      lwa_sd lwb_m    lwb_sd
#> 1 Zebrasoma scopas 0.02455 0.002627551  2.98 0.0255102

The model uses parameters von Bertalanffy’s growth model (VBGM) to estimate growth rates. A quick way to get available information from FishBase is the function growth_params(). This can be a good indication, but users should interpret these estimates with a critical eye, as they come from disparate sources of varying accuracy. Alternatively, it is advised to use growth curves derived from otolith readings. In the absence of otolith data, one might consider extracting standardised estimations from Morais and Bellwood (2018).

# example
# The option otolith=TRUE filters out sources that used otoliths for the estimation of growth parameters
fishflux::growth_params("Sargocentron microstoma", otolith = FALSE)
#> Warning: `data_frame()` is deprecated as of tibble 1.1.0.
#> Please use `tibble()` instead.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_warnings()` to see where this warning was generated.
#> # A tibble: 1 x 7
#>   species           Locality                k  Linf    t0 method        comments
#>   <chr>             <chr>               <dbl> <dbl> <dbl> <chr>         <chr>   
#> 1 Sargocentron mic… Tiahura reef, Moor…     1  18.6    NA length-frequ… <NA>

Further, there are a couple more basic functions to get an indication of parameters that are available on FishBase such as trophic_level() and aspect_ratio(). Note that it is always better to get the approximations through analysis, measurements and otolith analysis over parameters extracted from functions, such as growth_params(), trophic_level() and aspect_ratio(). To get an overview of all parameters available, fishflux provides a wrapper function model_parameters().

# example
zebsco <- fishflux::model_parameters("Zebrasoma scopas", family = "Acanthuridae", temp = 27, mirror = "se")
## Here we set the temperature at 27 degrees as an example, this the average sea temperature in Moorea, French Polynesia
print(zebsco)
#>            species    t0 Linf     k     asp troph   lwa_m      lwa_sd lwb_m
#> 1 Zebrasoma scopas -0.49 13.3 0.425 2.02091     2 0.02455 0.002627551  2.98
#>      lwb_sd     mdw_m        f0_m       f0_sd alpha_m   alpha_sd
#> 1 0.0255102 0.2504833 0.001517989 2.99088e-10    0.77 0.05286288

All other parameters have to be provided by the user. For more information on how to acquire these parameters, take a look at (“this paper” add reference to methods paper).

Run model

Once all the parameters are collected, we can run the model through cnp_model_mcmc(). Note that this model can be run with or without specifying the standard deviation (sd) of each parameter. If the sd of a certain parameter is not provided, it will be automatically set to a very low value (1-10). As mentioned before, it is advisable to include uncertainty of parameters. fishflux is designed to use the MCMC sampler in order to include uncertainty of predictions.

## load the example parameters for Zebrasoma scopas, a list
param_zebsco <- fishflux::param_zebsco
## Run the model, specifying the target length(s) and the parameter list
model <- fishflux::cnp_model_mcmc(TL = 5:20, param = param_zebsco)

The object model now contains all the samples generated from the MCMC simulation and a summary of all parameters generated. To extract certain variables of interest, use the extract() function. Predictions for fluxes of C, N and P are all in g / day.

fishflux::extract(model, c("Fn","Fp"))
#>    TL      Fn_mean    Fn_median        Fn_sd      Fn_2.5%    Fn_97.5%
#> 1   5 0.0008812686 0.0008235356 0.0004328303 0.0002384015 0.001760192
#> 2   6 0.0013258007 0.0012913356 0.0006177459 0.0003644033 0.002755424
#> 3   7 0.0018520248 0.0017147691 0.0008552925 0.0005221026 0.003827689
#> 4   8 0.0024955783 0.0022691806 0.0011744544 0.0007582033 0.005239428
#> 5   9 0.0033594675 0.0030645399 0.0017593784 0.0008027211 0.007896552
#> 6  10 0.0044427023 0.0038105732 0.0024817585 0.0009983687 0.010373224
#> 7  11 0.0056018792 0.0050818190 0.0031276618 0.0013638631 0.012408699
#> 8  12 0.0071700684 0.0061603963 0.0044810007 0.0013596635 0.018974660
#> 9  13 0.0091006186 0.0078059917 0.0055584034 0.0019719075 0.023112483
#> 10 14 0.0111509279 0.0097442706 0.0073693155 0.0021695742 0.028637060
#> 11 15 0.0134713432 0.0117680462 0.0089187037 0.0021922154 0.034930769
#> 12 16 0.0166723546 0.0147366213 0.0104757216 0.0032225340 0.041858269
#> 13 17 0.0189434339 0.0164110237 0.0119481674 0.0041790129 0.045019645
#> 14 18 0.0231042007 0.0194581939 0.0151278836 0.0055791577 0.059950559
#> 15 19 0.0274471491 0.0237701337 0.0173273606 0.0064690370 0.068388780
#> 16 20 0.0317089992 0.0272101447 0.0196819228 0.0079804906 0.079354290
#>          Fn_25%      Fn_75%      Fp_mean    Fp_median        Fp_sd      Fp_2.5%
#> 1  0.0005731828 0.001120930 7.901167e-05 4.262093e-05 9.636217e-05 1.769438e-06
#> 2  0.0008725869 0.001668676 1.693996e-04 9.514647e-05 1.954007e-04 4.619992e-06
#> 3  0.0012096329 0.002352575 2.481992e-04 1.360243e-04 2.892781e-04 9.856487e-06
#> 4  0.0017157330 0.003143184 4.707332e-04 2.797757e-04 4.930189e-04 2.089223e-05
#> 5  0.0021280784 0.004303073 7.136319e-04 4.656971e-04 6.976681e-04 3.296718e-05
#> 6  0.0026399817 0.005693377 1.059754e-03 7.451556e-04 9.610281e-04 4.139310e-05
#> 7  0.0032874885 0.007322587 1.530951e-03 1.143573e-03 1.285731e-03 8.666743e-05
#> 8  0.0039232907 0.009516102 2.108272e-03 1.595223e-03 1.805492e-03 1.367883e-04
#> 9  0.0049345179 0.012385438 2.847663e-03 2.240994e-03 2.282329e-03 1.426152e-04
#> 10 0.0054598903 0.014898217 3.686355e-03 3.075416e-03 2.942267e-03 2.575545e-04
#> 11 0.0066444537 0.018763595 4.693189e-03 3.977092e-03 3.577911e-03 5.232711e-04
#> 12 0.0081617495 0.023365235 6.028523e-03 5.089274e-03 4.188773e-03 7.179604e-04
#> 13 0.0092474664 0.025789070 7.145662e-03 6.230212e-03 4.791509e-03 1.250463e-03
#> 14 0.0111159207 0.031291327 8.956436e-03 7.574565e-03 6.087325e-03 1.880206e-03
#> 15 0.0127549185 0.039211442 1.090561e-02 9.438208e-03 6.882298e-03 2.507441e-03
#> 16 0.0157018379 0.043334661 1.263614e-02 1.093755e-02 7.860730e-03 3.143533e-03
#>        Fp_97.5%       Fp_25%       Fp_75%
#> 1  0.0003813117 2.066783e-05 9.071778e-05
#> 2  0.0006910814 4.649674e-05 2.286414e-04
#> 3  0.0010155546 7.028683e-05 3.167641e-04
#> 4  0.0017828806 1.196509e-04 6.533386e-04
#> 5  0.0025701470 1.980511e-04 1.007623e-03
#> 6  0.0034296188 3.302923e-04 1.565533e-03
#> 7  0.0046330963 5.288092e-04 2.269363e-03
#> 8  0.0068843395 6.964291e-04 3.034089e-03
#> 9  0.0084119003 9.763717e-04 4.172867e-03
#> 10 0.0102418477 1.368398e-03 5.155713e-03
#> 11 0.0129396242 1.795076e-03 6.722186e-03
#> 12 0.0156817228 2.599549e-03 8.765427e-03
#> 13 0.0177168997 3.193866e-03 9.982705e-03
#> 14 0.0234772567 4.145680e-03 1.219971e-02
#> 15 0.0271361022 5.121089e-03 1.554783e-02
#> 16 0.0323245239 6.115753e-03 1.722432e-02

Sensitivity

The function sensitivity() looks at how the distribution of the input variables affects the uncertainty of the model predictions. Basically, the model is run for each input parameter, while keeping all the others fixed. The output of the function gives a matrix of the width of the 95% CI for all model predictions (columns), depending on the input variables (rows). The input parameters and output variables of interest can be specified by arguments “par” and “out” respectively.

## General overview:
fishflux::sensitivity(TL = 10, param = param_zebsco, par = c("Dn_sd", "Dp_sd", "Qn_sd", "Qp_sd", "k_sd"), out = c("Fn", "Fp", "Ic"))

#>              Fn_CI        Fp_CI        Ic_CI
#> Dn_sd 2.058257e-10 0.0002510894 8.967479e-03
#> Dp_sd 2.080024e-10 0.0007505586 2.122006e-09
#> Qn_sd 1.970958e-03 0.0007692026 2.747152e-02
#> Qp_sd 1.905995e-10 0.0007283809 2.020027e-09
#> k_sd  2.073855e-10 0.0001094801 1.052693e-02

More information

For more information on the theoretical framework of the model, see Schiettekatte et al. (2020) ( paper ). Every function of fishflux has a help page with more documentation. In the case of errors, bugs or discomfort, you are invited to raise an issue on GitHub. fishflux is always in development and we are happy to take your comments or suggestions into consideration.

Froese, R., and D. Pauly. 2018. “FishBase.” World Wide Web Electronic Publication.

Morais, Renato A, and David R Bellwood. 2018. “Global Drivers of Reef Fish Growth.” Fish and Fisheries 19 (5): 874–89.

Schiettekatte, N. M. D., D. R. Barneche, S. Villéger, J. E. Allgeier, D. E. Burkepile, S. J. Brandl, J. M. Casey, et al. 2020. “Nutrient Limitation, Bioenergetics, and Stoichiometry: A New Model to Predict Elemental Fluxes Mediated by Fishes.” Functional Ecology, no. Accepted Author Manuscript. https://doi.org/10.1111/1365-2435.13618.