Quantitative Fatty Acid Signature Analysis

Accurate estimates of the diets of predators are required in many areas of ecology, but for many species current methods are imprecise, limited to the last meal, and often biased. The diversity of fatty acids and their patterns in organisms, coupled with the narrow limitations on their biosynthesis, properties of digestion in monogastric animals, and the prevalence of large storage reservoirs of lipid in many predators, led us to propose the use of quantitative fatty acid signature analysis (QFASA) to study predator diets.


Overview

Accurate estimates of the diets of predators are required in many areas of ecology, but for many species current methods are imprecise, limited to the last meal, and often biased. The diversity of fatty acids and their patterns in organisms, coupled with the narrow limitations on their biosynthesis, properties of digestion in monogastric animals, and the prevalence of large storage reservoirs of lipid in many predators, led us to propose the use of quantitative fatty acid signature analysis (QFASA) to study predator diets.

Installing

devtools::install_github('justinkamerman/QFASA')
install.packages('QFASA')

Load Package

library(QFASA)

Modeling Inputs

Prior to starting make sure that:

  • Fatty acid names in all files are the same (contain the exact same numbers/characters and punctuation)
  • There are no fatty acids in the prey file that do not appear in the predator file and visa versa

Choose from one of three distance measures:
1=KL (Kullback-Leibler) || 2=AIT (Aitchison) || 3=CSD (Chi-Squared)

dist.meas=1
  • This is the list of FAs to be used in the modelling.
  • The simplest alternative is to load a .csv file which contains a single column with a header row and the names of the fatty acids listed below (see example file __"FAset.csv"__).
  • A more complicated alternative is to load a .csv file with the full set of FAs and then add code to subset the FAs you wish to use from that set --> this alternative is useful if you are planning to test multiple FA sets.
  • Regardless of how you load the FA set it must be converted to a vector.
data(FAset)
fa.set = as.vector(unlist(FAset))
  • The FA signatures in the originating .csv file should be in percentages not proportions (i.e. adding to ~100 not 1).

  • Each predator signature is a row with the FAs in columns (see example file __"predatorFAs.csv"__).

  • the FA signatures are subsetted for the chosen FA set (created above) and renormalized during the modelling so there is no need to subset and/or renormalize prior to loading the .csv file or running p.QFASA BUT make sure that the the same FAs appear in the predator and prey files (if a FA appears in one but not the other the code will give you an error).

  • Unlike the original QFASApack code the predator FA .csv file can contain as much tombstone data in columns as you wish but the predator FA signatures must be extracted as a separate input in order to run in p.QFASA. For example: in the code below the predator .csv file ("predatorFAs.csv") has 4 tombstone columns (SampleCode, AnimalCode, SampleGroup, Biopsy). Prior to running QFASA the tombstone (columns 1-4) and FA data (columns 5 onward) are each extracted from the original data frame. The FA data becaomes the the predator.matrix (which is passed to p.QFASA) and the tombstone data is retained so that it can be recombined with the model output later on.

data(predatorFAs)
tombstone.info = predatorFAs[,1:4]
predator.matrix = predatorFAs[,5:(ncol(predatorFAs))]
 
# number of predator FA signatures this is used to create the matrix of CC values (see section 6 below)
npredators = nrow(predator.matrix)
  • The FA signatures in the originating .csv file should be in percentages not proportions (i.e. adding to ~100 not 1).

  • The prey file should contain all of the individual FA signatures of the prey and their lipid contents (where appropriate) - a matrix of the mean values for the FAs (prey.matrix) by the designated prey modelling group is then calculated using the MEANmeth function loaded above.

  • Like the predator .csv file you can have as many tombstone data columns as required but there must be at least one column that identifies the modelling group to be used (in the example file used below "preyFAs.csv" it is the "Species" column).

  • Unlike the predator data, the prey data is not subsetted and renomalized during the modelling so the prey file needs to be subsetted for the desired FA set (created above) and renormalized to sum to 1 prior to calculating the mean values (see code below). Example: in the code below the "preyFAs.csv" file has 3 tombstone columns. The full FA set is extracted from the data frame (columns 4 onward), subsetted for the FA set in use and then renormalized over 1. The modelling group names (the "Species" column in this case) is then added back to the subsetted and renormalized data (as the first column) and the average values calculated using the MEANmeth function. Note that for the MEANmeth function to work the modelling group name must be in the first column.

