EU-kalat: Difference between revisions

From Opasnet
Jump to navigation Jump to search
(→‎Calculations: preprocess works)
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]


<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 185: Line 186:
fisl
fisl


eu <- EvalOutput(eu)
eu2 <- EvalOutput(eu)
 
eu <- eu2
replaces <- list(
replaces <- list(
   c("Chlorinated dibenzo-p-dioxins", "TEQdx"),
   c("Chlorinated dibenzo-p-dioxins", "TEQdx"),
   c("Chlorinated dibenzofurans", "TEQdx"),
   c("Chlorinated dibenzofurans", "TEQdx"),
   c("Mono-ortho–substituted PCBs", "TEQpcb"),
   c("Mono-ortho-substituted PCBs", "TEQpcb"),
   c("Non-ortho–substituted PCBs", "TEQpcb")
   c("Non-ortho-substituted PCBs", "TEQpcb")
)
)


for(i in 1:length(replaces)) {
for(i in 1:length(replaces)) {
   levels(eu$Compound)[replaces[[i]][1]] <- replaces[[i]][2]
#  print(replaces[[i]][1])
#  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, INDEX = "THLcode", FUN = "sum")
eu <- oapply(eu, cols = "TEFversion", FUN = "sum") # This goes wrong if > 1 TEFversion


# Hierarchical Bayes model.
# Hierarchical Bayes model.
Line 217: Line 220:
   conl
   conl
   fisl
   fisl
   fishsamples <- reshape(
   eu3 <- reshape(
     eu@output,  
     eu@output,  
     v.names = "euResult",  
     v.names = "euResult",  
Line 227: Line 230:
    
    
   # Find the level of quantification for dinterval function
   # Find the level of quantification for dinterval function
   LOQ <- unlist(lapply(fishsamples[3:ncol(fishsamples)], FUN = function(x) min(x[x!=0])))
   LOQ <- unlist(lapply(eu3[3:ncol(eu3)], FUN = function(x) min(x[x!=0])))
   names(LOQ) <- conl
   names(LOQ) <- conl
   cong <- data.matrix(fishsamples[3:ncol(fishsamples)])
   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]))
   cong <- sapply(1:length(LOQ), FUN = function(x) ifelse(cong[,x]==0, 0.5*LOQ[x], cong[,x]))
    
    
   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)
      Omega[i,1:C,1:C] ~ dwish(Omega0[1:C,1:C],S)
                        pred[i,1:C] ~ dmnorm(mu[i,], Omega[i,,]) # Model prediction
      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)
                        tau1[i] ~ dunif(0,10000)
      tau1[i] ~ dunif(0,10000)
                        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)
                        }
  }
                        ")
")
    
    
   jags <- jags.model(
   jags <- jags.model(
     mod,
     mod,
     data = list(
     data = list(
       S = nrow(fishsamples),
       S = nrow(eu3),
       C = C,
       C = C,
       Fi = Fi,
       Fi = Fi,
Line 263: Line 266:
       #    LOQ = LOQ,
       #    LOQ = LOQ,
       #    below.LOQ = is.na(cong)*1,
       #    below.LOQ = is.na(cong)*1,
       fis = match(fishsamples$Fish, fisl),
       fis = match(eu3$Fish, fisl),
       Omega0 = diag(C)/100000
       Omega0 = diag(C)/100000
     ),
     ),
Line 271: Line 274:
} # if(FALSE)
} # if(FALSE)


fishsamples <- unkeep(eu, prevresults = TRUE, sources = TRUE)@output
eu3 <- unkeep(eu, prevresults = TRUE, sources = TRUE)@output
fishsamples <- fishsamples[fishsamples$Compound %in% conl & fishsamples$Matrix == "Muscle" , ]
eu3 <- eu3[eu3$Compound %in% conl & eu$Fish %in% fisl & eu3$Matrix == "Muscle" , ]
fishsamples <- reshape(
eu3 <- reshape(
   fishsamples,  
   eu3,  
   v.names = "euResult",  
   v.names = "euResult",  
   idvar = "THLcode",  
   idvar = "THLcode",  
Line 282: Line 285:
)
)


# colnames(eu@output)
oprint(head(eu3))
# "THLcode"      "Matrix"      "Compound"    "Fish"        "euRawSource"
# [6] "TEFversion"  "TEFrawSource" "TEFSource"    "Source"      "euResult"
# [11] "euSource"


