-
Notifications
You must be signed in to change notification settings - Fork 1
/
script_satscan_dzc_rio
144 lines (112 loc) · 5.12 KB
/
script_satscan_dzc_rio
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
### To identify space-time clusters of Zika, Chikungunya and Dengue using SaTScan
# Packages needed
library(rsatscan)
library(sf)
# Load the cases and populations data. We don't have permission to reproduce the data,
# but the data can be found at:
# http://www.rio.rj.gov.br/web/sms/exibeConteudo?id=6525201
cases <- read_csv('DZC_cases_pop.csv')
# Let's consider cases dataframe as containing the following columns:
# names(cases)
# [1] "Cod_Neigh" "Neigh_name" "time" "dengue" "chikungunya" "zika" "population"
# Load centroids of the neighbourhoods (our spatial unit analysis)
neigh <- read_sf('realcentroides_bairros.shp')
# neigh dataframe must contain the longitude (X) and latitude (Y) coordinates of the centroids of
# each neighbourhood, as well as the same identification for the neighbourhoods than the case dataframe
# names(neigh)
# [1] "Cod_Neigh" "Neigh_name" "X" "Y"
tmp <- tempdir()
old <- getwd()
setwd(tmp)
# SaTSCan must be installed, it can be downloaded at:
# https://www.satscan.org/download.html
# Load SaTScan
ss.local <- "~/bin/SaTScan/" # change location accordingly
# Load the parameters for SaTScan
ssenv$.ss.params <- readLines('template_satscan.txt')
#############################################################################
# The following lines corresponds to SaTScan analysis for one disease
# It was done for zika, chikungunya, and dengue, individually, by changing to the corresponding row number
### Creating files required to run SaTSCan
DISEASE <- 6 #row number of the cases
ARQ <- 'zika.cas' #change name for dengue.cas and chikungunya.cas accordingly
# Case files
write.table(cases[,c(1,DISEASE,8)],file=ARQ ,
row.names = FALSE,col.names = FALSE,qmethod = "double",fileEncoding = "latin1")
# Population files
write.table(cases[,c(1,8,7)],file='dzc.pop' ,
row.names = FALSE,col.names = FALSE,qmethod = "double",fileEncoding = "latin1")
# Coordinates files
write.table(neigh[,c(1,4,3)],file='dzc.geo' ,
row.names = FALSE,col.names = FALSE,qmethod = "double",fileEncoding = "latin1")
## Running SaTScan
ss.options(list(CaseFile=ARQ,
StartDate="2015/08/02",
EndDate="2016/12/25",
PrecisionCaseTimes=3 ,
PopulationFile="dzc.pop",
CoordinatesFile="dzc.geo",
CoordinatesType=1,
AnalysisType=3,
ModelType=0,
TimeAggregationUnits=3,
ScanAreas=1,
TimeAggregationLength=7,
MaxSpatialSizeInPopulationAtRisk=50,
MinimumTemporalClusterSize=1,
MaxTemporalSize=31,
MinimumCasesInHighRateClusters=5,
MaxSpatialSizeInPopulationAtRisk_Reported=5
))
ss.options(c("NonCompactnessPenalty=0", "ReportGiniClusters=n", "LogRunToHistoryFile=n"))
modelo <- paste0(ARQ,'_modelo')
write.ss.prm(tmp,modelo)
result_zika <- satscan(tmp,modelo, sslocation="/bin/SaTScan/")
summary(result_zika)
result_zika
############################################################################
## Runing SaTScan for Multiple data sets analysis (Dengue, Zika, and Chikungunya simultaneously)
# Load parameters for multiple datasets
ssenv$.ss.params <- readLines('multiple_datasets.txt')
ARQ <- 'dengue.cas'
ARQ2 <- 'zika.cas'
ARQ3 <- 'chikungunya.cas'
write.table(cases[,c(1,4,8)],file=ARQ ,
row.names = FALSE,col.names = FALSE,qmethod = "double",fileEncoding = "latin1")
write.table(cases[,c(1,6,8)],file=ARQ2 ,
row.names = FALSE,col.names = FALSE,qmethod = "double",fileEncoding = "latin1")
write.table(cases[,c(1,5,8)],file=ARQ3 ,
row.names = FALSE,col.names = FALSE,qmethod = "double",fileEncoding = "latin1")
write.table(cases[,c(1,8,7)],file='dzc.pop' ,
row.names = FALSE,col.names = FALSE,qmethod = "double",fileEncoding = "latin1")
write.table(neigh[,c(1,4,3)],file='dzc.geo' ,
row.names = FALSE,col.names = FALSE,qmethod = "double",fileEncoding = "latin1")
ss.options(list(CaseFile=ARQ,
StartDate="2015/08/02",
EndDate="2016/12/25",
PrecisionCaseTimes=3 ,
PopulationFile="dzc.pop",
CoordinatesFile="dzc.geo",
CoordinatesType=1,
AnalysisType=3,
ModelType=0,
TimeAggregationUnits=3,
ScanAreas=1,
TimeAggregationLength=7,
MaxSpatialSizeInPopulationAtRisk=50,
MinimumTemporalClusterSize=1,
MaxTemporalSize=31,
MinimumCasesInHighRateClusters=5,
MaxSpatialSizeInPopulationAtRisk_Reported=5,
MultipleDataSetsPurposeType=0,
CaseFile2=ARQ2,
PopulationFile2='dzc.pop',
CaseFile3=ARQ3,
PopulationFile3='dzc.pop'
))
ss.options(c("NonCompactnessPenalty=0", "ReportGiniClusters=n", "LogRunToHistoryFile=n"))
model <- paste0(ARQ, '_Modelo')
write.ss.prm(tmp,model)
result_dzc <- satscan(tmp,model, sslocation="/bin/SaTScan/")
summary(result_dzc)
result_dzc