#full file
data(preyFAs)
 
#extract prey FA only from data frame and subset them for the FA set designated above
prey.sub=(preyFAs[,4:(ncol(preyFAs))])[fa.set]
 
#renormalize over 1
prey.sub=prey.sub/apply(prey.sub,1,sum) 
 
#extract the modelling group names from the full file
group=as.vector(preyFAs$Species)
 
#add modelling group names to the subsetted and renormalized FAs
prey.matrix=cbind(group,prey.sub)
 
#create an average value for the FA signature for each designated modelling group
prey.matrix=MEANmeth(prey.matrix) 
  • mean lipid content by modelling group is calculated from the full prey file using the modelling group as a summary variable (see code below).
  • Note: if no lipid content correction is going to be applied then a vector of '1's of length equal to the number of modelling groups is used as the vector instead i.e. FC=rep(1,nrow(prey.matrix))
#numbers are the column which identifies the modelling group, and the column which contains the lipid contents
FC = preyFAs[,c(2,3)] 
FC = as.vector(tapply(FC$lipid,FC$Species,mean,na.rm=TRUE))
  • Originating .csv file should contain 2 columns (with headers). The first contains the FA names, the second the value of the CC for each FA (see example file __"CC.csv"__).
  • IMPORTANT: the FAs in the CC.csv file MUST be exactly the same as the FAs in the originating predator.csv file AND they MUST BE IN THE EXACT SAME ORDER.
data(CC)
cal.vec = CC[,2]
cal.mat = replicate(npredators, cal.vec)

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)

The QFASA output is a list with 2 components:

  • Diet Estimates
  • Additional Measures

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:

DietEst = Q$'Diet Estimates'
 
#estimates changed from proportions to percentages
DietEst = round(DietEst*100,digits=2)
colnames(DietEst) = (as.vector(rownames(prey.matrix)))
DietEst = cbind(tombstone.info,DietEst)
knitr::kable(DietEst)
SampleCodeAnimalCodeSampleGroupBiopsycapelincohoeulachonherringmackerelpilchardpollocksandlancesquidsurfsmelt_lgsurfsmelt_s
3-01AP031TA35.300044.909.252.3608.1900.000
3-01BP031T1B43.060044.793.724.2504.1800.000
3-01CP031T1C50.150034.346.143.9705.4000.000
3-02AP032TA37.800047.141.425.0408.6000.000
3-02BP032T1B39.860045.503.695.7705.1800.000
3-02CP032T1C47.990035.594.475.3906.5500.000
3-04AP034TA41.290046.338.242.6501.4900.000
3-04BP034T2B31.960028.002.952.40034.7000.000
3-04CP034T2C21.070014.450.272.00037.03025.170
3-05AP035TA28.910063.500.003.9303.6600.000

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.

