Package 'fluxweb'

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-12-04 07:26:53 UTC
Source: CRAN

Help Index


The fluxweb package

Description

the new fancy package fluxweb that fluxes webs

Author(s)

Benoit Gauzens


generate fluxes

Description

Creates a valuated graph adjacency matrix from its binary version.

Usage

fluxing(mat, biomasses = NULL, losses, efficiencies, bioms.prefs = TRUE,
  bioms.losses = TRUE, ef.level = "prey")

Arguments

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 TRUE, consumer preferences are scaled according to species biomasses.

bioms.losses

Logical - if TRUE, losses are scaled with species biomasses.

ef.level

Set to "prey" if efficiencies are defined by prey, "pred" if they are a property of the predator.

Details

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:

Fi=1ei(Li+jWijFj)ifef.level == "pred"F_{i} = \frac{1}{e_i} (L_i + \sum_j W_{ij}F_j) \quad if \quad \code{ef.level == "pred"}

Fi=Li+jWijFjjWjiejifef.level == "pred"F_{i} = \frac{L_i + \sum_j W_{ij}F_j}{\sum_j W_{ji}e_j} \quad if \quad \code{ef.level == "pred"}

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 WijW_{ij} of predator j on prey i are scaled accordingly to species biomass using the following formula:

    Wi,j=mat[i,j]biomasses[i]kmat[i,k]biomasses[k]W_{i,j} = \frac{mat[i,j] * biomasses[i]}{\sum_k mat[i,k]* biomasses[k]}

    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.

Value

Returns an adjacency matrix where entries are the computed energy fluxes between consumer species and their respective resources.

Author(s)

Benoit gauzens, [email protected]

Examples

# 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")

Aggregated version of the Food web of a soil network ecosystem and species general information (species.level).

Description

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.

Format

a list of 5 elements:

mat

the network adjacency matrix

biomasses

groups total biomasses (g)

bodymasses

group mean bodymasses of species (g)

efficiencies

group species mean assimilation efficiencies

species.tgs

groups' species composition


making network stability

Description

Find the smallest scalar multiplying a variable from losses insuring system stability

Usage

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), ...)

Arguments

val.mat

A matrix describing fluxes between species (usually a result of fluxing function).

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 losses on which scalar multiplication will be tested. (default NULL if the value is independent of losses).

bioms.prefs

Logical, if TRUE (default) preferences are scaled accordingly to species biomasses.

bioms.losses

Logical, if TRUE (default) losses are scaled with biomass.

ef.level

Set to "prey" if efficiencies are defined by prey, "pred" if they are a property of the predator.

interval

Search interval for returned value.

...

Optional parameters for function uniroot

Details

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.

Value

A list from uniroot function.

See Also

uniroot for root estimate and stability.value for assessing system stability.

Examples

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")

sensitivity analysis

Description

Assesses how sensitive the results from argument function are to variability of input parameter through coefficient of variation.

Usage

sensitivity(fun.name, param.name, var, n, full.output = FALSE, ...)

Arguments

fun.name

Function to analyse.

param.name

Parameter from ... on which variation is applied.

var

Define the interval of uncertainty for the uniform law around x as [x - x*var, x + x*var].

n

Number of replicates.

full.output

Logical, if TRUE all of n estimations of fun.name are returned. Only their mean otherwise.

...

Arguments to be passed to fun.name. Argument names must exactly match those of fun.name.

Details

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.

Value

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

Examples

# 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)

Food web of a soil network ecosystem and species general information.

Description

This dataset correspond to the food web of a microcosm assembled from the Chesapeake Bay estuary (Lefcheck and Duffy 2010, Ecology)

Format

a list of 4 elements:

mat

the network adjacency matrix

met.rate

metabolic rates of species (J.h-1)

biomasses

species biomasses (g)

efficiencies

species assimilation efficiencies

names

species names


Food web of a soil network ecosystem and species general information.

Description

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.

Format

a list of 5 elements:

mat

the network adjacency matrix

biomasses

species biomasses (g)

bodymasses

species bodymasses (g)

efficiencies

species assimilation efficiencies

names

species names


Estimates network stability

Description

Computes resilience of the system through Jacobian matrix eigenvalues.

Usage

stability.value(val.mat, biomasses, losses, efficiencies, growth.rate,
  bioms.prefs = TRUE, bioms.losses = TRUE, ef.level = "prey",
  full.output = FALSE)

Arguments

val.mat

A matrix describing fluxes between species (usually a result of fluxing function).

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 TRUE (default) preferences are scaled according to species biomasses.

bioms.losses

Logical, if TRUE (default) losses are scaled with biomass.

ef.level

Set to "prey" if efficiencies are defined by prey, "pred" if they are a property of the predator.

full.output

Logical, if TRUE function return supplementary informations.

Details

  • 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 wijw_{ij} of predator j on prey i are scaled according to species biomass using the following formula:

    wi,j=mat[i,j]biomasses[i]kmat[i,k]biomasses[k]w_{i,j} = \frac{mat[i,j] * biomasses[i]}{\sum_k mat[i,k]* biomasses[k]}

  • 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.

Value

Maximum eigenvalue of the Jacobian matrix of a Lotka Voltera like system of equations. If full.output, Jacobian eigenvalues and eigenvectors are returned.

Author(s)

Benoit Gauzens, [email protected]

Examples

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")