-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheffect-sizes.qmd
278 lines (222 loc) · 8.58 KB
/
effect-sizes.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
---
title: "Polygenic risk score effect sizes"
---
<details>
<summary>Metrics explanation</summary>
<dl>
<dt>AUC</dt>
<dd>Area Under Receiver Operating Characteristic</dd>
<dd>This metric cares only about relative ordering of observations, and is available only for binary traits.</dd>
<dt>β</dt>
<dd>Standardized regression coefficients. For continuous traits, this is the change in the trait (in standard deviations) per standard deviation of the PGS. For binary traits, this is the change in the log-odds per standard deviation of the PGS.</dd>
<dd>This is the metric that was used for meta-analyses.</dd>
<dt>Odds Ratio (OR)</dt>
<dd>This is the change in the odds ratio per standard deviation of the PGS (exp(β))</dd>
<dt>R²</dt>
<dd>This is the variance explained by the PGS on the observed scale for continuous traits, or on the liability scale for binary traits</dd>
</dl>
</details>
This interactive plot corresponds to Figure 2A and Supplementary Figures 1-5 in the published article.
::: {.callout-tip}
We're fetching score and performance metadata from the [PGS Catalog](https://www.pgscatalog.org/rest/). It might take a few seconds to fully load!
:::
```{ojs setup}
//| echo: false
import { aq, op } from '@uwdata/arquero'
d3 = require('d3')
async function* fetchPaginatedData(baseUrl, paramName, paramValue) {
const results = [];
let hasMore = true;
let url = new URL(baseUrl);
// Set the single query parameter
url.searchParams.set(paramName, paramValue);
while (hasMore) {
try {
const response = await d3.json(url.toString());
if (response && response.results) {
results.push(...response.results);
yield results;
if (response.next) {
hasMore = true;
url = new URL(response.next);
} else {
hasMore = false;
}
} else {
hasMore = false;
}
} catch (error) {
console.error("Error fetching data:", error);
hasMore = false;
}
}
}
```
```{ojs, get_performance}
//| echo: false
// parse performance metrics here into a consistent structure
performanceResults = fetchPaginatedData(
"https://www.pgscatalog.org/rest/performance/search",
"pgp_id",
"PGP000517"
);
raw_metrics = aq.from(performanceResults)
.select("id", "associated_pgs_id", "sampleset", "performance_metrics")
.derive({
cohort_name_full: d => d.sampleset.samples[0].cohorts[0].name_full,
cohort_name_short: d => d.sampleset.samples[0].cohorts[0].name_short,
ancestry: d=> d.sampleset.samples[0].ancestry_broad,
effect_sizes: d=> d.performance_metrics.effect_sizes,
othermetrics: d=> d.performance_metrics.othermetrics,
class_acc: d=> d.performance_metrics.class_acc
})
cols = ["id", "associated_pgs_id", "cohort_name_full", "cohort_name_short", "ancestry", "metric_type", "value", "value_ci_lower", "value_ci_upper"]
effect_sizes = raw_metrics
.filter(d => op.length(d.effect_sizes) > 0)
.unroll("effect_sizes")
.derive({
metric_type: d=> d.effect_sizes.name_short,
value: d=> d.effect_sizes.estimate,
value_ci_lower: d=> d.effect_sizes.ci_lower,
value_ci_upper: d=> d.effect_sizes.ci_upper
})
.select(cols)
othermetrics = raw_metrics
.filter(d => op.length(d.othermetrics) > 0)
.unroll("othermetrics")
.derive({
metric_type: d => d.othermetrics.name_short,
value: d=> d.othermetrics.estimate,
value_ci_lower: d=> d.othermetrics.ci_lower,
value_ci_upper: d=> d.othermetrics.ci_upper
})
.select(cols)
class_acc = raw_metrics
.filter(d => op.length(d.class_acc) > 0)
.unroll("class_acc")
.derive({
metric_type: d => d.class_acc.name_short,
value: d=> d.class_acc.estimate,
value_ci_lower: d=> d.class_acc.ci_lower,
value_ci_upper: d=> d.class_acc.ci_upper
})
.select(cols)
```
```{ojs, get_score}
//| echo: false
// parse score data here including method names and tuning types
scoreResults = fetchPaginatedData(
"https://www.pgscatalog.org/rest/score/search",
"pgp_id",
"PGP000517"
);
// notes: method name and tuning type is extracted from the PGS names, which isn't ideal
// recode pt_clump_nested as pt_clump
// UKBB_EnsPGS is always CV
scoreData = aq.from(scoreResults)
.select("id", "name", "trait_reported")
.spread({ name: d => op.split(d.name, '.') }, {as: ["method_name", "tuning_type"], limit: 2})
.derive({ method_name: d => d.method_name === "pt_clump_nested" ? "pt_clump" : d.method_name,
tuning_type: d => d.method_name === "UKBB_EnsPGS" ? "CV" : d.tuning_type })
```
```{ojs, ui_elements}
//| echo: false
//| panel: sidebar
biobank_names = plotData.select("cohort_name_full", "cohort_name_short").dedupe().objects()
viewof biobanks = Inputs.checkbox(biobank_names, {label: "Biobank", format: x => `${x.cohort_name_full} (${x.cohort_name_short})`, value: biobank_names} )
method_names = plotData.select("method_name").dedupe().objects()
viewof methods = Inputs.checkbox(method_names, { label: "Method:", format: x => x.method_name, value: method_names })
ancestry_names = plotData.select("ancestry").dedupe().objects()
viewof ancestries = Inputs.checkbox(ancestry_names, { label: "Genetic ancestry", format: x => x.ancestry, value: ancestry_names})
// some metrics for endpoints have no data, so must be disabled in the UI
metric_names = plotData.select("metric_type").dedupe().objects().map((x) => x.metric_type )
all_available_metrics = plotData.select("metric_type").dedupe()
enabled_metrics = plotData.params(endpoint).filter((d, $) => d.trait_reported == $.trait_reported).select("metric_type")
disabled_metrics = all_available_metrics.dedupe("metric_type").antijoin(enabled_metrics, "metric_type").objects().map((x) => x.metric_type )
viewof chosen_metric = Inputs.radio(metric_names, {label: "Metric", disabled: disabled_metrics, value: "β" })
endpoints = plotData.select("trait_reported").dedupe().objects()
viewof endpoint = Inputs.select(endpoints, {value: endpoints.find(t => t.trait_reported === "Type 2 diabetes (T2D)"), format: x => x.trait_reported, label: "Endpoint:"})
viewof best_method = Inputs.toggle({ label: "Filter best method?:", values: [["best"], ["best", "notbest"]]})
```
```{ojs, filter_data}
//| echo: false
// prepare pgs catalog data for plotting
plotData = effect_sizes.concat(othermetrics, class_acc)
.join_left(scoreData, (a, b) => op.equal(a.associated_pgs_id, b.id), [[aq.all()], ["method_name", "tuning_type", "trait_reported"]])
filtered = plotData.params({ biobanks: biobanks.map((x) => x.cohort_name_short),
methods: methods.map((x) => x.method_name),
ancestry: ancestries.map((x) => x.ancestry),
endpoint: endpoint.trait_reported,
metric_type: chosen_metric,
best_method: best_method
})
.filter((d, $) => op.includes($.biobanks, d.cohort_name_short) &&
op.includes($.methods, d.method_name) &&
op.includes($.ancestry, d.ancestry) &&
$.endpoint === d.trait_reported &&
$.metric_type == d.metric_type)
.groupby(["cohort_name_short", "ancestry", "trait_reported"])
.derive( { best_method: d => d.value == op.max(d.value) ? "best": "notbest" })
.filter((d, $) => op.includes($.best_method, d.best_method ))
```
```{ojs, plot}
//| echo: false
//| panel: fill
Plot.plot({
grid: true,
// make plot accessible for screen readers
ariaLabel: "Explanation of some stuff", // todo: fix
marginTop: 50,
marginLeft: 150,
marginRight: 80,
x: {
label: chosen_metric + " →",
nice: true
},
y: {
label: "Development method"
},
// tableau10 theme, manually assigning each method a colour to be consistent
color: {
domain: ["dbslmm", "sbayesr", "lassosum", "prscs", "ldpred2", "megaprs", "pt_clump", "UKBB_EnsPGS"],
range: ["#5778a4", "#e49444", "#d1615d", "#85b6b2", "#6a9f58", "#e7ca60", "#a87c9f", "#f1a2a9"]
},
symbol: {
legend: true
},
style: {
fontSize: "12px"
},
facet: {
data: filtered,
y: "cohort_name_short",
x: "ancestry",
marginRight: 75,
marginTop: 50
},
fx: {
label: "Genetic ancestry"
},
fy: {
label: "Biobank"
},
marks: [
Plot.frame(),
// link == error bar
Plot.link(filtered, {
x1: "value_ci_lower",
x2: "value_ci_upper",
y1: "method_name",
y2: "method_name"
}),
Plot.dot(filtered, {
x: "value",
y: "method_name",
fill: "method_name",
symbol: "tuning_type"
})
]
})
```
## Conclusion
Using an ensemble of scores, each created using a different PGS development method, can capture a larger effect size for a phenotype. This means that the strength of the relationship between genetic data and phenotype is greater.