# plyr package
library(plyr)
Add.meas = ldply(Q$'Additional Measures', data.frame)
knitr::kable(Add.meas)
ModFAS.c14.0ModFAS.c16.0ModFAS.c16.1w7ModFAS.c16.2w6ModFAS.c16.2w4ModFAS.c16.3w6ModFAS.c17.0ModFAS.c16.3w4ModFAS.c16.4w3ModFAS.c16.4w1ModFAS.c18.0ModFAS.c18.1w9ModFAS.c18.1w7ModFAS.c18.2w6ModFAS.c18.2w4ModFAS.c18.3w6ModFAS.c18.3w4ModFAS.c18.3w3ModFAS.c18.3w1ModFAS.c18.4w3ModFAS.c18.4w1ModFAS.c20.1w11ModFAS.c20.1w9ModFAS.c20.1w7ModFAS.c20.2w6ModFAS.c20.3w6ModFAS.c20.4w6ModFAS.c20.3w3ModFAS.c20.4w3ModFAS.c20.5w3ModFAS.c22.1w11ModFAS.c22.1w9ModFAS.c22.1w7ModFAS.c21.5w3ModFAS.c22.4w6ModFAS.c22.5w6ModFAS.c22.4w3ModFAS.c22.5w3ModFAS.c22.6w3DistCont.c14.0DistCont.c16.0DistCont.c16.1w7DistCont.c16.2w6DistCont.c16.2w4DistCont.c16.3w6DistCont.c17.0DistCont.c16.3w4DistCont.c16.4w3DistCont.c16.4w1DistCont.c18.0DistCont.c18.1w9DistCont.c18.1w7DistCont.c18.2w6DistCont.c18.2w4DistCont.c18.3w6DistCont.c18.3w4DistCont.c18.3w3DistCont.c18.3w1DistCont.c18.4w3DistCont.c18.4w1DistCont.c20.1w11DistCont.c20.1w9DistCont.c20.1w7DistCont.c20.2w6DistCont.c20.3w6DistCont.c20.4w6DistCont.c20.3w3DistCont.c20.4w3DistCont.c20.5w3DistCont.c22.1w11DistCont.c22.1w9DistCont.c22.1w7DistCont.c21.5w3DistCont.c22.4w6DistCont.c22.5w6DistCont.c22.4w3DistCont.c22.5w3DistCont.c22.6w3PropDistCont.c14.0PropDistCont.c16.0PropDistCont.c16.1w7PropDistCont.c16.2w6PropDistCont.c16.2w4PropDistCont.c16.3w6PropDistCont.c17.0PropDistCont.c16.3w4PropDistCont.c16.4w3PropDistCont.c16.4w1PropDistCont.c18.0PropDistCont.c18.1w9PropDistCont.c18.1w7PropDistCont.c18.2w6PropDistCont.c18.2w4PropDistCont.c18.3w6PropDistCont.c18.3w4PropDistCont.c18.3w3PropDistCont.c18.3w1PropDistCont.c18.4w3PropDistCont.c18.4w1PropDistCont.c20.1w11PropDistCont.c20.1w9PropDistCont.c20.1w7PropDistCont.c20.2w6PropDistCont.c20.3w6PropDistCont.c20.4w6PropDistCont.c20.3w3PropDistCont.c20.4w3PropDistCont.c20.5w3PropDistCont.c22.1w11PropDistCont.c22.1w9PropDistCont.c22.1w7PropDistCont.c21.5w3PropDistCont.c22.4w6PropDistCont.c22.5w6PropDistCont.c22.4w3PropDistCont.c22.5w3PropDistCont.c22.6w3MinDist
0.05476640.18539660.07018870.00094760.00178540.00690450.00566820.00522320.00136930.00932760.02326660.14805620.03708540.00964650.00159220.00127390.00083160.00476090.00078090.01414350.00145030.01783650.06504700.00409280.00173000.00075390.00617310.00049310.00385500.11473190.08202860.00745020.00224160.00401790.00036080.00110300.00042090.01109930.09209900.00887910.01509250.00011736.05e-050.00023960.00006500.00038140.00026660.00003050.00054860.00010310.01834380.00008620.00004012.07e-052.0e-070.00015910.00002130.00000100.00131397.90e-060.00311490.01553930.00033080.00013634.91e-050.00011600.00011740.00004400.00060080.02124950.00000010.00358840.00021991.26e-050.00015060.00011600.00579750.01478400.07945850.13506170.00104950.00054160.00214430.00058150.00341320.00238540.00027330.00490930.00092250.16415650.00077140.00035930.00018561.60e-060.00142390.00019090.00000860.01175810.00007030.02787490.13906010.00296050.00121980.00043950.00103770.00105020.00039340.00537660.19015950.00000060.03211220.00196760.00011280.00134780.00103830.05188120.13230030.1117455
0.05504600.18411670.07200540.00099300.00163040.00708300.00533600.00563220.00125720.01046160.02336790.14788950.03671060.00932630.00169730.00130890.00086640.00435750.00077580.01383420.00155880.01427260.06828180.00423210.00162450.00077790.00616540.00044800.00385040.11638100.08149980.00768300.00221850.00411820.00035390.00107870.00040580.01197360.08938010.00630320.01718960.00369392.20e-060.00034320.00023710.00049680.00036330.00000410.00102760.00001370.01783500.00014260.00050431.04e-052.2e-060.00021630.00011600.00007370.00112339.90e-060.00236130.01392780.00039840.00000137.77e-050.00035170.00005050.00021810.00000050.02441850.00003360.00328710.00013715.53e-050.00015870.00011280.00647670.01210050.05535180.15095000.03243770.00001910.00301370.00208220.00436290.00319000.00003630.00902370.00012060.15661820.00125180.00442870.00009101.94e-050.00189960.00101870.00064730.00986440.00008660.02073530.12230680.00349830.00001150.00068220.00308850.00044360.00191550.00000410.21443050.00029490.02886520.00120420.00048600.00139330.00099020.05687540.10626080.1138759
0.05602790.17898900.07237390.00095910.00174440.00672730.00491630.00537200.00127020.01013040.02286790.13783880.03552060.00964230.00167930.00128810.00083720.00431670.00080860.01371510.00158430.01521220.07326480.00467660.00166300.00076120.00599780.00045160.00393080.11638640.08619030.00869550.00228330.00407130.00034480.00106330.00040230.01237920.09361610.00170160.01071100.00616746.90e-060.00045230.00025860.00044840.00043570.00001360.00083260.00004240.01263270.00000730.00090511.39e-051.7e-060.00004590.00010080.00009440.00129283.40e-060.00291030.01444330.00070500.00000701.93e-050.00003840.00004880.00020880.00044330.02856980.00002620.00469120.00003561.12e-050.00007810.00004730.00521830.00809270.01672160.10525440.06060550.00006740.00444480.00254100.00440650.00428180.00013350.00818130.00041650.12413870.00007200.00889440.00013701.68e-050.00045120.00099070.00092720.01270390.00003330.02859920.14193050.00692740.00006870.00018980.00037780.00047910.00205170.00435570.28074800.00025770.04609890.00034980.00010980.00076750.00046450.05127920.07952490.1017630
0.05493240.18868190.07139460.00102260.00170540.00717490.00535010.00581600.00126530.01094740.02438620.15043010.03687510.00929080.00178850.00135300.00089090.00462210.00083880.01481940.00161000.01283130.06322520.00399400.00166460.00079200.00630650.00046830.00400660.11925300.07509860.00698160.00216330.00423420.00037460.00110810.00042060.01215300.08972840.01309360.01882710.00158584.30e-050.00022970.00004080.00052600.00017120.00002030.00027500.00055480.02394210.00001780.00008011.40e-069.1e-060.00014400.00028300.00001920.00018501.30e-050.00169610.01583070.00053300.00010750.00e+000.00001220.00000660.00013550.00128610.01394200.00008000.00253240.00026611.00e-070.00013240.00010490.00809110.01315390.11098850.15958870.01344180.00036430.00194720.00034540.00445840.00145080.00017220.00233130.00470310.20294590.00015130.00067940.00001217.71e-050.00122050.00239900.00016300.00156820.00011030.01437720.13418960.00451830.00091150.00000000.00010300.00005590.00114840.01090180.11817950.00067840.02146620.00225550.00000100.00112270.00088890.06858450.11149910.1179728
0.05515640.18609060.07185310.00103090.00163270.00721220.00528260.00590860.00124210.01132760.02419410.14890660.03691720.00923670.00180670.00136350.00090500.00440980.00082020.01442340.00166610.01397870.06445880.00402550.00162260.00080940.00631200.00045370.00402790.11912230.07717740.00725740.00214360.00427230.00036670.00108280.00041330.01265880.08843080.00751530.01507450.00122352.24e-050.00031310.00027110.00061230.00038670.00000060.00082650.00023060.01672780.00007550.00042543.30e-061.1e-060.00023670.00015340.00009010.00082562.25e-050.00188370.01207980.00053370.00000553.60e-060.00025540.00005680.00010100.00000000.01867030.00004720.00225970.00020011.65e-050.00014320.00004870.00773640.01039540.07555030.15154090.01229940.00022530.00314750.00272540.00615570.00388710.00000640.00830880.00231850.16816100.00075930.00427650.00003311.09e-050.00237940.00154180.00090610.00829980.00022600.01893600.12143560.00536470.00005540.00003590.00256710.00057090.00101530.00000000.18768840.00047410.02271600.00201200.00016550.00143940.00048980.07777220.10450250.0994748
0.05605050.18179950.07238150.00100290.00173530.00689260.00485370.00569540.00124260.01105860.02376880.13989260.03571120.00949750.00179790.00134440.00087760.00436570.00085410.01435840.00168660.01386870.06948060.00446640.00165350.00079110.00614520.00045350.00408790.11934320.08100380.00817870.00220980.00422710.00035890.00107200.00040930.01300230.09238060.00238710.00878710.00211405.80e-060.00039580.00030190.00054160.00038370.00002110.00057780.00041600.01143370.00007480.00073506.00e-063.7e-060.00005210.00012350.00024170.00086502.36e-050.00183870.01121230.00057560.00000402.06e-050.00000820.00000610.00005620.00059610.01898130.00006570.00366010.00002065.07e-050.00006510.00001140.00644570.00649890.02998520.11037920.02655440.00007260.00497210.00379270.00680280.00481980.00026550.00725810.00522580.14362480.00093940.00923320.00007594.70e-050.00065480.00155110.00303620.01086530.00029620.02309630.14084300.00723030.00005030.00025860.00010320.00007680.00070660.00748770.23843400.00082470.04597610.00025880.00063690.00081780.00014310.08096790.08163620.0796084
0.05470010.18175550.07153310.00095100.00159600.00701670.00563790.00532220.00130400.00950830.02245400.14866810.03715630.00942650.00155740.00125420.00083430.00430980.00070350.01303050.00144590.01746400.06995670.00424520.00162570.00075820.00608700.00045000.00367420.11262390.08676040.00793800.00226200.00396820.00033950.00106560.00039990.01123300.08898330.00477550.01746950.00366036.00e-060.00015900.00012890.00073560.00041640.00002810.00124250.00039700.02010240.00028630.00001333.82e-056.6e-060.00019210.00005080.00000300.00100645.00e-070.00326540.01560700.00054520.00000892.14e-050.00017900.00004510.00001470.00000770.02911260.00003200.00459750.00017984.68e-050.00015650.00011030.00936660.01643090.03660900.13392160.02805980.00004560.00121910.00098780.00563930.00319240.00021510.00952520.00304350.15410550.00219480.00010170.00029285.09e-050.00147300.00038980.00002280.00771500.00000350.02503250.11964380.00417970.00006830.00016440.00137200.00034570.00011250.00005880.22317760.00024550.03524420.00137860.00035870.00120000.00084540.07180420.12595980.1304458
0.05638240.19680770.06717190.00093910.00263760.00613700.00479620.00489370.00152360.00906230.02645450.13436050.03434800.01059950.00183570.00135590.00080150.00637430.00117860.01891720.00154800.01207230.05479570.00427690.00213560.00070970.00625150.00063370.00464360.12629070.06383490.00666880.00226290.00422350.00044130.00125290.00049360.01136550.10952150.00366470.00991240.00147623.04e-050.00032300.00007800.00006630.00011420.00000720.00009340.00000100.01329540.00010110.00049963.46e-055.0e-070.00016430.00100050.00004800.00029081.76e-050.00153430.01502370.00022990.00000852.14e-050.00006470.00003280.00034020.00004570.00943490.00059350.00382850.00020984.90e-060.00004900.00018880.00515520.00662880.04911500.13284950.01978490.00040700.00432940.00104510.00088820.00153090.00009710.00125140.00001340.17818880.00135540.00669590.00046387.10e-060.00220240.01340900.00064300.00389740.00023600.02056380.20135180.00308160.00011400.00028740.00086670.00044020.00455930.00061200.12644990.00795450.05131050.00281170.00006600.00065690.00253020.06909160.08884140.0746140
0.05600890.19939660.06217630.00090450.00365970.00549410.00434800.00449630.00175550.00840720.03114060.12241580.03346520.01080720.00203140.00154950.00078440.00733890.00163740.02071080.00151470.00855090.04181520.00568030.00249590.00071860.00862720.00077660.00503960.13752960.04548240.00661720.00247610.00435250.00067070.00213010.00052430.01220090.13426870.00193810.00350510.00277731.35e-050.00042090.00001440.00086350.00001940.00016710.00002880.00032190.00824160.00107110.00154013.05e-051.5e-060.00000590.00152700.00012050.00128474.43e-050.00104780.01055490.00047790.00002061.00e-070.00015620.00000120.00050870.00021610.00468740.00023210.00354180.00009069.70e-060.00014400.00012020.00261360.00196080.03851540.06965460.05519100.00026890.00836360.00028520.01715970.00038530.00332030.00057180.00639780.16378000.02128590.03060610.00060692.94e-050.00011740.03034530.00239540.02553100.00088090.02082330.20975090.00949740.00041010.00000250.00310350.00002400.01010870.00429480.09314940.00461220.07038410.00180120.00019240.00286190.00238790.05193790.03896590.0503210
0.05360440.19163650.07110100.00102400.00152100.00750650.00598290.00585470.00126650.01050920.02396680.16171850.03834450.00898010.00168510.00132150.00089150.00452760.00073130.01407010.00147830.01338080.06118320.00362680.00160140.00078790.00637290.00045380.00371500.11577220.07530600.00626370.00214950.00413540.00036770.00110930.00041400.01106480.08457370.01123920.01039270.00619867.60e-050.00021060.00000470.00075630.00002270.00009180.00010020.00010740.01776740.00011460.00001454.05e-051.6e-060.00015520.00017150.00022820.00023354.50e-060.00141460.01243590.00019250.00146533.50e-060.00010690.00002190.00004350.00227070.00758540.00000000.00304670.00017231.50e-060.00004050.00008000.00598790.00927410.12206600.11287210.06732110.00082590.00228760.00005080.00821390.00024630.00099750.00108800.00116660.19296650.00124490.00015790.00043971.74e-050.00168570.00186300.00247890.00253550.00004940.01536360.13506250.00209040.01591420.00003800.00116070.00023800.00047250.02466200.08238330.00000000.03308880.00187160.00001590.00043960.00086860.06503270.10072300.0920750

News

News

  • Fix bug whereby using data frames masks dimension incompatibilities of inputs.
  • Fix documentation based on feddback from Connie Stewart.
  • Added separate tests for each distance measure.
  • Fixed author list
  • Added bibliographic references
  • Add Shiny sample application

Initial release of code created in support of article

Iverson, S. J., Field, C., Don Bowen, W. and Blanchard, W. (2004) QUANTITATIVE FATTY ACID SIGNATURE ANALYSIS: A NEW METHOD OF ESTIMATING PREDATOR DIETS Ecological Monographs 74: 211–235. doi:10.1890/02-4105

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("QFASA")

1.0.2 by Justin Kamerman, 4 months ago


Browse source code at https://github.com/cran/QFASA


Authors: Sara Iverson [aut], Chris Field [aut], Don Bowen [aut], Wade Blanchard [aut], Connie Stewart [aut, cph], Shelley Lang [aut], Justin Kamerman [cre, cph]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports Rsolnp, grid

Suggests knitr, rmarkdown, testthat, plyr, gtools


See at CRAN