Difference between revisions of "EU-kalat"

From Testiwiki
Jump to: navigation, search
(Bayes model for dioxin concentrations)
(Bayes model for dioxin concentrations)
Line 164: Line 164:
 
::{{comment|# |Maybe we should just estimate TEQs until the problem is fixed.|--[[User:Jouni|Jouni]] ([[User talk:Jouni|talk]]) 19:37, 19 May 2017 (UTC)}}
 
::{{comment|# |Maybe we should just estimate TEQs until the problem is fixed.|--[[User:Jouni|Jouni]] ([[User talk:Jouni|talk]]) 19:37, 19 May 2017 (UTC)}}
 
* Model run 22.5.2017 with TEQdx and TEQpcb as the only Compounds [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=2vTgALXXTzLgd4l1]
 
* Model run 22.5.2017 with TEQdx and TEQpcb as the only Compounds [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=2vTgALXXTzLgd4l1]
* Model run 23.5.2017 debugged [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=rMSAZy6PSKzKhHwp]
+
* Model run 23.5.2017 debugged [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=rMSAZy6PSKzKhHwp] [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=1P7ZPBbghEfisEcH]
  
 
<rcode name="bayes" label="Sample Bayes model (for developers only)" graphics=1>
 
<rcode name="bayes" label="Sample Bayes model (for developers only)" graphics=1>
Line 176: Line 176:
 
library(car) # scatterplotMatrix
 
library(car) # scatterplotMatrix
  
objects.latest("Op_en3104", code_name = "preprocess") # [[EU-kalat]]
+
objects.latest("Op_en3104", code_name = "preprocess") # [[EU-kalat]] eu, euRatio, indices
 +
 
 +
eu2 <- eu <- EvalOutput(eu)
  
 
conl <- indices$Compound.TEQ2
 
conl <- indices$Compound.TEQ2
Line 186: Line 188:
 
fisl
 
fisl
  
eu2 <- EvalOutput(eu)
 
eu <- eu2
 
 
replaces <- list(
 
replaces <- list(
 
   c("Chlorinated dibenzo-p-dioxins", "TEQdx"),
 
   c("Chlorinated dibenzo-p-dioxins", "TEQdx"),
Line 196: Line 196:
  
 
for(i in 1:length(replaces)) {
 
for(i in 1:length(replaces)) {
#  print(replaces[[i]][1])
+
   levels(eu2$Compound)[levels(eu2$Compound)==replaces[[i]][1]] <- replaces[[i]][2]
#  print(levels(eu$Compound)[levels(eu$Compound)==replaces[[i]][1]])
 
   levels(eu$Compound)[levels(eu$Compound)==replaces[[i]][1]] <- replaces[[i]][2]
 
 
}
 
}
  
eu <- oapply(eu, cols = "TEFversion", FUN = "sum") # This goes wrong if > 1 TEFversion
+
eu2 <- unkeep(eu2, prevresults = TRUE, sources = TRUE)
 +
eu2 <- oapply(eu2, cols = "TEFversion", FUN = "sum") # This goes wrong if > 1 TEFversion
  
 
# Hierarchical Bayes model.
 
# Hierarchical Bayes model.
  
 
# PCDD/F concentrations in fish.
 
# PCDD/F concentrations in fish.
# It uses the sum of PCDD/F (Pcdsum) as the total concentration of dioxin in fish.
+
# It uses the TEQ sum of PCDD/F (TEQdx) as the total concentration
# Cong_j is the fraction of a congener from pcdsum.
+
# of dioxin and TEQpcb respectively for PCB in fish.
# pcdsum is log-normally distributed. cong_j follows Dirichlet distribution.
+
# TEQdx depends on age of fish, fish species and catchment area,
# pcdsum depends on age of fish, fish species and catchment area, but we only have species now so other variables are omitted.
+
# but we only have species now so other variables are omitted.
# cong_j depends on fish species.
+
# cong depends on fish species.
  
if(FALSE) { # Multicongener model NOT updated to reflect new names: eu -> euMain
+
eu3 <- eu2[eu2$Compound %in% conl & eu2$Fish %in% fisl & eu2$Matrix == "Muscle" , ]
  conl <- as.character(unique(eu@output$Congener))
 
  fisl <- sort(as.character(unique(eu@output$Fish)))
 
  C <- length(conl)
 
  Fi <- length(fisl)
 
  N <- 1000
 
  conl
 
  fisl
 
  eu3 <- reshape(
 
    eu@output,
 
    v.names = "euResult",
 
    idvar = "THLcode",
 
    timevar = "Congener",
 
    drop = c("Matrix", "euSource"),
 
    direction = "wide"
 
  )
 
 
 
  # Find the level of quantification for dinterval function
 
  LOQ <- unlist(lapply(eu3[3:ncol(eu3)], FUN = function(x) min(x[x!=0])))
 
  names(LOQ) <- conl
 
  cong <- data.matrix(eu3[3:ncol(eu3)])
 
  cong <- sapply(1:length(LOQ), FUN = function(x) ifelse(cong[,x]==0, 0.5*LOQ[x], cong[,x]))
 
 
 
  mod <- textConnection("
 
    model{
 
      for(i in 1:S) { # s = fish sample
 
        #        below.LOQ[i,j] ~ dinterval(-cong[i,j], -LOQ[j])
 
        cong[i,1:C] ~ dmnorm(mu[fis[i],], Omega[fis[i],,])
 
      }
 
      for(i in 1:Fi) { # Fi = fish species
 
      for(j in 1:C) {
 
        mu[i,j] ~ dnorm(mu1[j], tau1[j])
 
      }
 
      Omega[i,1:C,1:C] ~ dwish(Omega0[1:C,1:C],S)
 
      pred[i,1:C] ~ dmnorm(mu[i,], Omega[i,,]) # Model prediction
 
    }
 
    for(i in 1:C) { # C = Compound
 
      mu1[i] ~ dnorm(0, 0.0001)
 
      tau1[i] ~ dunif(0,10000)
 
      pred1[i] ~ dnorm(mu1[i], tau1[i])
 
    }
 
    Omega1[1:C,1:C] ~ dwish(Omega0[1:C,1:C],S)
 
  }
 
")
 
 
 
  jags <- jags.model(
 
    mod,
 
    data = list(
 
      S = nrow(eu3),
 
      C = C,
 
      Fi = Fi,
 
      cong = log(cong),
 
      #    LOQ = LOQ,
 
      #    below.LOQ = is.na(cong)*1,
 
      fis = match(eu3$Fish, fisl),
 
      Omega0 = diag(C)/100000
 
    ),
 
    n.chains = 4,
 
    n.adapt = 100
 
  )
 
} # if(FALSE)
 
 
 
eu3 <- unkeep(eu, prevresults = TRUE, sources = TRUE)@output
 
eu3 <- eu3[eu3$Compound %in% conl & eu$Fish %in% fisl & eu3$Matrix == "Muscle" , ]
 
 
eu3 <- reshape(
 
eu3 <- reshape(
   eu3,  
+
   eu3@output,  
 
   v.names = "euResult",  
 
   v.names = "euResult",  
 
   idvar = "THLcode",  
 
   idvar = "THLcode",  
Line 301: Line 237:
 
mod <- textConnection("
 
mod <- textConnection("
 
   model{
 
   model{
    for(i in 1:S) { # s = fish sample
+
  for(i in 1:S) { # s = fish sample
      #        below.LOQ[i,j] ~ dinterval(-cong[i,j], -LOQ[j])
+
    #        below.LOQ[i,j] ~ dinterval(-cong[i,j], -LOQ[j])
      cong[i,1:C] ~ dmnorm(mu[fis[i],], Omega[fis[i],,])
+
    cong[i,1:C] ~ dmnorm(mu[fis[i],], Omega[fis[i],,])
    }
+
  }
    for(i in 1:Fi) { # Fi = fish species
+
  for(i in 1:Fi) { # Fi = fish species
      for(j in 1:C) {  
+
    for(j in 1:C) {  
        mu[i,j] ~ dnorm(mu1[j], tau1[j])
+
      mu[i,j] ~ dnorm(mu1[j], tau1[j])
      }
 
      Omega[i,1:C,1:C] ~ dwish(Omega0[1:C,1:C],S)
 
      pred[i,1:C] ~ dmnorm(mu[i,], Omega[i,,]) # Model prediction
 
 
     }
 
     }
 +
    Omega[i,1:C,1:C] ~ dwish(Omega0[1:C,1:C],S)
 +
    pred[i,1:C] ~ dmnorm(mu[i,], Omega[i,,]) # Model prediction
 +
  }
 
   for(i in 1:C) { # C = Compound
 
   for(i in 1:C) { # C = Compound
 
     mu1[i] ~ dnorm(0, 0.0001)
 
     mu1[i] ~ dnorm(0, 0.0001)
Line 317: Line 253:
 
     pred1[i] ~ dnorm(mu1[i], tau1[i])
 
     pred1[i] ~ dnorm(mu1[i], tau1[i])
 
   }
 
   }
    Omega1[1:C,1:C] ~ dwish(Omega0[1:C,1:C],S)
+
  Omega1[1:C,1:C] ~ dwish(Omega0[1:C,1:C],S)
 
   }
 
   }
 
")
 
")
Line 328: Line 264:
 
     Fi = Fi,
 
     Fi = Fi,
 
     cong = log(cong),
 
     cong = log(cong),
    #    LOQ = LOQ,
 
    #    below.LOQ = is.na(cong)*1,
 
 
     fis = match(eu3$Fish, fisl),
 
     fis = match(eu3$Fish, fisl),
 
     Omega0 = diag(C)/100000
 
     Omega0 = diag(C)/100000
Line 341: Line 275:
 
samps.j <- jags.samples(
 
samps.j <- jags.samples(
 
   jags,  
 
   jags,  
   c('mu', 'Omega', 'pred', 'mu1', 'Omega1', 'tau1', 'pred1'),  
+
   c(
 +
    'mu', # mean by fish and compound
 +
    'Omega', # precision matrix by fish and compound
 +
    'pred', # predicted concentration by fish and compound
 +
#    'mu1', # mean prior for mu by compound
 +
    'Omega1', # precision matrix by compound
 +
#    'tau1', # precision for prior of all mu
 +
    'pred1' # predicted concentration by compound
 +
  ),  
 
   N
 
   N
 
)
 
)
 
dimnames(samps.j$mu) <- list(Fish = fisl, Compound = conl, Iter = 1:N, Chain = 1:4)
 
dimnames(samps.j$mu) <- list(Fish = fisl, Compound = conl, Iter = 1:N, Chain = 1:4)
dimnames(samps.j$mu1) <- list(Compound = conl, Iter = 1:N, Chain = 1:4)
+
#dimnames(samps.j$mu1) <- list(Compound = conl, Iter = 1:N, Chain = 1:4)
 
dimnames(samps.j$pred) <- list(Fish = fisl, Compound = conl, Iter = 1:N, Chain = 1:4)
 
dimnames(samps.j$pred) <- list(Fish = fisl, Compound = conl, Iter = 1:N, Chain = 1:4)
dimnames(samps.j$mu1) <- list(Compound = conl, Iter = 1:N, Chain = 1:4)
+
#dimnames(samps.j$tau1) <- list(Compound = conl, Iter = 1:N, Chain = 1:4)
dimnames(samps.j$tau1) <- list(Compound = conl, Iter = 1:N, Chain = 1:4)
 
 
dimnames(samps.j$pred1) <- list(Compound = conl, Iter = 1:N, Chain = 1:4)
 
dimnames(samps.j$pred1) <- list(Compound = conl, Iter = 1:N, Chain = 1:4)
 
dimnames(samps.j$Omega) <- list(Fish = fisl, Compound = conl, Compound2 = conl, Iter=1:N, Chain=1:4)
 
dimnames(samps.j$Omega) <- list(Fish = fisl, Compound = conl, Compound2 = conl, Iter=1:N, Chain=1:4)
Line 359: Line 300:
 
   pred.mean = apply(samps.j$pred[,,,1], MARGIN = 1:2, FUN = mean),
 
   pred.mean = apply(samps.j$pred[,,,1], MARGIN = 1:2, FUN = mean),
 
   pred.sd = apply(samps.j$pred[,,,1], MARGIN = 1:2, FUN = sd),
 
   pred.sd = apply(samps.j$pred[,,,1], MARGIN = 1:2, FUN = sd),
  mu1 = apply(samps.j$mu1[,,1], MARGIN = 1, FUN = mean),
+
mu1 = apply(samps.j$mu1[,,1], MARGIN = 1, FUN = mean),
  tau1 = apply(samps.j$tau1[,,1], MARGIN = 1, FUN = mean),
+
tau1 = apply(samps.j$tau1[,,1], MARGIN = 1, FUN = mean),
 
   pred1.mean = apply(samps.j$pred1[,,1], MARGIN = 1, FUN = mean),
 
   pred1.mean = apply(samps.j$pred1[,,1], MARGIN = 1, FUN = mean),
 
   pred1.sd = apply(samps.j$pred1[,,1], MARGIN = 1, FUN = sd)
 
   pred1.sd = apply(samps.j$pred1[,,1], MARGIN = 1, FUN = sd)
 
)
 
)
 +
  
 
objects.store(conc.param, samps.j)
 
objects.store(conc.param, samps.j)
Line 372: Line 314:
 
cat("Descriptive statistics:\n")
 
cat("Descriptive statistics:\n")
  
eu <- eu2
+
# Leave only the main fish species and congeners and remove others
euRatio <- EvalOutput(euRatio)
 
 
 
 
conl <- indices$Compound.PCDDF14
 
conl <- indices$Compound.PCDDF14
 
# Leave only the main fish species and congeners and remove others
 
 
eu <- eu[eu$Compound %in% conl & eu$Fish %in% fisl , ]  
 
eu <- eu[eu$Compound %in% conl & eu$Fish %in% fisl , ]  
  
ggplot(eu@output, aes(x = euResult, colour = Fish))+geom_density()+
+
euRatio <- EvalOutput(euRatio)
  facet_wrap(~ Compound) + scale_x_log10()
 
  
euRatio <- euRatio[euRatio$Compound %in% conl & euRatio$Fish %in% fisl , ]
+
ggplot(eu@output, aes(x = euResult, colour=Compound))+geom_density()+
 +
  facet_wrap( ~ Fish, scales = "free_y")+scale_x_log10()
 +
#stat_ellipse()
  
 
ggplot(euRatio@output, aes(x = euRatioResult, colour = Fish))+geom_density()+
 
ggplot(euRatio@output, aes(x = euRatioResult, colour = Fish))+geom_density()+
 
   facet_wrap(~ Compound, scales = "free_y")
 
   facet_wrap(~ Compound, scales = "free_y")
 
# Predictions for all congeners of fish1 (Baltic herring)
 
scatterplotMatrix(t(samps.j$pred[1,,,1]))
 
# Means for all congeners of the generic fish
 
scatterplotMatrix(t(samps.j$mu1[,,1]))
 
# Prediction for all congeners of the generic fish
 
scatterplotMatrix(t(samps.j$pred1[,,1]))
 
# Predictions for all fish species for TCDD
 
scatterplotMatrix(t(samps.j$pred[,1,,1]))
 
# Predictions for pike for omegas and PeCDD
 
scatterplotMatrix(t(samps.j$Omega[6,2,,,1]))
 
  
 
ggplot(melt(exp(samps.j$pred[,,,1])), aes(x=value, colour=Compound))+geom_density()+
 
ggplot(melt(exp(samps.j$pred[,,,1])), aes(x=value, colour=Compound))+geom_density()+
 
   facet_wrap( ~ Fish,scales = "free_y")+scale_x_log10()
 
   facet_wrap( ~ Fish,scales = "free_y")+scale_x_log10()
ggplot(eu@output, aes(x = euResult, colour=Compound))+geom_density()+
+
 
   facet_wrap( ~ Fish, scales = "free_y")+scale_x_log10()
+
ggplot(melt(exp(samps.j$pred1[,,1])), aes(x=value, colour=Compound))+geom_density()+
#stat_ellipse()
+
   scale_x_log10()
 +
 
 +
 
 +
scatterplotMatrix(t(samps.j$pred[1,,,1]), main = "Predictions for all compounds for Baltic herring")
 +
## scatterplotMatrix(t(samps.j$mu1[,,1]), main = "Means for all compounds of the generic fish")
 +
scatterplotMatrix(t(samps.j$pred1[,,1]), main = "Prediction for all compounds of the generic fish")
 +
scatterplotMatrix(t(samps.j$pred[,1,,1]), main = "Predictions for all fish species for TEQdx")
 +
scatterplotMatrix(t(samps.j$Omega[6,2,,,1]), main = "Predictions of Omega for pike and TEQpcb")
  
 
coda.j <- coda.samples(
 
coda.j <- coda.samples(

Revision as of 16:02, 23 May 2017


EU-kalat is a study, where concentrations of PCDD/Fs, PCBs, PBDEs and heavy metals have been measured from fish

Question

The scope of EU-kalat study was to measure concentrations of persistent organic pollutants (POPs) including dioxin (PCDD/F), PCB and BDE in fish from Baltic sea and Finnish inland lakes and rivers. [1] [2] [3].

Answer

The original sample results can be acquired from Opasnet base. The study showed that levels of PCDD/Fs and PCBs depends especially on the fish species. Highest levels were on salmon and large sized herring. Levels of PCDD/Fs exceeded maximum level of 4 pg TEQ/g fw multiple times. Levels of PCDD/Fs were correlated positively with age of the fish.

Mean congener concentrations as WHO2005-TEQ in Baltic herring can be printed out with the Run code below.

+ Show code

Rationale

Data

Data was collected between 2009-2010. The study contains years, tissue type, fish species, and fat content for each concentration measurement. Number of observations is 285.

There is a new study EU-kalat 3, which will produce results in 2016.

Calculations

+ Show code

Bayes model for dioxin concentrations

  • Model run 28.2.2017 [8]
  • Model run 28.2.2017 with corrected survey model [9]
  • Model run 28.2.2017 with Mu estimates [10]
  • Model run 1.3.2017 [11]
  • Model run 23.4.2017 [12] produces list conc.param and ovariable concentration
  • Model run 24.4.2017 [13]
  • Model run 19.5.2017 without ovariable concentration [14] # : The model does not mix well, so the results should not be used for final results. --Jouni (talk) 19:37, 19 May 2017 (UTC)
--# : Maybe we should just estimate TEQs until the problem is fixed. --Jouni (talk) 19:37, 19 May 2017 (UTC)
  • Model run 22.5.2017 with TEQdx and TEQpcb as the only Compounds [15]
  • Model run 23.5.2017 debugged [16] [17]

+ Show code

Initiate concentration

  • Model run 19.5.2017 [18]

+ Show code

See also

References

  1. A. Hallikainen, H. Kiviranta, P. Isosaari, T. Vartiainen, R. Parmanne, P.J. Vuorinen: Kotimaisen järvi- ja merikalan dioksiinien, furaanien, dioksiinien kaltaisten PCB-yhdisteiden ja polybromattujen difenyylieettereiden pitoisuudet. Elintarvikeviraston julkaisuja 1/2004. [1]
  2. E-R.Venäläinen, A. Hallikainen, R. Parmanne, P.J. Vuorinen: Kotimaisen järvi- ja merikalan raskasmetallipitoisuudet. Elintarvikeviraston julkaisuja 3/2004. [2]
  3. Anja Hallikainen, Riikka Airaksinen, Panu Rantakokko, Jani Koponen, Jaakko Mannio, Pekka J. Vuorinen, Timo Jääskeläinen, Hannu Kiviranta. Itämeren kalan ja muun kotimaisen kalan ympäristömyrkyt: PCDD/F-, PCB-, PBDE-, PFC- ja OT-yhdisteet. Eviran tutkimuksia 2/2011. ISSN 1797-2981 ISBN 978-952-225-083-4 [3]