-
Notifications
You must be signed in to change notification settings - Fork 0
/
pairwise.qmd
196 lines (171 loc) · 5.7 KB
/
pairwise.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
---
title: "Pairwise method comparison"
---
<details>
<summary>Difference metric explanation</summary>
<p>Rather than comparing absolute method performance (see [effect sizes](effect-sizes.qmd)), here we compare PGS effect sizes β relative to each other. For this, a baseline PGS against which we compare (baseline method) has to be chosen.</p>
<p>For each PGS with effect size βₓ, we calculate the difference to the baseline method with effect size βᵧ. Confidence intervals are calculated adjusting for the correlation between PGS x and y. These confidence intervals form the basis of significance tests reported in the manuscript.</p>
<p>The "raw" differences (βₓ - βᵧ) are on the same scale as the original effect sizes. Relative differences ((βₓ - βᵧ) / βᵧ) are often reported in methods comparisons, as different phenotypes and target data may have different baseline performance.</p>
</details>
This interactive plot corresponds to Figure 1C in the published article.
```{r setup, echo=FALSE}
library(pgsCompaR)
data(dst) # load data from R package
endpoints <- unique(metrics$phenotype)
# pass data to observable JS
ojs_define(dst)
ojs_define(endpoints)
```
```{ojs}
//| echo: false
//| panel: sidebar
viewof method_y = Inputs.radio(
["dbslmm", "sbayesr", "lassosum", "prscs", "ldpred2", "megaprs", "pt.clump", "UKBB.EnsPRS"],
{ value: ["dbslmm", "sbayesr", "lassosum", "prscs", "ldpred2", "megaprs", "pt.clump", "UKBB.EnsPRS"],
value: "pt.clump",
label: "Baseline method:",
sort: true,
unique: true,
disabled: disable_method_type[method_type]}
)
viewof method_type = Inputs.radio(["CV", "auto"],
{ label: "Tuning method:",
value: "CV"})
viewof endpoint = Inputs.select(endpoints, {value: "T2D", label: "Endpoint:"})
viewof use_relative = Inputs.radio(["relative", "raw"],
{ label: "Difference metric",
value: "relative"})
```
```{ojs}
//| echo: false
//| panel: fill
Plot.plot({
grid: true,
marginLeft: 150,
color: {
domain: ["dbslmm", "sbayesr", "lassosum", "prscs", "ldpred2", "megaprs", "pt.clump", "UKBB.EnsPRS"],
range: ["#5778a4", "#e49444", "#d1615d", "#85b6b2", "#6a9f58", "#e7ca60", "#a87c9f", "#f1a2a9"]
},
symbol: {
legend: true
},
style: {
fontSize: "12px"
},
facet: {
data: eur,
y: "bbid",
marginRight: 75,
},
fy: {
label: "Biobank"
},
x: {
label: x_map[use_relative].get("x_label")
},
y: {
label: "Score development method"
},
marks: [
Plot.frame(),
Plot.link(eur, {
x1: x_map[use_relative].get("error_bar_low"),
x2: x_map[use_relative].get("error_bar_high"),
y1: "method_x",
y2: "method_x"
}),
Plot.text([`EUR`], {
fy: ["bbid"],
frameAnchor: "bottom-right",
lineWidth: 18,
dx: -5,
dy: -5
}),
Plot.ruleX([0], {stroke: "lightgray", strokeWidth: 2, strokeDasharray: "4 2"}),
Plot.dot(eur, {
x: x_map[use_relative].get("x"),
y: "method_x",
fill: "method_x",
symbol: "method_type_x"
})
]
})
Plot.plot({
grid: true,
marginLeft: 150,
color: {
domain: ["dbslmm", "sbayesr", "lassosum", "prscs", "ldpred2", "megaprs", "pt.clump", "UKBB.EnsPRS"],
range: ["#5778a4", "#e49444", "#d1615d", "#85b6b2", "#6a9f58", "#e7ca60", "#a87c9f", "#f1a2a9"]
},
symbol: {
legend: false
},
style: {
fontSize: "12px"
},
facet: {
data: sas,
y: "bbid",
marginRight: 75,
marginTop: 50
},
fy: {
label: "Biobank"
},
x: {
label: x_map[use_relative].get("x_label")
},
y: {
label: "Score development method"
},
marks: [
Plot.frame(),
Plot.dot(sas, {
x: x_map[use_relative].get("x"),
y: "method_x",
fill: "method_x",
symbol: "method_type_x"
}),
Plot.link(sas, {
x1: x_map[use_relative].get("error_bar_low"),
x2: x_map[use_relative].get("error_bar_high"),
y1: "method_x",
y2: "method_x"
}),
Plot.text([`SAS`], {
fy: ["bbid"],
frameAnchor: "bottom-right",
lineWidth: 18,
dx: -5,
dy: -5
}),
Plot.ruleX([0], {stroke: "lightgray", strokeWidth: 2, strokeDasharray: "4 2"})
]
})
```
```{ojs}
//| echo: false
beta_map = new Map([["x_label", "βₓ - βᵧ"], ["x", "beta_diff"], ["error_bar_low", "ci_low_diff"], ["error_bar_high", "ci_high_diff"]])
relative_map = new Map([["x_label", "(βₓ - βᵧ) / βᵧ"], ["x", "relative_beta_diff"], ["error_bar_low", "relative_ci_low_diff"], ["error_bar_high", "relative_ci_high_diff"]])
x_map = ({ "relative": relative_map, "raw": beta_map })
// some methods only have one method type, so disable the radio button
disable_method_type = ({ "CV": ["prscs", "sbayesr", "dbslmm"], "auto": ["UKBB.EnsPRS"]})
```
```{ojs}
//| echo: false
import { aq, op } from '@uwdata/arquero'
filtered = aq.fromJSON(dst)
.select("method_x", "bbid", "ancestry", "method_x", "method_type_x", "beta_diff", "beta_y", "ci_low_diff", "ci_high_diff", "phenotype", "method_y", "method_type_y")
.derive({ relative_beta_diff: d => d.beta_diff / d.beta_y,
relative_ci_high_diff: d => d.ci_high_diff / d.beta_y,
relative_ci_low_diff: d => d.ci_low_diff / d.beta_y })
.params({endpoint: endpoint, method_y: method_y, method_type: method_type})
.filter((d, $) => op.includes($.method_type, d.method_type_y ) &&
op.includes($.method_y, d.method_y) &&
op.includes($.endpoint, d.phenotype ))
// need to filter before plotting to prevent empty facets appearing
eur = filtered.filter(d => d.ancestry == "EUR")
sas = filtered.filter(d => d.ancestry == "SAS")
```
## Conclusion
If you're using [pt.clump](glossary.html) (without cross validation) to develop new polygenic risk scores for type 2 diabetes, you could make a better score by using any of the other tested methods.