-
Notifications
You must be signed in to change notification settings - Fork 0
/
CombinedAnalysisTreatedFoI_MHI_95pc_20-50_treat1x.R
179 lines (122 loc) · 8.29 KB
/
CombinedAnalysisTreatedFoI_MHI_95pc_20-50_treat1x.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
library(ggplot2)
library(matrixStats)
library(cowplot)
# thresholds for medium-to-heavy infection
mediumHeavyInfectionThreshold_epg <- 2000 # WHO value for hookworm
diagnosticDivisor <- 24 # 24 for Kato-Katz.
mediumHeavyInfectionThreshold_counts <- mediumHeavyInfectionThreshold_epg / diagnosticDivisor
# thresholds for heavy infection
heavyInfectionThreshold_epg <- 4000 # WHO value for hookworm
diagnosticDivisor <- 24 # 24 for Kato-Katz.
heavyInfectionThreshold_counts <- heavyInfectionThreshold_epg / diagnosticDivisor
outpath <- "D:\\STH\\ModellingConsortium\\WRAquestion\\ForPublication\\Tables_OneList\\"
# for column names and iterations
path <- "D:\\STH\\ModellingConsortium\\WRAquestion\\ForPublication\\ICLsimoutput\\"
file <- "fertilisedFemaleWorms_old_20-50_treat1x.RData"
results <- get(load(paste0(path, file)))
################################################################################################################################
## DETERMINE PERCENTAGE OF WOMEN WITH MEDIUM-HIGH INTENSITY INFECTION FROM ICL EGG OUTPUT
################################################################################################################################
#################################################################################################################################
# read in data
#################################################################################################################################
path <- "D:\\STH\\ModellingConsortium\\WRAquestion\\ForPublication\\ICLsimoutput\\"
file1 <- "redoneEggCountsOneList_old_20-50_treat1x.RData"
file2 <- "redoneEggCountsOneList_new_20-50_treat1x.RData"
stub1 <- substring(file1, first=23, last=40)
stub2 <- substring(file2, first=23, last=40)
eggCounts_old <- get(load(paste0(path, file1)))
eggCounts_new <- get(load(paste0(path, file2)))
#####################################################################################
# determine number of women in cohort with medium-to-heavy infection over time
#####################################################################################
MHI <- eggCounts_old > mediumHeavyInfectionThreshold_counts
MHI <- as.data.frame(cbind(results[, 1], MHI))
names(MHI) <- colnames(results)
MHIList <- split(MHI, MHI$rep)
MHIList <- lapply(MHIList, function(x){ x[, 1] <- NULL; x})
MHICountsList <- lapply(MHIList, rowSums)
MHICounts <- do.call(cbind, MHICountsList)
MHIFrac <- MHICounts / 500
pp15_50 <- mean(colSums(MHIFrac[180:600, ]) / nrow(MHIFrac[180:600, ]))
pp15_19 <- mean(colSums(MHIFrac[180:239, ]) / nrow(MHIFrac[180:239, ]))
pp20_50 <- mean(colSums(MHIFrac[240:600, ]) / nrow(MHIFrac[240:600, ]))
pc_95_15_50 <- quantile(colSums(MHIFrac[180:600, ]) / nrow(MHIFrac[180:600, ]), probs=c(0.05, 0.95))
pc_95_15_19 <- quantile(colSums(MHIFrac[180:239, ]) / nrow(MHIFrac[180:239, ]), probs=c(0.05, 0.95))
pc_95_20_50 <- quantile(colSums(MHIFrac[240:600, ]) / nrow(MHIFrac[240:600, ]), probs=c(0.05, 0.95))
df <- data.frame(Mean=c(pp15_50, pp15_19, pp20_50), pc5=c(pc_95_15_50[1], pc_95_15_19[1], pc_95_20_50[1]), pc95=c(pc_95_15_50[2], pc_95_15_19[2], pc_95_20_50[2]))
df <- df*100
df <- signif(df, digits=5)
write.table(df, file=paste0(outpath, "pc95MHI", stub1, "_ICL.txt"), sep="\t", col.names=TRUE, row.names=FALSE)
#####################################################################################
MHI <- eggCounts_new > mediumHeavyInfectionThreshold_counts
MHI <- as.data.frame(cbind(results[, 1], MHI))
names(MHI) <- colnames(results)
MHIList <- split(MHI, MHI$rep)
MHIList <- lapply(MHIList, function(x){ x[, 1] <- NULL; x})
MHICountsList <- lapply(MHIList, rowSums)
MHICounts <- do.call(cbind, MHICountsList)
MHIFrac <- MHICounts / 500
pp15_50 <- mean(colSums(MHIFrac[180:600, ]) / nrow(MHIFrac[180:600, ]))
pp15_19 <- mean(colSums(MHIFrac[180:239, ]) / nrow(MHIFrac[180:239, ]))
pp20_50 <- mean(colSums(MHIFrac[240:600, ]) / nrow(MHIFrac[240:600, ]))
pc_95_15_50 <- quantile(colSums(MHIFrac[180:600, ]) / nrow(MHIFrac[180:600, ]), probs=c(0.05, 0.95))
pc_95_15_19 <- quantile(colSums(MHIFrac[180:239, ]) / nrow(MHIFrac[180:239, ]), probs=c(0.05, 0.95))
pc_95_20_50 <- quantile(colSums(MHIFrac[240:600, ]) / nrow(MHIFrac[240:600, ]), probs=c(0.05, 0.95))
df <- data.frame(Mean=c(pp15_50, pp15_19, pp20_50), pc5=c(pc_95_15_50[1], pc_95_15_19[1], pc_95_20_50[1]), pc95=c(pc_95_15_50[2], pc_95_15_19[2], pc_95_20_50[2]))
df <- df*100
df <- signif(df, digits=5)
write.table(df, file=paste0(outpath, "pc95MHI", stub2, "_ICL.txt"), sep="\t", col.names=TRUE, row.names=FALSE)
################################################################################################################################
## DETERMINE PERCENTAGE OF WOMEN WITH MEDIUM-HIGH INTENSITY INFECTION FROM EMC EGG OUTPUT
################################################################################################################################
#################################################################################################################################
# read in data
#################################################################################################################################
path <- "D:\\STH\\ModellingConsortium\\WRAquestion\\ForPublication\\EMCsimoutput\\"
file1 <- "redoneEggCountsOneList_old_20-50_treat1x.RData"
file2 <- "redoneEggCountsOneList_new_20-50_treat1x.RData"
stub1 <- substring(file1, first=23, last=40)
stub2 <- substring(file2, first=23, last=40)
eggCounts_old <- get(load(paste0(path, file1)))
eggCounts_new <- get(load(paste0(path, file2)))
#####################################################################################
# determine number of women in cohort with medium-to-heavy infection over time
#####################################################################################
MHI <- eggCounts_old > mediumHeavyInfectionThreshold_counts
MHI <- as.data.frame(cbind(results[, 1], MHI))
names(MHI) <- colnames(results)
MHIList <- split(MHI, MHI$rep)
MHIList <- lapply(MHIList, function(x){ x[, 1] <- NULL; x})
MHICountsList <- lapply(MHIList, rowSums)
MHICounts <- do.call(cbind, MHICountsList)
MHIFrac <- MHICounts / 500
pp15_50 <- mean(colSums(MHIFrac[180:600, ]) / nrow(MHIFrac[180:600, ]))
pp15_19 <- mean(colSums(MHIFrac[180:239, ]) / nrow(MHIFrac[180:239, ]))
pp20_50 <- mean(colSums(MHIFrac[240:600, ]) / nrow(MHIFrac[240:600, ]))
pc_95_15_50 <- quantile(colSums(MHIFrac[180:600, ]) / nrow(MHIFrac[180:600, ]), probs=c(0.05, 0.95))
pc_95_15_19 <- quantile(colSums(MHIFrac[180:239, ]) / nrow(MHIFrac[180:239, ]), probs=c(0.05, 0.95))
pc_95_20_50 <- quantile(colSums(MHIFrac[240:600, ]) / nrow(MHIFrac[240:600, ]), probs=c(0.05, 0.95))
df <- data.frame(Mean=c(pp15_50, pp15_19, pp20_50), pc5=c(pc_95_15_50[1], pc_95_15_19[1], pc_95_20_50[1]), pc95=c(pc_95_15_50[2], pc_95_15_19[2], pc_95_20_50[2]))
df <- df*100
df <- signif(df, digits=5)
write.table(df, file=paste0(outpath, "pc95MHI", stub1, "_EMC.txt"), sep="\t", col.names=TRUE, row.names=FALSE)
#####################################################################################
MHI <- eggCounts_new > mediumHeavyInfectionThreshold_counts
MHI <- as.data.frame(cbind(results[, 1], MHI))
names(MHI) <- colnames(results)
MHIList <- split(MHI, MHI$rep)
MHIList <- lapply(MHIList, function(x){ x[, 1] <- NULL; x})
MHICountsList <- lapply(MHIList, rowSums)
MHICounts <- do.call(cbind, MHICountsList)
MHIFrac <- MHICounts / 500
pp15_50 <- mean(colSums(MHIFrac[180:600, ]) / nrow(MHIFrac[180:600, ]))
pp15_19 <- mean(colSums(MHIFrac[180:239, ]) / nrow(MHIFrac[180:239, ]))
pp20_50 <- mean(colSums(MHIFrac[240:600, ]) / nrow(MHIFrac[240:600, ]))
pc_95_15_50 <- quantile(colSums(MHIFrac[180:600, ]) / nrow(MHIFrac[180:600, ]), probs=c(0.05, 0.95))
pc_95_15_19 <- quantile(colSums(MHIFrac[180:239, ]) / nrow(MHIFrac[180:239, ]), probs=c(0.05, 0.95))
pc_95_20_50 <- quantile(colSums(MHIFrac[240:600, ]) / nrow(MHIFrac[240:600, ]), probs=c(0.05, 0.95))
df <- data.frame(Mean=c(pp15_50, pp15_19, pp20_50), pc5=c(pc_95_15_50[1], pc_95_15_19[1], pc_95_20_50[1]), pc95=c(pc_95_15_50[2], pc_95_15_19[2], pc_95_20_50[2]))
df <- df*100
df <- signif(df, digits=5)
write.table(df, file=paste0(outpath, "pc95MHI", stub2, "_EMC.txt"), sep="\t", col.names=TRUE, row.names=FALSE)