Skip to content

Commit 9a751f1

Browse files
committed
Add test
1 parent 8a12c0e commit 9a751f1

File tree

9 files changed

+304
-0
lines changed

9 files changed

+304
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
input_namespace: null
2+
output_namespace: out
3+
params:
4+
path: "data.csv"
5+
out: "out.csv"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fields:
2+
- name: dates
3+
type: date
4+
- name: I
5+
type: integer
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
fields:
2+
- name: t_start
3+
type: integer
4+
- name: t_end
5+
type: integer
6+
- name: Mean(R)
7+
type: number
8+
- name: Std(R)
9+
type: number
10+
- name: Quantile.0.025(R)
11+
type: number
12+
- name: Quantile.0.05(R)
13+
type: number
14+
- name: Quantile.0.25(R)
15+
type: number
16+
- name: Median(R)
17+
type: number
18+
- name: Quantile.0.75(R)
19+
type: number
20+
- name: Quantile.0.95(R)
21+
type: number
22+
- name: Quantile.0.975(R)
23+
type: number
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"dates","I"
2+
2009-04-27,1
3+
2009-04-28,1
4+
2009-04-29,0
5+
2009-04-30,2
6+
2009-05-01,5
7+
2009-05-02,3
8+
2009-05-03,3
9+
2009-05-04,3
10+
2009-05-05,6
11+
2009-05-06,2
12+
2009-05-07,5
13+
2009-05-08,9
14+
2009-05-09,13
15+
2009-05-10,12
16+
2009-05-11,13
17+
2009-05-12,11
18+
2009-05-13,12
19+
2009-05-14,6
20+
2009-05-15,6
21+
2009-05-16,6
22+
2009-05-17,3
23+
2009-05-18,1
24+
2009-05-19,0
25+
2009-05-20,2
26+
2009-05-21,0
27+
2009-05-22,0
28+
2009-05-23,0
29+
2009-05-24,0
30+
2009-05-25,2
31+
2009-05-26,0
32+
2009-05-27,2
33+
2009-05-28,0
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"date","confirm"
2+
2020-02-22,14
3+
2020-02-23,62
4+
2020-02-24,53
5+
2020-02-25,97
6+
2020-02-26,93
7+
2020-02-27,78
8+
2020-02-28,250
9+
2020-02-29,238
10+
2020-03-01,240
11+
2020-03-02,561
12+
2020-03-03,347
13+
2020-03-04,466
14+
2020-03-05,587
15+
2020-03-06,769
16+
2020-03-07,778
17+
2020-03-08,1247
18+
2020-03-09,1492
19+
2020-03-10,1797
20+
2020-03-11,977
21+
2020-03-12,2313
22+
2020-03-13,2651
23+
2020-03-14,2547
24+
2020-03-15,3497
25+
2020-03-16,2823
26+
2020-03-17,4000
27+
2020-03-18,3526
28+
2020-03-19,4207
29+
2020-03-20,5322
30+
2020-03-21,5986
31+
2020-03-22,6557
32+
2020-03-23,5560
33+
2020-03-24,4789
34+
2020-03-25,5249
35+
2020-03-26,5210
36+
2020-03-27,6153
37+
2020-03-28,5959
38+
2020-03-29,5974
39+
2020-03-30,5217
40+
2020-03-31,4050
41+
2020-04-01,4053
42+
2020-04-02,4782
43+
2020-04-03,4668
44+
2020-04-04,4585
45+
2020-04-05,4805
46+
2020-04-06,4316
47+
2020-04-07,3599
48+
2020-04-08,3039
49+
2020-04-09,3836
50+
2020-04-10,4204
51+
2020-04-11,3951
52+
2020-04-12,4694
53+
2020-04-13,4092
54+
2020-04-14,3153
55+
2020-04-15,2972
56+
2020-04-16,2667
57+
2020-04-17,3786
58+
2020-04-18,3493
59+
2020-04-19,3491
60+
2020-04-20,3047
61+
2020-04-21,2256

