-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
143 lines (106 loc) · 4.61 KB
/
Makefile
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
## Directory information
RAWDATDIR = ./data/raw-data
CLEANDATDIR = ./data/clean-data
CODEDIR = ./code
RESDIR = ./results
MSDIR = ./manuscript
SIMDIR = ./simulations
## Analysis information
NREPS = 50
## Set the manuscript as the overall target
.PHONY: all
all: $(MSDIR)/measles-ews-manuscript.pdf
## Clean the data
DATA_DEPS := $(RAWDATDIR)/district_pops.csv
DATA_DEPS += $(RAWDATDIR)/niger_crude_birth_rates.csv
DATA_DEPS += $(RAWDATDIR)/niger_regional_1995_2005.csv
DATA_DEPS += $(CODEDIR)/fetch-clean-data.R
DATA_TARG = $(CLEANDATDIR)/weekly-measles-incidence-niger-cities-clean.RDS
COVAR_TARG = $(CLEANDATDIR)/annual-demographic-data-niger-cities-clean.RDS
$(DATA_TARG): $(DATA_DEPS)
Rscript $(CODEDIR)/fetch-clean-data.R
$(COVAR_TARG): $(DATA_DEPS)
Rscript $(CODEDIR)/fetch-clean-data.R
## Make pomp objects
POMP_DEPS := $(DATA_TARG)
POMP_DEPS += $(COVAR_TARG)
POMP_DEPS += $(CODEDIR)/define-continuous-measles-pomp.R
POMP_TARG = $(CODEDIR)/measles-pomp-object-*.RDS
$(POMP_TARG): $(POMP_DEPS)
Rscript $(CODEDIR)/define-continuous-measles-pomp.R
$(warning Pomp objects updated. Do you need to refit on HPC?)
## Fit the POMP models
## NOTE: model fitting was done on a high performance computing cluster,
## using 1000s of cores. Therefore, this Makefile skips over the model
## fitting stage, but the R script global-search-mif.R can be interrogated
## by interested users.
.INTERMEDIATE = $(RESDIR)/initial-mif-lls-*.csv
#FIT_DEPS := $(POMP_TARG)
#FIT_DEPS += $(CODEDIR)/global-search-mif.R
#FIT_TARG := $(RESDIR)/initial-mif-lls-Agadez.csv
#FIT_TARG += $(RESDIR)/initial-mif-lls-Maradi.csv
#FIT_TARG += $(RESDIR)/initial-mif-lls-Niamey.csv
#FIT_TARG += $(RESDIR)/initial-mif-lls-Zinder.csv
#$(FIT_TARG): $(FIT_DEPS)
#Rscript $(CODEDIR)/global-search-mif.R 1
LOGLIKS = $(RESDIR)/initial-mif-lls-*.csv
## Fit bootstrapped simulations for parameter uncertainty estimates.
## NOTE: much like the primary model fitting above, this round of fitting
## was also done on a high performance computing cluster, using 1000s
## of cores. Therefore, this Makefile skips over fitting of the bootstrap
## simulations, but the R script bootstrap-fit-mif.R can be interrogated
## by interested users.
.INTERMEDIATE = $(RESDIR)/bootstrap-mif-lls-*.csv
BOOT_LOGLIKS = $(RESDIR)/bootstrap-mif-lls-*.csv
## Make one-week-ahead predictions
PRED_DEPS := $(LOGLIKS)
PRED_DEPS += $(CODEDIR)/estimate-transmission-state.R
PRED_TARG = $(RESDIR)/predictive-dist-states-*.RDS
$(PRED_TARG): $(PRED_DEPS)
Rscript $(CODEDIR)/estimate-transmission-state.R 1
Rscript $(CODEDIR)/estimate-transmission-state.R 2
Rscript $(CODEDIR)/estimate-transmission-state.R 3
Rscript $(CODEDIR)/estimate-transmission-state.R 4
## Simulate bootstrap replicates for parameter uncertainty
BOOT_DEPS := $(CODEDIR)/simulate-bootstrap-series.R
BOOT_DEPS += $(CODEDIR)/make-pomp-simulator-function.R
BOOT_DEPS += $(LOGLIKS)
BOOT_TARG = $(SIMDIR)/bootstrap-sims-*.RDS
$(BOOT_TARG): $(BOOT_DEPS)
Rscript $(CODEDIR)/simulate-bootstrap-series.R
## Simulate emergence replicates
EMERG_DEPS := $(LOGLIKS)
EMERG_DEPS += $(CODEDIR)/make-pomp-simulator-function.R
EMERG_DEPS += $(CODEDIR)/simulate-emergence-grid.R
EMERG_TARG = $(SIMDIR)/emergence-simulations-grid-*.RDS
$(EMERG_TARG): $(EMERG_DEPS)
Rscript $(CODEDIR)/simulate-emergence-grid.R $(NREPS)
## Simulate elimination replicates
ELIMIN_DEPS := $(LOGLIKS)
ELIMIN_DEPS += $(CODEDIR)/make-pomp-simulator-function.R
ELIMIN_DEPS += $(CODEDIR)/simulate-emergence-grid.R
ELIMIN_TARG = $(SIMDIR)/elimination-simulations-grid-*.RDS
$(ELIMIN_TARG): $(ELIMIN_DEPS)
Rscript $(CODEDIR)/simulate-elimination-grid.R $(NREPS)
## Analyze the emergence sims (EWS and AUC)
EM_EWS_DEPS := $(SIMDIR)/emergence-simulations-grid-*.RDS
EM_EWS_DEPS += $(CODEDIR)/analyze-emergence-grid-sims.R
EM_EWS_TARG = $(RESDIR)/emergence-grid-aucs.csv
$(EM_EWS_TARG): $(EM_EWS_DEPS)
Rscript $(CODEDIR)/analyze-emergence-grid-sims.R
## Analyze the elimination sims (EWS and AUC)
EL_EWS_DEPS := $(SIMDIR)/elimination-simulations-grid-*.RDS
EL_EWS_DEPS += $(CODEDIR)/analyze-elimination-grid-sims.R
EL_EWS_TARG = $(RESDIR)/elimination-grid-aucs.csv
$(EL_EWS_TARG): $(EL_EWS_DEPS)
Rscript $(CODEDIR)/analyze-elimination-grid-sims.R
## Make the manuscript
MS_DEPS := $(MSDIR)/measles-ews-manuscript.Rmd
MS_DEPS += $(POMP_TARG) # pomp model objects
MS_DEPS += $(PRED_TARG) # fitted model predictions
MS_DEPS += $(LOGLIKS) # MLE parameter estimates
MS_DEPS += $(BOOT_LOGLIKS) # bootstrapped MLEs
MS_DEPS += $(EM_EWS_TARG) # emergence EWS and AUCs
MS_DEPS += $(EL_EWS_TARG) # elimination EWS and AUCs
$(MSDIR)/measles-ews-manuscript.pdf: $(MS_DEPS)
Rscript -e 'rmarkdown::render("$<")'