QFASA Workflow Example"

Load Package


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

fa.set = as.vector(unlist(FAset))

Matrix of Predator FA signatures

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)

Matrix of Prey FA signatures

#full file

#extract prey FA only from data frame and subset them for the FA set designated above

#renormalize over 1

#extract the modelling group names from the full file

#add modelling group names to the subsetted and renormalized FAs

#create an average value for the FA signature for each designated modelling group

Prey Lipid Content

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

Calibration Coefficients

cal.vec = CC[,2]
cal.mat = replicate(npredators, cal.vec)


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:

DietEst = Q$'Diet Estimates'

#estimates changed from proportions to percentages
DietEst = round(DietEst*100,digits=2)
DietEst = cbind(tombstone.info,DietEst)

Additional Measures

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

Add.meas = ldply(Q$'Additional Measures', data.frame)

Note that the function "conf.meth" will return approximate simultaneous confidence intervals for diet.

Try the QFASA package in your browser

Any scripts or data that you put into this service are public.

QFASA documentation built on July 21, 2021, 1:06 a.m.