-
Notifications
You must be signed in to change notification settings - Fork 0
/
_02-06_executive.qmd
executable file
·441 lines (406 loc) · 11.3 KB
/
_02-06_executive.qmd
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
## Attention/Executive {#sec-executive}
{{< include _02-06_executive_text.qmd >}}
```{r}
#| label: setup-executive
#| include: false
# Suppress warnings from being converted to errors
options(warn = 1) # Set warn to 1 to make warnings not halt execution
# domain
domains <- c("Attention/Executive")
# Target phenotype
pheno <- "executive"
```
```{r}
#| label: export-executive
#| include: false
# Read the CSV file into a data frame
executive <- vroom::vroom("neurocog.csv")
# Filter the data frame based on certain conditions
# Keep only the rows where 'domain' equals 'domains' and 'z_mean_domain' is not NA
executive <- executive |>
dplyr::filter(domain %in% domains)
# Select specific columns from the data frame
executive <- executive |>
dplyr::select(
test,
test_name,
scale,
raw_score,
score,
ci_95,
percentile,
range,
domain,
subdomain,
narrow,
pass,
verbal,
timed,
description,
result,
z,
z_mean_domain,
z_sd_domain,
z_mean_subdomain,
z_sd_subdomain,
z_mean_narrow,
z_sd_narrow,
z_mean_pass,
z_sd_pass,
z_mean_verbal,
z_sd_verbal,
z_mean_timed,
z_sd_timed
)
# Write the 'executive' data frame to a CSV file
# The file name is derived from the 'pheno' variable
readr::write_excel_csv(executive, paste0(pheno, ".csv"), na = "", col_names = TRUE, append = FALSE)
```
```{r}
#| label: data-executive
#| include: false
# read and filter data
data <- executive
scales <- c(
"Animal Coding",
"Arithmetic",
"Attention Domain",
"Attention Index",
"Auditory Working Memory (AWMI)",
"Bug Search",
"Cancellation Random",
"Cancellation Structured",
"Cancellation",
"Categories",
"Category Fluency",
"Clock Drawing",
"Coding",
"Cognitive Proficiency (CPI)",
"Comprehension",
"CVLT-3 Total Intrusions",
"CVLT-3 Total Repetitions",
"D-KEFS Color Naming",
"D-KEFS Inhibition Total Errors",
"D-KEFS Inhibition",
"D-KEFS Switching Total Errors",
"D-KEFS Switching",
"D-KEFS Word Reading",
"Digit Span Backward",
"Digit Span Forward",
"Digit Span Sequencing",
"Digit Span",
"Digits Backward Longest Span",
"Digits Backward",
"Digits Forward Longest Span",
"Digits Forward",
"Dots",
"Driving Scenes",
"Spatial Addition",
"Executive Functions Domain",
"Judgment",
"Letter Fluency",
"Letter-Number Sequencing",
"List Memory Intrusions",
"List Memory Repetitions",
"Longest Digit Span Backward",
"Longest Digit Span Forward",
"Longest Digit Span Sequence",
"Longest Letter-Number Sequence",
"Mazes",
"NAB Attention Index",
"NAB Executive Functions Index",
"Numbers & Letters Part A Efficiency",
"Numbers & Letters Part A Errors",
"Numbers & Letters Part A Speed",
"Numbers & Letters Part B Efficiency",
"Numbers & Letters Part C Efficiency",
"Numbers & Letters Part D Disruption",
"Numbers & Letters Part D Efficiency",
"Orientation",
"Picture Memory",
"Picture Span",
"Processing Speed (PSI)",
"Processing Speed",
"Psychomotor Speed",
"ROCFT Copy",
"Sentence Repetition",
"Similarities",
"Spatial Span",
"Statue-Body Movement",
"Statue-Eye Opening",
"Statue-Vocalization",
"Statue",
"Symbol Search",
"Symbol Span",
"TMT, Part A",
"TMT, Part B",
"Total Deviation Score",
"Unstructured Task",
"Word Generation Perseverations",
"Word Generation",
"Working Memory (WMI)",
"Working Memory",
"Zoo Locations",
"RBANS Digit Span",
"RBANS Coding"
)
# Filter the data using the filter_data function from the bwu library
# The domain is specified by the 'domains' variable
# The scale is specified by the 'scales' variable
data_executive <- bwu::filter_data(data, domain = domains, scale = scales)
```
```{r}
#| label: text-executive
#| cache: true
#| include: false
# Generate the text for the executive domain
bwu::cat_neuropsych_results(data = data_executive, file = "_02-06_executive_text.qmd")
```
```{r}
#| label: qtbl-executive
#| dev: tikz
#| fig-process: pdf2png
#| include: false
# Set the default engine for tikz to "xetex"
options(tikzDefaultEngine = "xetex")
# more filtering for exe tables
data_executive <-
data_executive |>
dplyr::filter(test_name != "CVLT-3 Brief") |>
dplyr::filter(scale != "Orientation") |>
dplyr::filter(scale %in% c(
"Animal Coding",
"Arithmetic",
"Attention Domain",
"Attention Index",
"Auditory Working Memory (AWMI)",
"Bug Search",
# "Cancellation Random",
# "Cancellation Structured",
"Cancellation",
"Categories",
"Category Fluency",
"Clock Drawing",
"Coding",
"Cognitive Proficiency (CPI)",
"Comprehension",
# "CVLT-3 Total Intrusions",
# "CVLT-3 Total Repetitions",
"D-KEFS Color Naming",
"D-KEFS Inhibition Total Errors",
"D-KEFS Inhibition",
"D-KEFS Switching Total Errors",
"D-KEFS Switching",
"D-KEFS Word Reading",
"Digit Span Backward",
"Digit Span Forward",
"Digit Span Sequencing",
"Digit Span",
"Digits Backward Longest Span",
"Digits Backward",
"Digits Forward Longest Span",
"Digits Forward",
"Dots",
"Driving Scenes",
"Spatial Addition",
"Executive Functions Domain",
"Judgment",
"Letter Fluency",
"Letter-Number Sequencing",
"List Memory Intrusions",
"List Memory Repetitions",
"Longest Digit Span Backward",
"Longest Digit Span Forward",
"Longest Digit Span Sequence",
"Longest Letter-Number Sequence",
"Mazes",
"NAB Attention Index",
"NAB Executive Functions Index",
"Numbers & Letters Part A Efficiency",
# "Numbers & Letters Part A Errors",
# "Numbers & Letters Part A Speed",
"Numbers & Letters Part B Efficiency",
"Numbers & Letters Part C Efficiency",
"Numbers & Letters Part D Disruption",
"Numbers & Letters Part D Efficiency",
"Orientation",
"Picture Memory",
"Picture Span",
"Processing Speed (PSI)",
"Processing Speed",
"Psychomotor Speed",
"ROCFT Copy",
"Sentence Repetition",
"Similarities",
"Spatial Span",
"Statue",
# "Statue-Body Movement",
# "Statue-Eye Opening",
# "Statue-Vocalization",
"Symbol Search",
"Symbol Span",
"TMT, Part A",
"TMT, Part B",
"Total Deviation Score",
"Unstructured Task",
"Word Generation Perseverations",
"Word Generation",
"Working Memory (WMI)",
"Working Memory",
"Zoo Locations"
# add RBANS
))
# table arguments
table_name <- "table_executive"
vertical_padding <- 0
multiline <- TRUE
# footnotes
fn_scaled_score <- gt::md("Scaled score: Mean = 10 [50th‰], SD ± 3 [16th‰, 84th‰]")
fn_standard_score <- gt::md("Standard score: Mean = 100 [50th‰], SD ± 15 [16th‰, 84th‰]")
fn_t_score <- gt::md("_T_-score: Mean = 50 [50th‰], SD ± 10 [16th‰, 84th‰]")
fn_z_score <- gt::md("_z_-score: Mean = 0 [50th‰], SD ± 1 [16th‰, 84th‰]")
# groupings
grp_executive <- list(
scaled_score = c("WAIS-IV", "D-KEFS", "NEPSY-2", "WISC-5", "WISC-V", "WPPSI-IV", "RBANS"),
standard_score = c("NAB", "NAB-S", "WISC-5", "WISC-V", "WAIS-IV", "WPPSI-IV", "WASI-II", "RBANS"),
t_score = c("NAB", "NAB-S", "NIH EXAMINER", "Trail Making Test")
)
# make `gt` table
bwu::tbl_gt(
data = data_executive,
pheno = pheno,
table_name = table_name,
fn_scaled_score = fn_scaled_score,
fn_standard_score = fn_standard_score,
fn_t_score = fn_t_score,
grp_scaled_score = grp_executive[["scaled_score"]],
grp_standard_score = grp_executive[["standard_score"]],
grp_t_score = grp_executive[["t_score"]],
dynamic_grp = grp_executive,
vertical_padding = vertical_padding,
multiline = multiline
)
```
```{r}
#| label: fig-executive-subdomain
#| include: false
#| fig-cap: "Attention and executive functions are essential for successful cognitive functioning, enabling us to perform everyday tasks, handle academic challenges, solve problems, manage our emotions, and interact effectively with others and our environment."
# dotplot arguments
filename <- "fig_executive_subdomain.svg"
colors <- NULL
return_plot <- Sys.getenv("RETURN_PLOT")
# dotplot variables to plot (x, y)
x <- data_executive$z_mean_subdomain
y <- data_executive$subdomain
# Suppress warnings from being converted to errors
options(warn = 1) # Set warn to 1 to make warnings not halt execution
bwu::dotplot(
data = data_executive,
x = x,
y = y,
colors = colors,
return_plot = return_plot,
filename = filename,
na.rm = TRUE
)
# Reset warning options to default if needed
options(warn = 0) # Reset to default behavior
```
```{r}
#| label: fig-executive-narrow
#| include: false
#| fig-cap: "Attention and executive functions are essential for successful cognitive functioning, enabling us to perform everyday tasks, handle academic challenges, solve problems, manage our emotions, and interact effectively with others and our environment."
# dotplot arguments
filename <- "fig_executive_narrow.svg"
colors <- NULL
return_plot <- Sys.getenv("RETURN_PLOT")
# dotplot variables to plot (x, y)
x <- data_executive$z_mean_narrow
y <- data_executive$narrow
bwu::dotplot(
data = data_executive,
x = x,
y = y,
colors = colors,
return_plot = return_plot,
filename = filename,
na.rm = TRUE
)
# Reset warning options to default if needed
options(warn = 0) # Reset to default behavior
```
```{=typst}
#let domain(title: none, file_qtbl, file_fig) = {
let font = (font: "Roboto Slab", size: 0.5em)
set text(..font)
pad(top: 0.5em)[]
grid(
columns: (50%, 50%),
gutter: 8pt,
figure([#image(file_qtbl)],
caption: figure.caption(position: top, [#title]),
kind: "qtbl",
supplement: [Table],
),
figure([#image(file_fig, width: auto)],
caption: figure.caption(position: bottom, [
Attention and executive functions are essential for successful
cognitive functioning, enabling us to perform everyday tasks, handle
academic challenges, solve problems, manage our emotions, and
interact effectively with others and our environment.
]),
placement: none,
kind: "image",
supplement: [Figure],
gap: 0.5em,
),
)
}
```
```{=typst}
#let title = "Attention/Executive"
#let file_qtbl = "table_executive.png"
#let file_fig = "fig_executive_subdomain.svg"
#domain(
title: [#title Scores],
file_qtbl,
file_fig
)
```
```{=typst}
#let domain(title: none, file_qtbl, file_fig) = {
let font = (font: "Roboto Slab", size: 0.5em)
set text(..font)
grid(
columns: (50%, 50%),
gutter: 8pt,
figure([#image(file_qtbl)],
caption: figure.caption(position: top, [#title]),
kind: "qtbl",
supplement: [Table],
),
figure([#image(file_fig, width: auto)],
caption: figure.caption(position: bottom, [
Attention and executive functions are essential for successful
cognitive functioning, enabling us to perform everyday tasks, handle
academic challenges, solve problems, manage our emotions, and
interact effectively with others and our environment.
]),
placement: none,
kind: "image",
supplement: [Figure],
gap: 0.5em,
),
)
}
```
```{=typst}
#let title = "Attention/Executive"
#let file_qtbl = "table_executive.png"
#let file_fig = "fig_executive_narrow.svg"
#domain(
title: [#title Scores],
file_qtbl,
file_fig
)
```