oprint(head(fishsamples))
#> colnames(eu3)
#[1] "THLcode"        "Fish"            "euResult.TEQdx"  "euResult.TEQpcb"


# Find the level of quantification for dinterval function
# Find the level of quantification for dinterval function
LOQ <- unlist(lapply(fishsamples[3:ncol(fishsamples)], FUN = function(x) min(x[x!=0])))
LOQ <- unlist(lapply(eu3[3:ncol(eu3)], FUN = function(x) min(x[x!=0])))
names(LOQ) <- conl
names(LOQ) <- conl
cong <- data.matrix(fishsamples[3:ncol(fishsamples)])
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]))
cong <- sapply(
  1:length(LOQ),
  FUN = function(x) ifelse(cong[,x]==0, 0.5*LOQ[x], cong[,x])
)


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)
      Omega[i,1:C,1:C] ~ dwish(Omega0[1:C,1:C],S)
                      pred[i,1:C] ~ dmnorm(mu[i,], Omega[i,,]) # Model prediction
      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)
                      tau1[i] ~ dunif(0,10000)
    tau1[i] ~ dunif(0,10000)
                      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)
                      }
  }
                      ")
")


jags <- jags.model(
jags <- jags.model(
   mod,
   mod,
   data = list(
   data = list(
     S = nrow(fishsamples),
     S = nrow(eu3),
     C = C,
     C = C,
     Fi = Fi,
     Fi = Fi,
Line 326: Line 330:
     #    LOQ = LOQ,
     #    LOQ = LOQ,
     #    below.LOQ = is.na(cong)*1,
     #    below.LOQ = is.na(cong)*1,
     fis = match(fishsamples$Fish, fisl),
     fis = match(eu3$Fish, fisl),
     Omega0 = diag(C)/100000
     Omega0 = diag(C)/100000
   ),
   ),
Line 368: Line 372:
cat("Descriptive statistics:\n")
cat("Descriptive statistics:\n")


eu <- eu2
euRatio <- EvalOutput(euRatio)
euRatio <- EvalOutput(euRatio)
conl <- indices$Compound.PCDDF14


# Leave only the main fish species and congeners and remove others
# Leave only the main fish species and congeners and remove others
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()+
ggplot(eu@output, aes(x = euResult, colour = Fish))+geom_density()+
   facet_wrap(~ Compound) + scale_x_log10()
   facet_wrap(~ Compound) + scale_x_log10()
euRatio <- euRatio[euRatio$Compound %in% conl & euRatio$Fish %in% fisl , ]


ggplot(euRatio@output, aes(x = euRatioResult, colour = Fish))+geom_density()+
ggplot(euRatio@output, aes(x = euRatioResult, colour = Fish))+geom_density()+
   facet_wrap(~ Compound)  
   facet_wrap(~ Compound, scales = "free_y")


# Predictions for all congeners of fish1 (Baltic herring)
# Predictions for all congeners of fish1 (Baltic herring)
Line 392: Line 401:
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=Congener))+geom_density()+
ggplot(eu@output, aes(x = euResult, colour=Compound))+geom_density()+
   facet_wrap( ~ Fish, scales = "free_y")+scale_x_log10()
   facet_wrap( ~ Fish, scales = "free_y")+scale_x_log10()
#stat_ellipse()
#stat_ellipse()
Line 398: Line 407:
coda.j <- coda.samples(
coda.j <- coda.samples(
   jags,  
   jags,  
   c('mu', 'pred', 'omega1', 'pred1'),  
   c('mu', 'pred', 'Omega', 'pred1'),  
   N
   N
)
)


plot(coda.j)
#plot(coda.j)
 
</rcode>
</rcode>



Revision as of 09:53, 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) (type: truth; paradigms: science: attack)
----#: . Maybe we should just estimate TEQs until the problem is fixed. --Jouni (talk) 19:37, 19 May 2017 (UTC) (type: truth; paradigms: science: comment)
  • Model run 22.5.2017 with TEQdx and TEQpcb as the only Compounds [15]
  • Model run 23.5.2017 debugged [16]

+ Show code

Initiate concentration

  • Model run 19.5.2017 [17]

+ 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]