-
Notifications
You must be signed in to change notification settings - Fork 0
/
summary_covid_dbs_samples.Rmd
303 lines (238 loc) · 7.15 KB
/
summary_covid_dbs_samples.Rmd
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
---
title: "Covid19 DBS Olink sample summary"
author: "Creator: Tea Dodig-Crnkovic"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
html_document:
toc: true
code_folding: hide
toc_float:
collapsed: false
---
<!-- highlight: textmate -->
<!-- Edit TOC style (background color) -->
<style>
.list-group-item.active, .list-group-item.active:focus, .list-group-item.active:hover {
background-color: #EAEAEA;
color: black;}
</style>
<!-- Set background color for highlighted text -->
<style>
div.highlight {
background-color: #EAEAEA; <!-- #39AC91 (turquoise) -->
color: #FFFFEF;
padding: 10px;
border-radius: 2px 2px 2px 2px;}
</style>
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, tidy=FALSE)
```
<style type="text/css">
h1.title {
font-size: 22px;
}
h1 { /* Header 1 */
font-size: 18px;
}
h2 { /* Header 2 */
font-size: 15px;
}
h3 { /* Header 3 */
font-size: 12px;
}
</style>
***
# Description
<div class = "highlight">
Summary of samples included in Covid19 DBS Olink panels CVD3, MET and CAM.
* Frequency table, demographics and meta data
</div>
***
# Initialization
```{r initialization, eval=T, warning=F}
# empty global environment
rm(list = ls(all.names = TRUE))
```
# Load packages
```{r packages, eval=T, warning=F, message=FALSE}
# load packages
library(tidyverse)
library(DT)
library(table1)
```
***
# Load files
```{r pathways, eval=t}
source("load_cov_npx.R")
cov_npx <- load_cov_npx("abspqn_excl")
data_set <- cov_npx$data_set
data_file_path <- cov_npx$data_path
```
Loaded data set **`r cov_npx$data_set`**
from **`r cov_npx$data_path`**, with the following treatment:
`r cov_npx$norm`
***
# Select data
```{r data_selection, eval=t}
# select input data
dat <- cov_npx
sinfo <- as.data.frame(dat$sinfo)
binder <- as.data.frame(dat$binder)
npx <- as.matrix(dat$npx)
norm_info <- cov_npx$norm
# select samples and binders to include
selected_samples <- sinfo$sample_id
selected_binders <- binder$unique_id
samp_info <- paste0("Samples n=", dim(npx[selected_samples, selected_binders])[1])
binder_info <- paste0("Binders n=", dim(npx[selected_samples, selected_binders])[2])
```
```{r}
ds3 <- load_cov_npx(paste0("ds3_", cov_npx$data_set))
sinfo_ds3 <- ds3$sinfo %>% rename(Analysis_group = grp)
npx_ds3 <- ds3$npx
sinfo_ds3 <- sinfo_ds3 %>% filter(sample_id %in% npx_ds3$sample_id)
binder_ds3 <- ds3$binfo
```
***
**Data options**
*Data set*:
`r cov_npx$data_set`
*Data set input file*:
`r cov_npx$data_path`
*Data set notes*:
`r norm_info`
*Number of samples included:*
`r samp_info`
*Number of binders included:*
`r binder_info`
***
# Frequency tables (demographics)
```{r fig.align='center', warning=F}
# only inlcude unique population participant samples (remove duplicates)
dat <- sinfo %>%
filter(grp == "Population" | grp == "Bridge") %>%
filter(!c(grp == "Bridge" & Analysis_date == "2020-11-13")) %>% # only keep bridge info from first Olink run
select(Sex,
Age_grp,
Symptom,
Breath,
Positive,
serostatus,
unique_participant_ID,
umap_seropositive_IgG_IgM,
Analysis_date,
Population_batch,
Analysis_group) %>%
distinct() %>%
mutate(serostatus = case_when(serostatus == "no reactivity" ~ "Seronegative, IgM-IgG-",
serostatus == "IgG + IgM" ~ "Seropositive, IgM+IgG+",
serostatus == "IgM" ~ "Early phase, IgM+IgG-",
serostatus == "IgG" ~ "Late phase, IgM-IgG+"))
# dat$p_val <- NA
dat$Analysis_group <- factor(dat$Analysis_group)
dat <-
dat %>% as_tibble()
label(dat$Sex) <- "Sex"
label(dat$Age_grp) <- "Age group"
label(dat$Symptom) <- "Symptom"
label(dat$Breath) <- "Breath"
label(dat$Positive) <- "Positive"
label(dat$serostatus) <- "Seropositivity group"
label(dat$umap_seropositive_IgG_IgM) <- "UMAP seropositive"
label(dat$Analysis_date) <- "Analysis date in lab"
label(dat$Population_batch) <- "Population batch"
label(dat$Analysis_group) <- "Analysis group"
# label(dat$p_val) <- "P value"
rndr <- function(x, name, ...) {
if (length(x) == 0) {
y <- tg[[name]]
s <- rep("", length(render.default(x=y, name=name, ...)))
p <- fisher.test(table(y, droplevels(tg$serostatus), useNA = "no"))$p.value
s[2] <- sub("<", "<", format.pval(p, digits=3, eps=0.001))
s
} else {
render.default(x=x, name=name, ...)
}
}
rndr.strat <- function(label, n, ...) {
ifelse(n==0, label, render.strat.default(label, n, ...))
}
```
## UMAP group
```{r fig.align='center', warning=F}
# UMAP analysis group
tg <- dat %>%
filter(Analysis_group == "UMAP_1" | Analysis_group == "UMAP_0") %>%
mutate(serostatus = factor(serostatus, levels = c(sort(unique(.$serostatus)), "P-value")))
table1(~ Sex +
Age_grp +
Symptom +
Breath +
Population_batch | serostatus, data=tg,
droplevels=F, render= rndr, render.strat=rndr.strat, overall=F)
```
## SPK group
```{r fig.align='center', warning=F}
# SPK analysis group
tg <- dat %>%
filter(str_detect(Analysis_group, "SPK")) %>%
mutate(serostatus = factor(serostatus, levels = c(sort(unique(.$serostatus)), "P-value")))
table1(~ Sex +
Age_grp +
Symptom +
Breath +
Population_batch | serostatus, data=tg,
droplevels=F, render= rndr, render.strat=rndr.strat, overall=F)
```
## Dataset 3
```{r}
# Make table for the table1 table
tg <- sinfo_ds3 %>%
filter(!str_detect(sample_id, "_[:alpha:]")) %>%
select(sex, age_group, symptoms, Analysis_group) %>%
mutate(Analysis_group = case_when(Analysis_group == "Negative" ~ "Seronegative, IgG-",
Analysis_group == "Positive" ~ "Seropositive, IgG+")) %>%
mutate(Analysis_group = factor(Analysis_group, levels = c(
sort(unique(as.character(Analysis_group))), "P-value"
))) %>%
rename(serostatus = Analysis_group)
label(tg$sex) <- "Sex"
label(tg$age_group) <- "Age group"
label(tg$symptoms) <- "Symptoms"
table1(~ sex + age_group + symptoms | serostatus, data = tg,
droplevels = F, render = rndr, render.strat = rndr.strat, overall = F)
```
## UMAP vs SPK group
```{r fig.align='center', warning=F}
# UMAP vs SPK analysis group
tg <- dat %>%
mutate(Analysis_date = factor(Analysis_date, levels = c("2020-06-23", "2020-11-13","P-value")))
rndr <- function(x, name, ...) {
if (length(x) == 0) {
y <- tg[[name]]
s <- rep("", length(render.default(x=y, name=name, ...)))
p <- fisher.test(table(y, droplevels(tg$Analysis_date), useNA = "no"))$p.value
s[2] <- sub("<", "<", format.pval(p, digits=3, eps=0.001))
s
} else {
render.default(x=x, name=name, ...)
}
}
rndr.strat <- function(label, n, ...) {
ifelse(n==0, label, render.strat.default(label, n, ...))
}
table1(~ Sex +
Age_grp +
Symptom +
Breath +
Analysis_group +
serostatus +
Population_batch | Analysis_date, data=tg,
droplevels=F, render= rndr, render.strat=rndr.strat, overall=F,
footnote = "All population participants with their single sample included here")
```
***
# Session information
```{r session_info, eval=T, echo=F}
sessionInfo()
```