FishLife
is an R package for predicting and repositing life-history parameters for >30,000 fishes using both life-history correlations and similarities among related species. This package uses data from FishBase as downloaded in 2016, and can be updated using a new database, or using additional data for a single species.
A graphical user interface (GUI) is available online
First, install and load the package.
# Install and load package devtools::install_github("james-thorson/FishLife") library( FishLife )
Next, we show predictions using the database.
First we demonstrate red snapper, which is within the FishBase database used to train the model, so its predictions are relatively tight.
# Get basic plot for Lutjanus campechanus Plot_taxa( Search_species(Genus="Lutjanus",Species="campechanus")$match_taxonomy, mfrow=c(2,2) )
Next we demonstrate cortez rockfish, which is not within the FishBase database used to train the model, so its predictions are relatively based on information from related species within genus Sebastes.
# Get basic plot for Sebastes cortezi Predict = Plot_taxa( Search_species(Genus="Sebastes",Species="cortezi")$match_taxonomy, mfrow=c(2,2) )
We then show updated values for the predictive mean using Predict[[1]]$Mean_pred
...
knitr::kable(Predict[[1]]$Mean_pred, digits=3)
... and predictive covariance using Predict[[1]]$Cov_pred
...
knitr::kable(Predict[[1]]$Cov_pred, digits=3)
... for life-history parameters. These values are in log-space for all variables except Temperature, and converting to the predictive median can be accomplished by exponentiating those variables: :
knitr::kable(c(exp(Predict[[1]]$Mean_pred[-8]),Predict[[1]]$Mean_pred['Temperature']), digits=3)
... or the predictive mean can be calculated by exponentiating and bias-correcting:
knitr::kable(c(exp(Predict[[1]]$Mean_pred[-8]+0.5*diag(Predict[[1]]$Cov_pred)[-8]),Predict[[1]]$Mean_pred['Temperature']), digits=3)
Please see code in "tutorial.Rmd" for details.
Third, we demonstrate predictions for family Scombridae, to show how predictions are available for higher-level taxonomies.
# Get basic plot for Family Scombridae Plot_taxa( Search_species(Family="Scombridae")$match_taxonomy, mfrow=c(2,2) )
Fourth, we compare predictions for two species, brown and rainbow trout.
# Compare two species Taxa = c( Search_species(Genus="Oncorhynchus",Species="mykiss",add_ancestors=FALSE)$match_taxonomy, Search_species(Genus="Salmo",Species="Trutta",add_ancestors=FALSE)$match_taxonomy ) Plot_taxa( Taxa, mfrow=c(2,2) )
The package also contains tools to replicate results, explore model uncertainty, and include new data.
We now show code for how the model can be re-run on the loaded database using a different structure on life-history correlations (although we do not run this, because it is slow).
# Load TMB library( TMB ) # Re-run results with a different model configuration Estimate_database = Fit_model( N_factors=-3, N_obsfactors=-3, Use_REML=TRUE)
We also show how to generate new predictions for a single species based on new life-history information.
Specifically, we imagine a scenario where we have a new value for asymptotic length, which we format in a new dataframe Ynew_ij
that can contain one or more parameters
Ynew_ij = matrix( c("Loo"=log(40),"K"=NA,"Winfinity"=NA,"tmax"=NA,"tm"=NA,"M"=NA,"Lm"=NA,"Temperature"=NA), nrow=1)
Then run an updating function for Cortez rockfish
library(TMB) Update = Update_prediction( Taxon=Search_species(Genus="Sebastes",Species="cortezi",add_ancestors=FALSE)$match_taxonomy, Ynew_ij=Ynew_ij)
We then show updated values for the predictive mean using Update$updateMean_j
...
knitr::kable(Update$updateMean_j, digits=3)
... and predictive covariance using Update$updateCov_j
...
knitr::kable(Update$updateCov_j, digits=3)
... for life-history parameters for this species. This update shows a change in asymptotic length (due to including new data) and also in relative growth rate (due to estimated covariance among traits).
If using the software or predictions please cite:
Also please see:
for further information regarding life-history predictions currently available in FishBase.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.