-
Notifications
You must be signed in to change notification settings - Fork 0
/
2. SNP_analyses.Rmd
2065 lines (1674 loc) · 88 KB
/
2. SNP_analyses.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: "Plaque expression levels of _HDAC9_ in association with plaque vulnerability traits and secondary vascular events in patients undergoing carotid endarterectomy: an analysis in the Athero-EXPRESS Biobank."
author: "[Sander W. van der Laan, PhD](https://swvanderlaan.github.io) | @swvanderlaan | [email protected]"
date: "`r Sys.Date()`"
output:
html_notebook:
cache: yes
code_folding: hide
collapse: yes
df_print: paged
fig.align: center
fig_caption: yes
fig_height: 6
fig_retina: 2
fig_width: 7
highlight: tango
theme: lumen
toc: yes
toc_float:
collapsed: no
smooth_scroll: yes
mainfont: Arial
subtitle: "A 'druggable-MI-targets' project"
editor_options:
chunk_output_type: inline
markdown:
wrap: 80
bibliography: references.bib
knit: worcs::cite_all
---
# General Setup
```{r setup, include=FALSE}
# We recommend that you prepare your raw data for analysis in 'prepare_data.R',
# and end that file with either open_data(yourdata), or closed_data(yourdata).
# Then, uncomment the line below to load the original or synthetic data
# (whichever is available), to allow anyone to reproduce your code:
# load_data()
# further define some knitr-options.
knitr::opts_chunk$set(fig.width = 12, fig.height = 8, fig.path = 'Figures/',
warning = TRUE, # show warnings during codebook generation
message = TRUE, # show messages during codebook generation
error = TRUE, # do not interrupt codebook generation in case of errors,
# usually better for debugging
echo = TRUE, # show R code
eval = TRUE)
library("worcs")
```
```{r echo = FALSE}
rm(list = ls())
```
```{r LocalSystem, echo = FALSE}
### Operating System Version
### MacBook Pro
ROOT_loc = "/Users/swvanderlaan"
### MacBook Air
# ROOT_loc = "/Users/slaan3"
### General
GENOMIC_loc = paste0(ROOT_loc, "/OneDrive - UMC Utrecht/Genomics")
AEDB_loc = paste0(GENOMIC_loc, "/Athero-Express/AE-AAA_GS_DBs")
LAB_loc = paste0(GENOMIC_loc, "/LabBusiness")
PROJECT_loc = paste0(ROOT_loc, "/git/CirculatoryHealth/AE_20211201_YAW_SWVANDERLAAN_HDAC9")
### SOME VARIABLES WE NEED DOWN THE LINE
TRAIT_OF_INTEREST = "HDAC9" # Phenotype
PROJECTNAME = "HDAC9"
cat("\nCreate a new analysis directory...\n")
ifelse(!dir.exists(file.path(PROJECT_loc, "/",PROJECTNAME)),
dir.create(file.path(PROJECT_loc, "/",PROJECTNAME)),
FALSE)
ANALYSIS_loc = paste0(PROJECT_loc,"/",PROJECTNAME)
ifelse(!dir.exists(file.path(ANALYSIS_loc, "/PLOTS")),
dir.create(file.path(ANALYSIS_loc, "/PLOTS")),
FALSE)
PLOT_loc = paste0(ANALYSIS_loc,"/PLOTS")
ifelse(!dir.exists(file.path(PLOT_loc, "/QC")),
dir.create(file.path(PLOT_loc, "/QC")),
FALSE)
QC_loc = paste0(PLOT_loc,"/QC")
ifelse(!dir.exists(file.path(ANALYSIS_loc, "/OUTPUT")),
dir.create(file.path(ANALYSIS_loc, "/OUTPUT")),
FALSE)
OUT_loc = paste0(ANALYSIS_loc, "/OUTPUT")
ifelse(!dir.exists(file.path(ANALYSIS_loc, "/BASELINE")),
dir.create(file.path(ANALYSIS_loc, "/BASELINE")),
FALSE)
BASELINE_loc = paste0(ANALYSIS_loc, "/BASELINE")
setwd(paste0(PROJECT_loc))
getwd()
list.files()
```
```{r Source functions}
source(paste0(PROJECT_loc, "/scripts/functions.R"))
```
```{r}
ggplot2::theme_set(ggplot2::theme_minimal())
pander::panderOptions("table.split.table", Inf)
```
```{r loading_packages, message=FALSE, warning=FALSE}
install.packages.auto("pander")
install.packages.auto("readr")
install.packages.auto("optparse")
install.packages.auto("tools")
install.packages.auto("dplyr")
install.packages.auto("tidyr")
install.packages.auto("naniar")
# To get 'data.table' with 'fwrite' to be able to directly write gzipped-files
# Ref: https://stackoverflow.com/questions/42788401/is-possible-to-use-fwrite-from-data-table-with-gzfile
# install.packages("data.table", repos = "https://Rdatatable.gitlab.io/data.table")
library(data.table)
install.packages.auto("tidyverse")
install.packages.auto("knitr")
install.packages.auto("DT")
install.packages.auto("eeptools")
install.packages.auto("haven")
install.packages.auto("tableone")
install.packages.auto("BlandAltmanLeh")
# Install the devtools package from Hadley Wickham
install.packages.auto('devtools')
# for plotting
install.packages.auto("pheatmap")
install.packages.auto("forestplot")
install.packages.auto("ggplot2")
install.packages.auto("ggpubr")
install.packages.auto("UpSetR")
devtools::install_github("thomasp85/patchwork")
install.packages.auto("sjPlot")
```
```{r Setting: Colors}
Today = format(as.Date(as.POSIXlt(Sys.time())), "%Y%m%d")
Today.Report = format(as.Date(as.POSIXlt(Sys.time())), "%A, %B %d, %Y")
### UtrechtScienceParkColoursScheme
###
### WebsitetoconvertHEXtoRGB:http://hex.colorrrs.com.
### Forsomefunctionsyoushoulddividethesenumbersby255.
###
### No. Color HEX (RGB) CHR MAF/INFO
###---------------------------------------------------------------------------------------
### 1 yellow #FBB820 (251,184,32) => 1 or 1.0>INFO
### 2 gold #F59D10 (245,157,16) => 2
### 3 salmon #E55738 (229,87,56) => 3 or 0.05<MAF<0.2 or 0.4<INFO<0.6
### 4 darkpink #DB003F ((219,0,63) => 4
### 5 lightpink #E35493 (227,84,147) => 5 or 0.8<INFO<1.0
### 6 pink #D5267B (213,38,123) => 6
### 7 hardpink #CC0071 (204,0,113) => 7
### 8 lightpurple #A8448A (168,68,138) => 8
### 9 purple #9A3480 (154,52,128) => 9
### 10 lavendel #8D5B9A (141,91,154) => 10
### 11 bluepurple #705296 (112,82,150) => 11
### 12 purpleblue #686AA9 (104,106,169) => 12
### 13 lightpurpleblue #6173AD (97,115,173/101,120,180) => 13
### 14 seablue #4C81BF (76,129,191) => 14
### 15 skyblue #2F8BC9 (47,139,201) => 15
### 16 azurblue #1290D9 (18,144,217) => 16 or 0.01<MAF<0.05 or 0.2<INFO<0.4
### 17 lightazurblue #1396D8 (19,150,216) => 17
### 18 greenblue #15A6C1 (21,166,193) => 18
### 19 seaweedgreen #5EB17F (94,177,127) => 19
### 20 yellowgreen #86B833 (134,184,51) => 20
### 21 lightmossgreen #C5D220 (197,210,32) => 21
### 22 mossgreen #9FC228 (159,194,40) => 22 or MAF>0.20 or 0.6<INFO<0.8
### 23 lightgreen #78B113 (120,177,19) => 23/X
### 24 green #49A01D (73,160,29) => 24/Y
### 25 grey #595A5C (89,90,92) => 25/XY or MAF<0.01 or 0.0<INFO<0.2
### 26 lightgrey #A2A3A4 (162,163,164) => 26/MT
###
### ADDITIONAL COLORS
### 27 midgrey #D7D8D7
### 28 verylightgrey #ECECEC"
### 29 white #FFFFFF
### 30 black #000000
###----------------------------------------------------------------------------------------------
uithof_color = c("#FBB820","#F59D10","#E55738","#DB003F","#E35493","#D5267B",
"#CC0071","#A8448A","#9A3480","#8D5B9A","#705296","#686AA9",
"#6173AD","#4C81BF","#2F8BC9","#1290D9","#1396D8","#15A6C1",
"#5EB17F","#86B833","#C5D220","#9FC228","#78B113","#49A01D",
"#595A5C","#A2A3A4", "#D7D8D7", "#ECECEC", "#FFFFFF", "#000000")
uithof_color_legend = c("#FBB820", "#F59D10", "#E55738", "#DB003F", "#E35493",
"#D5267B", "#CC0071", "#A8448A", "#9A3480", "#8D5B9A",
"#705296", "#686AA9", "#6173AD", "#4C81BF", "#2F8BC9",
"#1290D9", "#1396D8", "#15A6C1", "#5EB17F", "#86B833",
"#C5D220", "#9FC228", "#78B113", "#49A01D", "#595A5C",
"#A2A3A4", "#D7D8D7", "#ECECEC", "#FFFFFF", "#000000")
### ----------------------------------------------------------------------------
```
## Background
Collaboration to study `r TRAIT_OF_INTEREST` in relation to atherosclerotic plaques characteristics.
- `Genes.xlsx` - list of genes of interest. This includes the `r TRAIT_OF_INTEREST` gene, _TWIST1_, and two upstream/downstream targets of the `r TRAIT_OF_INTEREST` gene, _IL1-beta_ and _IL6_.
- `Variants.xlsx` - list of variant(s) of interest. This includes the `r TRAIT_OF_INTEREST` variant.
```{r targets, message=FALSE, warning=FALSE}
library(openxlsx)
gene_list_df <- read.xlsx(paste0(PROJECT_loc, "/targets/Genes.xlsx"), sheet = "Genes")
gene_list <- unlist(gene_list_df$Gene)
gene_list
variant_list <- read.xlsx(paste0(PROJECT_loc, "/targets/Variants.xlsx"), sheet = "Variants")
DT::datatable(variant_list)
```
## This notebook
In this notebook we create a baseline table of the whole cohort and of the CEA-cohort.
## Athero-Express Biobank Study
The [*Athero-Express Biobank Study (AE)*](http://www.atheroexpress.nl){target="_blank"} contains plaque material of
patients that underwent endarterectomyat two Dutch tertiary referral centers. Details of the study design were described
before. Briefly, blood and plaque material were obtained during endarterectomy and stored at -80 ℃. Only carotid
endarterectomy (CEA) patients were included in the present study. All patients provided informed consent and the study
was approved by the medical ethics committee.
## Athero-Express Genomics Study
### DNA isolation and genotyping
We genotyped the AE in three separate, but consecutive experiments. In short, DNA was extracted from EDTA blood or (when
no blood was available) plaque samples of 1,858 consecutive patients from the Athero-Express Biobank Study and genotyped
in 3 batches.
For the *Athero-Express Genomics Study 1 (AEGS1)* 891 patients (602 males, 262 females, 27 unknown sex), included
between 2002 and 2007, were genotyped (440,763 markers) using the Affymetrix Genome-Wide Human SNP Array 5.0 (SNP5) chip
(Affymetrix Inc., Santa Clara, CA, USA) at [Eurofins Genomics](https://www.eurofinsgenomics.eu/){target="_blank"}
(formerly known as AROS).
For the *Athero-Express Genomics Study 2 (AEGS2)* 954 patients (640 makes, 313 females, 1 unknown sex), included between
2002 and 2013, were genotyped (587,351 markers) using the Affymetrix AxiomⓇ GW CEU 1 Array (AxM) at the [Genome Analysis
Center](https://www.helmholtz-muenchen.de/no_cache/gac/index.html){target="_blank"}.
For the *Athero-Express Genomics Study 3 (AEGS3)* 658 patients (448 males, 203 females, 5 unknown sex), included between
2002 and 2016, were genotyped (693,931 markers) using the Illumina GSA MD v1 BeadArray (GSA) at [Human Genomics
Facility, HUGE-F](http://glimdna.org/index.html){target="_blank"}.
All experiments were carried out according to OECD standards.
### Genotyping calling
We used the genotyping calling algorithms as advised by Affymetrix (AEGS1 and AEGS2) and Illumina (AEGS3):
- AEGS1: BRLMM-P
- AEGS2: AxiomGT1
- AEGS3: Illumina GenomeStudio
### Quality control after genotyping
After genotype calling, we adhered to community standard quality control and assurance (QCA) procedures of the genotype
data from AEGS1, AEGS2, and AEGS3. Samples with low average genotype calling and sex discrepancies (compared to the
clinical data available) were excluded. The data was further filtered on:
1) individual (sample) call rate \> 97%,
2) SNP call rate \> 97%,
3) minor allele frequencies (MAF) \> 3%,
4) average heterozygosity rate ± 3.0 s.d.,
5) relatedness (pi-hat \> 0.20),
6) Hardy--Weinberg Equilibrium (HWE p \< 1.0×10<sup>−3\<\sup\>), and
7) Monomorphic SNPs (\< 1.0×10<sup>−6\<\sup\>).
After QCA 2,493 samples remained, 108 of non-European descent/ancestry, and 156 related pairs. These comprise 890
samples and 407,712 SNPs in AEGS1, 869 samples and 534,508 SNPs in AEGS2, and 649954 samples and 534,508 SNPs in AEGS3
remained.
### Imputation
Before phasing using SHAPEIT2, data was lifted to genome build b37 using the liftOver tool from UCSC
(<https://genome.ucsc.edu/cgi-bin/hgLiftOver>). Finally, data was imputed with 1000G phase 3, version 5 and HRC release
1.1 as a reference using the [Michigan Imputation Server](https://imputationserver.sph.umich.edu/){target="_blank"}.
These results were further integrated using QCTOOL v2, where HRC imputed variants are given precendence over 1000G phase
3 imputed variants.
### Quality control after imputation
We compared quality of the three AEGS datasets, and listed some variables of interest.
- sample type (EDTA blood or plaque)
- genotyping chip used
- reason for filtering
We checked the studytype (AE or not), and *identity-by-descent (IBD)* within and between datasets to aid in sample
mixups, duplicate sample use, and relatedness. In addition, during genotyping quality control samples were identified
that deviated from *Hardy-Weinberg Equilibrium (HWE)*, had discordance in sex-coding and genotype sex, and deviated from
the *principal component analysis (PCA)* plot.
We will load the Athero-Express Biobank Study data, and all the samples that were send for genotyping and the final
QC'ed sampleList.
# Loading data
Loading Athero-Express Biobank Study clinical and biobank data, as well as the SampleList of genetic data.
## Clinical data
```{r LoadAEDB}
cat("* get Athero-Express Biobank Study Database...")
# METHOD 1: It seems this method gives loads of errors and warnings, which all are hard to comprehend
# or debug. We expect 3,527 samples, and 927 variables; we get 927 variables!!!
# AEdata = as.data.table(read.spss(paste0(INP_loc,"/2017-1NEW_AtheroExpressDatabase_ScientificAE_20171306_v1.0.sav"),
# trim.factor.names = TRUE, trim_values = TRUE, # we trim spaces in values
# reencode = TRUE, # we re-encode to the local locale encoding
# add.undeclared.levels = "append", # we do *not* want to convert to R-factors
# use.value.labels = FALSE, # we do *not* convert variables with value labels into R factors
# use.missings = TRUE, sub = "NA", # we will set every missing variable to NA
# duplicated.value.labels = "condense", # we will condense duplicated value labels
# to.data.frame = TRUE))
# AEdata.labels <- as.data.table(attr(AEdata, "variable.labels"))
# names(AEdata.labels) <- "Variable"
# METHOD 2: Using library("haven") importing seems flawless; best argument being:
# we expect 3,527 samples and 888 variables, which is what you'd get with this method
# So for now, METHOD 2 is prefered.
#
require(haven)
AEDB <- haven::read_sav(paste0(AEDB_loc, "/2022_1_NEW_AtheroExpressDatabase_ScientificAE_15-02-2022.sav"))
# writing off the SPSS data to an Excel.
# fwrite(AEdata, file = paste0(INP_loc,"/2017-1NEW_AtheroExpressDatabase_ScientificAE_20171306_v1.0.values.xlsx"),
# sep = ";", na = "NA", dec = ".", col.names = TRUE, row.names = FALSE,
# dateTimeAs = "ISO", showProgress = TRUE, verbose = TRUE)
# warnings()
AEDB[1:10, 1:10]
dim(AEDB)
cat("* get Athero-Express Genomics Study keys...")
AEGS123.sampleList.keytable <- fread(paste0(AEGSQC_loc, "/QC/SELECTIONS/20200419.QC.AEGS123.sampleList.keytable.txt"))
dim(AEGS123.sampleList.keytable)
# AEGS123.sampleList.keytable[1:10, 1:10]
```
## Examine AEDB
We can examine the contents of the Athero-Express Biobank dataset to know what each variable is called, what class
(type) it has, and what the variable description is.
There is an excellent post on this: <https://www.r-bloggers.com/working-with-spss-labels-in-r/>.
```{r AEDB: describe}
AEDB %>% sjPlot::view_df(show.type = TRUE,
show.frq = TRUE,
show.prc = TRUE,
show.na = TRUE,
max.len = TRUE,
wrap.labels = 20,
verbose = FALSE,
use.viewer = FALSE,
file = paste0(OUT_loc, "/", Today, ".AEDB.dictionary.html"))
```
## Fix clinical data
We need to be very strict in defining *symptoms.* Therefore we will fix a new variable that groups *symptoms* at
inclusion.
Coding of *symptoms* is as follows:
- missing -999\
- Asymptomatic 0\
- TIA 1\
- minor stroke 2\
- Major stroke 3\
- Amaurosis fugax 4\
- Four vessel disease 5\
- Vertebrobasilary TIA 7\
- Retinal infarction 8\
- Symptomatic, but aspecific symtoms 9
- Contralateral symptomatic occlusion 10\
- retinal infarction 11\
- armclaudication due to occlusion subclavian artery, CEA needed for bypass 12\
- retinal infarction + TIAs 13\
- Ocular ischemic syndrome 14\
- ischemisch glaucoom 15\
- subclavian steal syndrome 16\
- TGA 17
We will group as follows:
1. Asymptomatic \> 0
2. TIA \> 1, 7, 13
3. Stroke \> 2, 3
4. Ocular \> 4, 14, 15
5. Retinal infarction \> 8, 11
6. Other \> 5, 9, 10, 12, 16, 17
```{r FixSymptoms}
# Fix symptoms
attach(AEDB)
AEDB[,"Symptoms.5G"] <- NA
AEDB$Symptoms.5G[sympt == 0] <- "Asymptomatic"
AEDB$Symptoms.5G[sympt == 1 | sympt == 7 | sympt == 13] <- "TIA"
AEDB$Symptoms.5G[sympt == 2 | sympt == 3] <- "Stroke"
AEDB$Symptoms.5G[sympt == 4 | sympt == 14 | sympt == 15 ] <- "Ocular"
AEDB$Symptoms.5G[sympt == 8 | sympt == 11] <- "Retinal infarction"
AEDB$Symptoms.5G[sympt == 5 | sympt == 9 | sympt == 10 | sympt == 12 | sympt == 16 | sympt == 17] <- "Other"
# AsymptSympt
AEDB[,"AsymptSympt"] <- NA
AEDB$AsymptSympt[sympt == -999] <- NA
AEDB$AsymptSympt[sympt == 0] <- "Asymptomatic"
AEDB$AsymptSympt[sympt == 1 | sympt == 7 | sympt == 13 | sympt == 2 | sympt == 3] <- "Symptomatic"
AEDB$AsymptSympt[sympt == 4 | sympt == 14 | sympt == 15 | sympt == 8 | sympt == 11 | sympt == 5 | sympt == 9 | sympt == 10 | sympt == 12 | sympt == 16 | sympt == 17] <- "Ocular and others"
# AsymptSympt
AEDB[,"AsymptSympt2G"] <- NA
AEDB$AsymptSympt2G[sympt == -999] <- NA
AEDB$AsymptSympt2G[sympt == 0] <- "Asymptomatic"
AEDB$AsymptSympt2G[sympt == 1 | sympt == 7 | sympt == 13 | sympt == 2 | sympt == 3 | sympt == 4 | sympt == 14 | sympt == 15 | sympt == 8 | sympt == 11 | sympt == 5 | sympt == 9 | sympt == 10 | sympt == 12 | sympt == 16 | sympt == 17] <- "Symptomatic"
detach(AEDB)
# table(AEDB$sympt, useNA = "ifany")
# table(AEDB$AsymptSympt2G, useNA = "ifany")
# table(AEDB$Symptoms.5G, useNA = "ifany")
#
# table(AEDB$AsymptSympt2G, AEDB$sympt, useNA = "ifany")
# table(AEDB$Symptoms.5G, AEDB$sympt, useNA = "ifany")
table(AEDB$AsymptSympt2G, AEDB$Symptoms.5G, useNA = "ifany")
# AEDB.temp <- subset(AEDB, select = c("STUDY_NUMBER", "UPID", "Age", "Gender", "Hospital", "Artery_summary", "sympt", "Symptoms.5G", "AsymptSympt"))
# require(labelled)
# AEDB.temp$Gender <- to_factor(AEDB.temp$Gender)
# AEDB.temp$Hospital <- to_factor(AEDB.temp$Hospital)
# AEDB.temp$Artery_summary <- to_factor(AEDB.temp$Artery_summary)
#
# DT::datatable(AEDB.temp[1:10,], caption = "Excerpt of the whole AEDB.", rownames = FALSE)
#
# table(AEDB.temp$Symptoms.5G, AEDB.temp$AsymptSympt)
#
# rm(AEDB.temp)
```
We will also fix the *plaquephenotypes* variable.
Coding of symptoms is as follows:
- missing -999\
- not relevant -888
- fibrous 1\
- fibroatheromatous 2\
- atheromatous 3
```{r FixPlaquePhenotypes}
# Fix plaquephenotypes
attach(AEDB)
AEDB[,"OverallPlaquePhenotype"] <- NA
AEDB$OverallPlaquePhenotype[plaquephenotype == -999] <- NA
AEDB$OverallPlaquePhenotype[plaquephenotype == -999] <- NA
AEDB$OverallPlaquePhenotype[plaquephenotype == 1] <- "fibrous"
AEDB$OverallPlaquePhenotype[plaquephenotype == 2] <- "fibroatheromatous"
AEDB$OverallPlaquePhenotype[plaquephenotype == 3] <- "atheromatous"
detach(AEDB)
# AEDB.temp <- subset(AEDB, select = c("STUDY_NUMBER", "UPID", "Age", "Gender", "Hospital", "Artery_summary", "plaquephenotype", "OverallPlaquePhenotype"))
# require(labelled)
# AEDB.temp$Gender <- to_factor(AEDB.temp$Gender)
# AEDB.temp$Hospital <- to_factor(AEDB.temp$Hospital)
# AEDB.temp$Artery_summary <- to_factor(AEDB.temp$Artery_summary)
#
# DT::datatable(AEDB.temp[1:10,], caption = "Excerpt of the whole AEDB.", rownames = FALSE)
#
# rm(AEDB.temp)
```
We will also fix the *diabetes* status variable.
```{r FixDiabetes}
# Fix diabetes
attach(AEDB)
AEDB[,"DiabetesStatus"] <- NA
AEDB$DiabetesStatus[DM.composite == -999] <- NA
AEDB$DiabetesStatus[DM.composite == 0] <- "Control (no Diabetes Dx/Med)"
AEDB$DiabetesStatus[DM.composite == 1] <- "Diabetes"
detach(AEDB)
# AEDB.temp <- subset(AEDB, select = c("STUDY_NUMBER", "UPID", "Age", "Gender", "Hospital", "Artery_summary", "DM.composite", "DiabetesStatus"))
# require(labelled)
# AEDB.temp$Gender <- to_factor(AEDB.temp$Gender)
# AEDB.temp$Hospital <- to_factor(AEDB.temp$Hospital)
# AEDB.temp$Artery_summary <- to_factor(AEDB.temp$Artery_summary)
# AEDB.temp$DiabetesStatus <- to_factor(AEDB.temp$DiabetesStatus)
#
# DT::datatable(AEDB.temp[1:10,], caption = "Excerpt of the whole AEDB.", rownames = FALSE)
#
# rm(AEDB.temp)
```
We will also fix the *smoking* status variable. We are interested in whether someone never, ever or is currently (at the
time of inclusion) smoking. This is based on the questionnaire.
- `diet801`: are you a smoker?
- `diet802`: did you smoke in the past?
We already have some variables indicating smoking status:
- `SmokingReported`: patient has reported to smoke.
- `SmokingYearOR`: smoking in the year of surgery?
- `SmokerCurrent`: currently smoking?
```{r FixSmoking}
require(labelled)
AEDB$diet801 <- to_factor(AEDB$diet801)
AEDB$diet802 <- to_factor(AEDB$diet802)
AEDB$diet805 <- to_factor(AEDB$diet805)
AEDB$SmokingReported <- to_factor(AEDB$SmokingReported)
AEDB$SmokerCurrent <- to_factor(AEDB$SmokerCurrent)
AEDB$SmokingYearOR <- to_factor(AEDB$SmokingYearOR)
# table(AEDB$diet801)
# table(AEDB$diet802)
# table(AEDB$SmokingReported)
# table(AEDB$SmokerCurrent)
# table(AEDB$SmokingYearOR)
# table(AEDB$SmokingReported, AEDB$SmokerCurrent, useNA = "ifany", dnn = c("Reported smoking", "Current smoker"))
#
# table(AEDB$diet801, AEDB$diet802, useNA = "ifany", dnn = c("Smoker", "Past smoker"))
cat("\nFixing smoking status.\n")
attach(AEDB)
AEDB[,"SmokerStatus"] <- NA
AEDB$SmokerStatus[diet802 == "don't know"] <- "Never smoked"
AEDB$SmokerStatus[diet802 == "I still smoke"] <- "Current smoker"
AEDB$SmokerStatus[SmokerCurrent == "no" & diet802 == "no"] <- "Never smoked"
AEDB$SmokerStatus[SmokerCurrent == "no" & diet802 == "yes"] <- "Ex-smoker"
AEDB$SmokerStatus[SmokerCurrent == "yes"] <- "Current smoker"
AEDB$SmokerStatus[SmokerCurrent == "no data available/missing"] <- NA
# AEDB$SmokerStatus[is.na(SmokerCurrent)] <- "Never smoked"
detach(AEDB)
cat("\n* Current smoking status.\n")
table(AEDB$SmokerCurrent,
useNA = "ifany",
dnn = c("Current smoker"))
cat("\n* Updated smoking status.\n")
table(AEDB$SmokerStatus,
useNA = "ifany",
dnn = c("Updated smoking status"))
cat("\n* Comparing to 'SmokerCurrent'.\n")
table(AEDB$SmokerStatus, AEDB$SmokerCurrent,
useNA = "ifany",
dnn = c("Updated smoking status", "Current smoker"))
# AEDB.temp <- subset(AEDB, select = c("STUDY_NUMBER", "UPID", "Age", "Gender", "Hospital", "Artery_summary", "DM.composite", "DiabetesStatus"))
# require(labelled)
# AEDB.temp$Gender <- to_factor(AEDB.temp$Gender)
# AEDB.temp$Hospital <- to_factor(AEDB.temp$Hospital)
# AEDB.temp$Artery_summary <- to_factor(AEDB.temp$Artery_summary)
# AEDB.temp$DiabetesStatus <- to_factor(AEDB.temp$DiabetesStatus)
#
# DT::datatable(AEDB.temp[1:10,], caption = "Excerpt of the whole AEDB.", rownames = FALSE)
#
# rm(AEDB.temp)
```
We will also fix the *alcohol* status variable.
```{r FixAlcohol}
# Fix diabetes
attach(AEDB)
AEDB[,"AlcoholUse"] <- NA
AEDB$AlcoholUse[diet810 == -999] <- NA
AEDB$AlcoholUse[diet810 == 0] <- "No"
AEDB$AlcoholUse[diet810 == 1] <- "Yes"
detach(AEDB)
# AEDB.temp <- subset(AEDB, select = c("STUDY_NUMBER", "UPID", "Age", "Gender", "Hospital", "Artery_summary", "diet810", "AlcoholUse"))
# require(labelled)
# AEDB.temp$Gender <- to_factor(AEDB.temp$Gender)
# AEDB.temp$Hospital <- to_factor(AEDB.temp$Hospital)
# AEDB.temp$Artery_summary <- to_factor(AEDB.temp$Artery_summary)
# AEDB.temp$AlcoholUse <- to_factor(AEDB.temp$AlcoholUse)
#
# DT::datatable(AEDB.temp[1:10,], caption = "Excerpt of the whole AEDB.", rownames = FALSE)
#
# rm(AEDB.temp)
```
We will also fix and inverse-rank normal transform the continuous (manually) scored plaque phenotypes.
```{r IRNT PlaquePhenotypes}
AEDB$macmean0 <- as.numeric(AEDB$macmean0)
AEDB$smcmean0 <- as.numeric(AEDB$smcmean0)
AEDB$neutrophils <- as.numeric(AEDB$neutrophils)
AEDB$Mast_cells_plaque <- as.numeric(AEDB$Mast_cells_plaque)
AEDB$vessel_density_averaged <- as.numeric(AEDB$vessel_density_averaged)
AEDB$MAC_rankNorm <- qnorm((rank(AEDB$macmean0, na.last = "keep") - 0.5) / sum(!is.na(AEDB$macmean0)))
AEDB$SMC_rankNorm <- qnorm((rank(AEDB$smcmean0, na.last = "keep") - 0.5) / sum(!is.na(AEDB$smcmean0)))
AEDB$Neutrophils_rankNorm <- qnorm((rank(AEDB$neutrophils, na.last = "keep") - 0.5) / sum(!is.na(AEDB$neutrophils)))
AEDB$MastCells_rankNorm <- qnorm((rank(AEDB$Mast_cells_plaque, na.last = "keep") - 0.5) / sum(!is.na(AEDB$Mast_cells_plaque)))
AEDB$VesselDensity_rankNorm <- qnorm((rank(AEDB$vessel_density_averaged, na.last = "keep") - 0.5) / sum(!is.na(AEDB$vessel_density_averaged)))
```
```{r IRNT PlaquePhenotypes: Visualisation, message=FALSE, warning=FALSE}
library(labelled)
AEDB$Gender <- to_factor(AEDB$Gender)
ggpubr::gghistogram(AEDB, "macmean0",
# y = "..count..",
color = "white",
fill = "Gender",
palette = c("#1290D9", "#DB003F"),
add = "median",
#add_density = TRUE,
rug = TRUE,
#add.params = list(color = "black", linetype = 2),
title = "% of macrophages (CD68)",
xlab = "% per region of interest",
ggtheme = theme_minimal())
ggpubr::gghistogram(AEDB, "MAC_rankNorm",
# y = "..count..",
color = "white",
fill = "Gender",
palette = c("#1290D9", "#DB003F"),
add = "median",
#add_density = TRUE,
rug = TRUE,
#add.params = list(color = "black", linetype = 2),
title = "% of macrophages (CD68)",
xlab = "% per region of interest\ninverse-rank normalized number",
ggtheme = theme_minimal())
ggpubr::gghistogram(AEDB, "smcmean0",
# y = "..count..",
color = "white",
fill = "Gender",
palette = c("#1290D9", "#DB003F"),
add = "median",
#add_density = TRUE,
rug = TRUE,
#add.params = list(color = "black", linetype = 2),
title = "% of smooth muscle cells (SMA)",
xlab = "% per region of interest",
ggtheme = theme_minimal())
ggpubr::gghistogram(AEDB, "SMC_rankNorm",
# y = "..count..",
color = "white",
fill = "Gender",
palette = c("#1290D9", "#DB003F"),
add = "median",
#add_density = TRUE,
rug = TRUE,
#add.params = list(color = "black", linetype = 2),
title = "% of smooth muscle cells (SMA)",
xlab = "% per region of interest\ninverse-rank normalized number",
ggtheme = theme_minimal())
ggpubr::gghistogram(AEDB, "neutrophils",
# y = "..count..",
color = "white",
fill = "Gender",
palette = c("#1290D9", "#DB003F"),
add = "median",
#add_density = TRUE,
rug = TRUE,
#add.params = list(color = "black", linetype = 2),
title = "number of neutrophils (CD66b)",
xlab = "counts per plaque",
ggtheme = theme_minimal())
ggpubr::gghistogram(AEDB, "Neutrophils_rankNorm",
# y = "..count..",
color = "white",
fill = "Gender",
palette = c("#1290D9", "#DB003F"),
add = "median",
#add_density = TRUE,
rug = TRUE,
#add.params = list(color = "black", linetype = 2),
title = "number of neutrophils (CD66b)",
xlab = "counts per plaque\ninverse-rank normalized number",
ggtheme = theme_minimal())
ggpubr::gghistogram(AEDB, "Mast_cells_plaque",
# y = "..count..",
color = "white",
fill = "Gender",
palette = c("#1290D9", "#DB003F"),
add = "median",
#add_density = TRUE,
rug = TRUE,
#add.params = list(color = "black", linetype = 2),
title = "number of mast cells",
xlab = "counts per plaque",
ggtheme = theme_minimal())
ggpubr::gghistogram(AEDB, "MastCells_rankNorm",
# y = "..count..",
color = "white",
fill = "Gender",
palette = c("#1290D9", "#DB003F"),
add = "median",
#add_density = TRUE,
rug = TRUE,
#add.params = list(color = "black", linetype = 2),
title = "number of mast cells",
xlab = "counts per plaque\ninverse-rank normalized number",
ggtheme = theme_minimal())
ggpubr::gghistogram(AEDB, "vessel_density_averaged",
# y = "..count..",
color = "white",
fill = "Gender",
palette = c("#1290D9", "#DB003F"),
add = "median",
#add_density = TRUE,
rug = TRUE,
#add.params = list(color = "black", linetype = 2),
title = "number of intraplaque neovessels",
xlab = "counts per 3-4 hotspots",
ggtheme = theme_minimal())
ggpubr::gghistogram(AEDB, "VesselDensity_rankNorm",
# y = "..count..",
color = "white",
fill = "Gender",
palette = c("#1290D9", "#DB003F"),
add = "median",
#add_density = TRUE,
rug = TRUE,
#add.params = list(color = "black", linetype = 2),
title = "number of intraplaque neovessels",
xlab = "counts per 3-4 hotspots\ninverse-rank normalized number",
ggtheme = theme_minimal())
```
Here we calculate the *plaque instability/vulnerability* index
```{r Plaque Vulnerability}
# Plaque vulnerability
require(labelled)
AEDB$Macrophages.bin <- to_factor(AEDB$Macrophages.bin)
AEDB$SMC.bin <- to_factor(AEDB$SMC.bin)
AEDB$IPH.bin <- to_factor(AEDB$IPH.bin)
AEDB$Calc.bin <- to_factor(AEDB$Calc.bin)
AEDB$Collagen.bin <- to_factor(AEDB$Collagen.bin)
AEDB$Fat.bin_10 <- to_factor(AEDB$Fat.bin_10)
AEDB$Fat.bin_40 <- to_factor(AEDB$Fat.bin_40)
table(AEDB$Macrophages.bin)
table(AEDB$Fat.bin_10)
table(AEDB$Collagen.bin)
table(AEDB$SMC.bin)
table(AEDB$IPH.bin)
# SPSS code
#
# *** syntax- Plaque vulnerability**.
# COMPUTE Macro_instab = -999.
# IF macrophages.bin=2 Macro_instab=1.
# IF macrophages.bin=1 Macro_instab=0.
# EXECUTE.
#
# COMPUTE Fat10_instab = -999.
# IF Fat.bin_10=2 Fat10_instab=1.
# IF Fat.bin_10=1 Fat10_instab=0.
# EXECUTE.
#
# COMPUTE coll_instab=-999.
# IF Collagen.bin=2 coll_instab=0.
# IF Collagen.bin=1 coll_instab=1.
# EXECUTE.
#
#
# COMPUTE SMC_instab=-999.
# IF SMC.bin=2 SMC_instab=0.
# IF SMC.bin=1 SMC_instab=1.
# EXECUTE.
#
# COMPUTE IPH_instab=-999.
# IF IPH.bin=0 IPH_instab=0.
# IF IPH.bin=1 IPH_instab=1.
# EXECUTE.
#
# COMPUTE Instability=Macro_instab + Fat10_instab + coll_instab + SMC_instab + IPH_instab.
# EXECUTE.
# Fix plaquephenotypes
attach(AEDB)
# mac instability
AEDB[,"MAC_Instability"] <- NA
AEDB$MAC_Instability[Macrophages.bin == -999] <- NA
AEDB$MAC_Instability[Macrophages.bin == "no/minor"] <- 0
AEDB$MAC_Instability[Macrophages.bin == "moderate/heavy"] <- 1
# fat instability
AEDB[,"FAT10_Instability"] <- NA
AEDB$FAT10_Instability[Fat.bin_10 == -999] <- NA
AEDB$FAT10_Instability[Fat.bin_10 == " <10%"] <- 0
AEDB$FAT10_Instability[Fat.bin_10 == " >10%"] <- 1
# col instability
AEDB[,"COL_Instability"] <- NA
AEDB$COL_Instability[Collagen.bin == -999] <- NA
AEDB$COL_Instability[Collagen.bin == "no/minor"] <- 1
AEDB$COL_Instability[Collagen.bin == "moderate/heavy"] <- 0
# smc instability
AEDB[,"SMC_Instability"] <- NA
AEDB$SMC_Instability[SMC.bin == -999] <- NA
AEDB$SMC_Instability[SMC.bin == "no/minor"] <- 1
AEDB$SMC_Instability[SMC.bin == "moderate/heavy"] <- 0
# iph instability
AEDB[,"IPH_Instability"] <- NA
AEDB$IPH_Instability[IPH.bin == -999] <- NA
AEDB$IPH_Instability[IPH.bin == "no"] <- 0
AEDB$IPH_Instability[IPH.bin == "yes"] <- 1
detach(AEDB)
table(AEDB$MAC_Instability, useNA = "ifany")
table(AEDB$FAT10_Instability, useNA = "ifany")
table(AEDB$COL_Instability, useNA = "ifany")
table(AEDB$SMC_Instability, useNA = "ifany")
table(AEDB$IPH_Instability, useNA = "ifany")
# creating vulnerability index
AEDB <- AEDB %>% mutate(Plaque_Vulnerability_Index = factor(rowSums(.[grep("_Instability", names(.))], na.rm = TRUE)),
)
table(AEDB$Plaque_Vulnerability_Index, useNA = "ifany")
# str(AEDB$Plaque_Vulnerability_Index)
```
## Prepare baseline summary
We are interested in the following variables at baseline.
- Age (years)
- Female sex (N, %)
- Hypertension (N, %)
- SBP (mmHg)
- DBP (mmHg)
- Diabetes mellitus (N, %)
- Total cholesterol levels (mg/dL)
- LDL cholesterol levels (mg/dL)
- HDL cholesterol levels (mg/dL)
- Triglyceride levels (mg/dL)
- Use of statins (N, %)
- Use of antiplatelet drugs (N, %)
- BMI (kg/m²)
- Smoking status (N, %)
- Never smokers
- Ex-smokers
- Current smokers
- History of CAD (N, %)
- History of PAD (N, %)
- Clinical manifestations
- Asymptomatic
- Amaurosis fugax
- TIA
- Stroke
- eGFR (mL/min/1.73 m²)
- stenosis
- year of surgery
- plaque characteristics
- PCSK9
### Fix things for Target
For this project we also fix the `r TRAIT_OF_INTEREST` levels for analyses.
> Measurement: This was measured in citrate plasma, at pg/mL using a LUMINEX assay.
```{r FixTarget}
# Fix hormones
attach(AEDB)
AEDB[,"Plasma_PCSK9"] <- NA
AEDB$Plasma_PCSK9 <- as.numeric(AEDB$PCSK9_plasma)
AEDB$Plasma_PCSK9[PCSK9_plasma == -999] <- NA
AEDB$Plasma_PCSK9[PCSK9_plasma == -888] <- NA
AEDB$Plasma_PCSK9[PCSK9_plasma == -777] <- NA
AEDB$Plasma_PCSK9[PCSK9_plasma == -666] <- NA
detach(AEDB)
AEDB$Plasma_PCSK9_rankNorm <- qnorm((rank(AEDB$PCSK9_plasma, na.last = "keep") - 0.5) / sum(!is.na(AEDB$PCSK9_plasma)))
AEDB.temp <- subset(AEDB, select = c("STUDY_NUMBER", "UPID", "Age", "Gender", "Hospital", "Artery_summary", "PCSK9_plasma", "Plasma_PCSK9", "Plasma_PCSK9_rankNorm"))
require(labelled)
AEDB.temp$Gender <- to_factor(AEDB.temp$Gender)
AEDB.temp$Hospital <- to_factor(AEDB.temp$Hospital)
AEDB.temp$Artery_summary <- to_factor(AEDB.temp$Artery_summary)
DT::datatable(AEDB.temp[1:10,], caption = "Excerpt of the whole AEDB.", rownames = FALSE)
rm(AEDB.temp)
```
```{r IRNT Target: Visualisation, message=FALSE, warning=FALSE}
library(labelled)
AEDB$Gender <- to_factor(AEDB$Gender)
AEDB$PCSK9_plasma <- as.numeric(AEDB$PCSK9_plasma)
ggpubr::gghistogram(AEDB, "Plasma_PCSK9",
# y = "..count..",
color = "white",
fill = "Gender",
palette = c("#1290D9", "#DB003F"),
add = "median",
#add_density = TRUE,
rug = TRUE,
#add.params = list(color = "black", linetype = 2),
title = "PCSK9 (citrate-plasma)",
xlab = "pg/mL",
ggtheme = theme_minimal())
ggpubr::gghistogram(AEDB, "Plasma_PCSK9_rankNorm",
# y = "..count..",
color = "white",