-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_02-12_daily_living.qmd
executable file
·242 lines (207 loc) · 6.11 KB
/
_02-12_daily_living.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
## Daily Living {#sec-daily-living}
{{< include _02-12_daily_living_text.qmd >}}
```{r}
#| label: setup-daily_living
#| include: false
# domain
domains <- c("Daily Living")
# phenotype
pheno <- "daily_living"
```
```{r}
#| label: export-daily_living
#| include: false
# Read the CSV file into a data frame
daily_living <- vroom::vroom("neurocog.csv")
# Filter the data frame to keep only rows where 'domain' equals 'domains'
daily_living <- daily_living |> dplyr::filter(domain %in% domains)
daily_living <- daily_living |>
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 resulting data frame to a new CSV file
# If the file already exists, it is overwritten (not appended)
readr::write_excel_csv(daily_living, paste0(pheno, ".csv"), na = "", col_names = TRUE, append = FALSE)
```
```{r}
#| label: data-daily_living
#| include: false
scales <- c(
"Bill Payment",
"Daily Living Memory Delayed Recall",
"Daily Living Memory Delayed Recognition",
"Daily Living Memory Immediate Recall",
"Daily Living Memory Recall vs. Recognition",
"Daily Living Memory Retention",
"Driving Scenes",
"Judgment",
"Map Reading",
"Medication Instructions Delayed Recall",
"Medication Instructions Delayed Recognition",
"Medication Instructions Immediate Recall",
"Name/Address/Phone Delayed Recall",
"Name/Address/Phone Delayed Recognition",
"Name/Address/Phone Immediate Recall"
)
# Filter the data using the filter_data function from the bwu library
data_daily_living <-
bwu::filter_data(
data = daily_living,
domain = domains,
scale = scales
)
```
```{r}
#| label: text-daily_living
#| cache: true
#| include: false
# export text
bwu::cat_neuropsych_results(
data = data_daily_living,
file = "_02-12_daily_living_text.qmd"
)
```
```{r}
#| label: qtbl-daily_living
#| dev: tikz
#| fig-process: pdf2png
#| include: false
#| eval: true
# Set the default engine for tikz to "xetex"
options(tikzDefaultEngine = "xetex")
data_daily_living_tbl <- dplyr::filter(data_daily_living, !is.na(percentile))
ordering_list <- c(
"Driving Scenes",
"Bill Payment",
"Daily Living Memory Immediate Recall",
"Daily Living Memory Delayed Recall",
"Daily Living Memory Retention",
"Daily Living Memory Delayed Recognition",
# "Daily Living Memory Recall vs. Recognition",
"Medication Instructions Immediate Recall",
"Medication Instructions Delayed Recall",
"Medication Instructions Delayed Recognition",
"Name/Address/Phone Immediate Recall",
"Name/Address/Phone Delayed Recall",
"Name/Address/Phone Delayed Recognition",
"Map Reading",
"Judgment"
)
# Process the data
data_daily_living_tbl <- data_daily_living |>
dplyr::filter(scale %in% ordering_list) |>
dplyr::mutate(scale = factor(scale, levels = ordering_list)) |>
dplyr::arrange(scale)
# args
table_name <- "table_daily_living"
vertical_padding <- 0
multiline <- TRUE
# footnotes
fn_t_score <- gt::md("T-score: Mean = 50 [50th‰], SD ± 10 [16th‰, 84th‰]")
source_note <- gt::md("_T_ score: Mean = 50 [50th‰], SD ± 10 [16th‰, 84th‰]")
# Define the groups for the table
grp_daily_living <- list(
t_score = c("NAB Daily Living", "NAB", "NAB-S", "NIH EXAMINER", "NAB Language")
)
# make `gt` table
bwu::tbl_gt(
data = data_daily_living_tbl,
pheno = pheno,
table_name = table_name,
source_note = source_note,
# fn_t_score = fn_t_score,
# grp_t_score = grp_daily_living[["t_score"]],
dynamic_grp = grp_daily_living,
vertical_padding = vertical_padding,
multiline = multiline
)
```
```{r}
#| label: fig-daily-living-subdomain
#| include: false
#| fig-cap: "Daily Living tests evaluate functional abilities required for independent living through ecologically-valid tasks, including bill payment processing, remembering appointments and medication instructions, map navigation, driving awareness, and everyday judgment. These tasks assess how cognitive abilities translate to real-world performance, providing insight into the patient's daily functioning and independence."
# Arguments
colors <- NULL
return_plot <- TRUE
filename <- "fig_daily_living_subdomain.svg"
# variables to plot
x <- data_daily_living$z_mean_subdomain
y <- data_daily_living$subdomain
# Suppress warnings from being converted to errors
options(warn = 1) # Set warn to 1 to make warnings not halt execution
# Make dotplot
bwu::dotplot(
data = data_daily_living,
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.7em)
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)],
caption: figure.caption(position: bottom, [
_Daily Living_ tests evaluate functional abilities required for independent living through ecologically-valid tasks, including bill payment processing, remembering appointments and medication instructions, map navigation, driving awareness, and everyday judgment. These tasks assess how cognitive abilities translate to real-world performance, providing insight into the patient's daily functioning and independence.
]),
placement: none,
kind: "image",
supplement: [*Figure*],
gap: 0.5em,
),
)
}
```
```{=typst}
#let title = "Daily Living"
#let file_qtbl = "table_daily_living.png"
#let file_fig = "fig_daily_living_subdomain.svg"
#domain(
title: [#title Scores],
file_qtbl,
file_fig
)
```