-
Notifications
You must be signed in to change notification settings - Fork 0
/
PosteriorPredictive_DataSummary.Rev
329 lines (260 loc) · 11 KB
/
PosteriorPredictive_DataSummary.Rev
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
################################################################################
#
# RevBayes Example: Bayesian model testing using posterior predictive simulation
# This file calculates the Data Summary Statistics
#
# authors: Sebastian Hoehna
#
################################################################################
outfileName = "results_" + model_name + "/simulated_data_" + analysis_name + ".csv"
write(file=outfileName,
"SimID",
"Number Invariant Sites",
"Number Invariant Sites Excluding Ambiguous",
"Max GC",
"Max GC Excluding Ambiguous",
"Max Invariant Block Length",
"Max Invariant Block Length Excluding Ambiguous",
"Max Pairwise Difference",
"Max Pairwise Difference Excluding Ambiguous",
"Max Variable Block Length",
"Max Variable Block Length Excluding Ambiguous",
"Min GC",
"Min GC Excluding Ambiguous",
"Min Pairwise Difference",
"Min Pairwise Difference Excluding Ambiguous",
"Number Invariable Block",
"Number Invariable Block Excluding Ambiguous",
"Mean GC",
"Mean GC Excluding Ambiguous",
"Mean GC 1",
"Mean GC 1 Excluding Ambiguous",
"Mean GC 2",
"Mean GC 2 Excluding Ambiguous",
"Mean GC 3",
"Mean GC 3 Excluding Ambiguous",
"Var GC",
"Var GC Excluding Ambiguous",
"Var GC 1",
"Var GC 1 Excluding Ambiguous",
"Var GC 2",
"Var GC 2 Excluding Ambiguous",
"Var GC 3",
"Var GC 3 Excluding Ambiguous",
"Theta",
"Tajima-D",
"Tajima-Pi",
"Segregating-Sites",
"Multinomial-Likelihood",
sep=",", append=FALSE)
write(file=outfileName, "\n", append=TRUE)
################### calculate the pps stats here #########################
## Iterate through all of the posterior tree files from the simulation analyses
for ( i in 1:num_post_sims) {
inFileName = "output_" + model_name + "/posterior_predictive_sim_" + i + "/" + analysis_name + "_posterior.trees"
sim_data <- readDiscreteCharacterData("output_" + model_name + "/" + analysis_name + "_post_sims/posterior_predictive_sim_" + i + "/seq.nex" )
num_inv = sim_data.getNumInvariantSites( excludeAmbiguous=FALSE )
num_inv_amb = sim_data.getNumInvariantSites( excludeAmbiguous=TRUE )
max_gc = sim_data.maxGcContent( excludeAmbiguous=FALSE )
max_gc_amb = sim_data.maxGcContent( excludeAmbiguous=TRUE )
min_inv_bl = sim_data.maxInvariableBlockLength( excludeAmbiguous=FALSE )
min_inv_bl_amb = sim_data.maxInvariableBlockLength( excludeAmbiguous=TRUE )
max_pd = sim_data.maxPairwiseDifference( excludeAmbiguous=FALSE )
max_pd_amb = sim_data.maxPairwiseDifference( excludeAmbiguous=TRUE )
max_var_bl = sim_data.maxVariableBlockLength( excludeAmbiguous=FALSE )
max_var_bl_amb = sim_data.maxVariableBlockLength( excludeAmbiguous=TRUE )
min_gc = sim_data.minGcContent( excludeAmbiguous=FALSE )
min_gc_amb = sim_data.minGcContent( excludeAmbiguous=TRUE )
min_pd = sim_data.minPairwiseDifference( excludeAmbiguous=FALSE )
min_pd_amb = sim_data.minPairwiseDifference( excludeAmbiguous=TRUE )
n_char = sim_data.nchar()
n_taxa = sim_data.ntaxa()
n_inv_b = sim_data.numInvariableBlocks( excludeAmbiguous=FALSE )
n_inv_b_amb = sim_data.numInvariableBlocks( excludeAmbiguous=TRUE )
mean_gc = sim_data.meanGcContent( excludeAmbiguous=FALSE )
mean_gc_amb = sim_data.meanGcContent( excludeAmbiguous=TRUE )
mean_gc_1 = sim_data.meanGcContentByCodonPosition(1, excludeAmbiguous=FALSE )
mean_gc_1_amb = sim_data.meanGcContentByCodonPosition(1, excludeAmbiguous=TRUE )
mean_gc_2 = sim_data.meanGcContentByCodonPosition(2, excludeAmbiguous=FALSE )
mean_gc_2_amb = sim_data.meanGcContentByCodonPosition(2, excludeAmbiguous=TRUE )
mean_gc_3 = sim_data.meanGcContentByCodonPosition(3, excludeAmbiguous=FALSE )
mean_gc_3_amb = sim_data.meanGcContentByCodonPosition(3, excludeAmbiguous=TRUE )
var_gc = sim_data.varGcContent( excludeAmbiguous=FALSE )
var_gc_amb = sim_data.varGcContent( excludeAmbiguous=TRUE )
var_gc_1 = sim_data.varGcContentByCodonPosition(1, excludeAmbiguous=FALSE )
var_gc_1_amb = sim_data.varGcContentByCodonPosition(1, excludeAmbiguous=TRUE )
var_gc_2 = sim_data.varGcContentByCodonPosition(2, excludeAmbiguous=FALSE )
var_gc_2_amb = sim_data.varGcContentByCodonPosition(2, excludeAmbiguous=TRUE )
var_gc_3 = sim_data.varGcContentByCodonPosition(3, excludeAmbiguous=FALSE )
var_gc_3_amb = sim_data.varGcContentByCodonPosition(3, excludeAmbiguous=TRUE )
n_taxa_50 = sim_data.numTaxaMissingSequence( 0.5 )
n_taxa_30 = sim_data.numTaxaMissingSequence( 0.3 )
n_taxa_10 = sim_data.numTaxaMissingSequence( 0.1 )
theta = fnWattersonsTheta( sim_data )
seg_sites = fnSegregatingSites( sim_data )
tajima_d = fnTajimasD( sim_data )
tajima_pi = fnTajimasPi( sim_data )
mult_lnl = sim_data.computeMultinomialProfileLikelihood()
write(file=outfileName, append=TRUE, sep=",",
i,
num_inv,
num_inv_amb,
max_gc,
max_gc_amb,
min_inv_bl,
min_inv_bl_amb,
max_pd,
max_pd_amb,
max_var_bl,
max_var_bl_amb,
min_gc,
min_gc_amb,
min_pd,
min_pd_amb,
n_inv_b,
n_inv_b_amb,
mean_gc,
mean_gc_amb,
mean_gc_1,
mean_gc_1_amb,
mean_gc_2,
mean_gc_2_amb,
mean_gc_3,
mean_gc_3_amb,
var_gc,
var_gc_amb,
var_gc_1,
var_gc_1_amb,
var_gc_2,
var_gc_2_amb,
var_gc_3,
var_gc_3_amb,
theta,
tajima_d,
tajima_pi,
seg_sites,
mult_lnl)
write(file=outfileName, "\n", append=TRUE)
}
###################
# Summary of data #
###################
outfileName = "results_" + model_name + "/empirical_data_" + analysis_name + ".csv"
write(file=outfileName, sep=",", append=FALSE,
"Number Invariant Sites",
"Number Invariant Sites Excluding Ambiguous",
"Max GC",
"Max GC Excluding Ambiguous",
"Max Invariant Block Length",
"Max Invariant Block Length Excluding Ambiguous",
"Max Pairwise Difference",
"Max Pairwise Difference Excluding Ambiguous",
"Max Variable Block Length",
"Max Variable Block Length Excluding Ambiguous",
"Min GC",
"Min GC Excluding Ambiguous",
"Min Pairwise Difference",
"Min Pairwise Difference Excluding Ambiguous",
"Number Invariable Block",
"Number Invariable Block Excluding Ambiguous",
"Mean GC",
"Mean GC Excluding Ambiguous",
"Mean GC 1",
"Mean GC 1 Excluding Ambiguous",
"Mean GC 2",
"Mean GC 2 Excluding Ambiguous",
"Mean GC 3",
"Mean GC 3 Excluding Ambiguous",
"Var GC",
"Var GC Excluding Ambiguous",
"Var GC 1",
"Var GC 1 Excluding Ambiguous",
"Var GC 2",
"Var GC 2 Excluding Ambiguous",
"Var GC 3",
"Var GC 3 Excluding Ambiguous",
"Theta",
"Segregating-Sites",
"Tajima-D",
"Tajima-Pi",
"Multinomial-Likelihood")
write("\n", file=outfileName, append=TRUE)
num_inv = data.getNumInvariantSites( excludeAmbiguous=FALSE )
num_inv_amb = data.getNumInvariantSites( excludeAmbiguous=TRUE )
max_gc = data.maxGcContent( excludeAmbiguous=FALSE )
max_gc_amb = data.maxGcContent( excludeAmbiguous=TRUE )
min_inv_bl = data.maxInvariableBlockLength( excludeAmbiguous=FALSE )
min_inv_bl_amb = data.maxInvariableBlockLength( excludeAmbiguous=TRUE )
max_pd = data.maxPairwiseDifference( excludeAmbiguous=FALSE )
max_pd_amb = data.maxPairwiseDifference( excludeAmbiguous=TRUE )
max_var_bl = data.maxVariableBlockLength( excludeAmbiguous=FALSE )
max_var_bl_amb = data.maxVariableBlockLength( excludeAmbiguous=TRUE )
min_gc = data.minGcContent( excludeAmbiguous=FALSE )
min_gc_amb = data.minGcContent( excludeAmbiguous=TRUE )
min_pd = data.minPairwiseDifference( excludeAmbiguous=FALSE )
min_pd_amb = data.minPairwiseDifference( excludeAmbiguous=TRUE )
n_inv_b = data.numInvariableBlocks( excludeAmbiguous=FALSE )
n_inv_b_amb = data.numInvariableBlocks( excludeAmbiguous=TRUE )
mean_gc = data.meanGcContent( excludeAmbiguous=FALSE )
mean_gc_amb = data.meanGcContent( excludeAmbiguous=TRUE )
mean_gc_1 = data.meanGcContentByCodonPosition(1, excludeAmbiguous=FALSE )
mean_gc_1_amb = data.meanGcContentByCodonPosition(1, excludeAmbiguous=TRUE )
mean_gc_2 = data.meanGcContentByCodonPosition(2, excludeAmbiguous=FALSE )
mean_gc_2_amb = data.meanGcContentByCodonPosition(2, excludeAmbiguous=TRUE )
mean_gc_3 = data.meanGcContentByCodonPosition(3, excludeAmbiguous=FALSE )
mean_gc_3_amb = data.meanGcContentByCodonPosition(3, excludeAmbiguous=TRUE )
var_gc = data.varGcContent( excludeAmbiguous=FALSE )
var_gc_amb = data.varGcContent( excludeAmbiguous=TRUE )
var_gc_1 = data.varGcContentByCodonPosition(1, excludeAmbiguous=FALSE )
var_gc_1_amb = data.varGcContentByCodonPosition(1, excludeAmbiguous=TRUE )
var_gc_2 = data.varGcContentByCodonPosition(2, excludeAmbiguous=FALSE )
var_gc_2_amb = data.varGcContentByCodonPosition(2, excludeAmbiguous=TRUE )
var_gc_3 = data.varGcContentByCodonPosition(3, excludeAmbiguous=FALSE )
var_gc_3_amb = data.varGcContentByCodonPosition(3, excludeAmbiguous=TRUE )
n_taxa_50 = data.numTaxaMissingSequence( 0.5 )
n_taxa_30 = data.numTaxaMissingSequence( 0.3 )
n_taxa_10 = data.numTaxaMissingSequence( 0.1 )
theta = fnWattersonsTheta( data )
seg_sites = fnSegregatingSites( data )
tajima_d = fnTajimasD( data )
tajima_pi = fnTajimasPi( data )
mult_lnl = data.computeMultinomialProfileLikelihood()
write(file=outfileName, append=TRUE, sep=",",
num_inv,
num_inv_amb,
max_gc,
max_gc_amb,
min_inv_bl,
min_inv_bl_amb,
max_pd,
max_pd_amb,
max_var_bl,
max_var_bl_amb,
min_gc,
min_gc_amb,
min_pd,
min_pd_amb,
n_inv_b,
n_inv_b_amb,
mean_gc,
mean_gc_amb,
mean_gc_1,
mean_gc_1_amb,
mean_gc_2,
mean_gc_2_amb,
mean_gc_3,
mean_gc_3_amb,
var_gc,
var_gc_amb,
var_gc_1,
var_gc_1_amb,
var_gc_2,
var_gc_2_amb,
var_gc_3,
var_gc_3_amb,
theta,
seg_sites,
tajima_d,
tajima_pi,
mult_lnl)
write(file=outfileName, "\n", append=TRUE)