-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatrix_summaries.R
263 lines (185 loc) · 6.43 KB
/
matrix_summaries.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
library(dplyr)
library(tidyr)
parametra_long<-read.csv("data/parametra_long.csv")
#### Parameter availability matrix ####
parameters<-parametra%>%
filter(!grepl(";", Pathogen))%>% #Filter for only individual pathogens
group_by(Pathogen, Parameter)%>%
summarise(n = n())%>%
arrange(desc(n))
matrix<-tidyr::pivot_wider(data=parameters[!is.na(parameters$n),],
id_cols=Pathogen,
names_from=Parameter,
values_from=n)
matrix_df<-as.data.frame(matrix)
write.csv(matrix_df, file = "outputs/parameters_matrix.csv", row.names = FALSE)
#matrix row names
rnames<-matrix$Pathogen
matrix$Pathogen<-NULL
matrix<-as.matrix(matrix)
row.names(matrix)<-rnames
matrix[is.na(matrix)]<-0
heatmap(matrix, Colv = NA, Rowv = NA)
#### Parameters by study ####
parameter_study_type<-parametra%>%
filter(!grepl(";", Parameter))%>% #Filter for only individual Parameters
group_by(Parameter, Study)%>%
summarise(n = n())%>%
arrange(desc(n))
matrix<-tidyr::pivot_wider(data=parameter_study_type[!is.na(parameter_study_type$n),],
id_cols=Parameter,
names_from=Study,
values_from=n)
matrix_df<-as.data.frame(matrix)
write.csv(matrix_df, file = "outputs/parameter_study_type_matrix.csv", row.names = FALSE)
#matrix row names
rnames<-matrix$Parameter
matrix$Parameter<-NULL
matrix<-as.matrix(matrix)
row.names(matrix)<-rnames
matrix[is.na(matrix)]<-0
heatmap(matrix, Colv = NA, Rowv = NA)
#### Study type matrix ####
pathogen_study_type<-parametra%>%
filter(!grepl(";", Pathogen))%>% #Filter for only individual pathogens
group_by(Pathogen, Study)%>%
summarise(n = n())%>%
arrange(desc(n))
matrix<-tidyr::pivot_wider(data=pathogen_study_type[!is.na(pathogen_study_type$n),],
id_cols=Pathogen,
names_from=Study,
values_from=n)
matrix_df<-as.data.frame(matrix)
write.csv(matrix_df, file = "outputs/pathogen_study_type_matrix.csv", row.names = FALSE)
#matrix row names
rnames<-matrix$Pathogen
matrix$Pathogen<-NULL
matrix<-as.matrix(matrix)
row.names(matrix)<-rnames
matrix[is.na(matrix)]<-0
heatmap(matrix, Colv = NA, Rowv = NA)
#### Year of publishing ####
study_year<-parametra%>%
mutate(Year = as.numeric(stringr::str_extract_all(Reference, "\\b\\d{4}\\b")))%>%
filter(!grepl(";", Pathogen))%>% #Filter for only individual pathogens
group_by(Pathogen, Year)%>%
summarise(n = n())%>%
arrange(Year, desc(n))
matrix<-tidyr::pivot_wider(data=study_year[!is.na(study_year$n),],
id_cols=Pathogen,
names_from=Year,
values_from=n)
matrix_df<-as.data.frame(matrix)
write.csv(matrix_df, file = "outputs/study_year_matrix.csv", row.names = FALSE)
#matrix row names
rnames<-matrix$Pathogen
matrix$Pathogen<-NULL
matrix<-as.matrix(matrix)
row.names(matrix)<-rnames
matrix[is.na(matrix)]<-0
heatmap(matrix, Colv = NA, Rowv = NA)
#### Model type ####
model_type<-parametra%>%
mutate(Model=`Type of infectious disease model`)%>%
filter(!grepl(";", Pathogen), #Filter for only individual pathogens
!is.na(Model))%>%
group_by(Pathogen, Model)%>%
summarise(n = n())%>%
arrange(desc(n))
# Map model names
model_mapping <- c(
# Simple Dynamics
"SIR model" = "SIR",
"SIR" = "SIR",
"SIR/SEIR model" = "SIR/SEIR",
"1R-SIR" = "SIR",
"2R-SIR" = "SIR",
"SLIR" = "SLIR",
"SLRI" = "SLIR",
"SLI" = "SLIR",
"SLI-SC" = "SLIR",
"SIS" = "SIS",
"SI/SIS" = "SIS",
"SIRS" = "SIRS",
"SI" = "SI",
"SI model" = "SI",
"Si" = "SI",
# Complex Dynamics
"SEIR model" = "SEIR",
"SEIR" = "SEIR",
"SOEI" = "SOEI",
"SLI/SLIE/SLICE" = "SLICE",
"SLICE" = "SLICE",
"SUD" = "SUD",
# Statistical Methods
"GLM" = "GLM",
"Time series data and generation time" = "Time Series",
"Bayesian analysis" = "Bayesian",
"Bayesian hierarchical model" = "Bayesian",
"Stochastic herd level simulation" = "Stochastic",
"Stochastic mathematical model" = "Stochastic",
# Growth and Transmission Patterns
"Exponential growth rate" = "Exponential Growth",
"Doubling time" = "Doubling Time",
"Epidemic doubling time" = "Doubling Time",
"Transmission network analysis" = "Network Analysis",
"Nearest infectious neighbour" = "Nearest Neighbor",
"Nearest infectious neighbour (Euclidean distance)" = "Nearest Neighbor",
"Nearest infectious neighbour (road distance)" = "Nearest Neighbor",
# Advanced Models
"Time-rooted phylodynamic evolutionary model" = "Phylodynamic",
"Continuous Markov Chain Model" = "Markov Chain",
"Multiscale model" = "Multiscale",
"Seasonal matrix population model" = "Seasonal Matrix",
# Other
"Final size" = "Final Size",
"FS" = "Final Size",
"None (descriptive)" = "Descriptive",
"/year" = "Annual Rate"
)
# Clean the data
model_type <- model_type %>%
mutate(
# Replace model names using the mapping
Model = case_when(
Model %in% names(model_mapping) ~ model_mapping[Model],
TRUE ~ Model
)
) %>%
# Group by pathogen and new model name, sum the counts
group_by(Pathogen, Model) %>%
summarise(
n = sum(n),
.groups = 'drop'
) %>%
# Sort by count in descending order
arrange(desc(n))
matrix<-tidyr::pivot_wider(data=model_type[!is.na(model_type$n),],
id_cols=Pathogen,
names_from=Model,
values_from=n)
matrix_df<-as.data.frame(matrix)
write.csv(matrix_df, file = "outputs/model_type_matrix.csv", row.names = FALSE)
#matrix row names
rnames<-matrix$Pathogen
matrix$Pathogen<-NULL
matrix<-as.matrix(matrix)
row.names(matrix)<-rnames
matrix[is.na(matrix)]<-0
heatmap(matrix, Colv = NA, Rowv = NA)
#### Parameters by reference ####
parameter_ref<-parametra%>%
filter(!grepl(";", Parameter))%>% #Filter for only individual Parameters
group_by(Parameter)%>%
summarise(n_param=n(),
n_ref = n_distinct(Reference))%>%
arrange(desc(n_param))
write.csv(parameter_ref, file = "outputs/parameter_n_ref.csv", row.names = FALSE)
#### Pathogens by reference ####
pathogen_ref<-parametra%>%
filter(!grepl(";", Parameter))%>% #Filter for only individual Parameters
group_by(Pathogen)%>%
summarise(n_param=n(),
n_ref = n_distinct(Reference))%>%
arrange(desc(n_param))
write.csv(pathogen_ref, file = "outputs/pathogen_n_ref.csv", row.names = FALSE)