Modeling Workflow

Shelley Lang

2019-06-14

Load Package

library(QFASA)

Modeling Inputs

Prior to starting make sure that:

Distance Measure

Choose from one of three distance measures:

  1. KL (Kullback-Leibler)
  2. AIT (Aitchison)
  3. CSD (Chi-Squared)

Fatty Acid Set

Matrix of Predator FA signatures

Matrix of Prey FA signatures

Prey Lipid Content

Calibration Coefficients

Run QFASA

Q = p.QFASA(predator.matrix, prey.matrix, cal.mat, dist.meas, gamma=1, FC, start.val=rep(1,nrow(prey.matrix)), fa.set)

p.QFASA Output

The QFASA output is a list with 2 components:

Diet Estimates

This is a matrix of the diet estimate for each predator (by rows, in the same order as the input file) by the modelling groups (by column, in the same order as the prey.matrix file). The estimates are expressed as a proportion (they will sum to 1). In the code below the Diet Estimate matrix is extracted from the QFASA output and the modelling group identities and predator tombstone data (created above) are added to the matrix:

Additional Measures

This is a list of lists where each list (one per predator) is itself a list of four outputs:

  • ModFAS: the value of the modelled FA (i.e. after CCs have been applied and the FA subsetted and renormalised over the designated FA set). These are expressed as proportions (they will sum to 1).

  • DistCont: the contribution of each FA to the final minimized distance.

  • PropDistCont: the contribution of each FA to the final minimized distance as a proportion of the total.

  • MinDist: the final minimized distance in the code below the ‘ldply’ function from the plyr package is used to compile the lists within ‘Additional Measures’ into a data frame with one row per predator (in the same order as the input predator matrix) and the values for each of the 4 lists arranged into columns. The ‘ldply’ function automatically names the columns of the data frame with a concatenation of the originating list name and the FA name so that the 4 sets of outputs can be easily identified within the data frame.