forked from opain/GenoPred
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFunctionally_informed_prediction.Rmd
5946 lines (4539 loc) · 284 KB
/
Functionally_informed_prediction.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: "Evaluation of Imputed Gene Expression Risk Scores"
output:
html_document:
toc: true
theme: united
toc_depth: 3
number_sections: true
toc_float: true
fig_caption: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
<style>
p.caption {
font-size: 1.5em;
}
</style>
```{css, echo=F}
pre code, pre, code {
white-space: pre !important;
overflow-x: scroll !important;
word-break: keep-all !important;
word-wrap: initial !important;
}
```
***
# Introduction
This study evaluates the predictive utility of GeRS calculated using several strategies. The predictive utility of models containing polygenic scores and GeRS is also investigated.
<br/>
***
# Aims
* Evaluate the predictive utility of GeRS based on a single eQTL data source.
* Evaluate models combining GeRS derived eQTL data from multiple tissues.
* Determine whether GeRS can improve prediction when in combination with polygenic scores.
<br/>
***
# Methods
## Samples
- UK Biobank
- TEDS
## Outcomes
* UK Biobank
* Depression (binary)
* Intelligence (continuous)
* Body mass index (BMI - continuous)
* Height (continuous)
* Coronary Artery Disease (CAD - Binary)
* Type II Diabetes (T2D - Binary)
* Inflammatory Bowel Disorder (IBD - Binary)
* Rheumatoid arthritis (RheuArth - Binary)
* TEDS
* ADHD traits (continuous)
* Height (continuous)
* Body mass index (BMI - continuous)
* GCSE scores (continuous)
Note. Multiple Slerosis in UK Biobank was not included due to insufficent SNP data in the corresponding GWAS for TWAS.
## Genotypic data
Both target sample underwent stringent quality control prior to imputation using the HRC-reference. After imputation, genotypes were converted to PLINK hard-calls, and only HapMap3 SNPs were retained. Eureopean individuals within the target samples were identified and retained if they were within the 3SD of the 1KG European mean of the first 100 principal components.
## GWAS summary statistics
For each target phenotype, the largest independent phenotype-matched GWAS was selected for calculating polygenic scores. More information can be found in the table below.
<details><summary>Preparing GWAS sumstats table for UK Biobank phenotypes</summary>
```{R, echo=T, eval=F}
source('/users/k1806347/brc_scratch/Software/MyGit/GenoPred/config_used/Phenotype_prep.config')
library(data.table)
pheno<-fread('/users/k1806347/brc_scratch/Data/GWAS_sumstats/QC_sumstats_list_031218.csv')
ukb_pheno=c('Depression','Intelligence','BMI','Height','T2D','CAD','IBD','MultiScler','RheuArth')
ukb_gwas=c('DEPR06','COLL01','BODY03','HEIG03','DIAB05','COAD01','CROH01','SCLE02','RHEU01')
ukb_prev=c(0.15,NA,NA,NA,0.05,0.03,0.013,0.00164,0.005)
ukb_dat<-data.frame(pheno=ukb_pheno,gwas=ukb_gwas,prev=ukb_prev)
pheno_ukb<-pheno[(pheno$Code %in% ukb_gwas),]
pheno_ukb<-pheno_ukb[,c('Code','trait','year','PMID','Ncases','Ncontrols','sample_size_discovery','h2 observed','h2 se','lambda GC','intercept','intercept se')]
names(pheno_ukb)<-c('Code','trait','year','PMID','Ncases','Ncontrols','sample_size_discovery','h2_obs','h2_se','lambda','intercept','intercept_se')
pheno_ukb$pop_prev<-ukb_dat$prev[match(pheno_ukb$Code, ukb_dat$gwas)]
pheno_ukb$Target_Phenotype<-ukb_dat$pheno[match(pheno_ukb$Code, ukb_dat$gwas)]
pheno_ukb$Ncases<-as.numeric(gsub(',','',pheno_ukb$Ncases))
pheno_ukb$Ncontrols<-as.numeric(gsub(',','',pheno_ukb$Ncontrols))
pheno_ukb$samp_prev<-pheno_ukb$Ncases/(pheno_ukb$Ncases+pheno_ukb$Ncontrols)
h2l_R2 <- function(k, r2, p) {
# K baseline disease risk
# r2 from a linear regression model attributable to genomic profile risk score
# P proportion of sample that are cases
# calculates proportion of variance explained on the liability scale
#from ABC at http://www.complextraitgenomics.com/software/
#Lee SH, Goddard ME, Wray NR, Visscher PM. (2012) A better coefficient of determination for genetic profile analysis. Genet Epidemiol. 2012 Apr;36(3):214-24.
x= qnorm(1-k)
z= dnorm(x)
i=z/k
C= k*(1-k)*k*(1-k)/(z^2*p*(1-p))
theta= i*((p-k)/(1-k))*(i*((p-k)/(1-k))-x)
h2l_R2 = C*r2 / (1 + C*theta*r2)
}
se_h2l_R2 <- function(k,h2,se, p) {
# K baseline disease risk
# r2 from a linear regression model attributable to genomic profile risk score
# P proportion of sample that are cases
# calculates proportion of variance explained on the liability scale
#from ABC at http://www.complextraitgenomics.com/software/
#Lee SH, Goddard ME, Wray NR, Visscher PM. (2012) A better coefficient of determination for genetic profile analysis. Genet Epidemiol. 2012 Apr;36(3):214-24.
#SE on the liability (From a Taylor series expansion)
#var(h2l_r2) = [d(h2l_r2)/d(R2v)]^2*var(R2v) with d being calculus differentiation
x= qnorm(1-k)
z= dnorm(x)
i=z/k
C= k*(1-k)*k*(1-k)/(z^2*p*(1-p))
theta= i*((p-k)/(1-k))*(i*((p-k)/(1-k))-x)
se_h2l_R2 = C*(1-h2*theta)*se
}
pheno_ukb$h2_obs<-as.numeric(pheno_ukb$h2_obs)
pheno_ukb$h2_se<-as.numeric(pheno_ukb$h2_se)
pheno_ukb$h2_liab<-round(h2l_R2(k=pheno_ukb$pop_prev, r2=pheno_ukb$h2_obs, p=pheno_ukb$samp_prev),3)
pheno_ukb$h2_liab_se<-round(se_h2l_R2(k=pheno_ukb$pop_prev,h2=pheno_ukb$h2_obs,se=pheno_ukb$h2_se, p=pheno_ukb$samp_prev),3)
pheno_ukb$h2_obs<-paste0(pheno_ukb$h2_obs," (", pheno_ukb$h2_se,")")
pheno_ukb$h2_se<-NULL
pheno_ukb$h2_liab[!is.na(pheno_ukb$Ncases)]<-paste0(pheno_ukb$h2_liab[!is.na(pheno_ukb$Ncases)]," (", pheno_ukb$h2_liab_se[!is.na(pheno_ukb$Ncases)],")")
pheno_ukb$h2_liab_se<-NULL
pheno_ukb$intercept<-paste0(pheno_ukb$intercept," (", pheno_ukb$intercept_se,")")
pheno_ukb$intercept_se<-NULL
pheno_ukb$trait<-c('BMI','CAD','College Completion',"Crohn's Disease",'Major Depression','T2D','Height','RheuArth','MultiScler')
pheno_ukb<-pheno_ukb[match(ukb_dat$gwas,pheno_ukb$Code),]
pheno_ukb<-pheno_ukb[,c('Target_Phenotype','Code','trait','year','PMID','Ncases','Ncontrols','sample_size_discovery','h2_obs','h2_liab','intercept','lambda')]
names(pheno_ukb)<-c('Target Phenotype','Code','GWAS Phenotype','Year','PMID','Ncase','Ncontrol','N','h2_obs','h2_liab','Intercept','Lambda')
write.csv(pheno_ukb, '/users/k1806347/brc_scratch/Data/GWAS_sumstats/UKBB_phenotype_GWAS_descrip.csv', row.names=F, quote=F)
```
</details>
<details><summary>Show GWAS for UK Biobank phenotypes</summary>
```{r, echo=F, eval=T, results='asis'}
res<-read.csv("/users/k1806347/brc_scratch/Data/GWAS_sumstats/UKBB_phenotype_GWAS_descrip.csv")
names(res)<-c('Target Phenotype','Code','GWAS Phenotype','Year','PMID','Ncase','Ncontrol','N',"h2-obs (SE)","h2-liab (SE)",'Intercept','Lambda')
library(knitr)
kable(res, rownames = FALSE, caption='GWAS used for each UK Biobank phenotype')
```
</details>
<details><summary>Preparing GWAS sumstats table for TEDS phenotypes</summary>
```{R, echo=T, eval=F}
source('/users/k1806347/brc_scratch/Software/MyGit/GenoPred/config_used/Phenotype_prep.config')
library(data.table)
pheno<-fread('/users/k1806347/brc_scratch/Data/GWAS_sumstats/QC_sumstats_list_031218.csv')
teds_pheno=c('Height21', 'BMI21', 'GCSE', 'ADHD')
teds_gwas=c('HEIG03', 'BODY11', 'EDUC03', 'ADHD04')
teds_prev=c(NA,NA,NA,0.05)
teds_dat<-data.frame(pheno=teds_pheno,gwas=teds_gwas,prev=teds_prev)
pheno_teds<-pheno[(pheno$Code %in% teds_gwas),]
pheno_teds<-pheno_teds[,c('Code','trait','year','PMID','Ncases','Ncontrols','sample_size_discovery','h2 observed','h2 se','lambda GC','intercept','intercept se')]
names(pheno_teds)<-c('Code','trait','year','PMID','Ncases','Ncontrols','sample_size_discovery','h2_obs','h2_se','lambda','intercept','intercept_se')
pheno_teds$pop_prev<-teds_dat$prev[match(pheno_teds$Code, teds_dat$gwas)]
pheno_teds$Target_Phenotype<-teds_dat$pheno[match(pheno_teds$Code, teds_dat$gwas)]
pheno_teds$Ncases<-as.numeric(gsub(',','',pheno_teds$Ncases))
pheno_teds$Ncontrols<-as.numeric(gsub(',','',pheno_teds$Ncontrols))
pheno_teds$samp_prev<-pheno_teds$Ncases/(pheno_teds$Ncases+pheno_teds$Ncontrols)
h2l_R2 <- function(k, r2, p) {
# K baseline disease risk
# r2 from a linear regression model attributable to genomic profile risk score
# P proportion of sample that are cases
# calculates proportion of variance explained on the liability scale
#from ABC at http://www.complextraitgenomics.com/software/
#Lee SH, Goddard ME, Wray NR, Visscher PM. (2012) A better coefficient of determination for genetic profile analysis. Genet Epidemiol. 2012 Apr;36(3):214-24.
x= qnorm(1-k)
z= dnorm(x)
i=z/k
C= k*(1-k)*k*(1-k)/(z^2*p*(1-p))
theta= i*((p-k)/(1-k))*(i*((p-k)/(1-k))-x)
h2l_R2 = C*r2 / (1 + C*theta*r2)
}
se_h2l_R2 <- function(k,h2,se, p) {
# K baseline disease risk
# r2 from a linear regression model attributable to genomic profile risk score
# P proportion of sample that are cases
# calculates proportion of variance explained on the liability scale
#from ABC at http://www.complextraitgenomics.com/software/
#Lee SH, Goddard ME, Wray NR, Visscher PM. (2012) A better coefficient of determination for genetic profile analysis. Genet Epidemiol. 2012 Apr;36(3):214-24.
#SE on the liability (From a Taylor series expansion)
#var(h2l_r2) = [d(h2l_r2)/d(R2v)]^2*var(R2v) with d being calculus differentiation
x= qnorm(1-k)
z= dnorm(x)
i=z/k
C= k*(1-k)*k*(1-k)/(z^2*p*(1-p))
theta= i*((p-k)/(1-k))*(i*((p-k)/(1-k))-x)
se_h2l_R2 = C*(1-h2*theta)*se
}
pheno_teds$h2_obs<-as.numeric(pheno_teds$h2_obs)
pheno_teds$h2_se<-as.numeric(pheno_teds$h2_se)
pheno_teds$h2_liab<-round(h2l_R2(k=pheno_teds$pop_prev, r2=pheno_teds$h2_obs, p=pheno_teds$samp_prev),3)
pheno_teds$h2_liab_se<-round(se_h2l_R2(k=pheno_teds$pop_prev,h2=pheno_teds$h2_obs,se=pheno_teds$h2_se, p=pheno_teds$samp_prev),3)
pheno_teds$h2_obs<-paste0(pheno_teds$h2_obs," (", pheno_teds$h2_se,")")
pheno_teds$h2_se<-NULL
pheno_teds$h2_liab[!is.na(pheno_teds$Ncases)]<-paste0(pheno_teds$h2_liab[!is.na(pheno_teds$Ncases)]," (", pheno_teds$h2_liab_se[!is.na(pheno_teds$Ncases)],")")
pheno_teds$h2_liab_se<-NULL
pheno_teds$intercept<-paste0(pheno_teds$intercept," (", pheno_teds$intercept_se,")")
pheno_teds$intercept_se<-NULL
pheno_teds$trait<-c("ADHD (mixed ancestry)",'BMI','Educational Attainment','Height')
pheno_teds<-pheno_teds[match(teds_dat$gwas,pheno_teds$Code),]
pheno_teds<-pheno_teds[,c('Target_Phenotype','Code','trait','year','PMID','Ncases','Ncontrols','sample_size_discovery','h2_obs','h2_liab','intercept','lambda')]
names(pheno_teds)<-c('Target Phenotype','Code','GWAS Phenotype','Year','PMID','Ncase','Ncontrol','N','h2_obs','h2_liab','Intercept','Lambda')
pheno_teds$PMID[2]<-30124842
pheno_teds$PMID[4]<-30478444
write.csv(pheno_teds, '/users/k1806347/brc_scratch/Data/GWAS_sumstats/TEDS_phenotype_GWAS_descrip.csv', row.names=F, quote=F)
```
</details>
<details><summary>Show GWAS for TEDS phenotypes</summary>
```{r, echo=F, eval=T, results='asis'}
res<-read.csv("/users/k1806347/brc_scratch/Data/GWAS_sumstats/TEDS_phenotype_GWAS_descrip.csv")
names(res)<-c('Target Phenotype','Code','GWAS Phenotype','Year','PMID','Ncase','Ncontrol','N',"h2-obs (SE)","h2-liab (SE)",'Intercept','Lambda')
library(knitr)
kable(res, rownames = FALSE, caption='GWAS used for each TEDS phenotype')
```
</details>
<br/>
## TWAS
<details><summary>Preparing table showing SNP-weight sets used</summary>
```{R, echo=T, eval=F}
source('/users/k1806347/brc_scratch/Software/MyGit/GenoPred/config_used/Phenotype_prep.config')
library(data.table)
weights<-fread(paste0(TWAS_rep, '/snp_weight_list.txt'), header=F)$V1
pos_unique<-fread('/users/k1806347/brc_scratch/Data/1KG/Phase3/Predicted_expression/Tissue_specific.pos')
pos_unique$WGT<-paste0(pos_unique$PANEL,'/',gsub('.*/','',pos_unique$WGT))
weights_info<-NULL
pos_all<-NULL
for(weights_i in weights){
pos<-fread(paste0(FUSION_dir,'/SNP-weights/',weights_i,'/',weights_i,'.pos'))
if(grepl('CMC', weights_i) == T){
sample_i<-'CMC'
tissue_i<-'Brain:DLPFC'
}
if(grepl('NTR', weights_i) == T){
sample_i<-'NTR'
tissue_i<-'Peripheral Blood'
}
if(grepl('YFS', weights_i) == T){
sample_i<-'YFS'
tissue_i<-'Whole Blood'
}
if(grepl('METSIM', weights_i) == T){
sample_i<-'METSIM'
tissue_i<-'Adipose'
}
if(grepl('CMC|NTR|YFS|METSIM', weights_i) == F){
sample_i<-'GTEx'
tissue_i<-gsub('_',' ',weights_i)
}
weights_info<-rbind(weights_info, data.frame(Set=weights_i,
Sample=sample_i,
Tissue=tissue_i,
Type='Expression',
N_indiv=pos$N[1],
N_feat=dim(pos)[1],
N_feat_spec=sum(pos$WGT %in% pos_unique$WGT)))
pos_all<-rbind(pos_all, pos)
}
dim(pos_all) # 260598
length(unique(pos_all$ID)) # 26434
weights_info$Type<-as.character(weights_info$Type)
weights_info$Type[weights_info$Set=='CMC.BRAIN.RNASEQ_SPLICING']<-'Splicing'
write.csv(weights_info, '/users/k1806347/brc_scratch/Analyses/GeRS_comparison/snp_weights_table.csv', row.names=F, quote=F)
```
</details>
<details><summary>Show SNP-weight characteristics</summary>
```{r, echo=F, eval=T, results='asis'}
res<-read.csv("/users/k1806347/brc_scratch/Analyses/GeRS_comparison/snp_weights_table.csv")
library(knitr)
kable(res, rownames = FALSE, caption='SNP-weight set characteristics')
```
</details>
<details><summary>Preparing table showing TWAS descriptives</summary>
```{R, echo=T, eval=F}
source('/users/k1806347/brc_scratch/Software/MyGit/GenoPred/config_used/Phenotype_prep.config')
library(data.table)
weights<-fread(paste0(TWAS_rep, '/snp_weight_list.txt'), header=F)$V1
pheno=c('Depression','Intelligence','BMI','Height','T2D','CAD','IBD','MultiScler','RheuArth','BMI','Educational Attainment','ADHD symptoms')
sample=c('UKB','UKB','UKB','Both','UKB','UKB','UKB','UKB','UKB','TEDS','TEDS','TEDS')
gwas=c('DEPR06','COLL01','BODY03','HEIG03','DIAB05','COAD01','CROH01','SCLE02','RHEU01','BODY11', 'EDUC03', 'ADHD04')
twas_descript<-NULL
for(i in 1:length(gwas)){
twas<-fread(paste0(TWAS_rep,'/',gwas[i],'_withCOLOC/',gwas[i],'_res_GW.txt'))
twas_descript<-rbind(twas_descript, data.frame(Sample=sample[i],
Target_Phenotype=pheno[i],
GWAS=gwas[i],
Nfeat=dim(twas)[1],
Nfeat_imp=sum(!is.na(twas$TWAS.P))))
}
twas_descript<-twas_descript[order(twas_descript$Sample),]
write.csv(twas_descript, '/users/k1806347/brc_scratch/Analyses/GeRS_comparison/twas_descript_table.csv', row.names=F, quote=F)
```
</details>
<details><summary>Show TWAS descriptives</summary>
```{r, echo=F, eval=T, results='asis'}
res<-read.csv("/users/k1806347/brc_scratch/Analyses/GeRS_comparison/twas_descript_table.csv")
library(knitr)
kable(res, rownames = FALSE, caption='TWAS descriptives')
```
</details>
<br/>
## Gene expression risk scores (GeRS)
TWAS integrates GWAS summary statistics with multi-SNP predictors of gene expression (SNP-weights) to infer gene expression associations. Multi-SNP predictors in combination with individual-level genotype data can also be used to predict the expression level of genes within an each individual. GeRS are calculated as the TWAS-effect size weighted sum of predicted gene expression levels in each individual.
This study used SNP-weights derived from multiple panels capturing eQTL effects across a range of adult tissues. SNP-weights were downloaded from the FUSION website. TWAS was performed using FUSION and SNP-weights were used to calculated predicted expression levels using PLINK. GeRS for each panel were then calculated in R. To account for the correlation between the predicted expression of nearby features due to LD, feature clumping was used to remove features within 5Mb of lead features with a predicted expression r^2 of >0.9. Due to the complex LD structure within the MHC region, only the lead feature within this region was retained.
TWAS, gene expression prediction and GeRS calculations were carried out using LD and MAF estimations from an ancestry matched reference genotype dataset. The same SNP-weights are used to predict expression levels regardless of the target samples, using MAF imputation to account for missing variation. Predicted expression levels for each gene are then standardised based on the ancestry-matched mean and standard deviation of expression. Clumping of features is performed using predicted expression level in the reference sample.
The code used to prepare the reference data required for calculating GeRS can be found [here](https://opain.github.io/GenoPred/Pipeline_prep.html#5_functionally-informed_polygenic_scoring).
The code used for calculating predicted expression levels in the target samples can be found [here](https://opain.github.io/GenoPred/Genotype-based_scoring_in_target_samples.html#4_functionally-informed_polygenic_scoring)
<details><summary>Calculating GeRS in samples</summary>
```{bash, echo=T, eval=F}
###
# UKBB
###
. /users/k1806347/brc_scratch/Software/MyGit/GenoPred/config_used/Target_scoring.config
mkdir -p ${UKBB_output}/GeRS_for_comparison/1KG_ref/EUR
> ${UKBB_output}/GeRS_for_comparison/1KG_ref/EUR/todo.txt
# Create variable listing phenotypes and corresponding GWAS
pheno=$(echo Depression Intelligence BMI Height T2D CAD IBD RheuArth)
gwas=$(echo DEPR06 COLL01 BODY03 HEIG03 DIAB05 COAD01 CROH01 RHEU01)
for i in $(seq 1 8);do
pheno_i=$(echo ${pheno} | cut -f ${i} -d ' ')
gwas_i=$(echo ${gwas} | cut -f ${i} -d ' ')
for weights in $(cat ~/brc_scratch/Data/TWAS_sumstats/FUSION/snp_weight_list.txt);do
if [ ! -f ${UKBB_output}/GeRS_for_comparison/1KG_ref/EUR/${weights}/UKBB.w_hm3.EUR.${weights}.${gwas_i}.fiprofile ]; then
echo $gwas_i $pheno_i $weights >> ${UKBB_output}/GeRS_for_comparison/1KG_ref/EUR/todo.txt
fi
done
done
for i in $(seq 1 $(wc -l ${UKBB_output}/GeRS_for_comparison/1KG_ref/EUR/todo.txt | cut -d ' ' -f 1));do
gwas=$(awk -v var="$i" 'NR == var {print $1}' ${UKBB_output}/GeRS_for_comparison/1KG_ref/EUR/todo.txt)
pheno=$(awk -v var="$i" 'NR == var {print $2}' ${UKBB_output}/GeRS_for_comparison/1KG_ref/EUR/todo.txt)
weights=$(awk -v var="$i" 'NR == var {print $3}' ${UKBB_output}/GeRS_for_comparison/1KG_ref/EUR/todo.txt)
sbatch -p brc,shared --mem 10G -n 1 /users/k1806347/brc_scratch/Software/Rscript.sh /users/k1806347/brc_scratch/Software/MyGit/GenoPred/Scripts/scaled_functionally_informed_risk_scorer/scaled_functionally_informed_risk_scorer.R \
--targ_feature_pred ${UKBB_output}/Predicted_expression/FUSION/EUR/${weights}/UKBB.w_hm3.QCd.AllSNP.FUSION.${weights}.predictions.gz \
--target_keep ${UKBB_output}/Phenotype/PRS_comp_subset/UKBB.${pheno}.txt \
--ref_score ${Geno_1KG_dir}/Score_files_for_functionally_informed_risk_scores/${gwas}/1KGPhase3.w_hm3.EUR.FUSION.${gwas}.${weights}.score \
--ref_scale ${Geno_1KG_dir}/Score_files_for_functionally_informed_risk_scores/${gwas}/1KGPhase3.w_hm3.EUR.FUSION.${gwas}.${weights}.scale \
--pheno_name ${gwas} \
--n_cores 1 \
--pigz ${pigz_binary} \
--output ${UKBB_output}/GeRS_for_comparison/1KG_ref/EUR/${weights}/UKBB.w_hm3.EUR.${weights}.${gwas}
sleep 20
done
###
# TEDS
###
. /users/k1806347/brc_scratch/Software/MyGit/GenoPred/config_used/Target_scoring.config
mkdir -p ${TEDS_output_dir}/FunctionallyInformedPolygenicScores/EUR
> ${TEDS_output_dir}/FunctionallyInformedPolygenicScores/EUR/todo.txt
# Create variable listing phenotypes and corresponding GWAS
gwas=$(echo HEIG03 EDUC03 ADHD04 BODY11)
for i in $(seq 1 4);do
gwas_i=$(echo ${gwas} | cut -f ${i} -d ' ')
for weights in $(cat ~/brc_scratch/Data/TWAS_sumstats/FUSION/snp_weight_list.txt);do
if [ ! -f ${TEDS_output_dir}/FunctionallyInformedPolygenicScores/EUR/${weights}/TEDS.w_hm3.EUR.${weights}.${gwas_i}.fiprofile ]; then
echo $gwas_i $weights >> ${TEDS_output_dir}/FunctionallyInformedPolygenicScores/EUR/todo.txt
fi
done
done
for i in $(seq 1 $(wc -l ${TEDS_output_dir}/FunctionallyInformedPolygenicScores/EUR/todo.txt | cut -d ' ' -f 1));do
gwas=$(awk -v var="$i" 'NR == var {print $1}' ${TEDS_output_dir}/FunctionallyInformedPolygenicScores/EUR/todo.txt)
weights=$(awk -v var="$i" 'NR == var {print $2}' ${TEDS_output_dir}/FunctionallyInformedPolygenicScores/EUR/todo.txt)
sbatch -p brc,shared --mem 10G -n 1 /users/k1806347/brc_scratch/Software/Rscript.sh /users/k1806347/brc_scratch/Software/MyGit/GenoPred/Scripts/scaled_functionally_informed_risk_scorer/scaled_functionally_informed_risk_scorer.R \
--targ_feature_pred ${TEDS_output_dir}/Predicted_expression/FUSION/EUR/${weights}/TEDS.w_hm3.QCd.AllSNP.FUSION.${weights}.predictions.gz \
--ref_score ${Geno_1KG_dir}/Score_files_for_functionally_informed_risk_scores/${gwas}/1KGPhase3.w_hm3.EUR.FUSION.${gwas}.${weights}.score \
--ref_scale ${Geno_1KG_dir}/Score_files_for_functionally_informed_risk_scores/${gwas}/1KGPhase3.w_hm3.EUR.FUSION.${gwas}.${weights}.scale \
--pheno_name ${gwas} \
--n_cores 1 \
--pigz ${pigz_binary} \
--output ${TEDS_output_dir}/FunctionallyInformedPolygenicScores/EUR/${weights}/TEDS.w_hm3.EUR.${weights}.${gwas}
sleep 5
done
```
</details>
<details><summary>Calculating GeRS in samples using PP4 to filter features</summary>
```{bash, echo=T, eval=F}
###
# UKBB
###
. /users/k1806347/brc_scratch/Software/MyGit/GenoPred/config_used/Target_scoring.config
mkdir -p ${UKBB_output}/GeRS_for_comparison/1KG_ref_withCOLOC/EUR
> ${UKBB_output}/GeRS_for_comparison/1KG_ref_withCOLOC/EUR/todo.txt
# Create variable listing phenotypes and corresponding GWAS
pheno=$(echo Depression Intelligence BMI Height T2D CAD IBD RheuArth)
gwas=$(echo DEPR06 COLL01 BODY03 HEIG03 DIAB05 COAD01 CROH01 RHEU01)
for i in $(seq 1 8);do
pheno_i=$(echo ${pheno} | cut -f ${i} -d ' ')
gwas_i=$(echo ${gwas} | cut -f ${i} -d ' ')
for weights in $(cat ~/brc_scratch/Data/TWAS_sumstats/FUSION/snp_weight_list.txt);do
if [ ! -f ${UKBB_output}/GeRS_for_comparison/1KG_ref_withCOLOC/EUR/${weights}/UKBB.w_hm3.EUR.${weights}.${gwas_i}.fiprofile ]; then
echo $gwas_i $pheno_i $weights >> ${UKBB_output}/GeRS_for_comparison/1KG_ref_withCOLOC/EUR/todo.txt
fi
done
done
for i in $(seq 1 $(wc -l ${UKBB_output}/GeRS_for_comparison/1KG_ref_withCOLOC/EUR/todo.txt | cut -d ' ' -f 1));do
gwas=$(awk -v var="$i" 'NR == var {print $1}' ${UKBB_output}/GeRS_for_comparison/1KG_ref_withCOLOC/EUR/todo.txt)
pheno=$(awk -v var="$i" 'NR == var {print $2}' ${UKBB_output}/GeRS_for_comparison/1KG_ref_withCOLOC/EUR/todo.txt)
weights=$(awk -v var="$i" 'NR == var {print $3}' ${UKBB_output}/GeRS_for_comparison/1KG_ref_withCOLOC/EUR/todo.txt)
sbatch -p brc,shared --mem 10G -n 1 /users/k1806347/brc_scratch/Software/Rscript.sh /users/k1806347/brc_scratch/Software/MyGit/GenoPred/Scripts/scaled_functionally_informed_risk_scorer/scaled_functionally_informed_risk_scorer.R \
--targ_feature_pred ${UKBB_output}/Predicted_expression/FUSION/EUR/${weights}/UKBB.w_hm3.QCd.AllSNP.FUSION.${weights}.predictions.gz \
--target_keep ${UKBB_output}/Phenotype/PRS_comp_subset/UKBB.${pheno}.txt \
--ref_score ${Geno_1KG_dir}/Score_files_for_functionally_informed_risk_scores/${gwas}_COLOC_PP4/1KGPhase3.w_hm3.EUR.FUSION.${gwas}.${weights}.score \
--ref_scale ${Geno_1KG_dir}/Score_files_for_functionally_informed_risk_scores/${gwas}_COLOC_PP4/1KGPhase3.w_hm3.EUR.FUSION.${gwas}.${weights}.scale \
--pheno_name ${gwas} \
--n_cores 1 \
--pigz ${pigz_binary} \
--output ${UKBB_output}/GeRS_for_comparison/1KG_ref_withCOLOC/EUR/${weights}/UKBB.w_hm3.EUR.${weights}.${gwas}
sleep 20
done
###
# TEDS
###
. /users/k1806347/brc_scratch/Software/MyGit/GenoPred/config_used/Target_scoring.config
mkdir -p ${TEDS_output_dir}/FunctionallyInformedPolygenicScores_withCOLOC/EUR
> ${TEDS_output_dir}/FunctionallyInformedPolygenicScores_withCOLOC/EUR/todo.txt
# Create variable listing phenotypes and corresponding GWAS
gwas=$(echo HEIG03 EDUC03 ADHD04 BODY11)
for i in $(seq 1 4);do
gwas_i=$(echo ${gwas} | cut -f ${i} -d ' ')
for weights in $(cat ~/brc_scratch/Data/TWAS_sumstats/FUSION/snp_weight_list.txt);do
if [ ! -f ${TEDS_output_dir}/FunctionallyInformedPolygenicScores_withCOLOC/EUR/${weights}/TEDS.w_hm3.EUR.${weights}.${gwas_i}.fiprofile ]; then
echo $gwas_i $weights >> ${TEDS_output_dir}/FunctionallyInformedPolygenicScores_withCOLOC/EUR/todo.txt
fi
done
done
for i in $(seq 1 $(wc -l ${TEDS_output_dir}/FunctionallyInformedPolygenicScores_withCOLOC/EUR/todo.txt | cut -d ' ' -f 1));do
gwas=$(awk -v var="$i" 'NR == var {print $1}' ${TEDS_output_dir}/FunctionallyInformedPolygenicScores_withCOLOC/EUR/todo.txt)
weights=$(awk -v var="$i" 'NR == var {print $2}' ${TEDS_output_dir}/FunctionallyInformedPolygenicScores_withCOLOC/EUR/todo.txt)
sbatch -p brc,shared --mem 10G -n 1 /users/k1806347/brc_scratch/Software/Rscript.sh /users/k1806347/brc_scratch/Software/MyGit/GenoPred/Scripts/scaled_functionally_informed_risk_scorer/scaled_functionally_informed_risk_scorer.R \
--targ_feature_pred ${TEDS_output_dir}/Predicted_expression/FUSION/EUR/${weights}/TEDS.w_hm3.QCd.AllSNP.FUSION.${weights}.predictions.gz \
--ref_score ${Geno_1KG_dir}/Score_files_for_functionally_informed_risk_scores/${gwas}_COLOC_PP4/1KGPhase3.w_hm3.EUR.FUSION.${gwas}.${weights}.score \
--ref_scale ${Geno_1KG_dir}/Score_files_for_functionally_informed_risk_scores/${gwas}_COLOC_PP4/1KGPhase3.w_hm3.EUR.FUSION.${gwas}.${weights}.scale \
--pheno_name ${gwas} \
--n_cores 1 \
--pigz ${pigz_binary} \
--output ${TEDS_output_dir}/FunctionallyInformedPolygenicScores_withCOLOC/EUR/${weights}/TEDS.w_hm3.EUR.${weights}.${gwas}
sleep 5
done
```
</details>
<details><summary>Calculating GeRS in samples using tissue specific features</summary>
```{bash, echo=T, eval=F}
###
# UKBB
###
. /users/k1806347/brc_scratch/Software/MyGit/GenoPred/config_used/Target_scoring.config
mkdir -p ${UKBB_output}/GeRS_for_comparison/1KG_ref/EUR
> ${UKBB_output}/GeRS_for_comparison/1KG_ref/EUR/todo.TissueSpecific.txt
# Create variable listing phenotypes and corresponding GWAS
pheno=$(echo Depression Intelligence BMI Height T2D CAD IBD RheuArth)
gwas=$(echo DEPR06 COLL01 BODY03 HEIG03 DIAB05 COAD01 CROH01 RHEU01)
for i in $(seq 1 8);do
pheno_i=$(echo ${pheno} | cut -f ${i} -d ' ')
gwas_i=$(echo ${gwas} | cut -f ${i} -d ' ')
for weights in $(cat ~/brc_scratch/Data/TWAS_sumstats/FUSION/snp_weight_list.txt);do
if [ ! -f ${UKBB_output}/GeRS_for_comparison/1KG_ref/EUR/${weights}/UKBB.w_hm3.EUR.TissueSpecific.${weights}.${gwas_i}.fiprofile ]; then
echo $gwas_i $pheno_i $weights >> ${UKBB_output}/GeRS_for_comparison/1KG_ref/EUR/todo.TissueSpecific.txt
fi
done
done
for i in $(seq 1 $(wc -l ${UKBB_output}/GeRS_for_comparison/1KG_ref/EUR/todo.TissueSpecific.txt | cut -d ' ' -f 1));do
gwas=$(awk -v var="$i" 'NR == var {print $1}' ${UKBB_output}/GeRS_for_comparison/1KG_ref/EUR/todo.TissueSpecific.txt)
pheno=$(awk -v var="$i" 'NR == var {print $2}' ${UKBB_output}/GeRS_for_comparison/1KG_ref/EUR/todo.TissueSpecific.txt)
weights=$(awk -v var="$i" 'NR == var {print $3}' ${UKBB_output}/GeRS_for_comparison/1KG_ref/EUR/todo.TissueSpecific.txt)
sbatch -p brc,shared --mem 10G -n 1 /users/k1806347/brc_scratch/Software/Rscript.sh /users/k1806347/brc_scratch/Software/MyGit/GenoPred/Scripts/scaled_functionally_informed_risk_scorer/scaled_functionally_informed_risk_scorer.R \
--targ_feature_pred ${UKBB_output}/Predicted_expression/FUSION/EUR/${weights}/UKBB.w_hm3.QCd.AllSNP.FUSION.${weights}.predictions.gz \
--target_keep ${UKBB_output}/Phenotype/PRS_comp_subset/UKBB.${pheno}.txt \
--ref_score ${Geno_1KG_dir}/Score_files_for_functionally_informed_risk_scores/${gwas}/1KGPhase3.w_hm3.EUR.FUSION.TissueSpecific.${gwas}.${weights}.score \
--ref_scale ${Geno_1KG_dir}/Score_files_for_functionally_informed_risk_scores/${gwas}/1KGPhase3.w_hm3.EUR.FUSION.TissueSpecific.${gwas}.${weights}.scale \
--pheno_name ${gwas} \
--n_cores 1 \
--pigz ${pigz_binary} \
--output ${UKBB_output}/GeRS_for_comparison/1KG_ref/EUR/${weights}/UKBB.w_hm3.EUR.TissueSpecific.${weights}.${gwas}
sleep 20
done
###
# TEDS
###
. /users/k1806347/brc_scratch/Software/MyGit/GenoPred/config_used/Target_scoring.config
mkdir -p ${TEDS_output_dir}/FunctionallyInformedPolygenicScores/EUR
> ${TEDS_output_dir}/FunctionallyInformedPolygenicScores/EUR/todo.TissueSpecific.txt
# Create variable listing phenotypes and corresponding GWAS
gwas=$(echo HEIG03 EDUC03 ADHD04 BODY11)
for i in $(seq 1 4);do
gwas_i=$(echo ${gwas} | cut -f ${i} -d ' ')
for weights in $(cat ~/brc_scratch/Data/TWAS_sumstats/FUSION/snp_weight_list.txt);do
if [ ! -f ${TEDS_output_dir}/FunctionallyInformedPolygenicScores/EUR/${weights}/TEDS.w_hm3.EUR.TissueSpecific.${weights}.${gwas_i}.fiprofile ]; then
echo $gwas_i $weights >> ${TEDS_output_dir}/FunctionallyInformedPolygenicScores/EUR/todo.TissueSpecific.txt
fi
done
done
for i in $(seq 1 $(wc -l ${TEDS_output_dir}/FunctionallyInformedPolygenicScores/EUR/todo.TissueSpecific.txt | cut -d ' ' -f 1));do
gwas=$(awk -v var="$i" 'NR == var {print $1}' ${TEDS_output_dir}/FunctionallyInformedPolygenicScores/EUR/todo.TissueSpecific.txt)
weights=$(awk -v var="$i" 'NR == var {print $2}' ${TEDS_output_dir}/FunctionallyInformedPolygenicScores/EUR/todo.TissueSpecific.txt)
sbatch -p brc,shared --mem 10G -n 1 /users/k1806347/brc_scratch/Software/Rscript.sh /users/k1806347/brc_scratch/Software/MyGit/GenoPred/Scripts/scaled_functionally_informed_risk_scorer/scaled_functionally_informed_risk_scorer.R \
--targ_feature_pred ${TEDS_output_dir}/Predicted_expression/FUSION/EUR/${weights}/TEDS.w_hm3.QCd.AllSNP.FUSION.${weights}.predictions.gz \
--ref_score ${Geno_1KG_dir}/Score_files_for_functionally_informed_risk_scores/${gwas}/1KGPhase3.w_hm3.EUR.FUSION.TissueSpecific.${gwas}.${weights}.score \
--ref_scale ${Geno_1KG_dir}/Score_files_for_functionally_informed_risk_scores/${gwas}/1KGPhase3.w_hm3.EUR.FUSION.TissueSpecific.${gwas}.${weights}.scale \
--pheno_name ${gwas} \
--n_cores 1 \
--pigz ${pigz_binary} \
--output ${TEDS_output_dir}/FunctionallyInformedPolygenicScores/EUR/${weights}/TEDS.w_hm3.EUR.TissueSpecific.${weights}.${gwas}
sleep 5
done
```
</details>
<details><summary>Calculating GeRS in samples using colocalised features</summary>
```{bash, echo=T, eval=F}
###
# UKBB
###
. /users/k1806347/brc_scratch/Software/MyGit/GenoPred/config_used/Target_scoring.config
mkdir -p ${UKBB_output}/GeRS_for_comparison/1KG_ref_pT_withColoc/EUR
> ${UKBB_output}/GeRS_for_comparison/1KG_ref_pT_withColoc/EUR/todo.txt
# Create variable listing phenotypes and corresponding GWAS
pheno=$(echo Depression Intelligence BMI Height T2D CAD IBD RheuArth)
gwas=$(echo DEPR06 COLL01 BODY03 HEIG03 DIAB05 COAD01 CROH01 RHEU01)
for i in $(seq 1 8);do
pheno_i=$(echo ${pheno} | cut -f ${i} -d ' ')
gwas_i=$(echo ${gwas} | cut -f ${i} -d ' ')
for weights in $(cat ~/brc_scratch/Data/TWAS_sumstats/FUSION/snp_weight_list.txt);do
if [ ! -f ${UKBB_output}/GeRS_for_comparison/1KG_ref_pT_withColoc/EUR/${weights}/UKBB.w_hm3.EUR.${weights}.${gwas_i}.fiprofile ]; then
echo $gwas_i $pheno_i $weights >> ${UKBB_output}/GeRS_for_comparison/1KG_ref_pT_withColoc/EUR/todo.txt
fi
done
done
for i in $(seq 1 $(wc -l ${UKBB_output}/GeRS_for_comparison/1KG_ref_pT_withColoc/EUR/todo.txt | cut -d ' ' -f 1));do
gwas=$(awk -v var="$i" 'NR == var {print $1}' ${UKBB_output}/GeRS_for_comparison/1KG_ref_pT_withColoc/EUR/todo.txt)
pheno=$(awk -v var="$i" 'NR == var {print $2}' ${UKBB_output}/GeRS_for_comparison/1KG_ref_pT_withColoc/EUR/todo.txt)
weights=$(awk -v var="$i" 'NR == var {print $3}' ${UKBB_output}/GeRS_for_comparison/1KG_ref_pT_withColoc/EUR/todo.txt)
sbatch -p brc,shared --mem 10G -n 1 /users/k1806347/brc_scratch/Software/Rscript.sh /users/k1806347/brc_scratch/Software/MyGit/GenoPred/Scripts/scaled_functionally_informed_risk_scorer/scaled_functionally_informed_risk_scorer.R \
--targ_feature_pred ${UKBB_output}/Predicted_expression/FUSION/EUR/${weights}/UKBB.w_hm3.QCd.AllSNP.FUSION.${weights}.predictions.gz \
--target_keep ${UKBB_output}/Phenotype/PRS_comp_subset/UKBB.${pheno}.txt \
--ref_score ${Geno_1KG_dir}/Score_files_for_functionally_informed_risk_scores/${gwas}_pT_withColoc/1KGPhase3.w_hm3.EUR.FUSION.${gwas}.${weights}.score \
--ref_scale ${Geno_1KG_dir}/Score_files_for_functionally_informed_risk_scores/${gwas}_pT_withColoc/1KGPhase3.w_hm3.EUR.FUSION.${gwas}.${weights}.scale \
--pheno_name ${gwas} \
--n_cores 1 \
--pigz ${pigz_binary} \
--output ${UKBB_output}/GeRS_for_comparison/1KG_ref_pT_withColoc/EUR/${weights}/UKBB.w_hm3.EUR.${weights}.${gwas}
sleep 20
done
###
# TEDS
###
. /users/k1806347/brc_scratch/Software/MyGit/GenoPred/config_used/Target_scoring.config
mkdir -p ${TEDS_output_dir}/FunctionallyInformedPolygenicScores_pT_withColoc/EUR
> ${TEDS_output_dir}/FunctionallyInformedPolygenicScores_pT_withColoc/EUR/todo.txt
# Create variable listing phenotypes and corresponding GWAS
gwas=$(echo HEIG03 EDUC03 ADHD04 BODY11)
for i in $(seq 1 4);do
gwas_i=$(echo ${gwas} | cut -f ${i} -d ' ')
for weights in $(cat ~/brc_scratch/Data/TWAS_sumstats/FUSION/snp_weight_list.txt);do
if [ ! -f ${TEDS_output_dir}/FunctionallyInformedPolygenicScores_pT_withColoc/EUR/${weights}/TEDS.w_hm3.EUR.${weights}.${gwas_i}.fiprofile ]; then
echo $gwas_i $weights >> ${TEDS_output_dir}/FunctionallyInformedPolygenicScores_pT_withColoc/EUR/todo.txt
fi
done
done
for i in $(seq 1 $(wc -l ${TEDS_output_dir}/FunctionallyInformedPolygenicScores_pT_withColoc/EUR/todo.txt | cut -d ' ' -f 1));do
gwas=$(awk -v var="$i" 'NR == var {print $1}' ${TEDS_output_dir}/FunctionallyInformedPolygenicScores_pT_withColoc/EUR/todo.txt)
weights=$(awk -v var="$i" 'NR == var {print $2}' ${TEDS_output_dir}/FunctionallyInformedPolygenicScores_pT_withColoc/EUR/todo.txt)
sbatch -p brc,shared --mem 10G -n 1 /users/k1806347/brc_scratch/Software/Rscript.sh /users/k1806347/brc_scratch/Software/MyGit/GenoPred/Scripts/scaled_functionally_informed_risk_scorer/scaled_functionally_informed_risk_scorer.R \
--targ_feature_pred ${TEDS_output_dir}/Predicted_expression/FUSION/EUR/${weights}/TEDS.w_hm3.QCd.AllSNP.FUSION.${weights}.predictions.gz \
--ref_score ${Geno_1KG_dir}/Score_files_for_functionally_informed_risk_scores/${gwas}_pT_withColoc/1KGPhase3.w_hm3.EUR.FUSION.${gwas}.${weights}.score \
--ref_scale ${Geno_1KG_dir}/Score_files_for_functionally_informed_risk_scores/${gwas}_pT_withColoc/1KGPhase3.w_hm3.EUR.FUSION.${gwas}.${weights}.scale \
--pheno_name ${gwas} \
--n_cores 1 \
--pigz ${pigz_binary} \
--output ${TEDS_output_dir}/FunctionallyInformedPolygenicScores_pT_withColoc/EUR/${weights}/TEDS.w_hm3.EUR.${weights}.${gwas}
sleep 5
done
```
</details>
<br/>
## Functionally-informed polygenic scoring
Functionally informed polygenic scores were derived as follows:
1. TWAS SNP-weight-stratified p-value thresholding and clumping (eQTL pT+clump)
<details><summary>Calculating GeRS in samples</summary>
```{bash, echo=T, eval=F}
# Set required variables
. /users/k1806347/brc_scratch/Software/MyGit/GenoPred/config_used/Target_scoring.config
#######
# UKBB
#######
# Create variable listing phenotypes and corresponding GWAS
pheno=$(echo Depression Intelligence BMI Height T2D CAD IBD RheuArth)
gwas=$(echo DEPR06 COLL01 BODY03 HEIG03 DIAB05 COAD01 CROH01 RHEU01)
# Calculate polygenic scores using 1KG reference
for i in $(seq 1 8);do
pheno_i=$(echo ${pheno} | cut -f ${i} -d ' ')
gwas_i=$(echo ${gwas} | cut -f ${i} -d ' ')
sbatch --mem 10G -p brc,shared -J pT_clump /users/k1806347/brc_scratch/Software/Rscript.sh /users/k1806347/brc_scratch/Software/MyGit/GenoPred/Scripts/Scaled_polygenic_scorer/Scaled_polygenic_scorer.R \
--target_plink_chr ${UKBB_output}/Genotype/Harmonised/UKBB.w_hm3.QCd.AllSNP.chr \
--target_keep ${UKBB_output}/Phenotype/PRS_comp_subset/UKBB.${pheno_i}.txt \
--ref_score ${Geno_1KG_dir}/Score_files_for_poylygenic_stratified_TWAS_Gene/${gwas_i}_withCOLOC/1KGPhase3.w_hm3.${gwas_i} \
--ref_scale ${Geno_1KG_dir}/Score_files_for_poylygenic_stratified_TWAS_Gene/${gwas_i}_withCOLOC/1KGPhase3.w_hm3.${gwas_i}.EUR.scale \
--ref_freq_chr ${Geno_1KG_dir}/freq_files/EUR/1KGPhase3.w_hm3.EUR.chr \
--plink ${plink1_9} \
--pheno_name ${gwas_i} \
--output ${UKBB_output}/PRS_for_comparison/1KG_ref_withCOLOC/pt_clump_stratified_TWAS_Gene/${gwas_i}/UKBB.subset.w_hm3.${gwas_i}
done
#######
# TEDS
#######
# Create variable listing phenotypes and corresponding GWAS
gwas=$(echo HEIG03 EDUC03 ADHD04 BODY11)
# Calculate polygenic scores using 1KG reference
for i in $(seq 1 4);do
gwas_i=$(echo ${gwas} | cut -f ${i} -d ' ')
sbatch --mem 10G -p brc,shared -J pT_clump /users/k1806347/brc_scratch/Software/Rscript.sh /users/k1806347/brc_scratch/Software/MyGit/GenoPred/Scripts/Scaled_polygenic_scorer/Scaled_polygenic_scorer.R \
--target_plink_chr ${TEDS_output_dir}/Genotype/Harmonised/TEDS.w_hm3.QCd.AllSNP.chr \
--target_keep ${TEDS_output_dir}/Projected_PCs/Ancestry_idenitfier/TEDS.w_hm3.AllAncestry.EUR.keep \
--ref_score ${Geno_1KG_dir}/Score_files_for_poylygenic_stratified_TWAS_Gene/${gwas_i}/1KGPhase3.w_hm3.${gwas_i} \
--ref_scale ${Geno_1KG_dir}/Score_files_for_poylygenic_stratified_TWAS_Gene/${gwas_i}/1KGPhase3.w_hm3.${gwas_i}.EUR.scale \
--ref_freq_chr ${Geno_1KG_dir}/freq_files/EUR/1KGPhase3.w_hm3.EUR.chr \
--plink ${plink1_9} \
--pheno_name ${gwas_i} \
--output ${TEDS_output_dir}/PolygenicScores_stratified_TWAS_Gene/${gwas_i}/TEDS.subset.w_hm3.${gwas_i}
done
```
</details>
<br/>
## Functionally-agnostic polygenic scoring
Polygenic scores were derived using PRScs-auto, a Bayesian shrinkage method that I have shown to perform well previously.
Polygenic scores were derived using a reference standardised pipeline. The European subset of the 1KG reference was used ([described here](https://opain.github.io/GenoPred/Pipeline_prep.html#4_polygenic_scoring)). In brief, all scores were derived using HapMap3 SNPs only, modelling LD based on the reference. Any HapMap3 missing in the target sample are imputed using the reference estimated allele frequency.
Polygenic scoring in target samples has been previously documented [here](https://opain.github.io/GenoPred/Determine_optimal_polygenic_scoring_approach.html)
<br/>
### Derive pT+clump polygenic scores without retaining single variant in the MHC
Only do this as a sensitivity analysis for Rheumatoid arthritis
<details><summary>Show code</summary>
```{R, eval=F, echo=T}
# Generate scoring files
. /users/k1806347/brc_scratch/Software/MyGit/GenoPred/config_used/Pipeline_prep.config
sbatch -p shared,brc --mem=6G /users/k1806347/brc_scratch/Software/Rscript.sh /users/k1806347/brc_scratch/Software/MyGit/GenoPred/Scripts/polygenic_score_file_creator/polygenic_score_file_creator.R \
--ref_plink_chr ${Geno_1KG_dir}/1KGPhase3.w_hm3.chr \
--ref_keep ${Geno_1KG_dir}/keep_files/EUR_samples.keep \
--sumstats ${gwas_rep}/RHEU01.sumstats.gz \
--plink ${plink1_9} \
--memory 3000 \
--prune_hla F \
--output ${Geno_1KG_dir}/Score_files_for_poylygenic/RHEU01.noMHCClump/1KGPhase3.w_hm3.RHEU01.noMHCClump \
--ref_pop_scale ${Geno_1KG_dir}/super_pop_keep.list
# Calculate scores in UKB
. /users/k1806347/brc_scratch/Software/MyGit/GenoPred/config_used/Target_scoring.config
sbatch --mem 10G -p brc,shared /users/k1806347/brc_scratch/Software/Rscript.sh /users/k1806347/brc_scratch/Software/MyGit/GenoPred/Scripts/Scaled_polygenic_scorer/Scaled_polygenic_scorer.R \
--target_plink_chr ${UKBB_output}/Genotype/Harmonised/UKBB.w_hm3.QCd.AllSNP.chr \
--target_keep ${UKBB_output}/Phenotype/PRS_comp_subset/UKBB.RheuArth.txt \
--ref_score ${Geno_1KG_dir}/Score_files_for_poylygenic/RHEU01.noMHCClump/1KGPhase3.w_hm3.RHEU01.noMHCClump \
--ref_scale ${Geno_1KG_dir}/Score_files_for_poylygenic/RHEU01.noMHCClump/1KGPhase3.w_hm3.RHEU01.noMHCClump.EUR.scale \
--ref_freq_chr ${Geno_1KG_dir}/freq_files/EUR/1KGPhase3.w_hm3.EUR.chr \
--plink ${plink1_9} \
--pheno_name RHEU01 \
--output ${UKBB_output}/PRS_for_comparison/1KG_ref/pt_clump/RHEU01.noMHCClump/UKBB.subset.w_hm3.RHEU01.noMHCClump
```
</details>
<br/>
## Estimating predictive ability
Models containing a single predictor were derived using generalised linear model (GLM). Models containing multiple predictors were derived using elastic-net regularisation to reduce the likelihood of overfitting and account for multicollinearity when modelling highly correlated predictors. Nested cross validation was used to estimate the variance explained by models to avoid overfitting. This involves an outer loop, splitting the data into training and test datasets, deriving the model using 10-fold cross validation in the training dataset, saving model predictions for the test dataset, combining the test predictions for each outer loop and estimating the variance explained.
Model building and evaluation was performed using an Rscript called Model_builder_V2_nested.R (more information [here](https://github.com/opain/GenoPred/tree/master/Scripts/Model_builder)).
### UK Biobank
<details><summary>Single-pT vs. Multi-pT</summary>
```{bash, echo=T, eval=F}
##############################
# Evaluating predictive utility of GeRS across multiple pTs individually and in combination
##############################
. /users/k1806347/brc_scratch/Software/MyGit/GenoPred/config_used/Target_scoring.config
# Make required directories
for pheno_i in $(echo Depression Intelligence BMI Height T2D CAD IBD MultiScler RheuArth);do
mkdir -p /users/k1806347/brc_scratch/Analyses/GeRS_comparison/UKBB_outcomes_for_prediction/${pheno_i}/Association_withGeRSs
done
# Create a file listing the predictors files
pheno=$(echo Depression Intelligence BMI Height T2D CAD IBD RheuArth)
gwas=$(echo DEPR06 COLL01 BODY03 HEIG03 DIAB05 COAD01 CROH01 RHEU01)
weights=$(cat ${TWAS_rep}/snp_weight_list.txt)
for i in $(seq 1 8);do
for weight in ${weights};do
pheno_i=$(echo ${pheno} | cut -f ${i} -d ' ')
gwas_i=$(echo ${gwas} | cut -f ${i} -d ' ')
cat > /users/k1806347/brc_scratch/Analyses/GeRS_comparison/UKBB_outcomes_for_prediction/${pheno_i}/Association_withGeRSs/UKBB.w_hm3.${weight}.${gwas_i}.EUR-GeRSs.predictor_groups <<EOF
predictors
${UKBB_output}/GeRS_for_comparison/1KG_ref/EUR/${weight}/UKBB.w_hm3.EUR.${weight}.${gwas_i}.fiprofile
EOF
done
done
# Derive and evaluate models
pheno=$(echo Depression Intelligence BMI Height T2D CAD IBD RheuArth)
gwas=$(echo DEPR06 COLL01 BODY03 HEIG03 DIAB05 COAD01 CROH01 RHEU01)
prev=$(echo 0.15 NA NA NA 0.05 0.03 0.013 0.00164 0.005)
weights=$(cat ${TWAS_rep}/snp_weight_list.txt)
# 1KG reference
for i in $(seq 1 8);do
for weight in ${weights};do
pheno_i=$(echo ${pheno} | cut -f ${i} -d ' ')
pheno_file_i=$(echo ${pheno_file} | cut -f ${i} -d ' ')
gwas_i=$(echo ${gwas} | cut -f ${i} -d ' ')
prev_i=$(echo ${prev} | cut -f ${i} -d ' ')
sbatch --mem 10G -n 2 -p brc,shared /users/k1806347/brc_scratch/Software/Rscript.sh /users/k1806347/brc_scratch/Software/MyGit/GenoPred/Scripts/Model_builder/Model_builder_V2_nested.R \
--pheno ${UKBB_output}/Phenotype/PRS_comp_subset/UKBB.${pheno_i}.txt \
--keep /users/k1806347/brc_scratch/Analyses/PRS_comparison/UKBB_outcomes_for_prediction/ukb18177_glanville_post_qc_id_list.UpdateIDs.fam \
--out /users/k1806347/brc_scratch/Analyses/GeRS_comparison/UKBB_outcomes_for_prediction/${pheno_i}/Association_withGeRSs/UKBB.w_hm3.${weight}.${gwas_i}.EUR-GeRSs \
--n_core 2 \
--compare_predictors T \
--assoc T \
--outcome_pop_prev ${prev_i} \
--predictors /users/k1806347/brc_scratch/Analyses/GeRS_comparison/UKBB_outcomes_for_prediction/${pheno_i}/Association_withGeRSs/UKBB.w_hm3.${weight}.${gwas_i}.EUR-GeRSs.predictor_groups
done
sleep 200
done
```
</details>
<details><summary>Single-tissue vs. Multi-tissue</summary>
```{bash, echo=T, eval=F}
##############################
# Evaluating predictive utility of GeRS across multiple tissues individually and in combination
##############################
. /users/k1806347/brc_scratch/Software/MyGit/GenoPred/config_used/Target_scoring.config
# Make required directories
for pheno_i in $(echo Depression Intelligence BMI Height T2D CAD IBD MultiScler RheuArth);do
mkdir -p /users/k1806347/brc_scratch/Analyses/GeRS_comparison/UKBB_outcomes_for_prediction/${pheno_i}/Association_withGeRSs
done
# Create a file listing the predictors files
pheno=$(echo Depression Intelligence BMI Height T2D CAD IBD RheuArth)
gwas=$(echo DEPR06 COLL01 BODY03 HEIG03 DIAB05 COAD01 CROH01 RHEU01)
weights=$(cat ${TWAS_rep}/snp_weight_list.txt)
for i in $(seq 1 8);do
pheno_i=$(echo ${pheno} | cut -f ${i} -d ' ')
gwas_i=$(echo ${gwas} | cut -f ${i} -d ' ')
echo "predictors group" > /users/k1806347/brc_scratch/Analyses/GeRS_comparison/UKBB_outcomes_for_prediction/${pheno_i}/Association_withGeRSs/UKBB.w_hm3.AllTissue.${gwas_i}.EUR-GeRSs.predictor_groups
for weight in ${weights}; do
echo ${UKBB_output}/GeRS_for_comparison/1KG_ref/EUR/${weight}/UKBB.w_hm3.EUR.${weight}.${gwas_i}.fiprofile ${weight} >> /users/k1806347/brc_scratch/Analyses/GeRS_comparison/UKBB_outcomes_for_prediction/${pheno_i}/Association_withGeRSs/UKBB.w_hm3.AllTissue.${gwas_i}.EUR-GeRSs.predictor_groups
done
done
# Derive and evaluate models
pheno=$(echo Depression Intelligence BMI Height T2D CAD IBD RheuArth)
gwas=$(echo DEPR06 COLL01 BODY03 HEIG03 DIAB05 COAD01 CROH01 RHEU01)
prev=$(echo 0.15 NA NA NA 0.05 0.03 0.013 0.00164 0.005)
weights=YFS.BLOOD.RNAARR
# 1KG reference
for i in $(seq 1 8);do
pheno_i=$(echo ${pheno} | cut -f ${i} -d ' ')
pheno_file_i=$(echo ${pheno_file} | cut -f ${i} -d ' ')
gwas_i=$(echo ${gwas} | cut -f ${i} -d ' ')
prev_i=$(echo ${prev} | cut -f ${i} -d ' ')
sbatch --mem 10G -n 2 -p brc,shared /users/k1806347/brc_scratch/Software/Rscript.sh /users/k1806347/brc_scratch/Software/MyGit/GenoPred/Scripts/Model_builder/Model_builder_V2_nested.R \
--pheno ${UKBB_output}/Phenotype/PRS_comp_subset/UKBB.${pheno_i}.txt \
--keep /users/k1806347/brc_scratch/Analyses/PRS_comparison/UKBB_outcomes_for_prediction/ukb18177_glanville_post_qc_id_list.UpdateIDs.fam \
--out /users/k1806347/brc_scratch/Analyses/GeRS_comparison/UKBB_outcomes_for_prediction/${pheno_i}/Association_withGeRSs/UKBB.w_hm3.AllTissue.${gwas_i}.EUR-GeRSs \
--n_core 2 \
--compare_predictors F \
--assoc T \
--outcome_pop_prev ${prev_i} \
--predictors /users/k1806347/brc_scratch/Analyses/GeRS_comparison/UKBB_outcomes_for_prediction/${pheno_i}/Association_withGeRSs/UKBB.w_hm3.AllTissue.${gwas_i}.EUR-GeRSs.predictor_groups
done
```
</details>
<details><summary>Multi-tissue per pT</summary>
```{bash, echo=T, eval=F}
##############################
# Evaluating predictive utility of GeRS across multiple tissues for each pT seperately
##############################
. /users/k1806347/brc_scratch/Software/MyGit/GenoPred/config_used/Target_scoring.config
# Make required directories
for pheno_i in $(echo Depression Intelligence BMI Height T2D CAD IBD MultiScler RheuArth);do
mkdir -p /users/k1806347/brc_scratch/Analyses/GeRS_comparison/UKBB_outcomes_for_prediction/${pheno_i}/Association_withGeRSs
done
# Split the GeRS files by pT
module add apps/R
R
source('/users/k1806347/brc_scratch/Software/MyGit/GenoPred/config_used/Target_scoring.config')
gwas<-c('DEPR06','COLL01','BODY03','HEIG03','DIAB05','COAD01','CROH01','RHEU01')
weights<-read.table('~/brc_scratch/Data/TWAS_sumstats/FUSION/snp_weight_list.txt', stringsAsFactors=F)$V1
library(data.table)
for(gwas_i in gwas){
print(gwas_i)
for(weights_i in weights){