-
Notifications
You must be signed in to change notification settings - Fork 0
/
_02-10_emotion_adult.qmd
317 lines (287 loc) · 6.57 KB
/
_02-10_emotion_adult.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
## Emotional/Behavioral/Personality {#sec-emotion}
{{< include _02-10_emotion_adult_text.qmd >}}
```{r}
#| label: setup-emotion
#| 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(
"Psychiatric Disorders", "Personality Disorders", "Substance Use",
"Psychosocial Problems", "Behavioral/Emotional/Social", "Emotional/Behavioral/Personality"
)
# phenotype
pheno <- "emotion"
```
```{r}
#| label: export-emotion
#| include: false
#| eval: true
# Read the CSV file into a data frame
emotion <- vroom::vroom("neurobehav.csv")
# Filter the data frame based on certain conditions
# Keep only the rows where 'domain' equals 'domains' and 'z_mean_domain' is not NA
emotion <- emotion |>
dplyr::filter(domain %in% domains)
# Select specific columns from the data frame
emotion <- emotion |>
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
)
# Write the 'emotion' data frame to a CSV file
# The file name is derived from the 'pheno' variable
readr::write_excel_csv(emotion, paste0(pheno, ".csv"), na = "", col_names = TRUE, append = FALSE)
```
```{r}
#| label: data-emotion
#| include: false
scales <- c(
"Activity Level",
"Affective (A)",
"Affective (D)",
"Affective Instability",
"Aggression",
"Aggressive Attitude",
"ALC Estimated Score",
"Alcohol Problems",
"Antisocial Behaviors",
"Antisocial Features",
"Anxiety-Related Disorders",
"Anxiety",
"Borderline Features",
"Cognitive (A)",
"Cognitive (D)",
"Conversion",
"Depression",
"Dominance",
"DRG Estimated Score",
"Drug Problems",
"Egocentricity",
"Grandiosity",
"Health Concerns",
"Hypervigilance",
"Identity Problems",
"Irritability",
"Mania",
"Negative Relationships",
"Nonsupport",
"Obsessive-Compulsive",
"Paranoia",
"Persecution",
"Phobias",
"Physical Aggression",
"Physiological (A)",
"Physiological (D)",
"Psychotic Experiences",
"Resentment",
"Schizophrenia",
"Self-Harm",
"Social Detachment",
"Somatic Complaints",
"Somatization",
"Stimulus-Seeking",
"Stress",
"Suicidal Ideation",
"Thought Disorder",
"Traumatic Stress",
"Treatment Rejection",
"Verbal Aggression",
"Warmth",
"BAI Total Score",
"BDI-2 Total Score",
"Activities of Daily Living",
"Adaptability",
"Adaptive Skills",
"Aggression",
"Anxiety",
"Attention Problems",
"Attitude to School",
"Attitude to Teachers",
"Atypicality",
"Behavioral Symptoms Index",
"Conduct Problems",
"Depression",
"Emotional Symptoms Index",
"Externalizing Problems",
"Functional Communication",
"Hyperactivity",
"Inattention/Hyperactivity",
"Internalizing Problems",
"Interpersonal Relations",
"Leadership",
"Locus of Control",
"Personal Adjustment",
"Relations with Parents",
"School Problems",
"Self-Esteem",
"Self-Reliance",
"Sensation Seeking",
"Sense of Inadequacy",
"Social Skills",
"Social Stress",
"Somatization",
"Withdrawal"
)
# 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_emotion <- bwu::filter_data(
data = emotion,
domain = domains,
scale = scales
)
```
```{r}
#| label: text-emotion
#| cache: true
#| include: false
#| eval: true
# Flatten the text
bwu::cat_neuropsych_results(
data = data_emotion,
file = "_02-10_emotion_adult_text.qmd"
)
```
```{r}
#| label: qtbl-emotion
#| dev: tikz
#| fig-process: pdf2png
#| eval: true
#| include: false
options(tikzDefaultEngine = "xetex")
# table arguments
table_name <- "table_emotion"
vertical_padding <- 0
multiline <- TRUE
# Source/footnote
source_note <- gt::md("Score = _T_ score (Mean = 50 [50th‰], SD ± 10 [16th‰, 84th‰])
_Note_: Higher scores reflect reduced functioning")
# groupings
grp_emotion <- list(
t_score = c("PAI", "MMPI-3")
)
data_emotion <-
dplyr::filter(data_emotion, domain %in% c(
"Psychiatric Disorders",
"Personality Disorders",
"Psychosocial Problems",
"Substance Use"
# "Behavioral/Emotional/Social",
# "Emotional/Behavioral/Personality"
)) |>
dplyr::arrange(factor(test_name, levels = c("PAI", "MMPI-3")), subdomain)
# Define the specific order of scales
scale_order <- c(
"Somatic Complaints",
"Anxiety",
"Anxiety-Related Disorders",
"Depression",
"Mania",
"Paranoia",
"Social Detachment",
"Schizophrenia",
"Borderline Features",
"Antisocial Features",
"Alcohol Problems",
"Drug Problems",
"Stress",
"Nonsupport"
)
# Filter and arrange the data in the specified order
data_emotion <- data_emotion |>
dplyr::filter(scale %in% scale_order) |>
dplyr::mutate(scale = factor(scale, levels = scale_order)) |>
dplyr::arrange(scale)
# View the arranged data
print(data_emotion)
# make `gt` table
bwu::tbl_gt(
data = data_emotion,
pheno = pheno,
table_name = table_name,
source_note = source_note,
vertical_padding = vertical_padding,
multiline = multiline
)
```
```{r}
#| label: fig-emotion
#| fig-cap: "Mood/Self-Report"
#| include: false
#| fig-height: 6
#| out-height: 100%
colors <- NULL
return_plot <- Sys.getenv("RETURN_PLOT")
filename <- "fig_emotion.svg"
# arguments
x <- data_emotion$z_mean_subdomain
y <- data_emotion$subdomain
# Make dotplot
bwu::dotplot(
colors = colors,
data = data_emotion,
filename = filename,
na.rm = TRUE,
return_plot = return_plot,
x = x,
y = y
)
```
```{=typst}
#let domain(title: none, file_qtbl, file_fig) = {
let font = (font: "Roboto Slab", size: 0.7em)
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,
[
Emotional, behavioral, and personality scores collapsed across broad domains of functioning.
]),
placement: none,
kind: "image",
supplement: [*Figure*],
gap: 0.5em,
),
)
}
```
```{=typst}
#let title = "Personality Assessment Scores"
#let file_qtbl = "table_emotion.png"
#let file_fig = "fig_emotion.svg"
#domain(
title: [#title],
file_qtbl,
file_fig
)
```