generated from UtrechtUniversity/simple-python-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
512 lines (512 loc) · 25.6 KB
/
.Rhistory
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
input.plot <- function(data,
color_scheme = c("#999999","#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7"),
period.labels = c("Negative", 'Neg->Pos', 'Positive', 'Pos-> Neg',"Negative again"),
sampling.times = NULL){
plot.data <- data[,c(1:4)];#only select indicators
#replace all negative numbers for lastObs
data$lastneg[data$lastneg<0 ]<- data$lastObs[data$lastneg<0 ]
data$firstpos[data$firstpos<0 ]<- data$lastObs[data$firstpos<0 ]
data$lastpos[data$lastpos<0 ]<- data$lastObs[data$lastpos<0 ]
data$firstrec[data$firstrec<0 ]<- data$lastObs[data$firstrec<0 ]
#replace infinity for appropriate values
data[is.infinite(data$lastneg),]$lastneg<-data[is.infinite(data$lastneg),]$firstpos
data[is.infinite(data$firstpos),]$firstpos<-data[is.infinite(data$firstpos),]$lastpos
data[is.infinite(data$lastpos),]$lastpos<-data[is.infinite(data$lastpos),]$lastObs
data[is.infinite(data$firstrec),]$firstrec<-data[is.infinite(data$firstrec),]$lastObs
#make sure that lastneg<=firspos<=lastpos<=firstrec
with(data,{
lastneg <- mapply(min,lastneg,firstpos);
firstpos <- mapply(min,firstpos, lastpos);
lastpos <-mapply(min,lastpos,firstneg);
firstrec <-mapply(min,firstneg,lastObs);
})
#replace real time with interval
if(!is.null(sampling.times)){
plot.data$start <-0;
plot.data$neg1 <- data$lastneg-plot.data$start;
plot.data$negpos <- data$firstpos - data$lastneg;
plot.data$pos <-data$lastpos - data$firstpos;
plot.data$posneg2 <- data$firstrec - data$lastpos;
plot.data$neg2 <- data$lastObs-data$firstrec;}else
{
#take into account the sampling times
plot.data$start <-min(sampling.times);
plot.data$neg1 <- data$lastneg-plot.data$start;
plot.data$negpos <- data$firstpos - data$lastneg;
plot.data$pos <-data$lastpos - data$firstpos;
plot.data$posneg2 <- data$firstrec - data$lastpos;
plot.data$neg2 <- data$lastObs-data$firstrec;
}
#melt down
plot.data <- melt(plot.data,id = c("host_id","inoculationStatus","group","treatment"))
#create plots per treatment
plots <- list();
for(i in unique(plot.data$treatment)){
y_breaks <- if(is.null(sampling.times)){c(0:max(plot.data$value[!is.infinite(plot.data$value)]))}else{sampling.times}
plots[[length(plots)+1]]<- ggplot(data = plot.data[plot.data$treatment == i,]%>%
arrange(group)%>%
arrange(desc(host_id)))+
geom_bar(aes(y = value, x = as.factor(host_id),
fill = factor(variable,levels = c("neg1","negpos","pos","posneg2","neg2")[c(5,4,3,2,1)])),stat= 'identity')+
coord_flip()+
scale_fill_manual('State',
values = color_scheme,
labels = period.labels[c(5,4,3,2,1)])+ylab("Days post challenge")+
xlab("host ID")+
ggtitle(i)+
scale_y_continuous(breaks = y_breaks )+
scale_x_discrete(limits = rev)+
if(length(unique(plot.data$group))>1){facet_grid(group + inoculationStatus ~. , scales = "free_y")}
}
return(list(plots = plots, data = plot.data))
}
test <- input.plot(transform.data.for.plot(localF$data),sampling.times = seq(0,3,.1))
data
source("C:/Users/fisch106/surfdrive - Fischer, E.A.J. (Egil)@surfdrive.surf.nl/Projecten/SUMMERFAIR/ProjectShareSUMMERFAIR/Syntax/autumn-fair/src/WorkingExample/ExperimentalPlots.R", echo=TRUE)
test <- input.plot(transform.data.for.plot(localF$data),sampling.times = seq(0,3,.1))
data
data$lastpos
debugSource("C:/Users/fisch106/surfdrive - Fischer, E.A.J. (Egil)@surfdrive.surf.nl/Projecten/SUMMERFAIR/ProjectShareSUMMERFAIR/Syntax/autumn-fair/src/WorkingExample/ExperimentalPlots.R", echo=TRUE)
test <- input.plot(transform.data.for.plot(localF$data),sampling.times = seq(0,3,.1))
debugSource("C:/Users/fisch106/surfdrive - Fischer, E.A.J. (Egil)@surfdrive.surf.nl/Projecten/SUMMERFAIR/ProjectShareSUMMERFAIR/Syntax/autumn-fair/src/WorkingExample/ExperimentalPlots.R", echo=TRUE)
test <- input.plot(transform.data.for.plot(localF$data),sampling.times = seq(0,3,.1))
in.data
plot.data
debugSource("C:/Users/fisch106/surfdrive - Fischer, E.A.J. (Egil)@surfdrive.surf.nl/Projecten/SUMMERFAIR/ProjectShareSUMMERFAIR/Syntax/autumn-fair/src/WorkingExample/ExperimentalPlots.R", echo=TRUE)
test <- input.plot(transform.data.for.plot(localF$data),sampling.times = seq(0,3,.1))
in.data
in.data$lastneg
mapply(min,in.data$lastneg,in.data$firstpos)
in.data$firstpos
in.data$lastpos
in.data$firstneg
in.data
#make sure that lastneg<=firspos<=lastpos<=firstrec
in.data$firstpos <- mapply(max,in.data$firstpos, in.data$lastneg);
in.data$lastpos <-mapply(max,in.data$lastpos,in.data$firstpos);
in.data$firstrec <-mapply(max,in.data$firstrec,in.data$lastpos);
in.data
debugSource("C:/Users/fisch106/surfdrive - Fischer, E.A.J. (Egil)@surfdrive.surf.nl/Projecten/SUMMERFAIR/ProjectShareSUMMERFAIR/Syntax/autumn-fair/src/WorkingExample/ExperimentalPlots.R", echo=TRUE)
source("C:/Users/fisch106/surfdrive - Fischer, E.A.J. (Egil)@surfdrive.surf.nl/Projecten/SUMMERFAIR/ProjectShareSUMMERFAIR/Syntax/autumn-fair/src/WorkingExample/ExperimentalPlots.R", echo=TRUE)
test <- input.plot(transform.data.for.plot(localF$data),sampling.times = seq(0,3,.1))
test
source("C:/Users/fisch106/surfdrive - Fischer, E.A.J. (Egil)@surfdrive.surf.nl/Projecten/SUMMERFAIR/ProjectShareSUMMERFAIR/Syntax/autumn-fair/src/WorkingExample/ExperimentalPlots.R", echo=TRUE)
test <- input.plot(transform.data.for.plot(localF$data),sampling.times = seq(0,3,.1))
test
#output estimation
localF
#output estimation
localF$estimation
install.packages("learnr")
#obtain the information from the configuration file
settings <- read_yaml("summerfair_config_example.yaml")
#load required packages
library("yaml")
#obtain the information from the configuration file
settings <- read_yaml("summerfair_config_example.yaml")
#obtain the information from the configuration file
settings <- read_yaml("summerfair_config_example.yaml")
#obtain the information from the configuration file
getwd()
settings <- read_yaml("summerfair_config_example.yaml")
settings <- read_yaml("summerfair_config_example.yaml")
#obtain the information from the configuration file
settings <- read_yaml("summerfair_config_example.yaml")
settings
path <- "./data/processed/example_project/"
#host.data <- read.csv(paste0(path, "host.csv")) #static host data
#host.event.data <- read.csv(paste0(path,"host_events.csv")) #events in the host
#environment.data <- read.csv(paste0(path,"environment.csv")) #static environment data
#environment.event.data <- read.csv(paste0(path,"environment_events.csv")) #events in environment
#obtain the information from the configuration file
settings <- read_yaml("summerfair_config_example.yaml")
data_path <- settings$data_path
host.data <- read.csv(paste0(data_path, "host.csv")) #static host data
#obtain the information from the configuration file
settings <- read_yaml("summerfair_config_example.yaml")
data_path <- settings$data_path
host.data <- read.csv(paste0(data_path, "host.csv")) #static host data
#obtain the information from the configuration file
settings <- read_yaml("summerfair_config_example.yaml")
data_path <- settings$data_path
host.data <- read.csv(paste0(settings$data_path, "/host.csv")) #static host data
#obtain the information from the configuration file
settings <- read_yaml("summerfair_config_example.yaml")
data_path <- settings$data_path
host.data <- read.csv(paste0(settings$data_path, "/host.csv")) #static host data
#obtain the information from the configuration file
settings <- read_yaml("summerfair_config_example.yaml")
data_path <- settings$data_path
host.data <- read.csv(paste0(settings$data_path, "/hosts.csv")) #static host data
#obtain the information from the configuration file
settings <- read_yaml("summerfair_config_example.yaml")
data_path <- settings$data_path
host.data <- read.csv(paste0(settings$data_path, "/hosts.csv")) #static host data
settings$data_path
settings <- read_yaml("summerfair_config_example.yaml")
data_path <- settings$data_path
data_path
rm(settings)
settings <- read_yaml("summerfair_config_example.yaml")
settings
#obtain the information from the configuration file
settings <- read_yaml("summerfair_config_example.yaml")
data_path <- settings$data_path
host.data <- read.csv(paste0(settings$data_path, "hosts.csv")) #static host data
settings$data_path
#obtain the information from the configuration file
settings <- read_yaml("summerfair_config_example.yaml")
#read in data
host.data <- read.csv(paste0(settings$data_path, "hosts.csv")) #static host data
#obtain the information from the configuration file
settings <- read_yaml("summerfair_config_example.yaml")
#read in data
host.data <- read.csv(paste0(settings$data_path, "hosts.csv")) #static host data
#read in data
getwd()
host.data <- read.csv(paste0(settings$data_path, "hosts.csv")) #static host data
#read in data
getwd()
host.data <- read.csv(paste0(settings$data_path, "hosts.csv")) #static host data
#obtain the information from the configuration file
settings <- read_yaml("summerfair_config_example.yaml")
#read in data
getwd()
host.data <- read.csv(paste0(settings$data_path, "hosts.csv")) #static host data
#obtain the information from the configuration file
settings <- read_yaml("summerfair_config_example.yaml")
#read in data
getwd()
host.data <- read.csv(paste0(settings$data_path, "hosts.csv")) #static host data
#read in data
settings$data_path
host.data <- read.csv(paste0(settings$data_path, "hosts.csv")) #static host data
#read in data
settings$data_path
host.data <- read.csv(paste0(settings$data_path, "hosts.csv")) #static host data
#obtain the information from the configuration file
settings <- read_yaml("summerfair_config_example.yaml")
#read in data
settings$data_path
host.data <- read.csv(paste0(settings$data_path, "hosts.csv")) #static host data
host.event.data <- read.csv(paste0(settings$data_path,"host_events.csv")) #events in the host
environment.data <- read.csv(paste0(settings$data_path,"environment.csv")) #static environment data
environment.event.data <- read.csv(paste0(settings$data_path,"environment_events.csv")) #events in environment
host.data
#read in data
settings$data_path
host.data <- read.csv(paste0(settings$data_path, "hosts.csv"), setp =";") #static host data
#read in data
settings$data_path
host.data <- read.csv(paste0(settings$data_path, "hosts.csv"), sep =";") #static host data
host.event.data <- read.csv(paste0(settings$data_path,"host_events.csv")) #events in the host
environment.data <- read.csv(paste0(settings$data_path,"environment.csv")) #static environment data
environment.event.data <- read.csv(paste0(settings$data_path,"environment_events.csv")) #events in environment
host.data
#read in data
settings$data_path
host.data <- read.csv(paste0(settings$data_path, "hosts.csv"), sep =";") #static host data
host.event.data <- read.csv(paste0(settings$data_path,"host_events.csv"), sep =";") #events in the host
environment.data <- read.csv(paste0(settings$data_path,"environment.csv"), sep =";") #static environment data
environment.event.data <- read.csv(paste0(settings$data_path,"environment_events.csv"), sep =";") #events in environment
#read in data - deal with separator issues if needed (sep = ";")
host.data <- read.csv(paste0(settings$data_path, "hosts.csv"), sep =";") #static host data
host.event.data <- read.csv(paste0(settings$data_path,"host_events.csv"), sep =";") #events in the host
environment.data <- read.csv(paste0(settings$data_path,"environment.csv"), sep =";") #static environment data
environment.event.data <- read.csv(paste0(settings$data_path,"environment_events.csv"), sep =";") #events in environment
host.event.data
input.data.events <- host.event.data%>%filter(measurement_type == "esbl_count")
#load required packages
library("yaml")
library("tidyverse")
#obtain the information from the configuration file
settings <- read_yaml("summerfair_config_example.yaml")
#read in data - deal with separator issues if needed (sep = ";")
host.data <- read.csv(paste0(settings$data_path, "hosts.csv"), sep =";") #static host data
host.event.data <- read.csv(paste0(settings$data_path,"host_events.csv"), sep =";") #events in the host
environment.data <- read.csv(paste0(settings$data_path,"environment.csv"), sep =";") #static environment data
environment.event.data <- read.csv(paste0(settings$data_path,"environment_events.csv"), sep =";") #events in environment
input.data.events <- host.event.data%>%filter(measurement_type == "esbl_count")
input.data.events
host.data
environment.event.data
environment.data
environment.event.data
left_join(x = input.data.events,
y = host.data)
#load required packages
library("yaml")
library("tidyverse")
#obtain the information from the configuration file
settings <- read_yaml("summerfair_config_example.yaml")
#read in data - deal with separator issues if needed (sep = ";")
host.data <- read.csv(paste0(settings$data_path, "hosts.csv"), sep =";") #static host data
host.event.data <- read.csv(paste0(settings$data_path,"host_events.csv"), sep =";") #events in the host
environment.data <- read.csv(paste0(settings$data_path,"environment.csv"), sep =";") #static environment data
environment.event.data <- read.csv(paste0(settings$data_path,"environment_events.csv"), sep =";") #events in environment
input.data.events
#filter out only relevant information. Here the count of ESBL producing E.coli
input.data.events <- host.event.data%>%filter(measurement_type == "esbl_count")
#When only using host data for measurements use function join_host_environment
input.data.events <- join_host_environment(input.data.events, environment.event.data)
## function to join host and environmental data such that each host sample is placed in a environment
#join_host_environment <- function(host_event_data,
# environment_event_data){
input.data.events
environment.event.data
## function to join host and environmental data such that each host sample is placed in a environment
#join_host_environment <- function(host_event_data,
# environment_event_data){
#create temporary output object
temp.output <- input.data.events#host_event_data
temp.output
depth(temp.output)
depht(temp.output)
dim(temp.output)
for(i in c(1:dim(temp.output)[1]))
{
print(input.data.events$host_id[i])
}
input.data.events[i]
input.data.events[i,]
environment.event.data
input.data.events[i,c("host_id","event_day","event_time")]
#find last movement of this host
environment_event_data<-environment.event.data
#select host_id, day and time
event_key <- temp.output[i,c("host_id","event_day","event_time")]
event_key$host_id
environment_event_data[,environment_event_data$host_id== event_key$host_id]
environment_event_data[environment_event_data$host_id== event_key$host_id,]
#last movement
last(environment_event_data[environment_event_data$host_id== event_key$host_id & environment_event_data$event_day <= event_key$event_day,])
#last movement
last(environment_event_data[environment_event_data$host_id== event_key$host_id &
environment_event_data$event_day <= event_key$event_day &
environment_event_data$event_time <= event_key$event_time,])
if(!is.na(event_key$event_time)){
env.id<-last(environment_event_data[environment_event_data$host_id== event_key$host_id &
environment_event_data$event_day <= event_key$event_day &
environment_event_data$event_time <= event_key$event_time,"environment_id"])
}else
{
env.id<-last(environment_event_data[environment_event_data$host_id== event_key$host_id &
environment_event_data$event_day <= event_key$event_day,"environment_id"])
}
env.id
#find last movement of this host
environment_event_data<-environment.event.data
env.id<-last(environment_event_data[environment_event_data$host_id== event_key$host_id &
environment_event_data$event_day <= event_key$event_day,"environment_id"])
env.id
#last movement
if(!is.na(event_key$event_time)){
env.id<-last(environment_event_data[environment_event_data$host_id== event_key$host_id &
environment_event_data$event_day <= event_key$event_day &
environment_event_data$event_time <= event_key$event_time,"environment_id"])
}else
#last movement
if(!is.na(event_key$event_time)){
env.id<-last(environment_event_data[environment_event_data$host_id== event_key$host_id &
environment_event_data$event_day <= event_key$event_day &
environment_event_data$event_time <= event_key$event_time,"environment_id"])
}else{
env.id<-last(environment_event_data[environment_event_data$host_id== event_key$host_id &
environment_event_data$event_day <= event_key$event_day,"environment_id"])
}
env.id
if(!is.na(event_key$event_time)){
env.id<-last(environment_event_data[environment_event_data$host_id== event_key$host_id &
environment_event_data$event_day <= event_key$event_day &
environment_event_data$event_time <= event_key$event_time,"environment_id"])
}else{
env.id<-last(environment_event_data[environment_event_data$host_id== event_key$host_id &
environment_event_data$event_day <= event_key$event_day,"environment_id"])
}
env.id
env.id<-last(environment_event_data[environment_event_data$host_id== event_key$host_id &
environment_event_data$event_day <= event_key$event_day,"environment_id"])
env.id
event_key$event_time
is.na(event_key$event_time)
is.null(event_key$event_time)
!is.na(as.numeric(event_key$event_time))
as.numeric(event_key$event_time)
is.na(as.numeric(event_key$event_time))
#last movement
if(!is.na(as.numeric(event_key$event_time))){
env.id<-last(environment_event_data[environment_event_data$host_id== event_key$host_id &
environment_event_data$event_day <= event_key$event_day &
environment_event_data$event_time <= event_key$event_time,"environment_id"])
}else{
env.id<-last(environment_event_data[environment_event_data$host_id== event_key$host_id &
environment_event_data$event_day <= event_key$event_day,"environment_id"])
}
env.id
temp.output$environment_id <- NULL
temp.output$environment_id
temp.output
#create temporary output object
temp.output <- input.data.events#host_event_data
temp.output$environment_id <- NA;
#iterate over the events of host
for(i in c(1:dim(temp.output)[1]))
{
#select host_id, day and time
event_key <- temp.output[i,c("host_id","event_day","event_time")]
#find last movement of this host
environment_event_data<-environment.event.data
#last movement
if(!is.na(as.numeric(event_key$event_time))){
temp.output$environment_id[i]<-last(environment_event_data[environment_event_data$host_id== event_key$host_id &
environment_event_data$event_day <= event_key$event_day &
environment_event_data$event_time <= event_key$event_time,"environment_id"])
}else{
temp.output$environment_id[i]<-env.id<-last(environment_event_data[environment_event_data$host_id== event_key$host_id &
environment_event_data$event_day <= event_key$event_day,"environment_id"])
}
}
return(temp.output)
temp.output
#When only using host data for measurements use function join_host_environment
input.data.events <- join_host_environment(input.data.events, environment.event.data)
#source required SUMMERFAIR files
source("LocalAlgorithm.R")
#filter out only relevant information. Here the count of ESBL producing E.coli
input.data.events <- host.event.data%>%filter(measurement_type == "esbl_count")
#When only using host data for measurements use function join_host_environment
input.data.events <- join_host_environment(input.data.events, environment.event.data)
#add additional data of the hosts
input.data.events <- left_join(x = input.data.events,
y = host.data)
#add position of host in the environment based on time
input.data.events
readRDS("dataE.RDS")
dataE
head(input.data.events)
head(dataE)
join_host_environment
head(input.data.events)
settings$rule_name
eval(str2expression(paste0("rule.",settings$rule_name)))
#apply rule and arrange data
arranged.data <- arrangeData(input.data.events,
eval(str2expression(paste0("rule.",settings$rule_name))))
#load required packages
library("yaml")
library("tidyverse")
#source required SUMMERFAIR files
source("LocalAlgorithm.R")
#load required packages
library("yaml")
library("tidyverse")
#source required SUMMERFAIR files
source("LocalAlgorithm.R")
arrangeData(input.data.events,
eval(str2expression(paste0("rule.",settings$rule_name))))
head(input.data.events)
source("C:/Users/fisch106/surfdrive - Fischer, E.A.J. (Egil)@surfdrive.surf.nl/Projecten/SUMMERFAIR/ProjectShareSUMMERFAIR/Syntax/autumn-fair/src/WorkingExample/LocalAlgorithm.R", echo=TRUE)
#apply rule and arrange data
arranged.data <- arrangeData(input.data.events,
eval(str2expression(paste0("rule.",settings$rule_name))))
debugSource("C:/Users/fisch106/surfdrive - Fischer, E.A.J. (Egil)@surfdrive.surf.nl/Projecten/SUMMERFAIR/ProjectShareSUMMERFAIR/Syntax/autumn-fair/src/WorkingExample/LocalAlgorithm.R", echo=TRUE)
arranged.data <- arrangeData(input.data.events,
eval(str2expression(paste0("rule.",settings$rule_name))))
data
arrangeData(input.data.events,
eval(str2expression(paste0("rule.",settings$rule_name))))
data
#treatment_type is required to have at least a value
input.data.events$treatment_type <- "control"
#treatment_type is required to have at least a value
input.data.events$treatment_type <- "control"
#apply rule and arrange data
arranged.data <- arrangeData(input.data.events,
eval(str2expression(paste0("rule.",settings$rule_name))))
#apply rule and arrange data
arranged.data <- arrangeData(input.data.events,
eval(str2expression(paste0("rule.",settings$rule_name))),
var.id = NULL)
input.data.events
#apply rule and arrange data
arranged.data <- arrangeData(input.data.events,
eval(str2expression(paste0("rule.",settings$rule_name))),
var.id = host_groupNumber)
#apply rule and arrange data
arranged.data <- arrangeData(input.data.events,
eval(str2expression(paste0("rule.",settings$rule_name))),
var.id = c("host_groupNumber"))
names(input.data.events)
#apply rule and arrange data
arranged.data <- arrangeData(input.data.events,
eval(str2expression(paste0("rule.",settings$rule_name))),
var.id = c("host_groupNumber"))
source("C:/Users/fisch106/surfdrive - Fischer, E.A.J. (Egil)@surfdrive.surf.nl/Projecten/SUMMERFAIR/ProjectShareSUMMERFAIR/Syntax/autumn-fair/src/WorkingExample/LocalAlgorithm.R", echo=TRUE)
arrangeData(input.data.events,
eval(str2expression(paste0("rule.",settings$rule_name))),
var.id = c("host_groupNumber"))
input.data.events$inoculation_type
host.event.data
sample(c("S","I"), length(input.data.events$inoculation_type))
sample(c("S","I"), length(input.data.events$inoculation_type),replace = TRUE)
input.data.events$inoculation_type <- sample(c("S","I"), length(input.data.events$inoculation_type),replace = TRUE)
#apply rule and arrange data
arranged.data <- arrangeData(input.data.events,
eval(str2expression(paste0("rule.",settings$rule_name))),
var.id = c("host_groupNumber"))
arranged.data
arranged.data[[1]]
arranged.data[[1]]$arranged.data
arranged.data[[2]]
raw.plot(arranged.data[[2]])
debugSource("C:/Users/fisch106/surfdrive - Fischer, E.A.J. (Egil)@surfdrive.surf.nl/Projecten/SUMMERFAIR/ProjectShareSUMMERFAIR/Syntax/autumn-fair/src/WorkingExample/ExperimentalPlots.R", echo=TRUE)
transform.data.for.plot(arranged.data[[2]])
debugSource("C:/Users/fisch106/surfdrive - Fischer, E.A.J. (Egil)@surfdrive.surf.nl/Projecten/SUMMERFAIR/ProjectShareSUMMERFAIR/Syntax/autumn-fair/src/WorkingExample/ExperimentalPlots.R", echo=TRUE)
debugSource("C:/Users/fisch106/surfdrive - Fischer, E.A.J. (Egil)@surfdrive.surf.nl/Projecten/SUMMERFAIR/ProjectShareSUMMERFAIR/Syntax/autumn-fair/src/WorkingExample/ExperimentalPlots.R", echo=TRUE)
transform.data.for.plot(arranged.data[[2]])
debugSource("C:/Users/fisch106/surfdrive - Fischer, E.A.J. (Egil)@surfdrive.surf.nl/Projecten/SUMMERFAIR/ProjectShareSUMMERFAIR/Syntax/autumn-fair/src/WorkingExample/ExperimentalPlots.R", echo=TRUE)
transform.data.for.plot(arranged.data[[2]])
sirdata
debugSource("C:/Users/fisch106/surfdrive - Fischer, E.A.J. (Egil)@surfdrive.surf.nl/Projecten/SUMMERFAIR/ProjectShareSUMMERFAIR/Syntax/autumn-fair/src/WorkingExample/ExperimentalPlots.R", echo=TRUE)
transform.data.for.plot(arranged.data[[2]])
sirdata
host.data[1,"inoculation_type"]
host.data
sirdata%>%filter(host_id ==i)
debugSource("C:/Users/fisch106/surfdrive - Fischer, E.A.J. (Egil)@surfdrive.surf.nl/Projecten/SUMMERFAIR/ProjectShareSUMMERFAIR/Syntax/autumn-fair/src/WorkingExample/ExperimentalPlots.R", echo=TRUE)
transform.data.for.plot(arranged.data[[2]])
single.host.data
out
debugSource("C:/Users/fisch106/surfdrive - Fischer, E.A.J. (Egil)@surfdrive.surf.nl/Projecten/SUMMERFAIR/ProjectShareSUMMERFAIR/Syntax/autumn-fair/src/WorkingExample/ExperimentalPlots.R", echo=TRUE)
transform.data.for.plot(arranged.data[[2]])
debugSource("C:/Users/fisch106/surfdrive - Fischer, E.A.J. (Egil)@surfdrive.surf.nl/Projecten/SUMMERFAIR/ProjectShareSUMMERFAIR/Syntax/autumn-fair/src/WorkingExample/ExperimentalPlots.R", echo=TRUE)
transform.data.for.plot(arranged.data[[2]])
single.host.data
sirdata
sirdata%>%filter(host_id ==i)
host.data
input.data.events
input.data.events%>%mutate(.by = host_id,
inoculation_type = sample(c("S","I"),1))
input.data.events <- input.data.events%>%mutate(.by = host_id,
inoculation_type = sample(c("S","I"),1))
input.data.events
#filter out only relevant information. Here the count of ESBL producing E.coli
input.data.events <- host.event.data%>%filter(measurement_type == "esbl_count")
#When only using host data for measurements use function join_host_environment
input.data.events <- join_host_environment(input.data.events,
environment.event.data)
#add additional data of the hosts
input.data.events <- left_join(x = input.data.events,
y = host.data)
head(input.data.events)
#treatment_type and inoculation_type is required to have at least a value
input.data.events$treatment_type <- "control"
input.data.events <- input.data.events%>%mutate(.by = host_id,
inoculation_type = sample(c("S","I"),1))
#apply rule and arrange data
arranged.data <- arrangeData(input.data.events,
eval(str2expression(paste0("rule.",settings$rule_name))),
var.id = c("host_groupNumber"))
transform.data.for.plot(arranged.data[[2]])
transform.data.for.plot(arranged.data[[2]])