Chemtax {limSolve} | R Documentation |
Input files for assessing the algal composition of a field sample, based on the pigment composition of the algal groups (measured in the laboratory) and the pigment composition of the field sample.
In the example there are 8 types of algae:
and 12 pigments:
Perid
= Peridinin,
19But
= 19-butanoyloxyfucoxanthin,
Fucox
= fucoxanthin,
19Hex
= 19-hexanoyloxyfucoxanthin,
Neo
= neoxanthin,
Pras
= prasinoxanthin,
Viol
= violaxanthin,
Allox
= alloxanthin,
Lutein
= lutein,
Zeax
= zeaxanthin,
Chlb
= chlorophyll b,
Chla
= chlorophyll a
The input data consist of:
Based on these data, the algal composition of the field sample is estimated, under the assumption that the pigment composition of the field sample is a weighted avertage of the pigment composition of algae present in the sample, where weighting is proportional to their biomass.
As there are more measurements (12 pigments) than unknowns (8 algae), the resulting linear system is overdetermined.
It is thus solved in a least squares sense (using function lsei
):
min(||Ax-b||^2)
subject to
Ex=f
Gx>=h
If there are 2 algae A,B
, and 3 pigments 1,2,3
then the 3 approximate equalities (A*x=B)would be:
f[1,S] = p[A]*f[A,1]+p[B]*f[B,1]
f[2,S] = p[A]*f[A,2]+p[B]*f[B,3]
f[3,S] = p[A]*f[A,3]+p[B]*f[B,3]
where p[A] and p[b] are the (unknown) proportions of algae A and B in the field sample (S), and f[A,1] is the relative amount of pigment 1 in alga A, etc...
The equality ensures that the sum of fractions equals 1:
1 = p[A]+p[b]
and the inequalities ensure that fractions are positive numbers
p[A] > 0
p[B] > 0
Chemtax
A list with the input ratio matrix (Ratio
) and a vector with the field data (Field
)
Ratio
contains the pigment compositions (columns) for each algal group (rows);
the compositions are scaled relative to Chla
(last column).
Field
data contains the pigment composition of a sample in the field, also scaled relative to Chla
;
the pigments are similarly ordened as for the input ratio matrix.
The rownames of matrix Ratio
are the algal group names, columnames of Ratio
(=names of Field
) are the pigments
Karline Soetaert <k.soetaert@nioo.knaw.nl>
BCE
lsei
, the function to solve for the algal composition of the field sample
# 1. Graphical representation of the chemtax example input data palette(rainbow(12, s = 0.6, v = 0.75)) mp <- apply(Chemtax$Ratio,MARGIN=2,max) pstars <- rbind(t(t(Chemtax$Ratio)/mp) , sample=Chemtax$Field/max(Chemtax$Field)) stars(pstars, len = 0.9, key.loc = c(7.2, 1.7),scale=FALSE,ncol=4, main = "CHEMTAX pigment composition", draw.segments = TRUE, flip.labels=FALSE) # 2. Estimating the algal composition of the field sample Nx <-nrow(Chemtax$Ratio) # equations that have to be met exactly Ex=f: # sum of all fraction must be equal to 1. EE <- rep(1,Nx) FF <- 1 # inequalities, Gx>=h: # all fractions must be positive numbers GG <- diag(nrow=Nx) HH <- rep(0,Nx) # equations that must be reproduced as close as possible, Ax ~ b # = the field data; the input ratio matrix and field data are rescaled AA <- Chemtax$Ratio/rowSums(Chemtax$Ratio) BB <- Chemtax$Field/sum(Chemtax$Field) # 1. Solve with lsei method X <-lsei(t(AA),BB,EE,FF,GG,HH)$X (Sample<-data.frame(Algae=rownames(Chemtax$Ratio),fraction=X)) # plot results barplot(X,names=rownames(Chemtax$Ratio),col=heat.colors(8), cex.names=0.8,main="Chemtax example solved with lsei") # 2. Bayesian sampling; # The standard deviation on the field data is assumed to be 0.01 # jump length not too large or NO solutions aer found! xs <- xsample(t(AA),BB,EE,FF,GG,HH, sdB=0.01, jmp=0.025)$X pairs(xs, main= "Chemtax, Bayesian sample")