Difference between revisions of "POPs in Baltic herring"

From Testiwiki
Jump to: navigation, search
m (Rationale: code updated)
m (Rationale: updated, plots TEQ figure)
Line 16: Line 16:
 
library(ggplot2)
 
library(ggplot2)
 
library(rjags)
 
library(rjags)
 +
library(reshape2)
  
 
dat <- opbase.data("Op_en3104", subset = "POPs")
 
dat <- opbase.data("Op_en3104", subset = "POPs")
Line 22: Line 23:
 
dat <- subset(dat,!(is.na(dat["Result"])))
 
dat <- subset(dat,!(is.na(dat["Result"])))
 
dat <- dropall(dat)
 
dat <- dropall(dat)
 +
levels(dat$POP) <- gsub("HCDD", "HxCDD", levels(dat$POP))
 +
levels(dat$POP) <- gsub("HCDF", "HxCDF", levels(dat$POP))
 +
levels(dat$POP) <- gsub("CoPCB", "PCB", levels(dat$POP))
  
 
congeners <- levels(dat$POP) #names of different congeners in data
 
congeners <- levels(dat$POP) #names of different congeners in data
Line 55: Line 59:
 
#update(jags, 1000)
 
#update(jags, 1000)
 
out <- coda.samples(jags, c('tau1', 'muOfCompound'), 500) # Stores a posterior sample
 
out <- coda.samples(jags, c('tau1', 'muOfCompound'), 500) # Stores a posterior sample
plot(out)
+
#plot(out)
  
 
Meanlogpost = c()
 
Meanlogpost = c()
Line 67: Line 71:
 
   logsd <- sqrt(1/(mean(out[[4]][,j+Y])))
 
   logsd <- sqrt(1/(mean(out[[4]][,j+Y])))
 
   Sdlogpost = c(Sdlogpost, logsd)
 
   Sdlogpost = c(Sdlogpost, logsd)
}
 
 
Meanpost = c()
 
for (j in 1 : Y) {
 
  mu  = out[[4]][,j]
 
  mean <- mean(10^mu)-1E-2 #calculate mean of mu for posterior (test 4)
 
  Meanpost = c(Meanpost, mean)
 
 
}
 
}
  
Line 87: Line 84:
 
   )
 
   )
  
oprint(resultsall)
+
#oprint(resultsall)
 +
 
 +
tef <- Ovariable("tef", ddata = "Op_en4017", subset = "TEF values")
 +
tef <- EvalOutput(tef)
 +
 
 +
colnames(resultsall)[1] <- "Congener"
 +
resultsall <- melt(resultsall)
 +
colnames(resultsall)[3] <- "Result"
 +
resultsall <-  Ovariable("resultsall", data = resultsall)
 +
resultsall <- EvalOutput(resultsall)
 +
teq = resultsall * tef
 +
teqpart <- teq@output
 +
teqpart <- teqpart[teqpart$variable == "Meanpost", ]
  
ggplot(dat, aes(x = Result, colour = Catch_location))+geom_density()+scale_x_log10()
+
ggplot(teqpart, aes(x = Congener, y = Result, fill = Congener)) + geom_bar(stat = "identity") +  
 +
  labs(x = "Congener", y = "TEQ (pg/g fat)") + coord_flip()
  
 
</rcode>
 
</rcode>

Revision as of 08:38, 16 June 2016



Question

What are the concentrations of persistent organic pollutants (POPs) in Baltic sea fish.

Answer

Rationale

POP concentrations in Baltic sea fish have been measured from samples collected in EU-kalat project.

+ Show code

See also

References