Wikisym 2012 Demo: Difference between revisions
Jump to navigation
Jump to search
Juha Villman (talk | contribs) |
mNo edit summary |
||
(19 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
[[Category:Code under inspection]] | |||
==Health effects of Drinking Water Model== | |||
This example is model which is built for calculating health effects of drinking water and how water treatment processess affect to the outcome. | |||
* [[Ground water pathogen concentrations]] | |||
<rcode | |||
name="answer" | |||
variables=" | |||
name:i.raw.class|description:Water resource|type:selection| | |||
options: | |||
'Ground water - Clean';Ground water - Clean; | |||
'Ground water - Surface water stress';Ground water - Surface water stress; | |||
'Surface water - Low stress';Surface water - Low stress; | |||
'Surface water - Medium stress';Surface water - Medium stress; | |||
'Surface water - High stress';Surface water - High stress| | |||
category:Ground water: Pathogenic concentrations| | |||
name:Kampylo|description:Cambylobacter-concentration estimation (microbe/l)|default:'Use water source specific classification'| | |||
name:Ecoli|description:E.coli O157:H7 -concentration estimation (microbe/l)|default:'Use water source specific classification'| | |||
name:Rota|description:Rotavirus-concentration estimation (microbe/l)|default:'Use water source specific classification'| | |||
name:Noro|description:Norovirus-concentration estimation (microbe/l)|default:'Use water source specific classification'| | |||
name:Crypto|description:Cryptosporidium-concentration estimation (microbe/l)|default:'Use water source specific classification'| | |||
name:Giardia|description:Giardia-concentration estimation (microbe/l)|default:'Use water source specific classification'| | |||
name:Kaupunni|description:City default values|default:'Custom'|type:selection| | |||
options: | |||
'Custom';Use values defined above; | |||
'Op_en5799';Gotham City; | |||
'Op_fi2603';Kuopio| | |||
name:Puhdistus|description:Available purification methods|type:checkbox| | |||
options: | |||
1;Traditional purification; | |||
2;Highly effective purification; | |||
3;Enhanced purification; | |||
4;Slow sand filtration; | |||
5;Limestone filtration; | |||
6;Activated carbon filtration; | |||
7;UV filtration; | |||
8;Ozonisation| | |||
default:1;4;5;6|category:Water purification: Purification processess and chlorinesation| | |||
name:KlooriAnnos|default:1.5|description:Chlorine dose (mg/l)| | |||
name:VedeKulu|default:1153|description:Water consumption (ml)|category:Water network and consumers| | |||
name:Vaestonkoko|default:100000|description:Population | |||
" | |||
> | |||
library(OpasnetUtils) | |||
library(xtable) | |||
library(reshape2) | |||
i.raw.pat.conc.val <- list(Kampylo, Ecoli, Rota, Noro, Crypto, Giardia) | |||
#vedenkulutus | |||
VedeKulu = data.frame(VedkulResult = VedeKulu) | |||
InpVedkul = new("ovariable",name = "InpVedkul" , output = VedeKulu) | |||
#Patogeenien pitoisuudet | |||
#Fetch2(data.frame(Name = "RaaPatPitLuo", Key = "AEmnj6ZNfhIHAt2X"), evaluate = TRUE) | |||
# fetching data from english Opasnet | |||
#Fetch2(data.frame(Name = "RaaPatPitLuo", Key = "kjRoRPqqAzhaG8qR"), evaluate = TRUE) | |||
temp <- tidy(op_baseGetData("opasnet_base", "Op_en5800"), objname = "RaaPatPitLuo") | |||
print(xtable(temp), type = "html") | |||
RaaPatPitLuo <- new("ovariable", | |||
name = "RaaPatPitLuo", | |||
data = temp | |||
) | |||
# RaaPatPitLuo@output <- RaaPatPitLuo@output[RaaPatPitLuo@output$Raakavesilähde == i.raw.class, ] | |||
RaaPatPitLuo@output <- RaaPatPitLuo@output[RaaPatPitLuo@output$Water_source == i.raw.class, ] | |||
RaaPatPitLuo@output <- merge( | |||
RaaPatPitLuo@output, | |||
data.frame( | |||
Patogeeni = c("Kampylobakteeri","E.coli O157:H7","Rotavirus","Norovirus","Cryptosporidium","Giardia"), | |||
TempResult = suppressWarnings(as.numeric(i.raw.pat.conc.val)) | |||
) | |||
) | |||
RaaPatPitLuo@output$RaaPatPitLuoResult <- ifelse( | |||
is.na(RaaPatPitLuo@output$TempResult), | |||
RaaPatPitLuo@output$RaaPatPitLuoResult, | |||
RaaPatPitLuo@output$TempResult | |||
) | |||
RaaPatPitLuo@output <- RaaPatPitLuo@output[,!colnames(RaaPatPitLuo@output)%in%"TempResult"] | |||
Temp = rep(FALSE,8) | |||
Temp[Puhdistus] = TRUE | |||
Puhdistus = Temp | |||
InpKloori = new("ovariable", output = data.frame(KlooriResult = KlooriAnnos)) | |||
#tehdaan InpVedKasTeh ovariable paalla olevista puhdistuksista | |||
Fetch2(data.frame(Name = c("VedKasTeh","VedDesTeh"), Key = c("J8AofoHKjKEOuPWK","iFnLQFpUAH3QfwGz"))) | |||
VedKasTeh <- EvalOutput(VedKasTeh) | |||
VedDesTeh <- EvalOutput(VedDesTeh, substitute = TRUE) | |||
Puhdistus = c(Puhdistus,TRUE) | |||
Puhdistus = data.frame(tottavaitarua = Puhdistus, Vedenpuhdistusmenetelmä = c("Perinteinen puhdistus" | |||
,"Hyvin toimva puhdistus" , "Tehostettu puhdistus" ,"Hidas hiekkasuodatus" | |||
,"Kalkkikivisuodatus","Aktiivihiilisuodatus" ,"UV" ,"Otsonointi","Klooraus")) | |||
PuhdistusKasTeh = Puhdistus[1:6,] | |||
PuhdistusDesTeh = Puhdistus[7:9,] | |||
VedKasTeh@output = merge(VedKasTeh@output, PuhdistusKasTeh) | |||
colnames(PuhdistusDesTeh)[colnames(PuhdistusDesTeh) == "Vedenpuhdistusmenetelmä"] = "Menetelmä" | |||
VedDesTeh@output = merge(VedDesTeh@output, PuhdistusDesTeh) | |||
VedKasTeh@output[,"VedKasTehResult"] = ifelse( | |||
VedKasTeh@output[,"tottavaitarua"] == FALSE, | |||
0, | |||
VedKasTeh@output[,"VedKasTehResult"] | |||
) | |||
VedDesTeh@output[,"VedDesTehResult"] = ifelse( | |||
VedDesTeh@output[,"tottavaitarua"] == FALSE, | |||
0, | |||
VedDesTeh@output[,"VedDesTehResult"] | |||
) | |||
VedKasTeh@output <- VedKasTeh@output[,!colnames(VedKasTeh@output) %in%c("tottavaitarua")] | |||
VedDesTeh@output <- VedDesTeh@output[,!colnames(VedDesTeh@output) %in%c("tottavaitarua")] | |||
Fetch2(data.frame(Name = "ExpoPatAnn", Key = "PPdMOCJzOZikWlKW")) | |||
#Fetch2(data.frame(Name = "Exposure", Key = "YpqDCiPvtTUDUGMO")) | |||
Fetch2(data.frame(Name = "PatPitPuhVed", Key = "hjUP8y5Rc2laF45F")) | |||
PatPitPuhVed <- EvalOutput(PatPitPuhVed) | |||
#print(xtable(VedKasTeh@output), type = "html") | |||
#print(xtable(VedDesTeh@output), type = "html") | |||
#print(xtable(PatPitPuhVed@output), type = "html") | |||
#Exposure <- EvalOutput(Exposure, substitute = TRUE) | |||
#Exposure | |||
#print(xtable(Exposure@output), type = "html") | |||
ExpoPatAnn <- EvalOutput(ExpoPatAnn, substitute = TRUE) | |||
#print(xtable(ExpoPatAnn@output), type = "html") | |||
################################################################################# | |||
dose.response = ExpoPatAnn@output | |||
Pathogen <- c("Kampylobakteeri","E.coli O157:H7","Rotavirus","Norovirus","Cryptosporidium","Giardia") | |||
vaesto <- op_baseGetData("opasnet_base", "Op_fi2652")[,c("Ikä","Result")] | |||
colnames(vaesto) <- c("Age", "Osuus") | |||
vaesto$Populaatio <- vaesto$Osuus * Vaestonkoko | |||
odotettu.elinika <- 81 | |||
colnames(dose.response)[colnames(dose.response) == "Patogeeni"] <- "Pathogen" | |||
colnames(dose.response)[colnames(dose.response) == "ExpoPatAnnResult"] <- "P.inf" | |||
colnames(dose.response)[colnames(dose.response) == "ExposureResult"] <- "Exp.pat" | |||
#dose.response = data.frame(Pathogen = ExpoPatAnn@output[,"Patogeeni"],P.inf = ExpoPatAnn@output[,"ExpoPatAnnResult"]) | |||
P.ill.g.inf <- data.frame(Pathogen, P.ill.g.inf = c(0.33, 1 - (270 / 1540), 0.9, 0.7, 0.71, 1)) # todennäköisyys sairastua kun saa infektion | |||
# Kampylobakteeri, DALYt per infektio | |||
P.treat.g.ill.Kamp.Gastr <- data.frame(Pathogen = Pathogen[c(1,1,1)], Outcome = "Gastroenteritis", ill.treat = c("Untreated", | |||
"General practitioner", "Hospitalised", "Unspecified")[c(1,2,3)], P.treat.g.ill = c(0.7627, 0.2373, 0.0097)) | |||
P.treat.ill.g.inf.Kamp.Gastr <- merge(P.treat.g.ill.Kamp.Gastr, P.ill.g.inf) | |||
P.treat.ill.g.inf.Kamp.Gastr$P.treat.ill.g.inf <- P.treat.ill.g.inf.Kamp.Gastr$P.ill.g.inf * | |||
P.treat.ill.g.inf.Kamp.Gastr$P.treat.g.ill | |||
duration.ill.treat.Kamp.Gastr <- data.frame(Outcome = c("Gastroenteritis"), ill.treat = c("Untreated", "General practitioner", | |||
"Hospitalised", "Unspecified")[c(1,2,3)], dur.ill = c(5.1 / 365, 8.4 / 365, 14.39 / 365)) | |||
severity.ill.treat.Kamp.Gastr <- data.frame(Outcome = c("Gastroenteritis"), ill.treat = c("Untreated", "General practitioner", | |||
"Hospitalised", "Unspecified")[c(1,2,3)], sev.ill = c(0.067, 0.393, 0.393)) | |||
daly.ill.treat.Kamp.Gastr <- merge(P.treat.ill.g.inf.Kamp.Gastr, duration.ill.treat.Kamp.Gastr) | |||
daly.ill.treat.Kamp.Gastr <- merge(daly.ill.treat.Kamp.Gastr, severity.ill.treat.Kamp.Gastr) | |||
daly.ill.treat.Kamp.Gastr$dalys <- daly.ill.treat.Kamp.Gastr$P.treat.ill.g.inf * daly.ill.treat.Kamp.Gastr$dur.ill * | |||
daly.ill.treat.Kamp.Gastr$sev.ill | |||
P.death.g.ill.Gastr <- 0.0004 | |||
P.death.g.inf.Gastr <- P.death.g.ill.Gastr * P.ill.g.inf$P.ill.g.inf[P.ill.g.inf$Pathogen == "Kampylobakteeri"] | |||
death.Gastr.life.lost <- 13.2 | |||
daly.death.Kamp.Gastr <- P.death.g.inf.Gastr * death.Gastr.life.lost | |||
## GBS Kamp. | |||
P.gbs.g.ill <- 2e-004 | |||
P.gbs.g.inf <- P.gbs.g.ill * P.ill.g.inf$P.ill.g.inf[P.ill.g.inf$Pathogen == "Kampylobakteeri"] | |||
dur.sev.factor.gbs <- data.frame(Outcome = c("Clinical GBS", "Residual GBS"), dur.sev.factor = c(0.29, 5.8)) # duration * severity * fraction? | |||
daly.Kamp.gbs <- data.frame(dur.sev.factor.gbs$Outcome, dalys = dur.sev.factor.gbs$dur.sev.factor * P.gbs.g.inf) | |||
P.death.g.gbs <- 0.08 / 3 # triangular 0.01, 0.02, 0.05 | |||
P.death.g.inf.gbs <- P.death.g.gbs * P.gbs.g.inf | |||
death.gbs.life.lost <- 18.7 | |||
daly.death.Kamp.gbs <- P.death.g.inf.gbs * death.gbs.life.lost | |||
## reactive arthritis Kamp. | |||
P.arth.g.ill <- 0.02 # triangluar 0.01, 0.02, 0.03 | |||
P.arth.g.inf <- P.arth.g.ill * P.ill.g.inf$P.ill.g.inf[P.ill.g.inf$Pathogen == "Kampylobakteeri"] | |||
duration.arth <- 6 / 52 | |||
severity.arth <- 0.21 | |||
daly.Kamp.arth <- P.arth.g.inf * duration.arth * severity.arth | |||
# E.coli | |||
P.wd.g.ill <- 0.53 # watery diarrhea | |||
P.wd.g.inf <- P.wd.g.ill * P.ill.g.inf$P.ill.g.inf[P.ill.g.inf$Pathogen == "E.coli O157:H7"] | |||
severity.wd <- 0.067 | |||
duration.wd <- 3.4 / 365 | |||
daly.wd.Ecoli <- P.wd.g.inf * severity.wd * duration.wd | |||
P.hc.g.ill <- 0.47 | |||
P.hc.g.inf <- P.hc.g.ill * P.ill.g.inf$P.ill.g.inf[P.ill.g.inf$Pathogen == "E.coli O157:H7"] | |||
severity.hc <- 0.39 | |||
duration.hc <- 5.6 / 365 | |||
daly.hc.Ecoli <- P.hc.g.inf * severity.hc * duration.hc | |||
P.death.g.ill.Ecoli <- 0.00027 | |||
P.death.g.inf.Ecoli <- P.death.g.ill.Ecoli * P.ill.g.inf$P.ill.g.inf[P.ill.g.inf$Pathogen == "E.coli O157:H7"] | |||
age.death.Ecoli <- 81 - 13.2 | |||
daly.death.Ecoli <- P.death.g.inf.Ecoli * (odotettu.elinika - age.death.Ecoli) | |||
## Haemolytic uraemic syndrome (HUS) | |||
P.hus.g.ill <- 0.01 | |||
P.hus.g.inf <- P.hus.g.ill * P.ill.g.inf$P.ill.g.inf[P.ill.g.inf$Pathogen == "E.coli O157:H7"] | |||
severity.hus <- 0.93 | |||
duration.hus <- 21 / 365 | |||
daly.hus.Ecoli <- P.hus.g.inf * severity.hus * duration.hus | |||
P.death.g.hus <- 0.04 | |||
P.death.hus.g.inf <- P.death.g.hus * P.hus.g.inf | |||
age.death.hus.Ecoli <- 81 - 26.2 | |||
daly.death.hus.Ecoli <- P.death.hus.g.inf * (odotettu.elinika - age.death.hus.Ecoli) | |||
## End Stage Renal Disease (ESRD) | |||
P.esrd.g.hus <- 0.118 | |||
P.esrd.g.inf <- P.hus.g.inf * P.esrd.g.hus | |||
severity.duration.hus <- 8.7 # severity * duration | |||
daly.esrd.Ecoli <- P.esrd.g.inf * severity.duration.hus | |||
P.death.g.esrd <- 0.0252 | |||
P.death.esrd.g.inf <- P.esrd.g.inf * P.death.g.esrd | |||
age.death.esrd.Ecoli <- 81 - 34 | |||
daly.death.esrd.Ecoli <- P.death.esrd.g.inf * (odotettu.elinika - age.death.esrd.Ecoli) | |||
# Rotavirus | |||
P.treat.g.ill.Rotavirus <- data.frame(Pathogen = "Rotavirus", ill.treat = c("Untreated", | |||
"General practitioner", "Hospitalised")[rep(1:3, each = 82)], Age = rep(0:81, 3), P.treat.g.ill = c(rep(0.82,5), | |||
rep(0.95, 10), rep(0.99, 50), rep(0.97, 17), rep(0.137, 5), rep(0.0244, 5), rep(0.0511, 5), rep(0.0127, 50), | |||
rep(0.0299, 17), rep(0.0416, 5), rep(0.0213, 5), rep(0, 72))) | |||
P.treat.ill.g.inf.Rotavirus <- merge(P.treat.g.ill.Rotavirus, P.ill.g.inf) | |||
P.treat.ill.g.inf.Rotavirus$P.treat.g.inf <- P.treat.ill.g.inf.Rotavirus$P.ill.g.inf * P.treat.ill.g.inf.Rotavirus$P.treat.g.ill | |||
duration.ill.treat.Rotavirus <- data.frame(ill.treat = c("Untreated", "General practitioner","Hospitalised"), dur.ill = c(4.9 / 365, | |||
7.1 / 365, 7.7 / 365)) | |||
severity.ill.treat.Rotavirus <- data.frame(ill.treat = c("Untreated", "General practitioner", "Hospitalised"), sev.ill = c(0.067, | |||
0.393, 0.393)) | |||
daly.ill.treat.Rotavirus <- merge(P.treat.ill.g.inf.Rotavirus, duration.ill.treat.Rotavirus) | |||
daly.ill.treat.Rotavirus <- merge(daly.ill.treat.Rotavirus, severity.ill.treat.Rotavirus) | |||
daly.ill.treat.Rotavirus$dalys <- daly.ill.treat.Rotavirus$P.treat.g.inf * daly.ill.treat.Rotavirus$dur.ill * | |||
daly.ill.treat.Rotavirus$sev.ill | |||
P.death.Rotavirus <- data.frame(Age = 0:81, P.death.g.ill = c(rep(2.13e-005, 5), rep(0, 77))) | |||
P.death.Rotavirus$P.death.g.inf <- P.death.Rotavirus$P.death.g.ill * P.ill.g.inf$P.ill.g.inf[P.ill.g.inf$Pathogen == "Rotavirus"] | |||
P.death.Rotavirus$Life.lost <- odotettu.elinika - P.death.Rotavirus$Age | |||
daly.death.Rotavirus <- data.frame(Age = P.death.Rotavirus$Age, dalys = P.death.Rotavirus$P.death.g.inf * P.death.Rotavirus$Life.lost) | |||
# Norovirus | |||
P.treat.g.ill.Norovirus <- data.frame(Pathogen = "Norovirus", ill.treat = c("Untreated", | |||
"General practitioner", "Hospitalised")[rep(1:3, each = 82)], Age = rep(0:81, 3), P.treat.g.ill = c(rep(0.94876706,5), | |||
rep(0.9902, 5), rep(0.98239, 5), rep(0.98434, 51), rep(0.992741, 16), rep(0.0448,5), rep(8.6e-003, 5), rep(0.0154, 5), | |||
rep(0.0137, 51), rep(6.17e-003, 16), rep(6.43e-003,5), rep(1.2e-003, 5), rep(2.21e-003, 5), rep(1.96e-003, 51), | |||
rep(8.85e-004, 16))) | |||
P.treat.ill.g.inf.Norovirus <- merge(P.treat.g.ill.Norovirus, P.ill.g.inf) | |||
P.treat.ill.g.inf.Norovirus$P.treat.g.inf <- P.treat.ill.g.inf.Norovirus$P.ill.g.inf * P.treat.ill.g.inf.Norovirus$P.treat.g.ill | |||
duration.ill.treat.Norovirus <- data.frame(ill.treat = c("Untreated", "General practitioner","Hospitalised"), dur.ill = c(3.8 / 365, | |||
5.73 / 365, 7.23 / 365)) | |||
severity.ill.treat.Norovirus <- data.frame(ill.treat = c("Untreated", "General practitioner", "Hospitalised"), sev.ill = c(0.067, | |||
0.393, 0.393)) | |||
daly.ill.treat.Norovirus <- merge(P.treat.ill.g.inf.Norovirus, duration.ill.treat.Norovirus) | |||
daly.ill.treat.Norovirus <- merge(daly.ill.treat.Norovirus, severity.ill.treat.Norovirus) | |||
daly.ill.treat.Norovirus$dalys <- daly.ill.treat.Norovirus$P.treat.g.inf * daly.ill.treat.Norovirus$dur.ill * | |||
daly.ill.treat.Norovirus$sev.ill | |||
P.death.Norovirus <- data.frame(Age = 0:81, P.death.g.ill = c(rep(2.94e-006, 5), rep(0, 61), rep(2.04e-004, 16))) | |||
P.death.Norovirus$P.death.g.inf <- P.death.Norovirus$P.death.g.ill * P.ill.g.inf$P.ill.g.inf[P.ill.g.inf$Pathogen == "Norovirus"] | |||
P.death.Norovirus$Life.lost <- odotettu.elinika - P.death.Norovirus$Age | |||
daly.death.Norovirus <- data.frame(Age = P.death.Norovirus$Age, dalys = P.death.Norovirus$P.death.g.inf * P.death.Norovirus$Life.lost) | |||
# Cryptosporidium | |||
P.treat.g.ill.Crypt <- data.frame(Pathogen = "Cryptosporidium", ill.treat = c("Untreated", | |||
"General practitioner", "Hospitalised")[rep(1:3, each = 82)], Age = rep(0:81, 3), P.treat.g.ill = c(rep(0.9175730049999999,5), | |||
rep(0.80937, 5), rep(0.6810499999999999, 5), rep(0.9774191, 50), rep(0.94706, 17), rep(0.082,5), rep(0.188, 5), rep(0.316, 5), | |||
rep(0.0209, 50), rep(0.0367, 17), rep(4.26e-004,5), rep(2.63e-003, 5), rep(2.95e-003, 5), rep(1.66e-003, 50), rep(0.0146, 17))) | |||
P.treat.ill.g.inf.Crypt <- merge(P.treat.g.ill.Crypt, P.ill.g.inf) | |||
P.treat.ill.g.inf.Crypt$P.treat.g.inf <- P.treat.ill.g.inf.Crypt$P.ill.g.inf * P.treat.ill.g.inf.Crypt$P.treat.g.ill | |||
duration.ill.treat.Crypt <- data.frame(ill.treat = c("Untreated", "General practitioner","Hospitalised"), dur.ill = c(3.5 / 365, | |||
7 /365, 18.4 / 365)) | |||
severity.ill.treat.Crypt <- data.frame(ill.treat = c("Untreated", "General practitioner", "Hospitalised"), sev.ill = c(0.067, | |||
0.393, 0.393)) | |||
daly.ill.treat.Crypt <- merge(P.treat.ill.g.inf.Crypt, duration.ill.treat.Crypt) | |||
daly.ill.treat.Crypt <- merge(daly.ill.treat.Crypt, severity.ill.treat.Crypt) | |||
daly.ill.treat.Crypt$dalys <- daly.ill.treat.Crypt$P.treat.g.inf * daly.ill.treat.Crypt$dur.ill * | |||
daly.ill.treat.Crypt$sev.ill | |||
P.death.Crypt <- data.frame(Age = 0:81, P.death.g.ill = c(rep(9.95e-007, 5), rep(0, 10), rep(2.09e-005, 50), rep(1.64e-003, 17))) | |||
P.death.Crypt$P.death.g.inf <- P.death.Crypt$P.death.g.ill * P.ill.g.inf$P.ill.g.inf[P.ill.g.inf$Pathogen == "Cryptosporidium"] | |||
P.death.Crypt$Life.lost <- odotettu.elinika - P.death.Crypt$Age | |||
daly.death.Crypt <- data.frame(Age = P.death.Crypt$Age, dalys = P.death.Crypt$P.death.g.inf * P.death.Crypt$Life.lost) | |||
# Giardia | |||
P.treat.g.ill.Giardia <- data.frame(Pathogen = "Giardia", ill.treat = c("Untreated", | |||
"General practitioner", "Hospitalised")[rep(1:3, each = 82)], Age = rep(0:81, 3), P.treat.g.ill = c(rep(0.9376,5), | |||
rep(0.91034, 5), rep(0.72642, 5), rep(0.92486, 50), 0.54596, rep(0.5365, 16), rep(0.0609,5), rep(0.0852, 5), rep(0.272, 5), | |||
rep(0.0721, 50), rep(0.451, 17), rep(1.5e-003,5), rep(4.46e-003, 5), rep(1.58e-003, 5), rep(3.04e-003, 51), rep(0.0125, 16))) | |||
P.treat.ill.g.inf.Giardia <- merge(P.treat.g.ill.Giardia, P.ill.g.inf) | |||
P.treat.ill.g.inf.Giardia$P.treat.g.inf <- P.treat.ill.g.inf.Giardia$P.ill.g.inf * P.treat.ill.g.inf.Giardia$P.treat.g.ill | |||
duration.ill.treat.Giardia <- data.frame(ill.treat = c("Untreated", "General practitioner","Hospitalised"), dur.ill = c(10 / 365, | |||
10 /365, 30 / 365)) | |||
severity.ill.treat.Giardia <- data.frame(ill.treat = c("Untreated", "General practitioner", "Hospitalised"), sev.ill = c(0.067, | |||
0.393, 0.393)) | |||
daly.ill.treat.Giardia <- merge(P.treat.ill.g.inf.Giardia, duration.ill.treat.Giardia) | |||
daly.ill.treat.Giardia <- merge(daly.ill.treat.Giardia, severity.ill.treat.Giardia) | |||
daly.ill.treat.Giardia$dalys <- daly.ill.treat.Giardia$P.treat.g.inf * daly.ill.treat.Giardia$dur.ill * | |||
daly.ill.treat.Giardia$sev.ill | |||
# yhteenveto DALYistä | |||
Health.effects <- vaesto[,c("Age","Populaatio")] | |||
Health.effects$Untreated.Gastr.Kamp <- daly.ill.treat.Kamp.Gastr[daly.ill.treat.Kamp.Gastr$ill.treat == "Untreated", c("dalys")] | |||
Health.effects$GP.Gastr.Kamp <- daly.ill.treat.Kamp.Gastr[daly.ill.treat.Kamp.Gastr$ill.treat == "General practitioner", c("dalys")] | |||
Health.effects$Hospitalised.Gastr.Kamp <- daly.ill.treat.Kamp.Gastr[daly.ill.treat.Kamp.Gastr$ill.treat == "Hospitalised", c("dalys")] | |||
Health.effects$Death.Gastr.Kamp <- daly.death.Kamp.Gastr | |||
Health.effects$Clinical.GBS.Kamp <- daly.Kamp.gbs$dalys[1] | |||
Health.effects$Residual.GBS.Kamp <- daly.Kamp.gbs$dalys[2] | |||
Health.effects$Death.GBS.Kamp <- daly.death.Kamp.gbs | |||
Health.effects$Arth.Kamp <- daly.Kamp.arth | |||
Health.effects$WD.Ecoli <- daly.wd.Ecoli | |||
Health.effects$HC.Ecoli <- daly.hc.Ecoli | |||
Health.effects$Death.Ecoli <- daly.death.Ecoli | |||
Health.effects$HUS.Ecoli <- daly.hus.Ecoli | |||
Health.effects$Death.HUS.Ecoli <- daly.death.hus.Ecoli | |||
Health.effects$ESRD.Ecoli <- daly.esrd.Ecoli | |||
Health.effects$Death.ESRD.Ecoli <- daly.death.esrd.Ecoli | |||
Health.effects <- merge(Health.effects, daly.ill.treat.Rotavirus[daly.ill.treat.Rotavirus$ill.treat == "Untreated", c("Age", "dalys")]) | |||
colnames(Health.effects)[ncol(Health.effects)] <- "Untreated.Rotavirus" | |||
Health.effects <- merge(Health.effects, daly.ill.treat.Rotavirus[daly.ill.treat.Rotavirus$ill.treat == "General practitioner", c("Age", "dalys")]) | |||
colnames(Health.effects)[ncol(Health.effects)] <- "GP.Rotavirus" | |||
Health.effects <- merge(Health.effects, daly.ill.treat.Rotavirus[daly.ill.treat.Rotavirus$ill.treat == "Hospitalised", c("Age", "dalys")]) | |||
colnames(Health.effects)[ncol(Health.effects)] <- "Hospitalised.Rotavirus" | |||
Health.effects <- merge(Health.effects, daly.death.Rotavirus) | |||
colnames(Health.effects)[ncol(Health.effects)] <- "Death.Rotavirus" | |||
Health.effects <- merge(Health.effects, daly.ill.treat.Norovirus[daly.ill.treat.Norovirus$ill.treat == "Untreated", c("Age", "dalys")]) | |||
colnames(Health.effects)[ncol(Health.effects)] <- "Untreated.Norovirus" | |||
Health.effects <- merge(Health.effects, daly.ill.treat.Norovirus[daly.ill.treat.Norovirus$ill.treat == "General practitioner", c("Age", "dalys")]) | |||
colnames(Health.effects)[ncol(Health.effects)] <- "GP.Norovirus" | |||
Health.effects <- merge(Health.effects, daly.ill.treat.Norovirus[daly.ill.treat.Norovirus$ill.treat == "Hospitalised", c("Age", "dalys")]) | |||
colnames(Health.effects)[ncol(Health.effects)] <- "Hospitalised.Norovirus" | |||
Health.effects <- merge(Health.effects, daly.death.Norovirus) | |||
colnames(Health.effects)[ncol(Health.effects)] <- "Death.Norovirus" | |||
Health.effects <- merge(Health.effects, daly.ill.treat.Crypt[daly.ill.treat.Crypt$ill.treat == "Untreated", c("Age", "dalys")]) | |||
colnames(Health.effects)[ncol(Health.effects)] <- "Untreated.Crypt" | |||
Health.effects <- merge(Health.effects, daly.ill.treat.Crypt[daly.ill.treat.Crypt$ill.treat == "General practitioner", c("Age", "dalys")]) | |||
colnames(Health.effects)[ncol(Health.effects)] <- "GP.Crypt" | |||
Health.effects <- merge(Health.effects, daly.ill.treat.Crypt[daly.ill.treat.Crypt$ill.treat == "Hospitalised", c("Age", "dalys")]) | |||
colnames(Health.effects)[ncol(Health.effects)] <- "Hospitalised.Crypt" | |||
Health.effects <- merge(Health.effects, daly.death.Crypt) | |||
colnames(Health.effects)[ncol(Health.effects)] <- "Death.Crypt" | |||
Health.effects <- merge(Health.effects, daly.ill.treat.Giardia[daly.ill.treat.Giardia$ill.treat == "Untreated", c("Age", "dalys")]) | |||
colnames(Health.effects)[ncol(Health.effects)] <- "Untreated.Giardia" | |||
Health.effects <- merge(Health.effects, daly.ill.treat.Giardia[daly.ill.treat.Giardia$ill.treat == "General practitioner", c("Age", "dalys")]) | |||
colnames(Health.effects)[ncol(Health.effects)] <- "GP.Giardia" | |||
Health.effects <- merge(Health.effects, daly.ill.treat.Giardia[daly.ill.treat.Giardia$ill.treat == "Hospitalised", c("Age", "dalys")]) | |||
colnames(Health.effects)[ncol(Health.effects)] <- "Hospitalised.Giardia" | |||
Health.effects <- reshape(Health.effects, idvar = c("Age"), times = colnames(Health.effects)[-c(1,2)], timevar = "Outcome", | |||
varying = list(colnames(Health.effects)[-c(1,2)]), direction = "long") | |||
colnames(Health.effects)[4] <- "P.daly.g.inf" | |||
Health.effects$Pathogen <- NA | |||
Health.effects$Pathogen[grep(".Kamp", Health.effects$Outcome)] <- Pathogen[1] | |||
Health.effects$Pathogen[grep(".Ecoli", Health.effects$Outcome)] <- Pathogen[2] | |||
Health.effects$Pathogen[grep(".Rotavirus", Health.effects$Outcome)] <- Pathogen[3] | |||
Health.effects$Pathogen[grep(".Norovirus", Health.effects$Outcome)] <- Pathogen[4] | |||
Health.effects$Pathogen[grep(".Crypt", Health.effects$Outcome)] <- Pathogen[5] | |||
Health.effects$Pathogen[grep(".Giardia", Health.effects$Outcome)] <- Pathogen[6] | |||
Health.effects <- merge(Health.effects, dose.response[,c("Pathogen", "P.inf")]) | |||
Health.effects$DALYs <- (1 - (1 - Health.effects$P.inf * Health.effects$P.daly.g.inf)^365) * Health.effects$Populaatio | |||
temp <- merge(dose.response, P.ill.g.inf) | |||
############# TULOKSET ######################################################################################################### | |||
cat("<span style='font-size: 1.2em;font-weight:bold;'>Patogeenien konsentraatio raakavedessä</span>\n") | |||
print(xtable(RaaPatPitLuo@output), type='html') # Patogeenien konsentraatio raakavedessä | |||
cat("<span style='font-size: 1.2em;font-weight:bold;'>Patogeenien log vähenemä puhdistuksessa</span>\n") | |||
print(xtable(VedKasTeh@output), type='html') # Patogeenien log vähenemä puhdistuksessa | |||
print(xtable(VedDesTeh@output), type='html') # Patogeenien log vähenemä desinfioinnissa | |||
cat("<span style='font-size: 1.2em;font-weight:bold;'>Patogeeneille altistuminen ja infektion todennäköisyys</span>\n") | |||
cat(colnames(dose.response), "\n") | |||
#cat(colnames(ExpoPatAnn@output), "\n") | |||
print(xtable(dose.response[,c("Pathogen", "Exp.pat", "P.inf", "VedDesTehSource")]), type="html") # Patogeeneille altistuminen ja infektion todennäköisyys | |||
cat("<span style='font-size: 1.2em;font-weight:bold;'>Estimated health effects</span>\n") | |||
cat(sum((1 - (1 - temp$P.ill.g.inf * temp$P.inf)^365) * Vaestonkoko, na.rm = TRUE), " stomach flus per year \n") | |||
cat(sum(Health.effects$DALYs, na.rm = TRUE), " DALY's from stomach flus \n") | |||
</rcode> | |||
== Polygons on dynamic Google Maps == | == Polygons on dynamic Google Maps == | ||
This example plots municipalities of Finland on Google Maps using data from National Land Survey of Finland. | This example plots municipalities of Finland on Google Maps using data from National Land Survey of Finland. |
Latest revision as of 09:28, 27 August 2013
Health effects of Drinking Water Model
This example is model which is built for calculating health effects of drinking water and how water treatment processess affect to the outcome.
Polygons on dynamic Google Maps
This example plots municipalities of Finland on Google Maps using data from National Land Survey of Finland.
Points on dynamic Google Maps
This examples plots buildings of Kuopio on Google Maps. User can give the minimum age of buildings to plot as an input parameter.
Large quantity of points on a static Google Maps
This example plots large number of point data on static Google Maps. The map produced in this example shows the age (in years) distribution of buildings within Kuopio. User can select the number of age classes (4,6 or 8) and the type of classification.