-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsex_age_bmi_associated_proteins.Rmd
3917 lines (3382 loc) · 151 KB
/
sex_age_bmi_associated_proteins.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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "CHRIS MS-based plasma proteome: general overview and sex, age, BMI and medication associated proteins"
author: "Nikola Dordevic, Clemens Dierks, Essi Hantikainen, Johannes Rainer"
graphics: yes
output:
BiocStyle::html_document:
toc_float: true
code_folding: hide
bibliography: references.bib
---
**Modified**: `r file.info("sex_age_bmi_associated_proteins.Rmd")$mtime`<br />
**Compiled**: `r date()`
```{r biocstyle, echo = FALSE, results = "hide", message = FALSE}
#' rmarkdown format settings
library(BiocStyle)
library(knitr)
BiocStyle::markdown()
```
```{r settings, echo = FALSE}
#' General settings
filename <- "sex_age_bmi_associated_proteins"
#' Path to save images to
IMAGE_PATH <- paste0("images/", filename, "/")
if (file.exists(IMAGE_PATH))
unlink(IMAGE_PATH, recursive = TRUE)
dir.create(IMAGE_PATH, recursive = TRUE)
#' Path to store RData files
RDATA_PATH <- paste0("data/RData/", filename, "/")
dir.create(RDATA_PATH, recursive = TRUE, showWarnings = FALSE)
#' wheter interactive plots should be used. Should be set to FALSE if report
#' is to be shared with external researchers.
PLOTLY <- FALSE
ggplotly_or_not <- function(x, interactive = TRUE) {
if (interactive) ggplotly(x)
else print(x)
}
opts_chunk$set(message = FALSE, warning = FALSE, fig.width = 8,
fig.height = 7, fig.path = IMAGE_PATH)
chris_path <- "."
```
# Introduction
This document provides a general description of the ScanningSWATH mass
spectrometry (MS)-based plasma proteome data set of the CHRIS population study
[@Pattaro:2015fu] and describes the analysis to identify plasma proteins that
are associated to age, sex and body mass index (BMI). The analysis is performed
similarly to the analysis for the identification of age, sex and BMI-associated
metabolites [@verri_hernandes_age_2022] but in addition, influence of (frequent)
medication on the quantified plasma proteome is evaluated.
The document and repository does not provide any data. Access to any individual
level data, including the mass spectrometry data, needs to be requested through
the CHRIS Access Committee.
# Data import
Below we load the data and all required libraries. The data is loaded from the
CHRIS *TDFF* modules (i.e. the data file format in which CHRIS study data is
internally stored). Most used packages are available either on
[CRAN](https://cran.r-project.org/) or [Bioconductor](https://bioconductor.org)
and can be installed using the `BiocManager::install` function. Exceptions are
the following packages that can be installed from github:
- [*tidyfr*](https://github.com/EuracBiomedicalResearch/tidyfr): can be
installed with `BiocManager::install("EuracBiomedicalResearch/tidyfr")`.
- [*atc*](https://github.com/jorainer/atc): can be installed with
`BiocManager::install("jorainer/atc")`.
- [*CompMetaboTools*](https://github.com/EuracBiomedicalResearch/CompMetaboTools):
can be installed with
`BiocManager::install("EuracBiomedicalResearch/CompMetaboTools")`.
Data packages (*chrisData* and *chrisUtils*) and the ScanningSWATH TDFF data
module *chris_scanningswath_proteins* are not publicly available. Any such data
access needs to got through a *CHRIS Access Committee* request.
```{r data-libraries}
library(chrisUtils)
library(chrisData)
library(RColorBrewer)
library(pander)
library(pheatmap)
library(DT)
library(ggfortify)
library(ggplot2)
library(ggpubr)
library(reshape2)
library(plotly)
options(rgl.useNULL = TRUE)
library(rgl)
library(readxl)
library(writexl)
library(tidyfr)
library(MatchIt)
library(pROC)
#' Load the CHRIS plasma proteomics data module
mdl <- data_module("chris_scanningswath_proteins", "1.0.0.1", chris_path)
prot_data <- data(mdl)
prot_ann <- labels(mdl)
stopifnot(all(colnames(prot_data) == rownames(prot_ann)))
colnames(prot_data) <- prot_ann$description
rownames(prot_ann) <- prot_ann$description
#' define the columns with protein concentrations
proteins <- rownames(prot_ann)[prot_ann$Genes != ""]
```
Before proceeding with the data analysis we remove the POOL samples. In addition
we restrict to samples from the CHRIS study (i.e., remove the samples from the
NAFLD sub-study).
```{r remove-POOLs-NAFLDs, message = FALSE, warning = FALSE}
prot_data <- prot_data[grep("^001", rownames(prot_data)), ]
```
Next we define the various variables which will be included in the analysis. The
related trait information is extracted from the `chrisData` R package.
First we define and add the BMI data, both as a numeric value, but also using
the BMI categories. For the BMI categories we are using *2* (18.5 - <25) as
baseline since that is supposed to be the *normal*.
```{r define-variables-bmi, message = FALSE, warning = FALSE}
clin <- chrisData("clinical")
rownames(clin) <- clin$AID
#' Adding this information to the colData
prot_data$BMI <- clin[rownames(prot_data), "x0an03q"]
prot_data$BMIcat <- factor(as.integer(clin[rownames(prot_data), "x0an03b"]),
levels = c("2", "1", "3", "4"))
```
We also define the season in which samples were collected from the study
participants and add the age and sex information for each study participant.
```{r define-variables-general-info, message = FALSE}
#' add here phenotype data from chrisData and recalculate season from exam day
gen_info <- chrisData("general_information", release = "baseline")
rownames(gen_info) <- gen_info$AID
prot_data$Sex <- gen_info[rownames(prot_data), "x0_sex"]
prot_data$Age <- gen_info[rownames(prot_data), "x0_age"]
```
Import information for pregnancy:
```{r define-variables-pregnant, message = FALSE}
interview_info <- chrisData("interview", release = "baseline")
rownames(interview_info) <- interview_info$AID
#' Add pregnancy information
prot_data$Pregnant <- interview_info[rownames(prot_data), "x0wo05"]
```
A categorical variable for fasting status is defined based self-reported data
from the participants' interview.
```{r define-variables-fasting, message = FALSE}
#' add number of people reporting fasting status (`x0bc12` from `chrisData`
#' `"labdata"`)
labdata_info <- chrisData("labdata", release = "baseline")
rownames(labdata_info) <- labdata_info$AID
prot_data$Fasting <- labdata_info[rownames(prot_data), "x0bc12"]
```
At last we load also the medication data which might be used later to test for
potential confounding.
```{r}
#' Load medication data
medi <- chrisData("drugs_1")
library(atc)
```
Create additional variable for age! Coefficients and effect sizes correspond to
one year difference. Dividing age with 10, difference in coefficents and effect
sizes would correspond to 10 years difference and it would be easier to define
meaningful cut-off!
```{r define-age10-variable, message = FALSE}
prot_data$Age_10 <- prot_data$Age/10
```
# General data overview
In resulting dataset, there are `r nrow(prot_data)` samples in total and
general overview of the trait is summarized below:
```{r, message=FALSE}
Overview <- summary(
prot_data[, c("Sex", "Fasting", "Age", "Age_10", "BMIcat",
"Pregnant", "Fasting")])
print(Overview)
```
We further remove all individuals with missing values for any of the required
variables (age, sex, fasting and BMI) as well as pregnant women.
```{r}
nas <- is.na(prot_data[, c("Sex", "Fasting", "Age", "BMIcat")])
prot_data <- prot_data[rowSums(nas) == 0, ]
## remove pregnant women
rem <- c(which(prot_data$Pregnant == "Yes"),
which(prot_data$Pregnant == "Don't know, possible"))
prot_data <- prot_data[-rem, ]
```
Summary for the final data set.
```{r}
prot_data[, c("Sex", "Fasting", "Age", "Age_10", "BMIcat",
"Pregnant", "Fasting")] %>% summary()
```
This reduces the data set to `r nrow(prot_data)` individuals.
We next evaluate the variance of protein abundances observed in the present data
set (study samples).
```{r}
#' Calculate CV for proteins across study samples
cv_study <- vapply(prot_data[proteins], function(z) {
z <- 2^z
(sd(z, na.rm = TRUE) / mean(z, na.rm = TRUE)) * 100
}, numeric(1))
cv_rel <- cv_study / (prot_ann[proteins, "cv_qc_chris"] * 100)
```
Top 30 proteins with highest absolute CV in study samples are listed in the
table below.
```{r, results = "asis"}
tab <- data.frame(
Genes = prot_ann[proteins, "Genes"],
cv_qc_chris = prot_ann[proteins, "cv_qc_chris"] * 100,
cv_study = cv_study,
cv_rel = cv_rel)
tab_sub <- tab[order(tab$cv_study, decreasing = TRUE), ][1:30, ]
pandoc.table(tab_sub, caption = "Top 30 proteins with largest CV.",
style = "rmarkdown", split.table = Inf)
```
In contrast, the proteins with the lowest absolute CV:
```{r, results = "asis"}
tab_sub <- tab[order(tab$cv_study), ][1:30, ]
pandoc.table(tab_sub, caption = "Top 30 proteins with smallest CV.",
style = "rmarkdown", split.table = Inf)
```
Proteins with highest relative CV.
```{r, results = "asis"}
tab_sub <- tab[order(tab$cv_rel, decreasing = TRUE), ][1:30, ]
pandoc.table(tab_sub, caption = "Top 30 proteins with largest relative CV.",
style = "rmarkdown", split.table = Inf)
```
Proteins with the lowest relative CV.
```{r, results = "asis"}
tab_sub <- tab[order(tab$cv_rel, decreasing = FALSE), ][1:30, ]
pandoc.table(tab_sub, caption = "Top 30 proteins with smallest relative CV.",
style = "rmarkdown", split.table = Inf)
```
We next perform a principal component analysis to group participants based on
their plasma proteome. Samples are colored according to their sex. Prior the
PCA, data is normalized to 0 mean and standard deviation of 1 (autoscaling). The
plot below shows the scores and loadings of all subjects in the space of the
first two PCs, with 15% of total variances explained.
```{r PCA_1_figure, fig.path = IMAGE_PATH, fig.width=12, fig.height=7}
## include age in PCA
scaledData <- scale(prot_data[, proteins], scale = TRUE)
scPCA <- svd(scaledData)
scPCA.scores <- scPCA$u %*% diag(scPCA$d) ## scores
scPCA.loadings <- scPCA$v ## loadings
rownames(scPCA.loadings) <- proteins
scPCA.variances <- round(100*((scPCA$d^2) / sum(scPCA$d^2)), 1)[1:10]
Sex <- prot_data$Sex
gg_1 <- autoplot(prcomp(scaledData), data = prot_data,
loadings = TRUE, loadings.colour = 'gray',
loadings.label = TRUE, loadings.label.size = 3,
loadings.label.colour ="darkblue", colour = NA) +
geom_point(aes(colour = Sex)) +
theme_bw()
ggplotly_or_not(gg_1, PLOTLY)
```
```{r FIGURE_1_MANUSCRIPT}
#' FIGURE 1
#' Transparency for protein names depending on arrow length?
png("images/manuscript/Figure_1.png", width = 15, height = 5, units = "cm",
res = 600, pointsize = 4, type = "cairo-png")
pc_all <- prcomp(scaledData)
library(CompMetaboTools)
cols <- rep("#E41A1C", nrow(prot_data))
cols[prot_data$Sex == "Male"] <- "#377EB8"
par(mfrow = c(1, 3), mar = c(4.5, 4.5, 0.5, 0.7), cex.lab = 2, bty = "n",
cex.axis = 1.5, las = 1)
plot_pca(pc_all, pch = NA, xlim = c(-16, 9))
mtext(side = 3, outer = FALSE, text = "a", cex = 3, at = -18, line = -4.0)
points(pc_all$x[, 1], pc_all$x[, 2], pch = 21, col = paste0(cols, 80),
bg = paste0(cols, 60), cex = 1.5)
plot_pca(pc_all, pch = NA, col = NA, xlim = c(-16, 9))
mtext(side = 3, outer = FALSE, text = "b", cex = 3, at = -18, line = -4.0)
unsigned.range <- function(x)
c(-abs(min(x, na.rm = TRUE)), abs(max(x, na.rm = TRUE)))
y <- pc_all$rotation[, 1:2]
scl <- max(
unsigned.range(y[, 1]) / unsigned.range(pc_all$x[, 1]),
unsigned.range(y[, 2]) / unsigned.range(pc_all$x[, 2]))
a_lengths <- sqrt(y[, 1]^2 + y[, 2]^2)
y <- y / scl
arrows(x0 = 0, x1 = y[, 1],
y0 = 0, y1 = y[, 2],
lwd = 0.75, angle = 30, length = 0.05,
col = "#00000050")
text(y[, 1] * 1.1, y[, 2] * 1.1, labels = prot_ann[rownames(y), "Genes"],
col = "#00000080", cex = 1.4)
## Correlation PC1 and age.
pc_s <- summary(pc_all)
plot(pc_all$x[, 1], prot_data$Age, pch = 21, col = paste0(cols, 80),
bg = paste0(cols, 60), cex = 1.5, xlim = c(-16, 9),
xlab = paste0("PC1: ", format(pc_s$importance[2, 1] * 100, digits = 3),
" % variance"), ylab = "Age")
mtext(side = 3, outer = FALSE, text = "c", cex = 3, at = -18, line = -4.0)
grid()
dev.off()
## Males only
png("images/manuscript/supplement/Figure_1_male.png", width = 15, height = 5,
units = "cm", res = 600, pointsize = 4, type = "cairo-png")
idx <- which(prot_data$Sex == "Male")
pc <- prcomp(scale(prot_data[idx, proteins], scale = TRUE))
par(mfrow = c(1, 3), mar = c(4.5, 4.5, 0.5, 0.5), cex.lab = 2, bty = "n",
cex.axis = 1.5, las = 1)
plot_pca(pc, pch = NA, xlim = c(-16, 12), ylim = c(-11, 12))
mtext(side = 3, outer = FALSE, text = "A", cex = 3, at = -18, line = -4.0)
points(pc$x[, 1], pc$x[, 2], pch = 21, col = paste0(cols[idx], 80),
bg = paste0(cols[idx], 60), cex = 1.5)
plot_pca(pc, pch = NA, col = NA, xlim = c(-16, 12), ylim = c(-11, 12))
mtext(side = 3, outer = FALSE, text = "B", cex = 3, at = -18, line = -4.0)
unsigned.range <- function(x)
c(-abs(min(x, na.rm = TRUE)), abs(max(x, na.rm = TRUE)))
y <- pc$rotation[, 1:2]
scl <- max(
unsigned.range(y[, 1]) / unsigned.range(pc$x[, 1]),
unsigned.range(y[, 2]) / unsigned.range(pc$x[, 2]))
a_lengths <- sqrt(y[, 1]^2 + y[, 2]^2)
y <- y / scl
arrows(x0 = 0, x1 = y[, 1],
y0 = 0, y1 = y[, 2],
lwd = 0.75, angle = 30, length = 0.05,
col = "#00000050")
text(y[, 1] * 1.1, y[, 2] * 1.1, labels = prot_ann[rownames(y), "Genes"],
col = "#00000080", cex = 1.4)
## Correlation PC1 and age.
pc_s <- summary(pc)
plot(pc$x[, 1], prot_data$Age[idx], pch = 21, col = paste0(cols[idx], 80),
bg = paste0(cols[idx], 60), cex = 1.5,
xlab = paste0("PC1: ", format(pc_s$importance[2, 1] * 100, digits = 3),
" % variance"), ylab = "Age", xlim = c(-16, 12))
mtext(side = 3, outer = FALSE, text = "C", cex = 3, at = -18, line = -4.0)
grid()
dev.off()
## Females only
png("images/manuscript/supplement/Figure_1_female.png", width = 15, height = 5,
units = "cm", res = 600, pointsize = 4, type = "cairo-png")
idx <- which(prot_data$Sex == "Female")
pc <- prcomp(scale(prot_data[idx, proteins], scale = TRUE))
par(mfrow = c(1, 3), mar = c(4.5, 4.5, 0.5, 0.5), cex.lab = 2, bty = "n",
cex.axis = 1.5, las = 1)
plot_pca(pc, pch = NA, xlim = c(-16, 9))
mtext(side = 3, outer = FALSE, text = "A", cex = 3, at = -18, line = -4.0)
points(pc$x[, 1], pc$x[, 2], pch = 21, col = paste0(cols[idx], 80),
bg = paste0(cols[idx], 60), cex = 1.5)
plot_pca(pc, pch = NA, col = NA, xlim = c(-16, 9), ylim = c(-11, 12))
mtext(side = 3, outer = FALSE, text = "B", cex = 3, at = -18, line = -4.0)
unsigned.range <- function(x)
c(-abs(min(x, na.rm = TRUE)), abs(max(x, na.rm = TRUE)))
y <- pc$rotation[, 1:2]
scl <- max(
unsigned.range(y[, 1]) / unsigned.range(pc$x[, 1]),
unsigned.range(y[, 2]) / unsigned.range(pc$x[, 2]))
a_lengths <- sqrt(y[, 1]^2 + y[, 2]^2)
y <- y / scl
arrows(x0 = 0, x1 = y[, 1],
y0 = 0, y1 = y[, 2],
lwd = 0.75, angle = 30, length = 0.05,
col = "#00000050")
text(y[, 1] * 1.1, y[, 2] * 1.1, labels = prot_ann[rownames(y), "Genes"],
col = "#00000080", cex = 1.4)
## Correlation PC1 and age.
pc_s <- summary(pc)
plot(pc$x[, 1], prot_data$Age[idx], pch = 21, col = paste0(cols[idx], 80),
bg = paste0(cols[idx], 60), cex = 1.5,
xlab = paste0("PC1: ", format(pc_s$importance[2, 1] * 100, digits = 3),
" % variance"), ylab = "Age", xlim = c(-16, 9))
mtext(side = 3, outer = FALSE, text = "C", cex = 3, at = -18, line = -4.0)
grid()
dev.off()
#' And again for the graphical abstract
## png("images/manuscript/Figure_2_GA.png", width = 5, height = 5, units = "cm",
## res = 600, pointsize = 4)
## par(mfrow = c(1, 1), mar = c(4.5, 4.3, 0.5, 0.5), cex.lab = 1.5, bty = "n")
## plot_pca(pc, pch = NA, col = NA, bg = paste0(cols, 60), cex = 1.5,
## xlim = c(-16, 9))
## unsigned.range <- function(x)
## c(-abs(min(x, na.rm = TRUE)), abs(max(x, na.rm = TRUE)))
## y <- pc$rotation[, 1:2]
## scl <- max(
## unsigned.range(y[, 1]) / unsigned.range(pc$x[, 1]),
## unsigned.range(y[, 2]) / unsigned.range(pc$x[, 2]))
## y <- y / scl
## points(pc$x[, 1], pc$x[, 2], pch = 21, col = NA, bg = paste0(cols, 60),
## cex = 1)
## grid()
## dev.off()
```
From the scores, there is a clear effect of sex in direction of PC1. From the
loadings we can observe relationships between proteins. Every arrow corresponds
to the one parameter (protein) in data set. Longest arrows in the direction of
particular Principal Component have the largest impact and importance for that
PC. The same direction of groups of arrows and their lengths indicates
correlation of corresponding parameters in the data set and opposite: opposite
directed arrows indicate negative correlation between corresponding
parameters. For the cases when angles between arrows are around 90°, indicates
that there is no correlation between corresponding parameters. Note that with
the large numbers of parameters in PCA, some loadings can be placed close to
each other even if there is no strong correlation. Thus, attention is necessary.
There is an interesting separation on PC1 with a subgroup of mostly female
participants which seems also to be related to Age (not shown). We next apply a
multivariate regression model to the data to identify which of the available
variables are strongest associated with the PC1. We first prepare the medication
data and define a (categorical) variable for each ATC level 3 medication taken
on a regular basis by at least 14 CHRIS participants.
```{r, warning = FALSE}
#' Prepare medication data
med <- chrisData("drugs_1")
med <- med[med$AID %in% rownames(prot_data), ]
med <- med[!is.na(med$x0dd03), ]
med$atc_2 <- toAtcLevel(med$x0dd03, level = 2)
med$atc_3 <- toAtcLevel(med$x0dd03, level = 3)
med$atc_4 <- toAtcLevel(med$x0dd03, level = 4)
med$atc_5 <- toAtcLevel(med$x0dd03, level = 5)
atc_df <- as.data.frame(atc)
med$atc_2_name <- atc_df[match(med$atc_2, atc_df$key), "name"]
med$atc_3_name <- atc_df[match(med$atc_3, atc_df$key), "name"]
med$atc_4_name <- atc_df[match(med$atc_4, atc_df$key), "name"]
med$atc_5_name <- atc_df[match(med$atc_5, atc_df$key), "name"]
#' Restrict to medications taken by at least 14 individuals on a regular
#' basis
tmp <- med[med$x0dd13 %in% c("daily", "every 2. day", "every 3. day",
"every 4. day = 2x per week"), ]
level3 <- split(tmp$AID, tmp$atc_3)
level3 <- lapply(level3, unique)
level3 <- level3[lengths(level3) > 14]
#' Reformat into categorical variables
general_data <- prot_data[, c("BMIcat", "Sex", "Age_10", "Fasting")]
tmp <- lapply(names(level3), function(z) {
cl <- rep("No", nrow(general_data))
cl[rownames(general_data) %in% level3[[z]]] <- "Yes"
factor(cl)
})
names(tmp) <- names(level3)
general_data <- cbind(general_data, do.call(cbind.data.frame, tmp))
```
Next we fit a multivariate regression model explaining PC1 by all available
variables, which includes age, sex, (categorical) BMI, (binary) self-reported
fasting status and the above medication information.
```{r}
#' association analysis: age, sex, BMI, medication on PC1.
general_data$pc1 <- pc_all$x[, 1L]
lmod <- lm(pc1 ~ ., data = general_data)
```
The significantly associated variables (at an alpha = 0.01) are listed below.
```{r table-association-pc1, results = "asis"}
lsum <- summary(lmod)
ltab <- lsum$coefficients[lsum$coefficients[, 4L] < 0.01, c(1L, 4L)]
ltab <- data.frame(variable = sub("Yes", "", rownames(ltab)), ltab,
check.names = FALSE)
ltab$name <- atc_df[match(ltab$variable, atc_df$key), c("name")]
ltab <- ltab[rownames(ltab) != "(Intercept)", ]
ltab <- ltab[order(ltab[, 3]), ]
rownames(ltab) <- NULL
pandoc.table(
ltab, style = "rmarkdown", split.table = "Inf",
caption = "Variables significantly associated with PC1.")
```
The sample sizes for the individual significant variables are:
```{r}
summary(general_data[, c("Sex", "BMIcat", "G03A", "G03H", "G02B", "G03F")])
```
Hormonal contraceptives seem to be the strongest drivers for the observed
separation on PC1, which is also related to age, sex and obesity.
To exclude potential other technical influence we in addition evaluate whether
there is a relationship between PC1 and the *age* of the samples, which we
estimate from the study participants' participation date.
```{r, fig.width = 5, fig.height = 5, fig.cap = "PC1 against the sample age (in days)."}
#' Calculate the difference (in days) between the partipation date and an
#' arbitrary day, in our case 2022-02-14.
part_date <- gen_info[rownames(prot_data), "x0_examd"]
sample_age <- as.integer(difftime("2022-02-14", part_date, units = "days"))
plot(pc_all$x[, 1L], sample_age, xlab = "PC1", ylab = "Sample age [days]")
grid()
cor(pc_all$x[, 1L], sample_age, method = "spearman")
```
There is thus no relationship between the samples' age and PC1.
We thus next define the categorical variable for *hormonal contraceptives* using
the ATC level 3 medication information from CHRIS. In particular, we define the
trait using the ATC3 categories *HORMONAL CONTRACEPTIVES FOR SYSTEMIC USE* and
*ANTIANDROGENS*. This definition is similar to the one in Ramsey et al
[@ramsey_variation_2016] that considered women taking oral
contraceptives. Contraceptives for topical use are not included in this
definition, because they don't have the same route of administration
(i.e. orally and metabolized in/through the liver).
```{r, warning = FALSE}
#' Subset to selected sex hormone treatment (WHO definition)
med_sex_horm <- med[med$atc_3_name %in%
c("HORMONAL CONTRACEPTIVES FOR SYSTEMIC USE",
"ANTIANDROGENS"), ]
prot_data$HCU <- "No"
prot_data$HCU[match(med_sex_horm$AID, rownames(prot_data))] <- "Yes"
prot_data$HCU <- factor(prot_data$HCU,
levels = c("No", "Yes"))
summary(prot_data$HCU)
```
```{r PCA_HCU, warning = FALSE, fig.width = 12, fig.height = 7}
gg_2 <- autoplot(prcomp(scaledData), x = 1, y = 2,
data = prot_data, loadings = TRUE, loadings.colour = 'gray',
loadings.label = TRUE, loadings.label.size = 3,
loadings.label.colour = "darkblue", colour = NA) +
geom_point(aes(colour = HCU), size = 1) +
theme_bw ()
ggplotly_or_not(gg_2, PLOTLY)
```
```{r, echo = FALSE}
#' Supplementary Figure PCA
#' Same plot but with coloring representing HCU.
png("images/manuscript/supplement/Figure_S149.png", width = 8.2, height = 6.4,
units = "cm", res = 600, pointsize = 4, type = "cairo-png")
par(mar = c(4.5, 4.3, 0.5, 0.5), cex.lab = 1.5, bty = "n", las = 1)
plot_pca(pc_all, pch = NA, col = NA, bg = paste0(cols, 60), cex = 1.5,
xlim = c(-16, 9))
unsigned.range <- function(x)
c(-abs(min(x, na.rm = TRUE)), abs(max(x, na.rm = TRUE)))
y <- pc_all$rotation[, 1:2]
scl <- max(
unsigned.range(y[, 1]) / unsigned.range(pc_all$x[, 1]),
unsigned.range(y[, 2]) / unsigned.range(pc_all$x[, 2]))
y <- y / scl
arrows(x0 = 0, x1 = y[, 1],
y0 = 0, y1 = y[, 2],
lwd = 0.75, angle = 30, length = 0.05,
col = "#00000050")
text(y[, 1] * 1.1, y[, 2] * 1.1, labels = prot_ann[rownames(y), "Genes"],
col = "#00000080", cex = 1.4)
cols <- rep("#E41A1C", nrow(prot_data))
cols[prot_data$Sex == "Male"] <- "#377EB8"
cols[prot_data$HCU == "Yes"] <- "#000000"
points(pc_all$x[, 1], pc_all$x[, 2], pch = 21, col = NA, bg = paste0(cols, 60),
cex = 1.5)
grid()
dev.off()
```
Most of the participants separating from the main group take indeed systemic
contraceptives. Other (female) participants in that group either take other
types of hormonal contraceptives, or did not bring the medication with them to
the study center and thus the medication was not recorded for them (false
negatives).
Below we evaluate the age distribution of participants by sex. Individuals are
colored according to the *HCU* variable.
```{r, BP_age_figure, fig.path = IMAGE_PATH, fig.width=10, fig.height=6, warning = FALSE}
prot_plot <- function(data, aes, protein) {
ggplot(data, aes) +
geom_jitter(position = position_jitter(0.24),
aes(colour = HCU, alpha = 0.5)) +
geom_violin(trim = FALSE, aes(alpha = 0.5)) +
stat_summary(fun = median, geom = "point", shape = 23, size = 2) +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, size = 8),
axis.title.y = element_blank()) + labs(title = protein) +
theme_bw ()
}
age_1 <- prot_plot(prot_data, aes(x = Sex, y = Age),
protein = "Sex Vs. Age")
ggplotly_or_not(age_1, PLOTLY)
```
Also, age distribution per HCU is visualized:
```{r, BP_age_2_figure, fig.path = IMAGE_PATH, fig.width=10, fig.height=6, warning = FALSE}
age_2 <- prot_plot(prot_data, aes(x = HCU, y = Age),
protein = "HCU Vs. Age")
ggplotly_or_not(age_2, PLOTLY)
```
Clearly there is an enrichment of young women among participants using hormonal
contraceptives. We next extract the information on the individual hormonal
contraceptive preparations to then (later) classify and categorize them based on
the type of hormones they contain.
```{r, results = "asis"}
contr <- med[med$atc_3_name %in% c("HORMONAL CONTRACEPTIVES FOR SYSTEMIC USE",
"CONTRACEPTIVES FOR TOPICAL USE",
"ANTIANDROGENS"), ]
tmp <- split(contr, f = contr$atc_5)
contr_atc5 <- lapply(tmp, function(z) {
a <- unique(z[, c("atc_3", "atc_4", "atc_5", "atc_4_name", "atc_5_name")])
a$count <- nrow(z)
a$preparation <- paste0(unique(z$x0dd07), collapse = ";")
a
})
contr_atc5 <- do.call(rbind, contr_atc5)
#' to manually go through preparations to classify.
write_xlsx(contr_atc5, path = "contraceptives.xlsx")
pandoc.table(
contr_atc5[, c("atc_4_name", "atc_5_name", "count")], style = "rmarkdown",
caption = "Types of hormonal contraceptives taken by participants.")
```
The table above was exported and manually evaluated/classified.
Additionally, we evaluate the predictive ability of all plasma proteins for
hormonal contraceptive use. To ensure comparability, we match the users of
hormonal contraceptives to a control group of identical size (n = 275). Only
non-pregnant women below the age of 40 not taking hormonal contraceptives were
considered for the control group.
```{r}
#' Prepare Data for matching
#' Filter for HCU users and controls
filter_hcu <- prot_data$Age < 40 & prot_data$HCU == "Yes" &
prot_data$Pregnant == "No"
filter_control <- prot_data$Age < 40 & prot_data$HCU == "No" &
prot_data$Pregnant == "No"
women_hcu <- na.omit(prot_data[filter_hcu, ])
women_control <- na.omit(prot_data[filter_control, ]) # n = 454 possible control candidates
#' combine HC users and control group within dataframe
women_hcu_control <- rbind(women_hcu, women_control)
#' drop unnecessary columns
drop_col <- c("File.Name", "Date", "Inst", "Inj", "Plate", "Sample.Name",
"Sex", "container", "MS_Batch", "SP_Batch", "BMIcat",
"Pregnant", "Age_10")
women_hcu_control <- women_hcu_control[, !(colnames(women_hcu_control) %in%
drop_col)]
#' Adjust covariates for matching
women_hcu_control$Fasting <- as.factor(women_hcu_control$Fasting)
women_hcu_control$HCU <- as.factor(women_hcu_control$HCU)
```
*Optimal* matching via a generalized linear model (GLM) was used for propensity
score calculation (including age, BMI and fasting status as covariates)
as implemented in the R package (MatchIt).
```{r}
#' Matching
match.out <- matchit(
HCU ~ Age + Fasting + BMI,
data = women_hcu_control[,c("HCU", "Fasting", "BMI", "Age")],
method = "optimal", distance = "glm")
#' Select matched participants
hcu_control_matched <- rbind(women_control[match.out$match.matrix, ],
women_hcu)
summary(match.out)
```
We further visualize propensity scores and covariate distributions to assess
matching quality. Controls (HCU = No) are shown in gray - Treatment group (HCU =
Yes) in black. Propensity score evaluation and inspection of covariate
distribution, show sufficient matching for the subsequent analysis.
```{r}
plot(match.out, type = "jitter", interactive = FALSE)
plot(match.out, type = "density", interactive = FALSE,
which.xs = ~Age + Fasting + BMI)
plot(summary(match.out))
```
Predictive performance of proteins for HCU is evaluated by calculating Area
Under the Receiver Operating Characteristic curve (AUROC).
```{r}
#' Select only plasma protein and HCU status
hcu_control_matched <- hcu_control_matched[, c(proteins, "HCU")]
labels <- hcu_control_matched$HCU
#' calculate ROC
calculate_roc <- function(col_name) {
if (!(col_name == "HCU")) {
protein_values <- hcu_control_matched[[col_name]]
roc_data <- roc(labels, protein_values)$auc
return(roc_data)
}
}
roc_list <- lapply(colnames(hcu_control_matched), calculate_roc)
#' Convert List to dataframe
roc_df <- do.call(rbind, lapply(roc_list, as.data.frame))
#' add Genes and UniProtIDs to dataframe
roc_df$Genes <- prot_ann[proteins, "Genes"]
roc_df$UniProtId <- prot_ann[proteins, "description"]
#' Save the ROC data to a CSV file
#write.csv(roc_df, "rocValsHCU.csv", row.names = FALSE)
```
Angiotensinogen (AGT) shows high predictive power for hormonal contraceptive
usage (AUROC = 0.89)
```{r,}
#' Calculate ROC seperately for AGT
roc_data_agt <- roc(hcu_control_matched$HCU, hcu_control_matched$P01019)
roc_df <- data.frame(
OneMinusSpecificity = 1 - roc_data_agt$specificities,
Sensitivity = roc_data_agt$sensitivities
)
```
```{r}
par(mfrow = c(1, 2), mar = c(4, 4.5, 5, 1), cex.axis = 1.5, cex.lab = 1.5,
bty = "n", cex.main = 2.5)
#' Supplementary Figure P01019 AGT concentration in different groups
f <- as.character(prot_data$Sex)
f[prot_data$HCU == "Yes"] <- "HCU"
f <- factor(f, levels = c("HCU", "Female", "Male"))
library(vioplot)
vioplot(split(prot_data$P01019, f), ylab = expression(log[2]~abundance),
main = "")
grid(nx = NA, ny = NULL)
mtext(side = 3, outer = FALSE, text = "P01019 (AGT)", line = 0,
cex = par("cex.main"))
mtext(side = 3, outer = FALSE, text = "A", cex = 5, at = 0.1, line = 0.5)
#' ROC
plot(roc_df$OneMinusSpecificity, roc_df$Sensitivity, xlab = "1 - Specificity",
ylab = "Sensitivity", type = "l", lwd = 2)
abline(0, 1, lty = 3, col = "grey")
grid()
legend("bottomright", legend = "AUC AGT = 0.89", cex = 2, bty = "n")
mtext(side = 3, outer = FALSE, text = "B", cex = 5, at = -0.14, line = 0.5)
```
```{r}
#' PAPER, Figure 5B
#' AGT abundance in HCU, women and men.
png("images/manuscript/_Figure_4B.png", width = 5,
height = 6, units = "cm", res = 600, pointsize = 4, type = "cairo-png")
par(mfrow = c(1, 1), mar = c(5, 6, 5, 1) + 0.1, cex.axis = 2, cex.lab = 2,
bty = "n", cex.main = 2.5, las = 1)
#' Supplementary Figure P01019 AGT concentration in different groups
f <- as.character(prot_data$Sex)
f[f == "Female"] <- "Women"
f[f == "Male"] <- "Men"
f[which(prot_data$HCU == "Yes")] <- "HCU"
f <- factor(f, levels = c("HCU", "Women", "Men"))
library(vioplot)
vioplot(split(prot_data$P01019, f), ylab = "",
main = "", yaxt = "n", xaxt = "n")
mtext(text = expression(log[2]~abundance), side = 2, line = 3, cex = 2, las = 0)
grid(nx = NA, ny = NULL)
xat <- c(1,2,3)
labs <- c("HCU", "Women", "Men")
axis(1, at = xat, labels = labs, padj = 0.4)
yat <- axTicks(2, usr = par("usr")[1:2])
labs <- gsub("-", "\U2212", print.default(yat))
axis(2, at = yat, labels = labs)
mtext(side = 3, outer = FALSE, text = "P01019 (AGT)", line = 0,
cex = par("cex.main"))
## mtext(side = 3, outer = FALSE, text = "A", cex = 5, at = 0.1, line = 0.5)
dev.off()
#' PAPER, Figure 5C
#' ROC for AGT
png("images/manuscript/_Figure_4C.png", width = 5,
height = 6, units = "cm", res = 600, pointsize = 4, type = "cairo-png")
par(mfrow = c(1, 1), mar = c(5, 6, 5, 1) + 0.1, cex.axis = 2, cex.lab = 2,
bty = "n", cex.main = 2.5, las = 1)
#' ROC
plot(roc_df$OneMinusSpecificity, roc_df$Sensitivity, xlab = "1 - Specificity",
ylab = "", type = "l", lwd = 2)
mtext(text = "Sensitivity", side = 2, line = 4, cex = 2, las = 0)
abline(0, 1, lty = 3, col = "grey")
grid()
legend("bottomright", legend = "AUC AGT = 0.89", cex = 2, bty = "n")
## mtext(side = 3, outer = FALSE, text = "B", cex = 5, at = -0.14, line = 0.5)
dev.off()
```
# Sex, Age, BMI and oral hormonal contraceptive-associated proteins
To identify proteins related with sex, age, fasting status and BMI, linear
regression models are fitted for all proteins separately (as a response) and
sex, age, fasting status and (categorical) BMI as a covariates (same as in
[@verri_hernandes_age_2022]). In addition, and based on the observations from
the previous section, a categorical variable representing the use of hormonal
contraceptives is included to adjust for the influence of this medication. In
this model, no interactions between variables are considered, although a
relationship between BMI and sex seems to be present in the data. A sensitivity
analysis evaluating the impact of the additional interaction between BMI and sex
was performed but did not show large differences (data not shown).
Raw p-values for each coefficient are adjusted for multiple hypothesis testing
with the method from Bonferroni.
```{r, message=FALSE}
#' Linear model LM1
FunForLinReg <- function(AnalyteName, Data) {
Analyte <- Data[, AnalyteName]
LMReg <- lm(Analyte ~ Sex + Age_10 + Fasting + BMIcat + HCU,
data = Data)
res <- coef(summary(LMReg))[-1, ]
p.Values <- data.frame(c(res[, 1],
res[, 4]))
names(p.Values) <- AnalyteName
rownames(p.Values) <- c(paste0("coef_", rownames(res)),
paste0("p-value_", rownames(res)))
return(p.Values)
}
LMRegtests <- do.call(
cbind, lapply(proteins, function(x) FunForLinReg(x, prot_data)))
Test_output <- t(LMRegtests)
#' Adjusting for multiple hypothesis testing
adjp <- apply(Test_output[, grep("p-value", colnames(Test_output))],
MARGIN = 2, p.adjust, method = "bonferroni")
colnames(adjp) <- sub("value", "adj", colnames(adjp))
Test_output <- cbind(Test_output, adjp)
```
To obtain comparable coefficients, prior to linear modelling all the variables
are standardized to zero mean and unit variance (note that this does not
influence the linear models since they are affine equivariant).
In autoscaled data, difference of 1 corresponds to standard deviation of 1.
This parameter will be called *effect size* and will be use to evaluate group
differences.
```{r, message = FALSE}
#' perform data normalization (autoscaling)
prot_data_AS <- prot_data
prot_data_AS[, proteins] <- scale(prot_data_AS[, proteins], scale = TRUE)
LMRegtests_AS <- do.call(cbind.data.frame,
lapply(proteins,
function(x) FunForLinReg(x, prot_data_AS)))
Test_output_AS <- t(LMRegtests_AS)
EffectSize <- Test_output_AS[, grep("coef", colnames(Test_output_AS))]
colnames(EffectSize) <- sub("coef", "effect_size", colnames(EffectSize))
```
We next define the criteria to call proteins *significant*. Due the size of the
data set (and hence the statistical power) proteins would be called significant,
even if their difference in concentrations is only very small. Hence we evaluate
whether we could combine the criteria for *statistical significance* (the
p-value) with another criteria that would allow us to define the proteins that
are the *strongest* associated with the contrast of interest.
```{r significant-effect-size}
comps <- colnames(Test_output)[grep("coef", colnames(Test_output))]
sign_p <- Test_output[, grep("p-adj", colnames(Test_output))] < 0.05
colnames(sign_p) <- sub("p-adj", "significant", colnames(sign_p))
#' Define significant analytes based on effect size.
cut_effect_size <- 0.5
sign_es <- sign_p &
abs(EffectSize) > cut_effect_size
sign_es[, "significant_Age_10"] <- sign_p[, "significant_Age_10"]
```
We require in addition to the *statistical significance* that the difference in
concentrations for a protein is larger than its *technical variance*. Technical
variance of an protein is estimated by the coefficient of variation of the
protein in QC CHRIS Pool samples.
Below we add thus evaluate for each protein and comparison whether it fulfills
that criteria.
```{r define-significant}
#' Calculate the (absolute) difference in abundance expressed as a percentage
#' based on a (log2) coefficient.
diff_percentage <- function(x) {
(2^abs(x) - 1) * 100
}
comps <- colnames(Test_output)[grep("coef", colnames(Test_output))]
diff_perc <- apply(Test_output[, comps],
MARGIN = 2, diff_percentage)
colnames(diff_perc) <- sub("coef", "diff_perc", colnames(diff_perc))
#' define which metabolites are considered significant: require p-value < 0.05
#' and difference in concentration > CV_QC (expressed in %)
sign_cv <- lapply(comps, function(z) {
z <- sub("coef_", "", z)
sign_p[, paste0("significant_", z)] &
diff_perc[, paste0("diff_perc_", z)] > 100 *
prot_ann[proteins, "cv_qc_chris"]
})
sign_cv <- do.call(cbind, sign_cv)
colnames(sign_cv) <- sub("coef", "significant", comps)
#' Add the significant for numeric variable
sign_cv[, "significant_Age_10"] <- sign_p[, "significant_Age_10"]
```
The number of proteins called significant or with an adjusted p-value smaller
than 0.05 for each of the extracted coefficients are shown below.
```{r table-sig-mets, results = "asis"}
sig_tab <- data.frame(
`p_adj < 0.05` = colSums(sign_p),
cv = colSums(sign_cv),
check.names = FALSE)
pandoc.table(
data.frame(no_sign = sig_tab, check.names = FALSE),
style = "rmarkdown",
caption = paste0("Number of significant proteins for each ",
"comparison and definition of significance.",
"cv: difference in concentration > * CV in QC samples."))
```
```{r export-results, warning = FALSE}
#' Loading also the information whether an analyte was already identified
#' before to be significant.
results <- data.frame(
prot_ann[proteins, c("description", "long_description", "PeptideNN",
"PeptideNames", "Protein.Ids", "Protein.Names",
"Genes", "Modified.Sequence", "Stripped.Sequence",
"Precursor.Id", "cv_qc_chris")],
Test_output,
EffectSize,
diff_perc,
sign_cv)
results$cv_qc_chris <- 100 * results$cv_qc_chris
results$cv_study <- cv_study
results$relative_cv <- cv_rel
#' Add average concentrations for most important groups.
results$Avg_Male <- colMeans(
prot_data[which(prot_data$Sex == "Male"), proteins])
results$Avg_Female <- colMeans(
prot_data[which(prot_data$Sex == "Female"), proteins])
results$Avg_BMI1 <- colMeans(
prot_data[which(prot_data$BMIcat == "1"), proteins])
results$Avg_BMI2 <- colMeans(
prot_data[which(prot_data$BMIcat == "2"), proteins])
results$Avg_BMI3 <- colMeans(
prot_data[which(prot_data$BMIcat == "3"), proteins])
results$Avg_BMI4 <- colMeans(
prot_data[which(prot_data$BMIcat == "4"), proteins])
dr <- paste0("data/xlsx/", filename)
dir.create(dr, showWarnings = FALSE, recursive = TRUE)
colnames(results) <- sub("^description$", "Uniprot", colnames(results))
colnames(results) <- sub("^long_description$", "Description", colnames(results))
write_xlsx(
results, path = paste0(dr, "/results_sex_age_bmi_hcu_adjusted.xlsx"))
```