workflows/working_example/out.csv

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
dates,I
2+
2020-02-22,14
3+
2020-02-23,62
4+
2020-02-24,53
5+
2020-02-25,97
6+
2020-02-26,93
7+
2020-02-27,78
8+
2020-02-28,250
9+
2020-02-29,238
10+
2020-03-01,240
11+
2020-03-02,561
12+
2020-03-03,347
13+
2020-03-04,466
14+
2020-03-05,587
15+
2020-03-06,769
16+
2020-03-07,778
17+
2020-03-08,1247
18+
2020-03-09,1492
19+
2020-03-10,1797
20+
2020-03-11,977
21+
2020-03-12,2313
22+
2020-03-13,2651
23+
2020-03-14,2547
24+
2020-03-15,3497
25+
2020-03-16,2823
26+
2020-03-17,4000
27+
2020-03-18,3526
28+
2020-03-19,4207
29+
2020-03-20,5322
30+
2020-03-21,5986
31+
2020-03-22,6557
32+
2020-03-23,5560
33+
2020-03-24,4789
34+
2020-03-25,5249
35+
2020-03-26,5210
36+
2020-03-27,6153
37+
2020-03-28,5959
38+
2020-03-29,5974
39+
2020-03-30,5217
40+
2020-03-31,4050
41+
2020-04-01,4053
42+
2020-04-02,4782
43+
2020-04-03,4668
44+
2020-04-04,4585
45+
2020-04-05,4805
46+
2020-04-06,4316
47+
2020-04-07,3599
48+
2020-04-08,3039
49+
2020-04-09,3836
50+
2020-04-10,4204
51+
2020-04-11,3951
52+
2020-04-12,4694
53+
2020-04-13,4092
54+
2020-04-14,3153
55+
2020-04-15,2972
56+
2020-04-16,2667
57+
2020-04-17,3786
58+
2020-04-18,3493
59+
2020-04-19,3491
60+
2020-04-20,3047
61+
2020-04-21,2256
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
"t_start","t_end","Mean(R)","Std(R)","Quantile.0.025(R)","Quantile.0.05(R)","Quantile.0.25(R)","Median(R)","Quantile.0.75(R)","Quantile.0.95(R)","Quantile.0.975(R)"
2+
2,8,2.24150921524098,0.0759070801626508,2.09518352956806,2.11813155565786,2.18985435170575,2.2406524274645,2.29223009644538,2.3678094697857,2.39270388467396
3+
3,9,1.86352323714699,0.0575095756447964,1.75249683361836,1.76994808771344,1.82441790328051,1.8629316758682,1.90198370850029,1.95911626348778,1.97791139421853
4+
4,10,2.07299383707559,0.0525187383183648,1.9713249716994,1.98737122338087,2.03733288858956,2.07255033793753,2.10817132243414,2.16012926991337,2.1771830510748
5+
5,11,1.78552586936264,0.0419920361587049,1.70416232660583,1.71702110428078,1.7570260983692,1.78519669028172,1.81366679798684,1.85515349612108,1.86876009664452
6+
6,12,1.64110716534551,0.0351405948549852,1.57294830314243,1.58373696348597,1.61727046315034,1.64085635339872,1.66467045358627,1.69933291058904,1.71069136292369
7+
7,13,1.63490775656697,0.0315222431202462,1.57370294831855,1.58340610035917,1.61353734222148,1.63470517023047,1.656057327984,1.68710045370823,1.69726384087048
8+
8,14,1.58884954264117,0.0280477427028148,1.53434742665519,1.54299830610413,1.56984274398435,1.58868450470634,1.60767643028723,1.63526373882758,1.64428955192381
9+
9,15,1.52405862535008,0.0248910921682078,1.47565915588075,1.48334883631668,1.50719679414159,1.52392311947894,1.54077273885901,1.56523063732639,1.57322816092841
10+
10,16,1.61594180562792,0.0234317536989426,1.57033906789541,1.57759412872001,1.60007620124791,1.61582855067491,1.6316839483211,1.65467580544493,1.66218816022022
11+
11,17,1.59618760779975,0.0211661719855232,1.55496914995039,1.56153264849058,1.5818607040068,1.59609405109298,1.61041252330953,1.63116169745781,1.63793773952672
12+
12,18,1.64194595724243,0.019435736851521,1.60407098211701,1.61010834139295,1.62879528707293,1.64186927085116,1.65501302977096,1.67404515722739,1.68025673404173
13+
13,19,1.43648366448917,0.0164258083741972,1.40446793806486,1.40957281575645,1.42537076336681,1.43642105672533,1.44752831539877,1.46360807389041,1.46885518509106
14+
14,20,1.48660749246693,0.0153544350868341,1.45666384065815,1.46144217489137,1.4762224709139,1.48655463000714,1.49693488736223,1.51195312858686,1.51685155687593
15+
15,21,1.53032604035021,0.0144242063318087,1.50218410654294,1.5066778765435,1.52057251670982,1.53028072176506,1.54003016107396,1.55412878986072,1.55872551565531
16+
16,22,1.48788105846554,0.0130370505364616,1.46243727631842,1.46650215768284,1.47906706968234,1.48784298106851,1.49665353811951,1.5093898446105,1.51354123111398
17+
17,23,1.47466548927818,0.0119317159913705,1.45137132875152,1.45509460104882,1.46660022467461,1.47463330903228,1.4826956733761,1.49434614716032,1.49814252734061
18+
18,24,1.3659369539958,0.0105998113937581,1.34523972350746,1.34854870438943,1.35877262335701,1.36590953555108,1.37307139508597,1.38341873032927,1.38679000112879
19+
19,25,1.34779498640758,0.00982745317720206,1.32860149176927,1.33167110480408,1.34115351490544,1.34777110084322,1.3544104196401,1.36400034376944,1.36712422064973
20+
20,26,1.35664775075455,0.0092829670310665,1.33851370684611,1.34141482566504,1.35037499727658,1.35662657767363,1.36289742290759,1.37195289908073,1.37490211946683
21+
21,27,1.30611860730865,0.00856549487225251,1.28938381280178,1.2920616289813,1.30033110819424,1.30609988325225,1.31188569484147,1.32023945503393,1.32295980902814
22+
22,28,1.29996932435291,0.00807403214939261,1.28419206275183,1.28671729382729,1.29451439948665,1.29995260861331,1.30540602695413,1.31327837373044,1.31584158007911
23+
23,29,1.32548227352106,0.00773537026812683,1.31036402870226,1.31278443764862,1.32025667599552,1.32546722595847,1.33069146730322,1.33823143794633,1.34068603236196
24+
24,30,1.30968400914032,0.00727355327581494,1.29546640533764,1.29774308772994,1.30477076027122,1.30967054419249,1.31458257951486,1.32167086066531,1.32397813310271
25+
25,31,1.27085276561173,0.00677761634167366,1.25760315043032,1.25972516603552,1.26627478924655,1.27084071700754,1.27541760747514,1.28202146403,1.28417085199379
26+
26,32,1.17557336899415,0.00620029528035552,1.16345201699373,1.16539341621949,1.17138541297793,1.17556246832808,1.1797494419061,1.18579050489348,1.18775666856027
27+
27,33,1.14297267004875,0.00588887412691164,1.13145945316565,1.13330361398134,1.13899519141547,1.14296255642579,1.14693912355393,1.15267622456781,1.15454336179894
28+
28,34,1.11095689318488,0.00564920924975479,1.09991187968316,1.10168113075816,1.10714135817188,1.11094731780098,1.11476198981826,1.12026531808265,1.12205632278691
29+
29,35,1.08469061467237,0.00545732539294281,1.07402048318025,1.07572975001917,1.08100473296991,1.08468146233733,1.08836651917184,1.09368269873992,1.09541275811413
30+
30,36,1.04709828430305,0.00526999103766011,1.03679443647624,1.03844502564828,1.04353892673011,1.04708944311967,1.05064800386767,1.05578170100667,1.05745237583078
31+
31,37,1.00851479060086,0.00511370162233939,0.99851670103935,1.00011826682167,1.00506095638935,1.00850614755973,1.01195920280427,1.01694079654843,1.01856199783731
32+
32,38,0.991588935459849,0.00505019578917344,0.981715117626536,0.983296750939276,0.988177973077257,0.991580361867374,0.994990551542201,0.999910365253406,1.00151147629711
33+
33,39,0.974079421936965,0.00500926262404248,0.964285869412895,0.965854589295851,0.970696061537542,0.974070835137933,0.977453421639442,0.98233354489986,0.983921772516425
34+
34,40,0.950486360239813,0.00496711836202873,0.940775596159137,0.942330961405206,0.947131390296268,0.950477707748512,0.953831897873723,0.958671273478407,0.960246295698978
35+
35,41,0.95458141914833,0.00501793100186796,0.944771462587645,0.946342680410886,0.951192100632754,0.954572626606802,0.957961152681888,0.962850150013369,0.964441342980922
36+
36,42,0.932933167042165,0.0050079590128277,0.923143234420733,0.924711118925198,0.929550483487021,0.932924206196403,0.936306082142668,0.941185781387369,0.942774023393514
37+
37,43,0.916499524969295,0.0050201256502425,0.906686329902359,0.908257815474985,0.913108524151223,0.916490359073751,0.919880533802821,0.924772500134765,0.926364809045963
38+
38,44,0.912200412819561,0.00508657546850865,0.902257799861916,0.903849896811598,0.908764435896179,0.9121909583174,0.915626083140976,0.920583178961274,0.922196754913211
39+
39,45,0.917663607057938,0.00519025890019086,0.907518719502348,0.909143112651982,0.914157517403484,0.91765382179597,0.921159029540668,0.926217479848431,0.927864103428911
40+
40,46,0.935231938152645,0.00532820012582989,0.924817639064073,0.926485120468016,0.931632627722277,0.93522181957107,0.93882021805093,0.944013271204229,0.945703740283365
41+
41,47,0.930270139492449,0.00538936237392633,0.919736786720691,0.921423213066601,0.92662941928466,0.930259732060673,0.933899514285246,0.939152566578758,0.940862636816754
42+
42,48,0.924608464638303,0.0054436786882541,0.91396943902503,0.915672667844807,0.920930959232306,0.924597781349855,0.928274323911,0.933580703063719,0.935308202473368
43+
43,49,0.936570682516146,0.00555899277582318,0.925706542048387,0.927445749765927,0.932815228061003,0.936559684116437,0.940314147327087,0.945733131770482,0.947497325955804
44+
44,50,0.940694329278112,0.00564688843216319,0.92965877251528,0.931425335566758,0.936879427085563,0.940683030077837,0.944496913916101,0.950001865550805,0.951794098436273
45+
45,51,0.959261777768469,0.00576989780088772,0.94798589317242,0.949790911980734,0.955363760880127,0.959250209272073,0.96314718353553,0.968772104710215,0.970603405146703
46+
46,52,0.969557089024138,0.0058555991677663,0.958113857914338,0.95994563267617,0.965601148288287,0.96954530083484,0.973500179145804,0.9792087559179,0.981067311411968
47+
47,53,0.966191759551539,0.00588332521779059,0.954694622892835,0.956534960343083,0.96221703485506,0.966179818016048,0.970153466467314,0.97588929238321,0.977756758941144
48+
48,54,0.975873708001942,0.00594967525296217,0.964246953548765,0.966108028608617,0.971854149659711,0.97586161676604,0.979880085371158,0.985680631659713,0.987569175920649
49+
49,55,0.943812621090132,0.00588345088498595,0.932316045971148,0.93415610104905,0.939837658299122,0.943800395882913,0.947774256863016,0.953510842383917,0.955378671020763
50+
50,56,0.944050351016111,0.0059333178537992,0.932456621874306,0.934312157846479,0.940041642441267,0.944037920825175,0.948045509114923,0.953830944656001,0.955714719873998
51+
51,57,0.948502480341031,0.00601596608240287,0.936747585353223,0.938628836860723,0.944437869948741,0.948489761428016,0.952553225514042,0.958419509148068,0.960329655827235
52+
52,58,0.921418613257084,0.0059909473766279,0.909713509468589,0.911586576372965,0.917370734564399,0.921405629162038,0.925452337649314,0.931294940027545,0.933197504548943
53+
53,59,0.90439072399206,0.00601458709498585,0.892640281256497,0.894520401081982,0.900326711852313,0.904377390830426,0.908440201305438,0.914306527485671,0.916216937944726
54+
54,60,0.900300929926303,0.00610981109143928,0.888365240940949,0.890274812850502,0.896172426056688,0.90028710873665,0.904414366958158,0.910374192292452,0.912315163548433
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Load configuration from config.yaml
2+
configfile: "config/config.yaml"
3+
4+
# Rule to run the R script with the path parameter
5+
rule run_r_script:
6+
input:
7+
script = "epiestim_estimate_r.R"
8+
params:
9+
path = config["path"]
10+
out = config["out"]
11+
shell:
12+
"""
13+
Rscript {input.script} --path={params.path} > {params.out}
14+
"""
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Example of using the EpiEstim package to estimate the effective reproduction number R parametrically
2+
if (!require(EpiEstim)) { install.packages('EpiEstim') }
3+
if (!require(ggplot2)) { install.packages('ggplot2') }
4+
if (!require(incidence)) { install.packages('incidence') }
5+
6+
# get command line args
7+
args <- commandArgs(trailingOnly = TRUE)
8+
9+
# print args
10+
# print(args)
11+
12+
# check if the file argument is provided
13+
if (length(args) == 0) {
14+
stop("No file argument provided. Usage: Rscript using_epiestim.R <file>")
15+
}
16+
17+
# read the file path
18+
file_path <- args[1]
19+
20+
# function to do the analysis
21+
parametric_estimation_of_R <- function(file_path) {
22+
# notify the user
23+
print(cat("Carrying out analysis using file '", file_path, "'..."))
24+
data <- read.csv(file_path, colClasses=c("Date", "numeric"))
25+
res_parametric_si <- estimate_R(
26+
data,
27+
method="parametric_si",
28+
config = make_config(list(
29+
mean_si = 2.6,
30+
std_si = 1.5))
31+
)
32+
# png("output_plot.png")
33+
quartz() # macOS
34+
# x11() # linux
35+
# windows() # windows
36+
# plot(res_parametric_si, legend = FALSE)
37+
# Sys.sleep(10) # goes together with quartz/x11/windows
38+
# dev.off() # goes together with png(...)
39+
write.csv(res_parametric_si$R, "output.csv", row.names=FALSE)
40+
}
41+
42+
43+
# load the file
44+
if (file.exists(file_path)) {
45+
parametric_estimation_of_R(file_path)
46+
} else {
47+
stop("File does not exist.")
48+
}

0 commit comments

Comments
 (0)