Title: | Estimate Energy Fluxes in Food Webs |
---|---|
Description: | Compute energy fluxes in trophic networks, from resources to their consumers, and can be applied to systems ranging from simple two-species interactions to highly complex food webs. It implements the approach described in Gauzens et al. (2017) <doi:10.1101/229450> to calculate energy fluxes, which are also used to calculate equilibrium stability. |
Authors: | Benoit Gauzens |
Maintainer: | Benoit Gauzens <[email protected]> |
License: | GPL (>= 2.0) |
Version: | 0.2.0 |
Built: | 2024-11-04 06:46:49 UTC |
Source: | CRAN |
the new fancy package fluxweb that fluxes webs
Benoit Gauzens
Creates a valuated graph adjacency matrix from its binary version.
fluxing(mat, biomasses = NULL, losses, efficiencies, bioms.prefs = TRUE, bioms.losses = TRUE, ef.level = "prey")
fluxing(mat, biomasses = NULL, losses, efficiencies, bioms.prefs = TRUE, bioms.losses = TRUE, ef.level = "prey")
mat |
Network adjacency matrix describing interactions among species. Interactions can be either binary or weighted. |
biomasses |
Vector of species biomasses. |
losses |
A vector or an array of species energy losses (excluding consumption). |
efficiencies |
A vector or an array of conversion efficiencies of species in the adjacency matrix. These values describe the proportion of consumed energy that is converted to biomass of the consumer. |
bioms.prefs |
Logical - if |
bioms.losses |
Logical - if |
ef.level |
Set to |
This function computes fluxes in food webs based on an equilibrium hypothesis: for each species, sum of ingoing fluxes (gains from predation) balances the sum of outgoing fluxes.
Outgoing fluxes are defined by consumption and the losses
argument. Usually losses
relate to species metabolic rates and/or natural death rates. For each species i
, sum of ingoing fluxes F_i
is computed as:
W
set the matrix of preferences estimated from mat
, according to bioms.prefs
. L
is the vector depicting sum of losses
(scaled or not by biomasses, accordingly to bioms.losses
) and e
is the vector of species efficiencies.
mat
: Either a binary or a valuated matrix can be used. A non zero value for mat[i,j] means that species i is consumed by species j.
Matrix entries would assess predator preferences on its prey, thus providing a binary matrix assumes no preferences.
losses
: Express species energetic losses not related to consumption. Usually metabolic or death rates.
When an array is provided, losses associated to each species correspond to line sums.
efficiencies
: Determines how efficient species are to convert energy (see ef.level
for more details).
Providing an array will assume values depending on both prey and predator identity.
bioms.pref
: If TRUE
, preferences of predator j on prey i are scaled accordingly to species biomass using the following formula:
If FALSE
, a normalisation on column values is performed.
bioms.losses
: Set to true, function will assume that losses are defined per biomass unit.
Thus, total losses will be thereafter multiplied by biomass values for each species.
ef.level
: If "prey"
(resp "pred"
), the total amount of energy that can be metabolized from a trophic link
will be determined by prey (resp predator) identity. "link.specific"
assumes that efficiencies are defined for each trophic interaction
and implies efficiencies
parameter to be a matrix.
Returns an adjacency matrix where entries are the computed energy fluxes between consumer species and their respective resources.
Benoit gauzens, [email protected]
# first compute species per unit biomass metabolic rates using the metabolic theory: losses = 0.1 * species.level$bodymasses^(-0.25) # call of the function: fluxing(species.level$mat, species.level$biomasses, losses, species.level$efficiencies, bioms.pref = TRUE, ef.level = "prey")
# first compute species per unit biomass metabolic rates using the metabolic theory: losses = 0.1 * species.level$bodymasses^(-0.25) # call of the function: fluxing(species.level$mat, species.level$biomasses, losses, species.level$efficiencies, bioms.pref = TRUE, ef.level = "prey")
species.level
).This dataset contains the matrix describing trophic interactions between trophic groups of a soil food-web (Digel et al. 2014, Oikos) as well as some ecological information on these groups: biomasses, body masses and and species composition.
a list of 5 elements:
the network adjacency matrix
groups total biomasses (g)
group mean bodymasses of species (g)
group species mean assimilation efficiencies
groups' species composition
Find the smallest scalar multiplying a variable from losses insuring system stability
make.stability(val.mat, biomasses, losses, efficiencies, growth.rate, losses.scale = NULL, bioms.prefs = TRUE, bioms.losses = TRUE, ef.level = "prey", interval = c(1e-12, 1), ...)
make.stability(val.mat, biomasses, losses, efficiencies, growth.rate, losses.scale = NULL, bioms.prefs = TRUE, bioms.losses = TRUE, ef.level = "prey", interval = c(1e-12, 1), ...)
val.mat |
A matrix describing fluxes between species (usually a result of |
biomasses |
A vector of species biomasses. |
losses |
A vector or an array of species energy losses (excluding predation). |
efficiencies |
A vector or an array of conversion efficiencies of species in the adjacency matrix. These values describe the proportion of consumed energy that is converted to biomass of the consumer. |
growth.rate |
A vector defining growth rate of basal species. |
losses.scale |
Defines a Column from |
bioms.prefs |
Logical, if |
bioms.losses |
Logical, if |
ef.level |
Set to |
interval |
Search interval for returned value. |
... |
Optional parameters for function |
The function assumes a monotonous increase of stability with multiplication by a scalar value. Solution is estimated from the uniroot
function, and stability using the fluxing
function
Thus, accordingly to uniroot
solving criteria, if stability values at the two extremum parts of the interval are of same sign, an error is raised.
Behavior of the multiplicative term depends on the type of losses:
losses.scale = NULL
and is.vector(losses)
: multiplication will be applied to the losses
vector.
losses.scale = NULL
and is.matrix(losses)
: multiplication will be independent of any columns from losses
.
losses.scale = FALSE
: value used for multiplication always independent of losses.
other values: should refer to an element of losses.
A list from uniroot
function.
uniroot
for root estimate and stability.value
for assessing system stability.
losses = 0.15 * groups.level$bodymasses^(-0.25) # growth rates of basal sppecies growth.rates = rep(NA, dim(groups.level$mat)[1]) growth.rates[colSums(groups.level$mat) == 0] = 0.5 val.mat = fluxing(groups.level$mat, groups.level$biomasses, losses, groups.level$efficiencies, bioms.pref = TRUE, ef.level = "pred") make.stability(val.mat, groups.level$biomasses, losses, groups.level$efficiencies, growth.rates, ef.level = "pred")
losses = 0.15 * groups.level$bodymasses^(-0.25) # growth rates of basal sppecies growth.rates = rep(NA, dim(groups.level$mat)[1]) growth.rates[colSums(groups.level$mat) == 0] = 0.5 val.mat = fluxing(groups.level$mat, groups.level$biomasses, losses, groups.level$efficiencies, bioms.pref = TRUE, ef.level = "pred") make.stability(val.mat, groups.level$biomasses, losses, groups.level$efficiencies, growth.rates, ef.level = "pred")
Assesses how sensitive the results from argument function are to variability of input parameter through coefficient of variation.
sensitivity(fun.name, param.name, var, n, full.output = FALSE, ...)
sensitivity(fun.name, param.name, var, n, full.output = FALSE, ...)
fun.name |
Function to analyse. |
param.name |
Parameter from |
var |
Define the interval of uncertainty for the uniform law around |
n |
Number of replicates. |
full.output |
Logical, if |
... |
Arguments to be passed to |
At each replicate, a coefficient of variation is computed (relative to results obtained form fun.name
without random variation).
if full.output
is FALSE
(default) a list of two objects of the same type as the one produced by fun.name
is returned,
first element contains the mean coefficient of variation in comparison to non randomised inputs among all the replicates,
second element contains the standard deviation of these coefficients of variation
If full.output
is TRUE
, a list of size n
with of objects containing the coefficients of variation is returned.
Argument for ...
should be passed with their names.
a list of two elements of the same type as param.name
:
first element contains the mean coefficient of variation in comparison to non randomised inputs among all the replicates,
second element contains the standard deviation of these coefficient of variation
# first compute species per unit biomass metabolic rates using the metabolic theory: losses = 0.1 * species.level$bodymasses^(-0.25) res = sensitivity(fluxing, "mat", 0.1, 5, full.output = TRUE, mat = species.level$mat, biomasses = species.level$biomasses, losses = losses, efficiencies = species.level$efficiencies) res = sensitivity(fluxing, "efficiencies", 0.01, 50, mat = species.level$mat, biomasses = species.level$biomasses, losses = losses, efficiencies = species.level$efficiencies) # growth rates of basal species growth.rates = rep(NA, dim(species.level$mat)[1]) growth.rates[colSums(species.level$mat) == 0] = 0.5 val.mat = fluxing(species.level$mat, species.level$biomasses, losses, species.level$efficiencies)
# first compute species per unit biomass metabolic rates using the metabolic theory: losses = 0.1 * species.level$bodymasses^(-0.25) res = sensitivity(fluxing, "mat", 0.1, 5, full.output = TRUE, mat = species.level$mat, biomasses = species.level$biomasses, losses = losses, efficiencies = species.level$efficiencies) res = sensitivity(fluxing, "efficiencies", 0.01, 50, mat = species.level$mat, biomasses = species.level$biomasses, losses = losses, efficiencies = species.level$efficiencies) # growth rates of basal species growth.rates = rep(NA, dim(species.level$mat)[1]) growth.rates[colSums(species.level$mat) == 0] = 0.5 val.mat = fluxing(species.level$mat, species.level$biomasses, losses, species.level$efficiencies)
This dataset correspond to the food web of a microcosm assembled from the Chesapeake Bay estuary (Lefcheck and Duffy 2010, Ecology)
a list of 4 elements:
the network adjacency matrix
metabolic rates of species (J.h-1)
species biomasses (g)
species assimilation efficiencies
species names
This dataset contains the matrix describing trophic interactions from a deutsch soil food-web (Digel et al. 2014, Oikos) as well as some ecological information on species: biomasses, body masses and and species names.
a list of 5 elements:
the network adjacency matrix
species biomasses (g)
species bodymasses (g)
species assimilation efficiencies
species names
Computes resilience of the system through Jacobian matrix eigenvalues.
stability.value(val.mat, biomasses, losses, efficiencies, growth.rate, bioms.prefs = TRUE, bioms.losses = TRUE, ef.level = "prey", full.output = FALSE)
stability.value(val.mat, biomasses, losses, efficiencies, growth.rate, bioms.prefs = TRUE, bioms.losses = TRUE, ef.level = "prey", full.output = FALSE)
val.mat |
A matrix describing fluxes between species (usually a result of |
biomasses |
A vector of species biomasses. |
losses |
A vector or an array of species energy losses (excluding predation). |
efficiencies |
A vector or an array of conversion efficiencies of species in the adjacency matrix. These values describe the proportion of consumed energy that is converted to biomass of the consumer. |
growth.rate |
A vector defining growth rate of basal species. |
bioms.prefs |
Logical, if |
bioms.losses |
Logical, if |
ef.level |
Set to |
full.output |
Logical, if |
losses
: Express species energetic losses not related to consumption. Usually metabolic or death rates.
When an array is provided, losses associated to each species correspond to line sums.
efficiencies
: Determines how efficient species are to convert energy (see ef.level
for more details).
Providing an array will assume values depending on both prey and predator identity.
growth.rate
: Growth rates of basal species defined. Length of the vector should be equal to the number of species.
expects positive numeric values for index corresponding to basal species, NA otherwise
bioms.pref
: If TRUE
, preferences of predator j on prey i are scaled according to species biomass using the following formula:
bioms.losses
: If TRUE
, function will assume that losses are defined per biomass unit.
Thus, total losses will be thereafter multiplied by biomass values for each species.
ef.level
: If "prey"
(resp "pred"
), the total amount of energy that can be metabolized from a trophic link
will be determined by prey (resp pred) identity. "link.specific"
assumes that efficiencies are defined for each trophic interaction
and implies efficiencies
parameter to be a matrix
full.output
: If TRUE
, function result is a list of eigenvalues and eigenvectors of the Jacobian matrix.
Maximum eigenvalue of the Jacobian matrix of a Lotka Voltera like system of equations. If full.output, Jacobian eigenvalues and eigenvectors are returned.
Benoit Gauzens, [email protected]
losses = 0.15 * groups.level$bodymasses^(-0.25) # growth rates of basal sppecies growth.rates = rep(NA, dim(groups.level$mat)[1]) growth.rates[colSums(groups.level$mat) == 0] = 0.5 val.mat = fluxing(groups.level$mat, groups.level$biomasses, losses, groups.level$efficiencies, bioms.pref = TRUE, ef.level = "pred") stability.value(val.mat, groups.level$biomasses, losses, groups.level$efficiencies, growth.rates, ef.level = "pred")
losses = 0.15 * groups.level$bodymasses^(-0.25) # growth rates of basal sppecies growth.rates = rep(NA, dim(groups.level$mat)[1]) growth.rates[colSums(groups.level$mat) == 0] = 0.5 val.mat = fluxing(groups.level$mat, groups.level$biomasses, losses, groups.level$efficiencies, bioms.pref = TRUE, ef.level = "pred") stability.value(val.mat, groups.level$biomasses, losses, groups.level$efficiencies, growth.rates, ef.level = "pred")