-
Notifications
You must be signed in to change notification settings - Fork 0
/
_03-00_sirf.qmd
executable file
·195 lines (177 loc) · 3.78 KB
/
_03-00_sirf.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
# SUMMARY/IMPRESSION {#sec-sirf}
```{r}
#| label: make-g
#| include: false
#| eval: false
scales <- c(
"Academic Skills",
"Attention",
"Attention Span",
"Attention/Executive",
"Attentional Fluency",
"Cognitive Efficiency",
"Cognitive Proficiency",
"Crystallized Knowledge",
"Delayed Recall",
"Executive Functions",
"Global Neurocognitive Index (G)",
"Verbal Fluency",
"Fluid Reasoning",
"General Ability",
"Learning Efficiency",
"Memory",
"Planning",
"Processing Speed",
"Psychomotor Speed",
"Verbal/Language",
"Visual Perception/Construction",
"Working Memory",
"Reading",
"Math",
"Writing",
"Academic Fluency"
)
# make g
g <-
readxl::read_excel("data/index_scores.xlsx") |>
janitor::clean_names() |>
dplyr::mutate(z = (index - 100) / 15) |>
dplyr::filter(composite_name %in% scales) |>
dplyr::rename(
scale = composite_name,
score = index,
ci_95 = x95_percent_ci
) |>
dplyr::mutate(
test = "index_score",
test_name = "Composite Scores",
domain = "General Cognitive Ability",
subdomain = scale,
test_type = "npsych_test"
) |>
bwu::gpluck_make_score_ranges(range = "", test_type = "npsych_test") |>
dplyr::select(
scale,
score,
ci_95,
z,
percentile,
range,
test,
test_name,
domain,
subdomain,
test_type,
reliability,
composition
)
# save g.csv
readr::write_csv(g, "data/csv/g.csv")
```
```{r}
#| label: fig-sirf
#| include: false
#| eval: true
#| fig-cap: "Overall neurocognitive function subdomain plots of the patient's strengths and weaknesses. _Note:_ _z_-Scores have a mean of 0 and a standard deviation of 1."
g <- vroom::vroom("data/csv/g.csv")
# scales
keep <- c(
"General Ability",
"Academic Skills",
"Fluid Reasoning",
# "Attention/Executive",
"Attention",
"Attention Span",
"Attentional Fluency",
"Cognitive Efficiency",
# "Cognitive Proficiency",
"Crystallized Knowledge",
"Executive Functions",
# "Global Neurocognitive Index (G)",
"Verbal Fluency",
"Delayed Recall",
"Learning Efficiency",
# "Memory",
"Planning",
# "Processing Speed",
"Psychomotor Speed",
"Verbal/Language",
"Visual Perception/Construction",
"Working Memory",
"Reading",
"Math",
"Writing",
"Academic Fluency"
)
g <- dplyr::filter(g, scale %in% keep)
g <- g[complete.cases(g$z), ]
pheno <- "g"
data <- g
x <- g$z
y <- g$scale
colors <- NULL
return_plot <- Sys.getenv("RETURN_PLOT")
filename <- "fig_g.svg"
bwu::dotplot(
data = g,
x = x,
y = y,
colors = colors,
return_plot = return_plot,
filename = filename
)
```
```{r}
#| label: fig-domains
#| include: false
#| eval: true
#| fig-cap: "Broad cognitive domains"
# args
data <- vroom::vroom("neurocog.csv")
data2 <- dplyr::filter(data, scale != "Cognitive Proficiency")
data2 <-
data2 |>
dplyr::group_by(domain, .add = TRUE) |>
dplyr::mutate(z_mean_domain = mean(z), z_sd_domain = sd(z)) |>
dplyr::ungroup()
x2 <- data2$z_mean_domain
y2 <- data2$domain
colors <- NULL
return_plot <- Sys.getenv("RETURN_PLOT")
filename <- "fig_domains.svg"
# Make dotplot
bwu::dotplot(
data = data2,
x = x2,
y = y2,
colors = colors,
return_plot = return_plot,
filename = filename
)
```
```{=typst}
#let domain(file_fig) = {
let font = (font: "Roboto Slab", size: 0.5em)
set text(..font)
figure(
[#image(file_fig, width: 85%)],
placement: none,
caption: figure.caption(
position: bottom,
[Overall neurocognitive function subdomain plots of the patient's strengths and
weaknesses. _Note:_ _z_-scores have a mean of 0 and a standard deviation of 1.],
),
kind: "image",
supplement: [Figure],
gap: 0.5em,
)
}
```
```{=typst}
#let file_fig = "fig_g.svg"
#domain(file_fig)
```
```{=typst}
#let file_fig = "fig_domains.svg"
#domain(file_fig)
```