| tags: [ Gaston Genomic Data GWAS Heritability ] categories: [Coding ]

Generating beta-values for significant SNPs

Introduction

The heritability values obtained from the previous GWAS using lmm and lrt appear to be artificially inflated. Therefore, beta values may be a better indication of SNP effect, which can be obtained by using the wald test, instead of lrt.

Methods and Results

Load packages

require(magicfor)
require(magrittr)
require(dplyr)
require(gaston)
require(qqman)

Load data

nies_heritable_pheno240918 <- read.csv('C:/Users/Martha/Documents/Honours/Project/honours.project/Data/nies_heritable_pheno240918.csv', header = TRUE)

nies_covar <- read.csv('C:/Users/Martha/Documents/Honours/Project/honours.project/Data/nies_covar.csv', header = T)
head(nies_covar)
##     UUID Sex Age
## 1 219960   1  53
## 2 313180   1  55
## 3 320511   2  60
## 4 400011   1  23
## 5 400013   1  50
## 6 316131   2  77
merged_nies_210818 <- read.bed.matrix("C:/Users/Martha/Documents/Honours/Project/honours.project/Data/merged_nies/merged_nies_geno_210818.bed")
## Reading C:/Users/Martha/Documents/Honours/Project/honours.project/Data/merged_nies/merged_nies_geno_210818.fam 
## Reading C:/Users/Martha/Documents/Honours/Project/honours.project/Data/merged_nies/merged_nies_geno_210818.bim 
## Reading C:/Users/Martha/Documents/Honours/Project/honours.project/Data/merged_nies/merged_nies_geno_210818.bed 
## ped stats and snps stats have been set. 
## 'p' has been set. 
## 'mu' and 'sigma' have been set.
merged_nies_GRM <- GRM(merged_nies_210818)
merged_nies_eiK <- eigen(merged_nies_GRM)
merged_nies_eiK$values[ merged_nies_eiK$values < 0] <- 0
merged_nies_PC <- sweep(merged_nies_eiK$vectors, 2, sqrt(merged_nies_eiK$values), "*")

1. L K-value H

lKvalH_wald_gwas <- association.test(merged_nies_210818, nies_heritable_pheno240918$L.K.value.H, X = nies_covar, method="lm", test = "wald", response = "quantitative", K = merged_nies_GRM, eigenK = merged_nies_eiK, p = 2)
## Warning in trans.X(X, mean.y = mean(Y)): An intercept column was added to
## the covariate matrix X
lKvalH_wald_gwas <- na.omit(lKvalH_wald_gwas)
l_kvalH_wfiltered <- lKvalH_wald_gwas %>% filter(-log10(p)>1) %>% filter(freqA2 < 0.99)
l_kvalH_wmeff <- l_kvalH_wfiltered %>% filter(p < 1.84e-7)
l_kvalH_wsig <- do.call(rbind, lapply(split(l_kvalH_wmeff,l_kvalH_wmeff$chr), function(x) {return(x[which.min(x$p),])}))

l_kvalH_wres <- NULL
for (i in l_kvalH_wsig$id) {
  snpID <- i
  snpCHR <- l_kvalH_wfiltered[l_kvalH_wfiltered$id == snpID,]$chr
  snpPOS <- l_kvalH_wfiltered[l_kvalH_wfiltered$id ==snpID,]$pos
  
  sig.peak <- l_kvalH_wfiltered %>%
    filter(chr == snpCHR) %>%
    filter(pos > snpPOS - 50000) %>%
    filter(pos < snpPOS + 50000) %>%
    filter(p < 1e-5)
  
  l_kvalH_wres <- rbind(l_kvalH_wres, sig.peak)
}

write.csv(l_kvalH_wres, 'C:/Users/Martha/Documents/Honours/Project/honours.project/Data/gwas_filter_covar/l_kvalH_wald_res.csv')
l_kvalH_wres
##     chr       pos          id A1 A2    freqA2     beta        sd
## 1     2 176830012  rs72940750  C  T 0.9898551 3.750520 0.5949583
## 2     2 176831387   rs7576095  A  G 0.9898551 3.750520 0.5949583
## 3     2 176832679   rs6758571  G  A 0.9898551 3.750520 0.5949583
## 4     2 176833429 rs139727961  G  A 0.9898551 3.750520 0.5949583
## 5     2 176839936  rs72940766  A  T 0.9898551 3.750520 0.5949583
## 6     2 176840625  rs72940776  T  C 0.9898551 3.750520 0.5949583
## 7     2 176840683  rs72940781  C  G 0.9898551 3.750520 0.5949583
## 8     2 176841189   rs6715723  T  A 0.9898551 3.750520 0.5949583
## 9     3  77739700   rs1163757  A  G 0.9869565 3.208147 0.5285691
## 10    5 115982105 rs114096393  T  A 0.9898551 3.273656 0.6035919
## 11    5 115982651  rs79849322  C  G 0.9898551 3.273656 0.6035919
## 12    5 116005046 rs186488524  A  T 0.9898551 3.273656 0.6035919
## 13    5 116019083  rs74459592  G  A 0.9884058 2.923871 0.5672395
## 14    5 116019686  rs73783057  T  C 0.9884058 2.923871 0.5672395
## 15    5 116021083  rs74809125  A  G 0.9898551 3.273656 0.6035919
## 16    5 116021134  rs73783063  C  T 0.9884058 2.923871 0.5672395
## 17    5 116021188  rs73783064  C  T 0.9884058 2.923871 0.5672395
## 18    5 116021961  rs61626272  T  G 0.9884058 2.923871 0.5672395
## 19    5 116022620  rs56745470  G  A 0.9884058 2.923871 0.5672395
## 20    5 116022897  rs17138683  G  A 0.9884058 2.923871 0.5672395
## 21    5 116023640  rs79219134  T  C 0.9898551 3.273656 0.6035919
## 22    5 116023793  rs77288792  T  G 0.9884058 2.923871 0.5672395
## 23    5 116025142  rs77471527  G  C 0.9898551 3.273656 0.6035919
## 24    5 116025217 rs142277837  G  T 0.9898551 3.273656 0.6035919
## 25    5 116025822 rs139742429  G  C 0.9898551 3.273656 0.6035919
## 26    6  82425908  rs73481987  C  T 0.9753623 1.922015 0.4001026
## 27    6  82442490 rs114928787  T  C 0.9855072 3.192738 0.4508034
## 28    6  82442833 rs116172930  C  A 0.9855072 3.192738 0.4508034
## 29    6  82443802  rs74436554  C  T 0.9855072 3.192738 0.4508034
## 30    6  82444791  rs78056249  C  G 0.9855072 3.192738 0.4508034
## 31    6  82445716  rs77941466  C  T 0.9855072 3.192738 0.4508034
## 32    6  82447004 rs116461493  T  C 0.9855072 3.192738 0.4508034
## 33    6  82447732  rs77666578  G  A 0.9855072 3.192738 0.4508034
## 34    6  82451563  rs75189229  A  G 0.9855072 3.192738 0.4508034
## 35    6  82453938 rs117178778  A  G 0.9855072 3.192738 0.4508034
## 36    6  82454058 rs116246536  T  G 0.9855072 3.192738 0.4508034
## 37    6  82454140  rs78427866  A  G 0.9855072 3.192738 0.4508034
## 38    6  82454380 rs147257041  A  G 0.9855072 3.192738 0.4508034
## 39    6  82454449 rs140711073  T  C 0.9855072 3.192738 0.4508034
## 40    6  82454505 rs142248448  T  C 0.9855072 3.192738 0.4508034
## 41    6  82454620 rs114442506  A  G 0.9855072 3.192738 0.4508034
## 42    6  82456537 rs145558293  A  G 0.9855072 3.192738 0.4508034
## 43    6  82458393  rs77391407  C  T 0.9855072 3.192738 0.4508034
## 44    6  82458546  rs77103853  G  C 0.9855072 3.192738 0.4508034
## 45    6  82459011 rs115096710  T  C 0.9855072 3.192738 0.4508034
## 46    6  82459713  rs77245672  G  C 0.9855072 3.192738 0.4508034
## 47    6  82459810  rs77599496  T  A 0.9855072 3.192738 0.4508034
## 48    6  82459890  rs77598967  G  A 0.9855072 3.192738 0.4508034
## 49    6  82460167 rs115847999  C  G 0.9855072 3.192738 0.4508034
## 50    6  82460379 rs116730626  G  A 0.9855072 3.192738 0.4508034
## 51    6  82460650 rs149355051  G  T 0.9855072 3.192738 0.4508034
## 52    6  82462126  rs76856243  T  C 0.9855072 3.192738 0.4508034
## 53    6  82462603   rs6933239  C  T 0.9855072 3.192738 0.4508034
## 54    6  82462992   rs6911216  A  C 0.9855072 3.192738 0.4508034
## 55    6  82465617   rs6928806  A  C 0.9855072 3.192738 0.4508034
## 56    6  82466574  rs74404091  C  T 0.9855072 3.192738 0.4508034
## 57    6  82466715  rs79358384  G  A 0.9855072 3.192738 0.4508034
## 58    6  82467200  rs77721025  A  C 0.9855072 3.192738 0.4508034
## 59    6  82467706 rs116423281  A  G 0.9855072 3.192738 0.4508034
## 60    6  82467953 rs142216660  T  C 0.9855072 3.192738 0.4508034
## 61    6  82467988 rs140099919  A  G 0.9855072 3.192738 0.4508034
## 62    6  82468668  rs78941585  G  A 0.9855072 3.192738 0.4508034
## 63    6  82468774  rs75228268  A  T 0.9855072 3.192738 0.4508034
## 64    6  82469116  rs77552654  T  A 0.9855072 3.192738 0.4508034
## 65    6  82470649 rs149706908  G  T 0.9855072 3.192738 0.4508034
## 66    6  82470651 rs144623191  T  C 0.9855072 3.192738 0.4508034
## 67    6  82470859 rs192614396  C  A 0.9855072 3.192738 0.4508034
## 68    6  82471119 rs151156468  C  T 0.9855072 3.192738 0.4508034
## 69    6  82471338 rs140554533  A  G 0.9855072 3.192738 0.4508034
## 70    6  82471381 rs150446760  C  G 0.9855072 3.192738 0.4508034
## 71    6  82471679 rs138339145  T  C 0.9855072 3.192738 0.4508034
## 72    6  82472140 rs142089466  T  C 0.9855072 3.192738 0.4508034
## 73    6  82473676 rs147151928  G  C 0.9855072 3.192738 0.4508034
## 74    6  82473679 rs140298049  C  T 0.9855072 3.192738 0.4508034
## 75    6  82473688 rs149655171  A  G 0.9855072 3.192738 0.4508034
## 76    6  82474468 rs146864360  T  C 0.9855072 3.192738 0.4508034
## 77    6  82474648 rs140520501  C  T 0.9855072 3.192738 0.4508034
## 78    6  82474867 rs150394443  T  C 0.9855072 3.192738 0.4508034
## 79    6  82475320 rs143579868  A  T 0.9855072 3.192738 0.4508034
## 80    6  82475696 rs115741750  C  T 0.9855072 3.192738 0.4508034
## 81    6  82477810  rs77406497  T  C 0.9855072 3.192738 0.4508034
## 82    6  82478378 rs115813741  T  G 0.9855072 3.192738 0.4508034
## 83    6  82478650  rs78900243  G  A 0.9855072 3.192738 0.4508034
## 84    6  82478870  rs76557363  T  G 0.9855072 3.192738 0.4508034
## 85    6  82479264  rs77943130  T  G 0.9855072 3.192738 0.4508034
## 86    6  82479546 rs115245280  A  G 0.9855072 3.192738 0.4508034
## 87    6  82479664  rs75910615  A  G 0.9855072 3.192738 0.4508034
## 88    6  82480370  rs76438934  A  G 0.9855072 3.192738 0.4508034
## 89    6  82481986 rs115034961  A  C 0.9855072 3.192738 0.4508034
## 90    6  82482183  rs79967481  G  A 0.9855072 3.192738 0.4508034
## 91    6  82482254 rs116699765  T  C 0.9855072 3.192738 0.4508034
## 92    6  82483125  rs78639250  T  C 0.9855072 3.192738 0.4508034
## 93    6  82483522  rs75763492  A  G 0.9855072 3.192738 0.4508034
## 94    6  82483898  rs76617768  T  C 0.9855072 3.192738 0.4508034
## 95    6  82484287  rs76652063  C  A 0.9855072 3.192738 0.4508034
## 96    6  82484758 rs114024754  A  G 0.9855072 3.192738 0.4508034
## 97    6  82485370  rs79031996  C  G 0.9855072 3.192738 0.4508034
## 98    6  82485916  rs77517398  C  T 0.9855072 3.192738 0.4508034
## 99    6  82486863  rs80252551  A  T 0.9855072 3.192738 0.4508034
## 100   6  82488997 rs114963095  G  T 0.9855072 3.192738 0.4508034
## 101   6  82489053  rs77561386  C  T 0.9855072 3.192738 0.4508034
## 102   6  82489164  rs76602861  A  G 0.9855072 3.192738 0.4508034
## 103   6  82490178  rs79435750  A  G 0.9855072 3.192738 0.4508034
## 104   6  82490367  rs80347071  C  G 0.9855072 3.192738 0.4508034
## 105   6  82492170  rs74785531  C  T 0.9855072 3.192738 0.4508034
## 106   6  82492233  rs74361967  C  T 0.9855072 3.192738 0.4508034
## 107   6  82492321  rs75373608  A  T 0.9855072 3.192738 0.4508034
## 108  10  64099069  rs74804993  G  A 0.9826087 2.596578 0.4600200
## 109  16  13935176   rs1800067  A  G 0.9550725 1.618276 0.2812503
##                p
## 1   9.068185e-10
## 2   9.068185e-10
## 3   9.068185e-10
## 4   9.068185e-10
## 5   9.068185e-10
## 6   9.068185e-10
## 7   9.068185e-10
## 8   9.068185e-10
## 9   3.444386e-09
## 10  1.114565e-07
## 11  1.114565e-07
## 12  1.114565e-07
## 13  4.334528e-07
## 14  4.334528e-07
## 15  1.114565e-07
## 16  4.334528e-07
## 17  4.334528e-07
## 18  4.334528e-07
## 19  4.334528e-07
## 20  4.334528e-07
## 21  1.114565e-07
## 22  4.334528e-07
## 23  1.114565e-07
## 24  1.114565e-07
## 25  1.114565e-07
## 26  2.344151e-06
## 27  8.269693e-12
## 28  8.269693e-12
## 29  8.269693e-12
## 30  8.269693e-12
## 31  8.269693e-12
## 32  8.269693e-12
## 33  8.269693e-12
## 34  8.269693e-12
## 35  8.269693e-12
## 36  8.269693e-12
## 37  8.269693e-12
## 38  8.269693e-12
## 39  8.269693e-12
## 40  8.269693e-12
## 41  8.269693e-12
## 42  8.269693e-12
## 43  8.269693e-12
## 44  8.269693e-12
## 45  8.269693e-12
## 46  8.269693e-12
## 47  8.269693e-12
## 48  8.269693e-12
## 49  8.269693e-12
## 50  8.269693e-12
## 51  8.269693e-12
## 52  8.269693e-12
## 53  8.269693e-12
## 54  8.269693e-12
## 55  8.269693e-12
## 56  8.269693e-12
## 57  8.269693e-12
## 58  8.269693e-12
## 59  8.269693e-12
## 60  8.269693e-12
## 61  8.269693e-12
## 62  8.269693e-12
## 63  8.269693e-12
## 64  8.269693e-12
## 65  8.269693e-12
## 66  8.269693e-12
## 67  8.269693e-12
## 68  8.269693e-12
## 69  8.269693e-12
## 70  8.269693e-12
## 71  8.269693e-12
## 72  8.269693e-12
## 73  8.269693e-12
## 74  8.269693e-12
## 75  8.269693e-12
## 76  8.269693e-12
## 77  8.269693e-12
## 78  8.269693e-12
## 79  8.269693e-12
## 80  8.269693e-12
## 81  8.269693e-12
## 82  8.269693e-12
## 83  8.269693e-12
## 84  8.269693e-12
## 85  8.269693e-12
## 86  8.269693e-12
## 87  8.269693e-12
## 88  8.269693e-12
## 89  8.269693e-12
## 90  8.269693e-12
## 91  8.269693e-12
## 92  8.269693e-12
## 93  8.269693e-12
## 94  8.269693e-12
## 95  8.269693e-12
## 96  8.269693e-12
## 97  8.269693e-12
## 98  8.269693e-12
## 99  8.269693e-12
## 100 8.269693e-12
## 101 8.269693e-12
## 102 8.269693e-12
## 103 8.269693e-12
## 104 8.269693e-12
## 105 8.269693e-12
## 106 8.269693e-12
## 107 8.269693e-12
## 108 3.511379e-08
## 109 1.955875e-08

2. R Cyl Pre-dilate

rcyl_wald_gwas <- association.test(merged_nies_210818, nies_heritable_pheno240918$R.Cyl..pre.dilate, X = nies_covar, method="lm", test = "wald", response = "quantitative", K = merged_nies_GRM, eigenK = merged_nies_eiK, p = 2)
rcyl_wald_gwas <- na.omit(rcyl_wald_gwas)
r_cyl_wfiltered <- rcyl_wald_gwas %>% filter(-log10(p)>1) %>% filter(freqA2 < 0.99)
r_cyl_wmeff <- r_cyl_wfiltered %>% filter(p < 1.84e-7)
r_cyl_wsig <- do.call(rbind, lapply(split(r_cyl_wmeff,r_cyl_wmeff$chr), function(x) {return(x[which.min(x$p),])}))

r_cyl_wres <- NULL
for (i in r_cyl_wsig$id) {
  snpID <- i
  snpCHR <- r_cyl_wfiltered[r_cyl_wfiltered$id == snpID,]$chr
  snpPOS <- r_cyl_wfiltered[r_cyl_wfiltered$id ==snpID,]$pos
  
  sig.peak <- r_cyl_wfiltered %>%
    filter(chr == snpCHR) %>%
    filter(pos > snpPOS - 50000) %>%
    filter(pos < snpPOS + 50000) %>%
    filter(p < 1e-5)
  
  r_cyl_wres <- rbind(r_cyl_wres, sig.peak)
}

write.csv(r_cyl_wres, 'C:/Users/Martha/Documents/Honours/Project/honours.project/Data/gwas_filter_covar/r_cyl_wald_res.csv')
r_cyl_wres
##    chr       pos          id A1 A2    freqA2      beta         sd
## 1    1 205916566  rs72752923  C  A 0.9782609 0.6646789 0.12172209
## 2    1 205916729  rs16830364  G  A 0.9782609 0.6646789 0.12172209
## 3    1 205916931  rs60255052  C  T 0.9811594 0.7038140 0.12413749
## 4    1 205917041  rs60716530  C  T 0.9782609 0.6646789 0.12172209
## 5    1 205917115  rs60644810  G  A 0.9782609 0.6646789 0.12172209
## 6    1 205917248  rs35694044  A  T 0.9782609 0.6646789 0.12172209
## 7    1 205917652  rs16830370  T  C 0.9782609 0.6646789 0.12172209
## 8    1 205918853  rs16856462  C  T 0.9782609 0.6646789 0.12172209
## 9    1 205919195  rs16856468  G  A 0.9782609 0.6646789 0.12172209
## 10   1 205919303  rs60001177  T  C 0.9782609 0.6646789 0.12172209
## 11   1 205919401  rs12723666  A  G 0.9782609 0.6646789 0.12172209
## 12   1 205920201  rs16856470  T  C 0.9811594 0.7038140 0.12413749
## 13   1 205920404  rs16856473  A  G 0.9811594 0.7038140 0.12413749
## 14   1 205922403  rs68189466  G  A 0.9797101 0.6984206 0.12410411
## 15   1 205922720  rs35648260  G  T 0.9797101 0.6984206 0.12410411
## 16   1 205922775  rs35360452  G  T 0.9797101 0.6984206 0.12410411
## 17   1 205925474  rs12727528  A  G 0.9797101 0.6984206 0.12410411
## 18   1 205935183   rs1891309  G  A 0.9782609 0.6885981 0.12388621
## 19   1 205935330   rs1891310  T  G 0.9782609 0.6885981 0.12388621
## 20   1 205936240   rs1473537  T  C 0.9739130 0.6453227 0.12092480
## 21   1 205942026  rs72752928  T  C 0.9782609 0.6885981 0.12388621
## 22   1 205943691  rs66593238  T  C 0.9782609 0.6885981 0.12388621
## 23   1 205944627   rs9438407  T  G 0.9782609 0.6885981 0.12388621
## 24   1 205945388  rs12741299  T  C 0.9782609 0.6885981 0.12388621
## 25   1 205946647  rs34265780  T  C 0.9782609 0.6885981 0.12388621
## 26   2  22752117  rs72793052  C  T 0.9768116 0.6739011 0.12214930
## 27   2  22759734  rs72793060  C  G 0.9579710 0.6091818 0.11124690
## 28   2  22763823  rs72793066  T  C 0.9579710 0.6091818 0.11124690
## 29   2  22764837  rs72793070  C  G 0.9579710 0.6091818 0.11124690
## 30   2  22770868   rs4353679  C  T 0.9579710 0.6091818 0.11124690
## 31   2  22771019   rs4343495  T  C 0.9579710 0.6091818 0.11124690
## 32   2  22778013  rs72793089  A  T 0.9579710 0.6091818 0.11124690
## 33   2  22780281  rs10187240  C  T 0.9579710 0.6091818 0.11124690
## 34   2  22786683  rs72794813  C  T 0.9579710 0.6091818 0.11124690
## 35   2  22792883   rs6719784  T  A 0.9579710 0.6091818 0.11124690
## 36   4  21642565   rs1604803  G  A 0.9724638 0.7175966 0.12075011
## 37   4  21644129  rs35792460  C  T 0.9724638 0.7175966 0.12075011
## 38   4  21644652  rs35038373  A  G 0.9724638 0.7175966 0.12075011
## 39   4  21648827  rs35325665  T  C 0.9724638 0.7175966 0.12075011
## 40   5 111517937  rs72792073  T  C 0.9434783 0.5500178 0.10272813
## 41   5 111519388 rs149693214  G  T 0.9434783 0.5500178 0.10272813
## 42   5 111519507 rs112881034  T  C 0.9434783 0.5500178 0.10272813
## 43   5 111520228  rs17133359  G  A 0.9434783 0.5500178 0.10272813
## 44   5 111522182  rs72792075  A  T 0.9434783 0.5500178 0.10272813
## 45   5 111522894  rs60878703  C  T 0.9434783 0.5500178 0.10272813
## 46   5 111525865  rs56273704  T  C 0.9434783 0.5500178 0.10272813
## 47   5 111527313  rs72792083  C  A 0.9434783 0.5500178 0.10272813
## 48   8 124203587 rs116856476  T  C 0.9840580 0.7052181 0.12982609
## 49   9  78643317  rs12377322  T  A 0.8942029 0.5291633 0.08715593
## 50   9  78643821  rs11137782  T  C 0.8942029 0.5291633 0.08715593
## 51   9  78644279  rs10867228  C  T 0.8942029 0.5291633 0.08715593
## 52   9  78645867   rs9644983  A  T 0.8942029 0.5291633 0.08715593
## 53   9  78650464   rs7870042  G  T 0.8869565 0.5196043 0.08617023
## 54  10  25947431 rs144363867  G  A 0.9565217 0.6297366 0.11062451
## 55  11 100721739 rs148096302  A  G 0.9840580 0.6452475 0.13469060
## 56  11 100769446  rs78598508  G  A 0.9753623 0.7344718 0.12088242
## 57  18  50137976  rs73430360  G  T 0.9855072 0.7093028 0.12336747
##               p
## 1  9.190772e-08
## 2  9.190772e-08
## 3  3.065254e-08
## 4  9.190772e-08
## 5  9.190772e-08
## 6  9.190772e-08
## 7  9.190772e-08
## 8  9.190772e-08
## 9  9.190772e-08
## 10 9.190772e-08
## 11 9.190772e-08
## 12 3.065254e-08
## 13 3.065254e-08
## 14 3.830535e-08
## 15 3.830535e-08
## 16 3.830535e-08
## 17 3.830535e-08
## 18 5.523311e-08
## 19 5.523311e-08
## 20 1.737014e-07
## 21 5.523311e-08
## 22 5.523311e-08
## 23 5.523311e-08
## 24 5.523311e-08
## 25 5.523311e-08
## 26 6.855414e-08
## 27 8.489388e-08
## 28 8.489388e-08
## 29 8.489388e-08
## 30 8.489388e-08
## 31 8.489388e-08
## 32 8.489388e-08
## 33 8.489388e-08
## 34 8.489388e-08
## 35 8.489388e-08
## 36 6.956532e-09
## 37 6.956532e-09
## 38 6.956532e-09
## 39 6.956532e-09
## 40 1.588553e-07
## 41 1.588553e-07
## 42 1.588553e-07
## 43 1.588553e-07
## 44 1.588553e-07
## 45 1.588553e-07
## 46 1.588553e-07
## 47 1.588553e-07
## 48 1.065448e-07
## 49 3.397391e-09
## 50 3.397391e-09
## 51 3.397391e-09
## 52 3.397391e-09
## 53 4.286167e-09
## 54 2.712142e-08
## 55 2.490562e-06
## 56 3.313262e-09
## 57 1.997800e-08

3. R K-value V

rkvalV_wald_gwas <- association.test(merged_nies_210818, nies_heritable_pheno240918$R.K.value.V, X = nies_covar, method="lm", test = "wald", response = "quantitative", K = merged_nies_GRM, eigenK = merged_nies_eiK, p = 2)
## Warning in trans.X(X, mean.y = mean(Y)): An intercept column was added to
## the covariate matrix X
rkvalV_wald_gwas <- na.omit(rkvalV_wald_gwas)
r_kvalV_wfiltered <- rkvalV_wald_gwas %>% filter(-log10(p)>1) %>% filter(freqA2 < 0.99)
r_kvalV_wmeff <- r_kvalV_wfiltered %>% filter(p < 1.84e-7)
r_kvalV_wsig <- do.call(rbind, lapply(split(r_kvalV_wmeff,r_kvalV_wmeff$chr), function(x) {return(x[which.min(x$p),])}))

r_kvalV_wres <- NULL
for (i in r_kvalV_wsig$id) {
  snpID <- i
  snpCHR <- r_kvalV_wfiltered[r_kvalV_wfiltered$id == snpID,]$chr
  snpPOS <- r_kvalV_wfiltered[r_kvalV_wfiltered$id ==snpID,]$pos
  
  sig.peak <- r_kvalV_wfiltered %>%
    filter(chr == snpCHR) %>%
    filter(pos > snpPOS - 50000) %>%
    filter(pos < snpPOS + 50000) %>%
    filter(p < 1e-5)
  
  r_kvalV_wres <- rbind(r_kvalV_wres, sig.peak)
}

write.csv(r_kvalV_wres, 'C:/Users/Martha/Documents/Honours/Project/honours.project/Data/gwas_filter_covar/r_kvalV_wald_res.csv')
r_kvalV_wres
##    chr       pos          id A1 A2    freqA2      beta        sd
## 1    1 205916566  rs72752923  C  A 0.9782609 -2.038243 0.3752191
## 2    1 205916729  rs16830364  G  A 0.9782609 -2.038243 0.3752191
## 3    1 205916931  rs60255052  C  T 0.9811594 -2.677836 0.3892119
## 4    1 205917041  rs60716530  C  T 0.9782609 -2.038243 0.3752191
## 5    1 205917115  rs60644810  G  A 0.9782609 -2.038243 0.3752191
## 6    1 205917248  rs35694044  A  T 0.9782609 -2.038243 0.3752191
## 7    1 205917652  rs16830370  T  C 0.9782609 -2.038243 0.3752191
## 8    1 205918853  rs16856462  C  T 0.9782609 -2.038243 0.3752191
## 9    1 205919195  rs16856468  G  A 0.9782609 -2.038243 0.3752191
## 10   1 205919303  rs60001177  T  C 0.9782609 -2.038243 0.3752191
## 11   1 205919401  rs12723666  A  G 0.9782609 -2.038243 0.3752191
## 12   1 205920201  rs16856470  T  C 0.9811594 -2.677836 0.3892119
## 13   1 205920404  rs16856473  A  G 0.9811594 -2.677836 0.3892119
## 14   1 205922403  rs68189466  G  A 0.9797101 -2.351687 0.3832183
## 15   1 205922720  rs35648260  G  T 0.9797101 -2.351687 0.3832183
## 16   1 205922775  rs35360452  G  T 0.9797101 -2.351687 0.3832183
## 17   1 205925474  rs12727528  A  G 0.9797101 -2.351687 0.3832183
## 18   1 205935183   rs1891309  G  A 0.9782609 -2.246581 0.3729493
## 19   1 205935330   rs1891310  T  G 0.9782609 -2.246581 0.3729493
## 20   1 205936240   rs1473537  T  C 0.9739130 -2.170629 0.3425381
## 21   1 205937685  rs34190121  T  C 0.9797101 -1.936564 0.4197622
## 22   1 205942026  rs72752928  T  C 0.9782609 -2.246581 0.3729493
## 23   1 205943691  rs66593238  T  C 0.9782609 -2.246581 0.3729493
## 24   1 205944627   rs9438407  T  G 0.9782609 -2.246581 0.3729493
## 25   1 205945388  rs12741299  T  C 0.9782609 -2.246581 0.3729493
## 26   1 205946647  rs34265780  T  C 0.9782609 -2.246581 0.3729493
## 27   4 119321195  rs77203710  A  G 0.9855072 -2.625926 0.4405142
## 28   4 119322197   rs1397614  T  C 0.9855072 -2.625926 0.4405142
## 29   4 119362510 rs112314510  A  G 0.9855072 -2.625926 0.4405142
## 30   4 119362552 rs111968273  T  A 0.9855072 -2.625926 0.4405142
## 31   4 119367677 rs113059419  A  G 0.9869565 -2.851907 0.4562266
## 32   4 119372303 rs112760591  G  A 0.9855072 -2.625926 0.4405142
## 33   4 119372480 rs111609258  C  G 0.9855072 -2.625926 0.4405142
## 34   4 119378224 rs147602981  G  A 0.9855072 -2.625926 0.4405142
## 35   4 119381167 rs143847948  A  C 0.9855072 -2.625926 0.4405142
## 36   4 119390257 rs113224532  T  C 0.9855072 -2.625926 0.4405142
## 37   4 119392279 rs117856633  C  A 0.9855072 -2.625926 0.4405142
## 38   4 119398681 rs113825627  C  G 0.9855072 -2.625926 0.4405142
## 39   4 119403429 rs112414671  A  G 0.9869565 -2.851907 0.4562266
## 40   4 119403485 rs185357281  A  G 0.9869565 -2.144971 0.4693895
## 41   4 119404439 rs183181597  A  G 0.9855072 -2.625926 0.4405142
## 42   4 119404927 rs113317707  C  A 0.9855072 -2.625926 0.4405142
## 43   4 119408454 rs184703141  T  C 0.9855072 -2.625926 0.4405142
## 44   5  33168945 rs113442983  T  C 0.9898551 -3.297808 0.6011238
##               p
## 1  1.066727e-07
## 2  1.066727e-07
## 3  2.908984e-11
## 4  1.066727e-07
## 5  1.066727e-07
## 6  1.066727e-07
## 7  1.066727e-07
## 8  1.066727e-07
## 9  1.066727e-07
## 10 1.066727e-07
## 11 1.066727e-07
## 12 2.908984e-11
## 13 2.908984e-11
## 14 2.358515e-09
## 15 2.358515e-09
## 16 2.358515e-09
## 17 2.358515e-09
## 18 4.447739e-09
## 19 4.447739e-09
## 20 7.489119e-10
## 21 5.628478e-06
## 22 4.447739e-09
## 23 4.447739e-09
## 24 4.447739e-09
## 25 4.447739e-09
## 26 4.447739e-09
## 27 6.305362e-09
## 28 6.305362e-09
## 29 6.305362e-09
## 30 6.305362e-09
## 31 1.228698e-09
## 32 6.305362e-09
## 33 6.305362e-09
## 34 6.305362e-09
## 35 6.305362e-09
## 36 6.305362e-09
## 37 6.305362e-09
## 38 6.305362e-09
## 39 1.228698e-09
## 40 6.856998e-06
## 41 6.305362e-09
## 42 6.305362e-09
## 43 6.305362e-09
## 44 8.069754e-08

4. UVAF

uvaf_wald_gwas <- association.test(merged_nies_210818, nies_heritable_pheno240918$totaluvafmm, X = nies_covar, method="lm", test = "wald", response = "quantitative", K = merged_nies_GRM, eigenK = merged_nies_eiK, p = 2)
## Warning in trans.X(X, mean.y = mean(Y)): An intercept column was added to
## the covariate matrix X
uvaf_wald_gwas <- na.omit(uvaf_wald_gwas)
uvaf_wfiltered <- uvaf_wald_gwas %>% filter(-log10(p)>1) %>% filter(freqA2 < 0.99)
uvaf_wmeff <- uvaf_wfiltered %>% filter(p < 1.84e-7)
uvaf_wsig <- do.call(rbind, lapply(split(uvaf_wmeff,uvaf_wmeff$chr), function(x) {return(x[which.min(x$p),])}))

uvaf_wres <- NULL
for (i in uvaf_wsig$id) {
  snpID <- i
  snpCHR <- uvaf_wfiltered[uvaf_wfiltered$id == snpID,]$chr
  snpPOS <- uvaf_wfiltered[uvaf_wfiltered$id ==snpID,]$pos
  
  sig.peak <- uvaf_wfiltered %>%
    filter(chr == snpCHR) %>%
    filter(pos > snpPOS - 50000) %>%
    filter(pos < snpPOS + 50000) %>%
    filter(p < 1e-5)
  
  uvaf_wres <- rbind(uvaf_wres, sig.peak)
}

write.csv(uvaf_wres, 'C:/Users/Martha/Documents/Honours/Project/honours.project/Data/gwas_filter_covar/uvaf_wald_res.csv')
uvaf_wres
##    chr       pos          id A1 A2    freqA2      beta       sd
## 1    1 158362100 rs112697372  T  G 0.9898551 -51.08282 9.320546
## 2    4  22963447  rs75555621  T  C 0.9753623 -36.07684 6.065289
## 3    4  22968049    rs961611  G  C 0.9753623 -36.07684 6.065289
## 4    4  22994702  rs77135796  C  A 0.9768116 -36.31808 6.250112
## 5    5 159560389  rs76476973  G  T 0.9594203 -25.45470 4.482965
## 6    5 159560514  rs10515800  T  C 0.9594203 -25.45470 4.482965
## 7    5 159560700  rs17056804  T  C 0.9594203 -25.45470 4.482965
## 8    7 107578936 rs191522213  G  C 0.9884058 -53.10171 8.662913
## 9    8  34731289 rs116937259  C  T 0.9884058 -44.01351 7.764533
## 10   8  34738629 rs141115618  C  G 0.9898551 -40.73365 8.262096
## 11   8  34743083 rs192922472  T  C 0.9884058 -44.01351 7.764533
## 12   9  68575580  rs34054758  A  G 0.9753623 -32.65221 5.670032
## 13   9  68576337  rs35666199  G  C 0.9753623 -32.65221 5.670032
## 14   9  68580538   rs6560237  C  T 0.9753623 -32.65221 5.670032
## 15   9  68581265   rs7048633  T  C 0.9753623 -32.65221 5.670032
## 16   9  68583308  rs71501771  T  A 0.9753623 -32.65221 5.670032
## 17   9  68586048  rs35551873  T  C 0.9753623 -32.65221 5.670032
## 18   9  68586254   rs7045561  G  A 0.9753623 -32.65221 5.670032
## 19   9  68587181  rs13288798  G  T 0.9753623 -32.65221 5.670032
## 20   9  68587313  rs13284137  G  A 0.9753623 -32.65221 5.670032
## 21   9  68588522 rs139047286  C  T 0.9753623 -32.65221 5.670032
## 22   9  68588999   rs7859065  C  T 0.9753623 -32.65221 5.670032
## 23   9  68594362  rs13290124  A  G 0.9753623 -32.65221 5.670032
## 24   9  68595978  rs10511959  A  G 0.9753623 -32.65221 5.670032
## 25   9  68597806  rs34412731  T  C 0.9753623 -32.65221 5.670032
## 26   9  68599834  rs12004993  G  A 0.9753623 -32.65221 5.670032
## 27   9  68605388  rs76930250  G  C 0.9753623 -32.65221 5.670032
## 28   9  68605806  rs13287094  A  G 0.9753623 -32.65221 5.670032
## 29   9  68608085  rs34921768  G  A 0.9753623 -32.65221 5.670032
## 30   9  68608420  rs13299492  A  G 0.9753623 -32.65221 5.670032
## 31   9  68612655  rs34344868  A  G 0.9753623 -32.65221 5.670032
## 32   9  68615281  rs34805084  A  G 0.9739130 -30.53099 5.558659
## 33   9  68618011  rs71501772  G  C 0.9739130 -30.53099 5.558659
## 34   9  68618330  rs34763246  T  C 0.9739130 -30.53099 5.558659
## 35   9  68619315  rs34436601  T  C 0.9739130 -30.53099 5.558659
## 36   9  68621728  rs13289515  C  G 0.9739130 -30.53099 5.558659
## 37   9  68621879  rs13289852  A  G 0.9753623 -29.48118 5.714665
## 38   9  68624185 rs117741244  T  C 0.9811594 -40.42978 6.284847
## 39   9  68629924 rs117987088  T  C 0.9811594 -40.42978 6.284847
## 40   9  68652928  rs77058957  C  T 0.9695652 -25.51528 5.255250
## 41   9  68654569  rs76760268  T  C 0.9695652 -25.51528 5.255250
## 42   9  68655326 rs186268857  C  G 0.9695652 -25.51528 5.255250
## 43   9  68655444 rs118049065  G  T 0.9695652 -25.51528 5.255250
## 44   9  68657621  rs75835902  G  A 0.9695652 -25.51528 5.255250
## 45   9  68658645 rs180877078  A  T 0.9695652 -25.51528 5.255250
## 46   9  68658661  rs78742689  G  C 0.9695652 -25.51528 5.255250
## 47   9  68659669 rs111504512  G  A 0.9695652 -25.51528 5.255250
## 48   9  68659832 rs150742857  G  C 0.9695652 -25.51528 5.255250
## 49   9  68659936 rs145005200  C  G 0.9695652 -25.51528 5.255250
## 50   9  68660811  rs76726918  A  G 0.9695652 -25.51528 5.255250
## 51   9  68660882  rs77616759  G  A 0.9695652 -25.51528 5.255250
## 52   9  68664724  rs78104260  C  T 0.9695652 -25.51528 5.255250
## 53   9  68668603  rs74341285  T  C 0.9695652 -25.51528 5.255250
## 54   9  68669378  rs75245907  T  C 0.9695652 -25.51528 5.255250
## 55   9  68669933 rs116959126  G  T 0.9695652 -25.51528 5.255250
## 56   9  68671411  rs79224950  G  A 0.9695652 -25.51528 5.255250
## 57   9  68672520  rs78935265  A  G 0.9695652 -25.51528 5.255250
## 58   9  68673301  rs80225323  G  A 0.9695652 -25.51528 5.255250
## 59  18  22734233   rs1357201  A  G 0.9637681 -25.09240 4.661405
## 60  18  22782053  rs10153383  C  T 0.9681159 -23.54607 4.943863
##               p
## 1  8.299304e-08
## 2  6.774313e-09
## 3  6.774313e-09
## 4  1.437436e-08
## 5  2.936260e-08
## 6  2.936260e-08
## 7  2.936260e-08
## 8  2.452435e-09
## 9  3.089838e-08
## 10 1.290054e-06
## 11 3.089838e-08
## 12 1.905184e-08
## 13 1.905184e-08
## 14 1.905184e-08
## 15 1.905184e-08
## 16 1.905184e-08
## 17 1.905184e-08
## 18 1.905184e-08
## 19 1.905184e-08
## 20 1.905184e-08
## 21 1.905184e-08
## 22 1.905184e-08
## 23 1.905184e-08
## 24 1.905184e-08
## 25 1.905184e-08
## 26 1.905184e-08
## 27 1.905184e-08
## 28 1.905184e-08
## 29 1.905184e-08
## 30 1.905184e-08
## 31 1.905184e-08
## 32 7.804189e-08
## 33 7.804189e-08
## 34 7.804189e-08
## 35 7.804189e-08
## 36 7.804189e-08
## 37 4.243244e-07
## 38 4.279007e-10
## 39 4.279007e-10
## 40 1.841426e-06
## 41 1.841426e-06
## 42 1.841426e-06
## 43 1.841426e-06
## 44 1.841426e-06
## 45 1.841426e-06
## 46 1.841426e-06
## 47 1.841426e-06
## 48 1.841426e-06
## 49 1.841426e-06
## 50 1.841426e-06
## 51 1.841426e-06
## 52 1.841426e-06
## 53 1.841426e-06
## 54 1.841426e-06
## 55 1.841426e-06
## 56 1.841426e-06
## 57 1.841426e-06
## 58 1.841426e-06
## 59 1.372926e-07
## 60 2.839311e-06

5. PC1

pc1_wald_gwas <- association.test(merged_nies_210818, nies_heritable_pheno240918$coord.Dim.1, X = nies_covar, method="lm", test = "wald", response = "quantitative", K = merged_nies_GRM, eigenK = merged_nies_eiK, p = 2)
pc1_wald_gwas <- na.omit(pc1_wald_gwas)
pc1_wfiltered <- pc1_wald_gwas %>% filter(-log10(p)>1) %>% filter(freqA2 < 0.99)
pc1_wmeff <- pc1_wfiltered %>% filter(p < 1.84e-7)
pc1_wsig <- do.call(rbind, lapply(split(pc1_wmeff,pc1_wmeff$chr), function(x) {return(x[which.min(x$p),])}))

pc1_wres <- NULL
for (i in pc1_wsig$id) {
  snpID <- i
  snpCHR <- pc1_wfiltered[pc1_wfiltered$id == snpID,]$chr
  snpPOS <- pc1_wfiltered[pc1_wfiltered$id ==snpID,]$pos
  
  sig.peak <- pc1_wfiltered %>%
    filter(chr == snpCHR) %>%
    filter(pos > snpPOS - 50000) %>%
    filter(pos < snpPOS + 50000) %>%
    filter(p < 1e-5)
  
  pc1_wres <- rbind(pc1_wres, sig.peak)
}

write.csv(pc1_wres, 'C:/Users/Martha/Documents/Honours/Project/honours.project/Data/gwas_filter_covar/pc1_wald_res.csv')
pc1_wres
##     chr       pos          id A1 A2    freqA2       beta        sd
## 1     1 197538281  rs10494757  T  C 0.9594203 -1.4256297 0.2477083
## 2     2 211334210   rs1821662  G  A 0.6898551 -0.7831531 0.1459409
## 3     2 211334911  rs10804194  T  C 0.7637681 -0.7882912 0.1550308
## 4     2 211335269   rs1595068  C  T 0.6927536 -0.7840114 0.1475340
## 5     3 160102701   rs6778335  T  C 0.9028986 -1.1737527 0.2178986
## 6     3 160102966  rs11922988  A  C 0.8637681 -1.0767482 0.1913661
## 7     3 160122371  rs66566032  G  A 0.9202899 -1.0901215 0.2281417
## 8     3 160123754  rs73171924  A  G 0.9159420 -1.0427722 0.2266812
## 9     3 160124095 rs113621516  T  C 0.9159420 -1.0427722 0.2266812
## 10    3 160125646   rs4541448  T  G 0.8884058 -1.0770006 0.2076571
## 11    3 160126934  rs11926233  C  T 0.8884058 -1.0770006 0.2076571
## 12    3 160126964 rs116472907  A  G 0.9217391 -1.1014880 0.2271433
## 13    3 160126966 rs115317177  C  A 0.9217391 -1.1014880 0.2271433
## 14    3 160126968 rs114050713  G  C 0.9217391 -1.1014880 0.2271433
## 15    3 160127332  rs67955459  C  T 0.9202899 -1.0901215 0.2281417
## 16    3 160130412  rs59287878  A  C 0.9202899 -1.0901215 0.2281417
## 17    4 161298219  rs75219943  A  T 0.9014493 -1.0068320 0.2018008
## 18    4 161298374  rs78397069  T  A 0.9086957 -1.1249478 0.2066917
## 19    4 161298417   rs7667597  G  A 0.9086957 -1.1249478 0.2066917
## 20    4 161299003  rs78982571  G  A 0.9086957 -1.1249478 0.2066917
## 21    4 161301597  rs11930861  A  C 0.9086957 -1.1249478 0.2066917
## 22    4 161302329   rs7658820  G  A 0.9086957 -1.1249478 0.2066917
## 23    4 161302835 rs113228726  G  T 0.9086957 -1.1249478 0.2066917
## 24    4 161308227   rs9308027  T  C 0.7579710 -0.6956557 0.1503054
## 25    4 161308302   rs9308028  T  G 0.7579710 -0.6956557 0.1503054
## 26    4 161308359  rs10027110  G  T 0.7579710 -0.6956557 0.1503054
## 27    4 161308518   rs9992864  G  A 0.7579710 -0.6956557 0.1503054
## 28    4 161308604  rs10015574  T  C 0.7579710 -0.6956557 0.1503054
## 29    4 161308878  rs10017957  G  C 0.7579710 -0.6956557 0.1503054
## 30    4 161308882  rs10018124  T  G 0.7579710 -0.6956557 0.1503054
## 31    4 161308926  rs10018045  T  C 0.7579710 -0.6956557 0.1503054
## 32    4 161308939  rs10029764  C  T 0.7579710 -0.6956557 0.1503054
## 33    4 161309025  rs10018146  T  C 0.7579710 -0.6956557 0.1503054
## 34    4 161309066  rs10029866  G  T 0.7579710 -0.6956557 0.1503054
## 35    4 161309184   rs6827362  A  G 0.7579710 -0.6956557 0.1503054
## 36    4 161309223   rs6826847  C  A 0.7579710 -0.6956557 0.1503054
## 37    4 161309666   rs6827877  G  C 0.7579710 -0.6956557 0.1503054
## 38    4 161309721  rs10018817  T  C 0.7579710 -0.6956557 0.1503054
## 39    4 161309899  rs10021326  A  G 0.7579710 -0.6956557 0.1503054
## 40    4 161309993   rs6854527  C  T 0.7579710 -0.6956557 0.1503054
## 41    4 161310377   rs6834175  T  C 0.7579710 -0.6956557 0.1503054
## 42    4 161310657   rs6536585  G  A 0.7579710 -0.6956557 0.1503054
## 43    4 161310853   rs7677663  T  A 0.7579710 -0.6956557 0.1503054
## 44    4 161311072   rs7678039  G  A 0.7579710 -0.6956557 0.1503054
## 45    4 161311138   rs7678417  T  C 0.7579710 -0.6956557 0.1503054
## 46    4 161311208  rs10007857  A  C 0.7579710 -0.6956557 0.1503054
## 47    4 161314841   rs5010468  A  G 0.7376812 -0.6786950 0.1431825
## 48    5 110018330   rs1563324  G  A 0.9637681 -1.2424987 0.2657114
## 49    5 110027474   rs1455554  G  A 0.8782609 -1.0517960 0.1865073
## 50    5 110034646   rs1869723  T  C 0.9550725 -1.1489939 0.2529790
## 51    5 110063032  rs72816853  T  C 0.9188406 -1.0011724 0.2186121
## 52    5 110063197   rs7710972  A  G 0.9188406 -1.0011724 0.2186121
## 53    5 110063858  rs10515409  G  C 0.9188406 -1.0011724 0.2186121
## 54    5 110063929  rs11959815  A  G 0.9188406 -1.0011724 0.2186121
## 55    5 110064678  rs72816864  G  C 0.9188406 -1.0011724 0.2186121
## 56    5 110065253  rs72816865  A  G 0.9188406 -1.0011724 0.2186121
## 57    5 110065473  rs17162644  C  T 0.9188406 -1.0011724 0.2186121
## 58    5 110065710  rs17162650  A  G 0.9188406 -1.0011724 0.2186121
## 59    5 110066417  rs72816868  C  T 0.9188406 -1.0011724 0.2186121
## 60    5 110068774  rs72816871  T  G 0.9188406 -1.0011724 0.2186121
## 61    5 110073037  rs72816880  T  C 0.9188406 -1.0011724 0.2186121
## 62    6  19696595   rs6921521  T  C 0.9811594 -1.2688520 0.2757097
## 63    6  19742012   rs1209816  T  C 0.9652174 -1.3539351 0.2428034
## 64    7   7976971  rs73049252  A  G 0.9376812 -1.2573307 0.2192251
## 65    7   7978549   rs7804306  A  G 0.9304348 -1.2755321 0.2192226
## 66    7   7978858  rs73049256  T  A 0.9376812 -1.2573307 0.2192251
## 67    7   7979532  rs67343471  T  G 0.9275362 -1.2107762 0.2172348
## 68    7   7981025  rs56073406  G  A 0.9304348 -1.2755321 0.2192226
## 69    7   7981281 rs112270482  C  T 0.9376812 -1.2573307 0.2192251
## 70    7   7981982   rs6975218  G  A 0.9304348 -1.2755321 0.2192226
## 71    7   7982015  rs73049270  T  C 0.9376812 -1.2573307 0.2192251
## 72    7   7982385  rs73049276  A  G 0.9376812 -1.2573307 0.2192251
## 73    7   7985192 rs113537684  T  G 0.9376812 -1.2573307 0.2192251
## 74    7   7985209  rs60466842  A  C 0.9188406 -1.0858589 0.2095709
## 75    7   7992584  rs73049290  C  T 0.9376812 -1.2573307 0.2192251
## 76    7   7993887  rs17566854  C  A 0.9376812 -1.2573307 0.2192251
## 77    7   7995282  rs56017154  A  G 0.9376812 -1.2573307 0.2192251
## 78    7   7997876 rs142269087  A  G 0.9376812 -1.2573307 0.2192251
## 79    7   7999017  rs73049293  C  T 0.9376812 -1.2573307 0.2192251
## 80    7   7999429  rs73049297  A  G 0.9376812 -1.2573307 0.2192251
## 81    7   8001135 rs138912252  A  G 0.9376812 -1.2573307 0.2192251
## 82    7   8001658 rs147420655  A  G 0.9376812 -1.2573307 0.2192251
## 83    7   8002315  rs73049300  G  C 0.9376812 -1.2573307 0.2192251
## 84    7   8010614  rs73050915  T  G 0.9376812 -1.2573307 0.2192251
## 85    7   8012093 rs149303885  T  G 0.9376812 -1.2573307 0.2192251
## 86    7   8016462 rs145954895  A  C 0.9376812 -1.2573307 0.2192251
## 87    7   8019638  rs73050929  A  C 0.9376812 -1.2573307 0.2192251
## 88    7   8027882  rs73050940  G  A 0.9376812 -1.2573307 0.2192251
## 89    9   2121302  rs58152462  C  G 0.9884058 -1.3502053 0.2960458
## 90    9   2124140  rs10811481  T  C 0.8739130 -1.0141919 0.1945314
## 91    9   2124569   rs4373572  G  A 0.8724638 -1.0248984 0.1951010
## 92    9   2124583   rs3829071  G  C 0.8724638 -1.0248984 0.1951010
## 93    9   2125231   rs7048496  A  C 0.8971014 -1.1498926 0.2086025
## 94    9   2126238   rs6475506  A  G 0.8971014 -1.1532723 0.2072771
## 95    9   2127469   rs6475507  T  A 0.8971014 -1.1498926 0.2086025
## 96    9   2127677   rs6475508  A  G 0.8971014 -1.1498926 0.2086025
## 97    9   2127796   rs3829072  A  G 0.8971014 -1.1498926 0.2086025
## 98    9   2129360   rs6475519  G  T 0.9014493 -1.1293905 0.2157940
## 99    9   2129744  rs10811504  C  T 0.8956522 -1.1683446 0.2082453
## 100   9   2129798  rs10964907  G  T 0.9014493 -1.1293905 0.2157940
## 101   9   2129832  rs10964908  C  T 0.8942029 -1.1598299 0.2067817
## 102   9   2129949  rs10964909  G  A 0.9028986 -1.1115208 0.2164786
## 103   9   2130029  rs10811507  T  C 0.8956522 -1.1432338 0.2074131
## 104   9   2130828   rs6475520  G  A 0.9028986 -1.1115208 0.2164786
## 105   9   2130861   rs6475521  G  C 0.8956522 -1.1432338 0.2074131
## 106   9   2131534   rs6475524  G  A 0.9362319 -1.1867207 0.2377471
## 107  10  58350923 rs117937758  T  C 0.9579710 -1.2816181 0.2401111
## 108  10  58363234   rs2306605  G  T 0.9507246 -1.2567480 0.2326473
## 109  10  58363726  rs73288305  G  A 0.9231884 -0.9798906 0.2065222
## 110  10  58367879  rs74377516  T  G 0.9507246 -1.2567480 0.2326473
## 111  10  58368078  rs75362994  A  G 0.9507246 -1.2567480 0.2326473
## 112  10  58371631  rs56713413  T  C 0.9333333 -1.0758271 0.2186407
## 113  10  58388991  rs16912188  G  A 0.9362319 -1.0500796 0.2174013
## 114  10  58391107 rs191321905  A  G 0.9623188 -1.2854714 0.2435308
## 115  10  58391386  rs16912196  G  A 0.9536232 -1.1571822 0.2335622
## 116  10  58391482  rs16912197  G  A 0.9521739 -1.1079482 0.2299337
## 117  10  58392399  rs79356971  C  T 0.9362319 -1.0500796 0.2174013
## 118  10  58392785  rs77124850  T  C 0.9362319 -1.0500796 0.2174013
## 119  10  58393772 rs112938146  C  G 0.9362319 -1.0500796 0.2174013
## 120  10  58396221  rs17847532  C  T 0.9536232 -1.1571822 0.2335622
## 121  10  58396842  rs74827573  C  T 0.9536232 -1.1571822 0.2335622
## 122  10  58396926  rs16912201  G  A 0.9536232 -1.1571822 0.2335622
## 123  10  58397881  rs77032090  A  G 0.9536232 -1.1571822 0.2335622
## 124  10  58398310  rs16912202  G  T 0.9536232 -1.1571822 0.2335622
## 125  10  58400877  rs79696318  T  C 0.9536232 -1.1571822 0.2335622
## 126  11  69654262      rs7178  G  A 0.9217391 -1.2094747 0.2089804
## 127  12 131726697  rs71470343  T  C 0.7565217 -0.8689439 0.1702817
## 128  12 131727978  rs11612305  G  A 0.7565217 -0.8689439 0.1702817
## 129  12 131732148  rs34459128  A  G 0.7565217 -0.8689439 0.1702817
## 130  12 131733497  rs11246782  C  A 0.7565217 -0.8689439 0.1702817
## 131  12 131735840  rs12426142  G  T 0.7565217 -0.8689439 0.1702817
## 132  12 131740230  rs35811529  A  T 0.7565217 -0.8689439 0.1702817
## 133  12 131741218  rs77720672  A  G 0.7565217 -0.8689439 0.1702817
## 134  12 131750373  rs11613616  A  G 0.7565217 -0.8689439 0.1702817
## 135  12 131751961  rs12814215  A  G 0.7565217 -0.8689439 0.1702817
## 136  12 131753205   rs1051219  T  C 0.7550725 -0.9111014 0.1703480
## 137  12 131755796   rs3741526  T  C 0.5246377 -0.8142617 0.1434219
## 138  12 131757714  rs10902445  A  G 0.5246377 -0.8142617 0.1434219
## 139  12 131759383  rs10751692  C  T 0.5231884 -0.8140192 0.1429634
## 140  12 131780621  rs35769880  A  G 0.7565217 -0.8488046 0.1691329
## 141  12 131782218  rs12824836  C  T 0.7579710 -0.8608964 0.1705522
## 142  12 131788771  rs10751693  A  G 0.5260870 -0.8135621 0.1440277
## 143  12 131789723  rs78792048  C  A 0.7579710 -0.8608964 0.1705522
## 144  12 131790985   rs7302570  A  C 0.7579710 -0.8608964 0.1705522
## 145  12 131792417   rs7972213  C  T 0.5362319 -0.8117677 0.1437640
## 146  12 131793860  rs35198651  A  G 0.7579710 -0.8608964 0.1705522
## 147  12 131794164  rs34705844  G  A 0.7579710 -0.8608964 0.1705522
## 148  12 131805033  rs11615253  T  C 0.7550725 -0.8682945 0.1705908
## 149  12 131805444  rs12319878  C  T 0.5188406 -0.8165264 0.1461678
## 150  12 131805478   rs7963727  C  G 0.7550725 -0.8682945 0.1705908
## 151  13  98207311    rs285107  G  A 0.5217391 -0.7591165 0.1420521
## 152  13  98240001    rs944095  C  T 0.6695652 -0.7384079 0.1436502
## 153  14  78416873  rs17829009  A  G 0.9463768 -1.2557271 0.2317082
## 154  15  45161524   rs1648315  G  A 0.9739130 -1.3000975 0.2737862
## 155  15  45163058    rs938130  G  A 0.9739130 -1.3000975 0.2737862
## 156  15  45163996   rs1648314  G  A 0.9739130 -1.3000975 0.2737862
## 157  15  45172570   rs1648290  A  G 0.9739130 -1.3000975 0.2737862
## 158  15  45173053   rs1706819  G  A 0.9739130 -1.3000975 0.2737862
## 159  15  45175342   rs1632144  C  G 0.9739130 -1.3000975 0.2737862
## 160  15  45181145   rs1625404  G  C 0.9739130 -1.3000975 0.2737862
## 161  15  45196676   rs2467839  A  T 0.9739130 -1.3000975 0.2737862
## 162  15  45199537   rs1648300  T  C 0.9739130 -1.3000975 0.2737862
## 163  15  45201250   rs2458239  C  G 0.9739130 -1.3000975 0.2737862
## 164  15  45201819   rs1648301  T  C 0.9637681 -1.3678326 0.2567521
## 165  15  45203931   rs2668750  A  G 0.9724638 -1.2762335 0.2714550
## 166  15  45206013   rs1648292  A  C 0.9724638 -1.2762335 0.2714550
## 167  15  45207831   rs2458240  G  A 0.9724638 -1.2762335 0.2714550
## 168  15  45208189   rs1628717  G  A 0.9724638 -1.2762335 0.2714550
## 169  15  45212788   rs1648291  T  C 0.9724638 -1.2762335 0.2714550
## 170  15  45213976   rs1648288  C  G 0.9724638 -1.2762335 0.2714550
## 171  15  45217126   rs1706828  C  T 0.9724638 -1.2762335 0.2714550
## 172  15  45218630   rs1648280  G  T 0.9724638 -1.2762335 0.2714550
## 173  15  45223046   rs2458241  C  T 0.9724638 -1.2762335 0.2714550
## 174  15  45225440   rs1706833  T  C 0.9724638 -1.2762335 0.2714550
## 175  15  45225994   rs1706836  A  G 0.9724638 -1.2762335 0.2714550
## 176  16  52630885   rs8050739  C  T 0.7362319 -0.8198966 0.1468328
## 177  16  52632690   rs7188201  G  A 0.7362319 -0.8198966 0.1468328
## 178  16  52632695   rs7188202  G  A 0.7362319 -0.8198966 0.1468328
## 179  16  52632827   rs7187724  A  C 0.7362319 -0.8198966 0.1468328
## 180  16  52635058   rs4536472  A  G 0.7362319 -0.8198966 0.1468328
## 181  16  52635377  rs58472864  C  A 0.7362319 -0.8198966 0.1468328
## 182  16  52635542  rs28542820  A  G 0.7362319 -0.8198966 0.1468328
## 183  16  52641501   rs3104819  G  A 0.7985507 -0.8674585 0.1586238
## 184  16  52642525   rs3112592  T  C 0.7985507 -0.8674585 0.1586238
## 185  16  52642931   rs3104822  A  G 0.7985507 -0.8674585 0.1586238
## 186  16  52647924   rs3112587  T  C 0.7869565 -0.8165291 0.1598739
## 187  18  36626107  rs75895411  C  A 0.8942029 -0.9276155 0.1934680
## 188  18  36626477   rs2644254  A  G 0.7927536 -0.8692300 0.1614081
## 189  18  36626486  rs79026601  G  A 0.8942029 -0.9276155 0.1934680
## 190  18  36627754  rs11661986  A  G 0.8985507 -0.8944593 0.1964448
## 191  18  36627944  rs11662615  T  C 0.8985507 -0.8944593 0.1964448
## 192  18  36629087  rs78120969  C  G 0.8942029 -0.9276155 0.1934680
## 193  18  36630706  rs11664734  T  G 0.8985507 -0.8944593 0.1964448
## 194  18  36631401   rs8083846  T  C 0.8985507 -0.8944593 0.1964448
## 195  18  36631850   rs8084815  C  G 0.8942029 -0.9276155 0.1934680
## 196  18  36631892   rs8084477  G  A 0.8942029 -0.9276155 0.1934680
## 197  18  36632135  rs74818539  G  T 0.8942029 -0.9276155 0.1934680
## 198  18  36632302  rs75323193  G  T 0.8942029 -0.9276155 0.1934680
## 199  18  36633245  rs79091544  G  C 0.8942029 -0.9276155 0.1934680
## 200  18  36633326  rs79603670  G  A 0.8942029 -0.9276155 0.1934680
## 201  18  36633458  rs16968087  G  A 0.8942029 -0.9276155 0.1934680
## 202  18  36633546  rs74583186  A  G 0.8942029 -0.9276155 0.1934680
## 203  18  36635242   rs8085903  T  C 0.8942029 -0.9276155 0.1934680
## 204  18  36635439   rs8086052  G  A 0.8942029 -0.9276155 0.1934680
## 205  18  36636441   rs1565976  G  A 0.8985507 -0.8944593 0.1964448
## 206  18  36636541  rs11660710  G  A 0.8985507 -0.8944593 0.1964448
## 207  18  36637747   rs2848921  T  C 0.8985507 -0.8944593 0.1964448
## 208  18  36637790   rs2644258  T  C 0.8985507 -0.8944593 0.1964448
## 209  18  36638574    rs990462  A  G 0.8985507 -0.8944593 0.1964448
## 210  19  50403272   rs1673043  A  G 0.9463768 -1.2671199 0.2337885
## 211  19  50410704   rs1673037  G  T 0.9463768 -1.2671199 0.2337885
## 212  19  50411356   rs2445830  C  T 0.9463768 -1.2671199 0.2337885
## 213  19  50416571   rs3218760  G  A 0.9463768 -1.2671199 0.2337885
## 214  19  50418015   rs2445837  C  T 0.9463768 -1.2671199 0.2337885
## 215  20   8549239   rs6039190  C  T 0.6072464 -0.6575422 0.1459235
## 216  20   8582435  rs12624339  G  A 0.8550725 -0.9444111 0.1745442
## 217  20   8582919  rs57379040  A  G 0.8550725 -0.9444111 0.1745442
## 218  20   8584320   rs6055922  G  A 0.7695652 -0.6873243 0.1498391
## 219  20   8586504   rs6055928  A  G 0.7000000 -0.7705549 0.1424458
## 220  20   8586872   rs6086518  G  A 0.6753623 -0.7003448 0.1445490
## 221  20   8608924   rs6055944  G  A 0.8594203 -0.8320014 0.1758258
## 222  21  26973633   rs2830592  A  G 0.7869565 -0.8156619 0.1719187
## 223  21  27012210   rs9983987  A  G 0.8347826 -0.9531290 0.1774854
## 224  21  27013043    rs977152  A  G 0.8333333 -0.9779213 0.1770009
##                p
## 1   1.936695e-08
## 2   1.493256e-07
## 3   6.102537e-07
## 4   1.946743e-07
## 5   1.344928e-07
## 6   3.852095e-08
## 7   2.637867e-06
## 8   5.971731e-06
## 9   5.971731e-06
## 10  3.695170e-07
## 11  3.695170e-07
## 12  1.891003e-06
## 13  1.891003e-06
## 14  1.891003e-06
## 15  2.637867e-06
## 16  2.637867e-06
## 17  9.704918e-07
## 18  1.008665e-07
## 19  1.008665e-07
## 20  1.008665e-07
## 21  1.008665e-07
## 22  1.008665e-07
## 23  1.008665e-07
## 24  5.257910e-06
## 25  5.257910e-06
## 26  5.257910e-06
## 27  5.257910e-06
## 28  5.257910e-06
## 29  5.257910e-06
## 30  5.257910e-06
## 31  5.257910e-06
## 32  5.257910e-06
## 33  5.257910e-06
## 34  5.257910e-06
## 35  5.257910e-06
## 36  5.257910e-06
## 37  5.257910e-06
## 38  5.257910e-06
## 39  5.257910e-06
## 40  5.257910e-06
## 41  5.257910e-06
## 42  5.257910e-06
## 43  5.257910e-06
## 44  5.257910e-06
## 45  5.257910e-06
## 46  5.257910e-06
## 47  3.149705e-06
## 48  4.227633e-06
## 49  3.599351e-08
## 50  7.761227e-06
## 51  6.549984e-06
## 52  6.549984e-06
## 53  6.549984e-06
## 54  6.549984e-06
## 55  6.549984e-06
## 56  6.549984e-06
## 57  6.549984e-06
## 58  6.549984e-06
## 59  6.549984e-06
## 60  6.549984e-06
## 61  6.549984e-06
## 62  5.919095e-06
## 63  5.026116e-08
## 64  2.156164e-08
## 65  1.375737e-08
## 66  2.156164e-08
## 67  5.097389e-08
## 68  1.375737e-08
## 69  2.156164e-08
## 70  1.375737e-08
## 71  2.156164e-08
## 72  2.156164e-08
## 73  2.156164e-08
## 74  3.789911e-07
## 75  2.156164e-08
## 76  2.156164e-08
## 77  2.156164e-08
## 78  2.156164e-08
## 79  2.156164e-08
## 80  2.156164e-08
## 81  2.156164e-08
## 82  2.156164e-08
## 83  2.156164e-08
## 84  2.156164e-08
## 85  2.156164e-08
## 86  2.156164e-08
## 87  2.156164e-08
## 88  2.156164e-08
## 89  7.129872e-06
## 90  3.228912e-07
## 91  2.647433e-07
## 92  2.647433e-07
## 93  7.024329e-08
## 94  5.363131e-08
## 95  7.024329e-08
## 96  7.024329e-08
## 97  7.024329e-08
## 98  2.919620e-07
## 99  4.197314e-08
## 100 2.919620e-07
## 101 4.229997e-08
## 102 4.777709e-07
## 103 7.042405e-08
## 104 4.777709e-07
## 105 7.042405e-08
## 106 9.598444e-07
## 107 1.727827e-07
## 108 1.243749e-07
## 109 3.082558e-06
## 110 1.243749e-07
## 111 1.243749e-07
## 112 1.349188e-06
## 113 2.069471e-06
## 114 2.330892e-07
## 115 1.146932e-06
## 116 2.185141e-06
## 117 2.069471e-06
## 118 2.069471e-06
## 119 2.069471e-06
## 120 1.146932e-06
## 121 1.146932e-06
## 122 1.146932e-06
## 123 1.146932e-06
## 124 1.146932e-06
## 125 1.146932e-06
## 126 1.627147e-08
## 127 5.580659e-07
## 128 5.580659e-07
## 129 5.580659e-07
## 130 5.580659e-07
## 131 5.580659e-07
## 132 5.580659e-07
## 133 5.580659e-07
## 134 5.580659e-07
## 135 5.580659e-07
## 136 1.634876e-07
## 137 2.941044e-08
## 138 2.941044e-08
## 139 2.692761e-08
## 140 8.422516e-07
## 141 7.311630e-07
## 142 3.427418e-08
## 143 7.311630e-07
## 144 7.311630e-07
## 145 3.466265e-08
## 146 7.311630e-07
## 147 7.311630e-07
## 148 5.949563e-07
## 149 4.769174e-08
## 150 5.949563e-07
## 151 1.673115e-07
## 152 4.643702e-07
## 153 1.136822e-07
## 154 3.027878e-06
## 155 3.027878e-06
## 156 3.027878e-06
## 157 3.027878e-06
## 158 3.027878e-06
## 159 3.027878e-06
## 160 3.027878e-06
## 161 3.027878e-06
## 162 3.027878e-06
## 163 3.027878e-06
## 164 1.819387e-07
## 165 3.763762e-06
## 166 3.763762e-06
## 167 3.763762e-06
## 168 3.763762e-06
## 169 3.763762e-06
## 170 3.763762e-06
## 171 3.763762e-06
## 172 3.763762e-06
## 173 3.763762e-06
## 174 3.763762e-06
## 175 3.763762e-06
## 176 4.828536e-08
## 177 4.828536e-08
## 178 4.828536e-08
## 179 4.828536e-08
## 180 4.828536e-08
## 181 4.828536e-08
## 182 4.828536e-08
## 183 8.816423e-08
## 184 8.816423e-08
## 185 8.816423e-08
## 186 5.462697e-07
## 187 2.443567e-06
## 188 1.354600e-07
## 189 2.443567e-06
## 190 7.375822e-06
## 191 7.375822e-06
## 192 2.443567e-06
## 193 7.375822e-06
## 194 7.375822e-06
## 195 2.443567e-06
## 196 2.443567e-06
## 197 2.443567e-06
## 198 2.443567e-06
## 199 2.443567e-06
## 200 2.443567e-06
## 201 2.443567e-06
## 202 2.443567e-06
## 203 2.443567e-06
## 204 2.443567e-06
## 205 7.375822e-06
## 206 7.375822e-06
## 207 7.375822e-06
## 208 7.375822e-06
## 209 7.375822e-06
## 210 1.133853e-07
## 211 1.133853e-07
## 212 1.133853e-07
## 213 1.133853e-07
## 214 1.133853e-07
## 215 9.103186e-06
## 216 1.188889e-07
## 217 1.188889e-07
## 218 6.335011e-06
## 219 1.196643e-07
## 220 1.929486e-06
## 221 3.269982e-06
## 222 3.086274e-06
## 223 1.463444e-07
## 224 6.577593e-08

6. PC3

pc3_wald_gwas <- association.test(merged_nies_210818, nies_heritable_pheno240918$coord.Dim.3, X = nies_covar, method="lm", test = "wald", response = "quantitative", K = merged_nies_GRM, eigenK = merged_nies_eiK, p = 2)
## Warning in trans.X(X, mean.y = mean(Y)): An intercept column was added to
## the covariate matrix X
pc3_wald_gwas <- na.omit(pc3_wald_gwas)
pc3_wfiltered <- pc3_wald_gwas %>% filter(-log10(p)>1) %>% filter(freqA2 < 0.99)
pc3_wmeff <- pc3_wfiltered %>% filter(p < 1.84e-7)
pc3_wsig <- do.call(rbind, lapply(split(pc3_wmeff,pc3_wmeff$chr), function(x) {return(x[which.min(x$p),])}))

pc3_wres <- NULL
for (i in pc3_wsig$id) {
  snpID <- i
  snpCHR <- pc3_wfiltered[pc3_wfiltered$id == snpID,]$chr
  snpPOS <- pc3_wfiltered[pc3_wfiltered$id ==snpID,]$pos
  
  sig.peak <- pc3_wfiltered %>%
    filter(chr == snpCHR) %>%
    filter(pos > snpPOS - 50000) %>%
    filter(pos < snpPOS + 50000) %>%
    filter(p < 1e-5)
  
  pc3_wres <- rbind(pc3_wres, sig.peak)
}

write.csv(pc3_wres, 'C:/Users/Martha/Documents/Honours/Project/honours.project/Data/gwas_filter_covar/pc3_wald_res.csv')
pc3_wres
##     chr       pos          id A1 A2    freqA2      beta        sd
## 1     1 205916566  rs72752923  C  A 0.9782609 -2.555298 0.4025047
## 2     1 205916729  rs16830364  G  A 0.9782609 -2.555298 0.4025047
## 3     1 205916931  rs60255052  C  T 0.9811594 -2.959985 0.4226675
## 4     1 205917041  rs60716530  C  T 0.9782609 -2.555298 0.4025047
## 5     1 205917115  rs60644810  G  A 0.9782609 -2.555298 0.4025047
## 6     1 205917248  rs35694044  A  T 0.9782609 -2.555298 0.4025047
## 7     1 205917652  rs16830370  T  C 0.9782609 -2.555298 0.4025047
## 8     1 205918853  rs16856462  C  T 0.9782609 -2.555298 0.4025047
## 9     1 205919195  rs16856468  G  A 0.9782609 -2.555298 0.4025047
## 10    1 205919303  rs60001177  T  C 0.9782609 -2.555298 0.4025047
## 11    1 205919401  rs12723666  A  G 0.9782609 -2.555298 0.4025047
## 12    1 205920201  rs16856470  T  C 0.9811594 -2.959985 0.4226675
## 13    1 205920404  rs16856473  A  G 0.9811594 -2.959985 0.4226675
## 14    1 205922403  rs68189466  G  A 0.9797101 -2.827531 0.4119262
## 15    1 205922720  rs35648260  G  T 0.9797101 -2.827531 0.4119262
## 16    1 205922775  rs35360452  G  T 0.9797101 -2.827531 0.4119262
## 17    1 205925474  rs12727528  A  G 0.9797101 -2.827531 0.4119262
## 18    1 205935183   rs1891309  G  A 0.9782609 -2.619719 0.4026668
## 19    1 205935330   rs1891310  T  G 0.9782609 -2.619719 0.4026668
## 20    1 205936240   rs1473537  T  C 0.9739130 -2.169598 0.3762565
## 21    1 205942026  rs72752928  T  C 0.9782609 -2.619719 0.4026668
## 22    1 205943691  rs66593238  T  C 0.9782609 -2.619719 0.4026668
## 23    1 205944627   rs9438407  T  G 0.9782609 -2.619719 0.4026668
## 24    1 205945388  rs12741299  T  C 0.9782609 -2.619719 0.4026668
## 25    1 205946647  rs34265780  T  C 0.9782609 -2.619719 0.4026668
## 26    2 131577086 rs151117086  T  C 0.9884058 -3.217951 0.5186455
## 27    3  42006157  rs71315517  G  C 0.9869565 -3.041892 0.5038856
## 28    4 119321195  rs77203710  A  G 0.9855072 -3.372387 0.4694447
## 29    4 119322197   rs1397614  T  C 0.9855072 -3.372387 0.4694447
## 30    4 119362510 rs112314510  A  G 0.9855072 -3.372387 0.4694447
## 31    4 119362552 rs111968273  T  A 0.9855072 -3.372387 0.4694447
## 32    4 119367677 rs113059419  A  G 0.9869565 -3.747963 0.4832128
## 33    4 119372303 rs112760591  G  A 0.9855072 -3.372387 0.4694447
## 34    4 119372480 rs111609258  C  G 0.9855072 -3.372387 0.4694447
## 35    4 119378224 rs147602981  G  A 0.9855072 -3.372387 0.4694447
## 36    4 119381167 rs143847948  A  C 0.9855072 -3.372387 0.4694447
## 37    4 119390257 rs113224532  T  C 0.9855072 -3.372387 0.4694447
## 38    4 119392279 rs117856633  C  A 0.9855072 -3.372387 0.4694447
## 39    4 119398681 rs113825627  C  G 0.9855072 -3.372387 0.4694447
## 40    4 119403429 rs112414671  A  G 0.9869565 -3.747963 0.4832128
## 41    4 119403485 rs185357281  A  G 0.9869565 -3.021618 0.5000945
## 42    4 119404439 rs183181597  A  G 0.9855072 -3.372387 0.4694447
## 43    4 119404927 rs113317707  C  A 0.9855072 -3.372387 0.4694447
## 44    4 119408454 rs184703141  T  C 0.9855072 -3.372387 0.4694447
## 45    5  25293191 rs138955515  A  G 0.9855072 -3.035716 0.4768751
## 46    5  25300269 rs140158697  C  T 0.9855072 -3.035716 0.4768751
## 47    5  25331088 rs114133913  T  A 0.9855072 -3.035716 0.4768751
## 48    6 121261079 rs116936384  G  C 0.9898551 -3.678807 0.6195338
## 49    7  65064421 rs187018641  T  A 0.9884058 -3.166156 0.5930444
## 50    8  80306741 rs111864836  G  T 0.9884058 -4.199841 0.5725396
## 51    8  80306859 rs113627660  G  C 0.9884058 -4.199841 0.5725396
## 52    8  80306990   rs7825643  G  T 0.9724638 -1.805367 0.3954829
## 53    8  80307293   rs7845792  A  G 0.9884058 -4.199841 0.5725396
## 54    8  80307388   rs7845575  G  A 0.9869565 -3.536816 0.5481756
## 55    8  80307700 rs114654811  C  T 0.9884058 -4.199841 0.5725396
## 56    8  80307701 rs115278078  A  T 0.9884058 -4.199841 0.5725396
## 57    8  80307837  rs79018076  T  C 0.9884058 -4.199841 0.5725396
## 58    8  80308098 rs112501384  G  C 0.9884058 -4.199841 0.5725396
## 59    8  80309142  rs60539023  G  A 0.9724638 -1.805367 0.3954829
## 60    8  80309305  rs11996376  A  G 0.9884058 -4.199841 0.5725396
## 61    8  80309598  rs79431653  C  G 0.9884058 -4.199841 0.5725396
## 62    8  80309626  rs11996450  T  C 0.9884058 -4.199841 0.5725396
## 63    8  80310193  rs60741023  C  G 0.9884058 -4.199841 0.5725396
## 64    8  80310485   rs7844286  C  T 0.9884058 -4.199841 0.5725396
## 65    8  80310716   rs7844696  A  T 0.9884058 -4.199841 0.5725396
## 66    8  80310720   rs7826434  G  A 0.9884058 -4.199841 0.5725396
## 67    8  80311242  rs80031189  C  T 0.9884058 -4.199841 0.5725396
## 68    8  80311252 rs113823684  A  G 0.9884058 -4.199841 0.5725396
## 69    8  80311311  rs61300312  A  C 0.9724638 -1.805367 0.3954829
## 70    8  80311329 rs142907856  A  G 0.9884058 -4.199841 0.5725396
## 71    8  80311457 rs112582272  A  G 0.9884058 -4.199841 0.5725396
## 72    8  80311580 rs116773209  G  A 0.9884058 -4.199841 0.5725396
## 73    8  80311736 rs113314270  G  T 0.9884058 -4.199841 0.5725396
## 74    8  80311746  rs73261635  G  A 0.9724638 -1.805367 0.3954829
## 75    8  80311838 rs117693425  A  G 0.9884058 -4.199841 0.5725396
## 76    8  80312291  rs11988873  C  T 0.9884058 -4.199841 0.5725396
## 77    8  80312345  rs11988904  A  T 0.9884058 -4.199841 0.5725396
## 78    8  80312623  rs36051398  A  C 0.9884058 -4.199841 0.5725396
## 79    8  80313237  rs73261640  G  A 0.9724638 -1.805367 0.3954829
## 80    8  80313751 rs114426401  T  C 0.9884058 -4.199841 0.5725396
## 81    8  80314228  rs74981396  G  A 0.9884058 -4.199841 0.5725396
## 82    8  80317028  rs11998344  T  G 0.9884058 -4.199841 0.5725396
## 83    8  80317208 rs113244900  C  T 0.9884058 -4.199841 0.5725396
## 84    8  80318583  rs57246091  A  G 0.9884058 -4.199841 0.5725396
## 85    8  80318643 rs113901603  G  A 0.9884058 -4.199841 0.5725396
## 86    8  80319691 rs113718590  A  G 0.9884058 -4.199841 0.5725396
## 87    8  80319794 rs111833373  C  T 0.9724638 -1.805367 0.3954829
## 88    8  80320713  rs11987997  A  G 0.9884058 -4.199841 0.5725396
## 89    8  80321002 rs111527437  T  A 0.9884058 -4.199841 0.5725396
## 90    8  80321694 rs112815920  G  C 0.9884058 -4.199841 0.5725396
## 91    8  80323890  rs11998156  C  A 0.9884058 -4.199841 0.5725396
## 92    8  80323964  rs16907573  G  A 0.9884058 -4.199841 0.5725396
## 93    8  80324156 rs111257240  C  T 0.9884058 -4.199841 0.5725396
## 94    8  80325047 rs113437388  T  C 0.9884058 -4.199841 0.5725396
## 95    8  80325311  rs73261674  G  C 0.9724638 -1.805367 0.3954829
## 96    8  80326033 rs111370206  G  A 0.9884058 -4.199841 0.5725396
## 97    8  80326181  rs73261679  A  C 0.9724638 -1.805367 0.3954829
## 98    8  80326935 rs147955676  A  G 0.9884058 -4.199841 0.5725396
## 99    8  80326985  rs61039050  A  C 0.9724638 -1.805367 0.3954829
## 100   8  80327347   rs7840954  C  T 0.9724638 -1.805367 0.3954829
## 101   8  80327348   rs7822886  A  G 0.9724638 -1.805367 0.3954829
## 102   8  80327442   rs7841095  C  T 0.9884058 -4.199841 0.5725396
## 103   8  80327549   rs7822828  C  A 0.9884058 -4.199841 0.5725396
## 104   8  80327674   rs7841418  C  T 0.9724638 -1.805367 0.3954829
## 105   8  80327732   rs7823481  C  G 0.9884058 -4.199841 0.5725396
## 106   8  80328450  rs11990649  A  G 0.9884058 -4.199841 0.5725396
## 107   8  80329801  rs56960849  A  G 0.9884058 -4.199841 0.5725396
## 108   8  80330197  rs11995624  C  T 0.9884058 -4.199841 0.5725396
## 109   8  80330467   rs7837761  A  G 0.9869565 -3.536816 0.5481756
## 110   8  80332180 rs113042618  T  C 0.9884058 -4.199841 0.5725396
## 111   8  80332423   rs7001142  G  T 0.9884058 -4.199841 0.5725396
## 112   8  80332520   rs6980915  G  A 0.9884058 -4.199841 0.5725396
## 113   8  80332901   rs6473220  T  C 0.9884058 -4.199841 0.5725396
## 114   8  80332907   rs6473221  A  G 0.9884058 -4.199841 0.5725396
## 115   8  80333316   rs7835862  C  T 0.9884058 -4.199841 0.5725396
## 116   8  80333340   rs7817696  A  G 0.9884058 -4.199841 0.5725396
## 117   8  80333506   rs7817634  T  C 0.9884058 -4.199841 0.5725396
## 118   8  80333599  rs57419267  C  T 0.9884058 -4.199841 0.5725396
## 119   8  80333823  rs59130219  C  T 0.9884058 -4.199841 0.5725396
## 120   8  80334098  rs73691385  T  A 0.9884058 -4.199841 0.5725396
## 121   8  80334328   rs7840559  C  T 0.9884058 -4.199841 0.5725396
## 122   8  80334334   rs7822177  G  A 0.9884058 -4.199841 0.5725396
## 123   8  80334582 rs111631456  A  G 0.9884058 -4.199841 0.5725396
## 124   8  80334982  rs58109903  T  C 0.9884058 -4.199841 0.5725396
## 125   8  80335583  rs73691388  G  A 0.9884058 -4.199841 0.5725396
## 126   8  80336124   rs7837108  T  C 0.9884058 -4.199841 0.5725396
## 127   8  80336300   rs7840857  T  G 0.9884058 -4.199841 0.5725396
## 128   8  80336310   rs7840861  T  G 0.9884058 -4.199841 0.5725396
## 129   8  80337292 rs111888115  T  C 0.9884058 -4.199841 0.5725396
## 130   8  80337308  rs56871558  T  C 0.9884058 -4.199841 0.5725396
## 131   8  80337408  rs56116331  A  G 0.9884058 -4.199841 0.5725396
## 132   8  80337443  rs58592997  T  C 0.9884058 -4.199841 0.5725396
## 133   8  80337629  rs76783901  A  G 0.9884058 -4.199841 0.5725396
## 134   8  80337634  rs74468856  G  A 0.9884058 -4.199841 0.5725396
## 135   8  80337985  rs73691394  C  A 0.9884058 -4.199841 0.5725396
## 136   8  80338076  rs73691395  T  C 0.9884058 -4.199841 0.5725396
## 137   8  80338219  rs73691397  C  G 0.9884058 -4.199841 0.5725396
## 138   8  80338255  rs73691398  G  A 0.9884058 -4.199841 0.5725396
## 139   8  80338835  rs58958046  A  G 0.9884058 -4.199841 0.5725396
## 140   8  80338910  rs58786240  C  T 0.9884058 -4.199841 0.5725396
## 141   8  80338955  rs76867788  C  T 0.9884058 -4.199841 0.5725396
## 142   8  80339017  rs73691399  T  C 0.9884058 -4.199841 0.5725396
## 143   8  80339217  rs73691400  C  G 0.9884058 -4.199841 0.5725396
## 144   8  80339959  rs61233095  C  A 0.9884058 -4.199841 0.5725396
## 145   8  80340238  rs56408864  A  T 0.9884058 -4.199841 0.5725396
## 146   8  80340749   rs7826667  A  G 0.9884058 -4.199841 0.5725396
## 147   8  80341236   rs7000592  G  C 0.9884058 -4.199841 0.5725396
## 148  10  25947431 rs144363867  G  A 0.9565217 -1.684966 0.3067035
## 149  12   5987972 rs142100550  T  G 0.9884058 -3.862914 0.5751795
## 150  14  82730166 rs139045884  A  G 0.9826087 -2.639915 0.4897466
## 151  14  82743030 rs117385547  C  T 0.9840580 -3.002400 0.5069886
## 152  16  63440590 rs141104955  G  C 0.9898551 -3.424795 0.6265245
## 153  18  48847895  rs11665050  A  G 0.9782609 -2.160804 0.4355790
## 154  18  48849360 rs141608868  C  G 0.9782609 -2.160804 0.4355790
## 155  18  48850433  rs78852912  C  G 0.9782609 -2.160804 0.4355790
## 156  18  48853167 rs151115377  A  G 0.9840580 -2.946344 0.5003625
## 157  18  48855955 rs143153469  A  G 0.9782609 -2.160804 0.4355790
## 158  18  48858545 rs117947063  G  A 0.9782609 -2.160804 0.4355790
## 159  19  54022720  rs12460863  G  A 0.9884058 -3.276104 0.5884045
## 160  19  54028461 rs117249591  G  A 0.9884058 -3.276104 0.5884045
## 161  20   2977131 rs145336914  G  C 0.9753623 -2.435610 0.4120601
## 162  20   2979974 rs141744903  G  A 0.9681159 -1.719531 0.3783060
## 163  20   2985515   rs6138975  C  T 0.9681159 -1.719531 0.3783060
## 164  20   2987464  rs74893620  A  G 0.9681159 -1.719531 0.3783060
## 165  20   2994423  rs60040561  T  G 0.9681159 -1.719531 0.3783060
## 166  20   2998407  rs78221943  G  A 0.9681159 -1.719531 0.3783060
## 167  20   3004167  rs58156936  C  A 0.9681159 -1.719531 0.3783060
## 168  20   3004208 rs146526220  A  G 0.9681159 -1.719531 0.3783060
## 169  20   3004309   rs6132999  T  C 0.9681159 -1.719531 0.3783060
## 170  20   3004313   rs6133000  T  C 0.9681159 -1.719531 0.3783060
## 171  20   3004887   rs3746692  A  C 0.9681159 -1.719531 0.3783060
## 172  20   3006691   rs6138976  T  G 0.9681159 -1.719531 0.3783060
## 173  20   3009458  rs75990124  T  G 0.9681159 -1.719531 0.3783060
## 174  20   3009687   rs6138979  A  G 0.9681159 -1.719531 0.3783060
## 175  20   3011439  rs16988201  T  C 0.9681159 -1.719531 0.3783060
## 176  20   3013926   rs6133003  G  A 0.9681159 -1.719531 0.3783060
## 177  22  44078144  rs11705487  T  C 0.9753623 -2.305982 0.4103061
## 178  22  44088452 rs147207731  A  G 0.9797101 -2.851280 0.4413914
##                p
## 1   7.001916e-10
## 2   7.001916e-10
## 3   1.357929e-11
## 4   7.001916e-10
## 5   7.001916e-10
## 6   7.001916e-10
## 7   7.001916e-10
## 8   7.001916e-10
## 9   7.001916e-10
## 10  7.001916e-10
## 11  7.001916e-10
## 12  1.357929e-11
## 13  1.357929e-11
## 14  3.209486e-11
## 15  3.209486e-11
## 16  3.209486e-11
## 17  3.209486e-11
## 18  2.783688e-10
## 19  2.783688e-10
## 20  1.829230e-08
## 21  2.783688e-10
## 22  2.783688e-10
## 23  2.783688e-10
## 24  2.783688e-10
## 25  2.783688e-10
## 26  1.603783e-09
## 27  4.135107e-09
## 28  4.356927e-12
## 29  4.356927e-12
## 30  4.356927e-12
## 31  4.356927e-12
## 32  1.041495e-13
## 33  4.356927e-12
## 34  4.356927e-12
## 35  4.356927e-12
## 36  4.356927e-12
## 37  4.356927e-12
## 38  4.356927e-12
## 39  4.356927e-12
## 40  1.041495e-13
## 41  4.016047e-09
## 42  4.356927e-12
## 43  4.356927e-12
## 44  4.356927e-12
## 45  6.329954e-10
## 46  6.329954e-10
## 47  6.329954e-10
## 48  7.161380e-09
## 49  1.720121e-07
## 50  1.651718e-12
## 51  1.651718e-12
## 52  7.004363e-06
## 53  1.651718e-12
## 54  3.825693e-10
## 55  1.651718e-12
## 56  1.651718e-12
## 57  1.651718e-12
## 58  1.651718e-12
## 59  7.004363e-06
## 60  1.651718e-12
## 61  1.651718e-12
## 62  1.651718e-12
## 63  1.651718e-12
## 64  1.651718e-12
## 65  1.651718e-12
## 66  1.651718e-12
## 67  1.651718e-12
## 68  1.651718e-12
## 69  7.004363e-06
## 70  1.651718e-12
## 71  1.651718e-12
## 72  1.651718e-12
## 73  1.651718e-12
## 74  7.004363e-06
## 75  1.651718e-12
## 76  1.651718e-12
## 77  1.651718e-12
## 78  1.651718e-12
## 79  7.004363e-06
## 80  1.651718e-12
## 81  1.651718e-12
## 82  1.651718e-12
## 83  1.651718e-12
## 84  1.651718e-12
## 85  1.651718e-12
## 86  1.651718e-12
## 87  7.004363e-06
## 88  1.651718e-12
## 89  1.651718e-12
## 90  1.651718e-12
## 91  1.651718e-12
## 92  1.651718e-12
## 93  1.651718e-12
## 94  1.651718e-12
## 95  7.004363e-06
## 96  1.651718e-12
## 97  7.004363e-06
## 98  1.651718e-12
## 99  7.004363e-06
## 100 7.004363e-06
## 101 7.004363e-06
## 102 1.651718e-12
## 103 1.651718e-12
## 104 7.004363e-06
## 105 1.651718e-12
## 106 1.651718e-12
## 107 1.651718e-12
## 108 1.651718e-12
## 109 3.825693e-10
## 110 1.651718e-12
## 111 1.651718e-12
## 112 1.651718e-12
## 113 1.651718e-12
## 114 1.651718e-12
## 115 1.651718e-12
## 116 1.651718e-12
## 117 1.651718e-12
## 118 1.651718e-12
## 119 1.651718e-12
## 120 1.651718e-12
## 121 1.651718e-12
## 122 1.651718e-12
## 123 1.651718e-12
## 124 1.651718e-12
## 125 1.651718e-12
## 126 1.651718e-12
## 127 1.651718e-12
## 128 1.651718e-12
## 129 1.651718e-12
## 130 1.651718e-12
## 131 1.651718e-12
## 132 1.651718e-12
## 133 1.651718e-12
## 134 1.651718e-12
## 135 1.651718e-12
## 136 1.651718e-12
## 137 1.651718e-12
## 138 1.651718e-12
## 139 1.651718e-12
## 140 1.651718e-12
## 141 1.651718e-12
## 142 1.651718e-12
## 143 1.651718e-12
## 144 1.651718e-12
## 145 1.651718e-12
## 146 1.651718e-12
## 147 1.651718e-12
## 148 7.752192e-08
## 149 7.922242e-11
## 150 1.322154e-07
## 151 7.822048e-09
## 152 8.939492e-08
## 153 1.114404e-06
## 154 1.114404e-06
## 155 1.114404e-06
## 156 9.409415e-09
## 157 1.114404e-06
## 158 1.114404e-06
## 159 5.265926e-08
## 160 5.265926e-08
## 161 8.320200e-09
## 162 7.648313e-06
## 163 7.648313e-06
## 164 7.648313e-06
## 165 7.648313e-06
## 166 7.648313e-06
## 167 7.648313e-06
## 168 7.648313e-06
## 169 7.648313e-06
## 170 7.648313e-06
## 171 7.648313e-06
## 172 7.648313e-06
## 173 7.648313e-06
## 174 7.648313e-06
## 175 7.648313e-06
## 176 7.648313e-06
## 177 3.995030e-08
## 178 3.654696e-10

7. PC4

pc4_wald_gwas <- association.test(merged_nies_210818, nies_heritable_pheno240918$coord.Dim.4, X = nies_covar, method="lm", test = "wald", response = "quantitative", K = merged_nies_GRM, eigenK = merged_nies_eiK, p = 2)
pc4_wald_gwas <- na.omit(pc4_wald_gwas)
pc4_wfiltered <- pc4_wald_gwas %>% filter(-log10(p)>1) %>% filter(freqA2 < 0.99)
pc4_wmeff <- pc4_wfiltered %>% filter(p < 1.84e-7)
pc4_wsig <- do.call(rbind, lapply(split(pc4_wmeff,pc4_wmeff$chr), function(x) {return(x[which.min(x$p),])}))

pc4_wres <- NULL
for (i in pc4_wsig$id) {
  snpID <- i
  snpCHR <- pc4_wfiltered[pc4_wfiltered$id == snpID,]$chr
  snpPOS <- pc4_wfiltered[pc4_wfiltered$id ==snpID,]$pos
  
  sig.peak <- pc4_wfiltered %>%
    filter(chr == snpCHR) %>%
    filter(pos > snpPOS - 50000) %>%
    filter(pos < snpPOS + 50000) %>%
    filter(p < 1e-5)
  
  pc4_wres <- rbind(pc4_wres, sig.peak)
}

write.csv(pc4_wfiltered, 'C:/Users/Martha/Documents/Honours/Project/honours.project/Data/gwas_filter_covar/pc4_wald_filter.csv')
pc4_wres
## NULL
manhattan(x = pc4_wfiltered, chr = "chr", bp = "pos", p = "p", snp = "id", ylim = c(0,12), genomewideline = -log10(1.84e-7), main = "Component 4")

8. PC8

pc8_wald_gwas <- association.test(merged_nies_210818, nies_heritable_pheno240918$coord.Dim.8, X = nies_covar, method="lm", test = "wald", response = "quantitative", K = merged_nies_GRM, eigenK = merged_nies_eiK, p = 2)
## Warning in trans.X(X, mean.y = mean(Y)): An intercept column was added to
## the covariate matrix X
pc8_wald_gwas <- na.omit(pc8_wald_gwas)
pc8_wfiltered <- pc8_wald_gwas %>% filter(-log10(p)>1) %>% filter(freqA2 < 0.99)
pc8_wmeff <- pc8_wfiltered %>% filter(p < 1.84e-7)
pc8_wsig <- do.call(rbind, lapply(split(pc8_wmeff,pc8_wmeff$chr), function(x) {return(x[which.min(x$p),])}))

pc8_wres <- NULL
for (i in pc8_wsig$id) {
  snpID <- i
  snpCHR <- pc8_wfiltered[pc8_wfiltered$id == snpID,]$chr
  snpPOS <- pc8_wfiltered[pc8_wfiltered$id ==snpID,]$pos
  
  sig.peak <- pc8_wfiltered %>%
    filter(chr == snpCHR) %>%
    filter(pos > snpPOS - 50000) %>%
    filter(pos < snpPOS + 50000) %>%
    filter(p < 1e-5)
  
  pc8_wres <- rbind(pc8_wres, sig.peak)
}

write.csv(pc8_wres, 'C:/Users/Martha/Documents/Honours/Project/honours.project/Data/gwas_filter_covar/pc8_wald_res.csv')
pc8_wres
##    chr       pos         id A1 A2    freqA2       beta         sd
## 1    2 147529465  rs1438873  T  C 0.5231884 -0.4168333 0.07894971
## 2    2 147529616  rs6710858  T  A 0.5231884 -0.4168333 0.07894971
## 3    2 147530296  rs6753791  C  G 0.5231884 -0.4168333 0.07894971
## 4    2 147530428 rs12469553  C  T 0.5927536  0.3747363 0.07965598
## 5    2 147531132  rs4145334  T  C 0.5927536  0.3747363 0.07965598
## 6    2 147531215  rs1347827  C  G 0.5231884 -0.4168333 0.07894971
## 7    2 147532048  rs4662523  A  T 0.5231884 -0.4168333 0.07894971
## 8    2 147532877  rs1438875  T  C 0.5231884 -0.4168333 0.07894971
## 9    2 147534397 rs12691757  G  A 0.5231884 -0.4168333 0.07894971
## 10   2 147534556 rs12691758  T  G 0.5231884 -0.4168333 0.07894971
## 11   2 147539904 rs11680551  C  T 0.5985507  0.3826837 0.07982540
## 12   2 147541431  rs4508547  A  T 0.5985507  0.3826837 0.07982540
## 13   2 147545563  rs1550320  C  A 0.5985507  0.3826837 0.07982540
## 14   2 147545749  rs1550319  T  C 0.5985507  0.3826837 0.07982540
## 15   2 147546686 rs13390421  A  G 0.5985507  0.3826837 0.07982540
## 16   2 147547000 rs13390757  A  G 0.5985507  0.3826837 0.07982540
## 17   2 147548196 rs17724539  C  T 0.5985507  0.3826837 0.07982540
## 18   2 147548936  rs6430197  C  T 0.5985507  0.3826837 0.07982540
## 19   2 147549509  rs7588634  G  A 0.5985507  0.3826837 0.07982540
## 20   2 147550185 rs17724612  G  A 0.5985507  0.3826837 0.07982540
## 21   2 147550211 rs17673675  C  T 0.5985507  0.3826837 0.07982540
## 22   2 147550250 rs17673688  G  A 0.5985507  0.3826837 0.07982540
## 23   2 147550602 rs10208724  G  A 0.5985507  0.3826837 0.07982540
## 24   2 147550839 rs10208983  G  A 0.5985507  0.3826837 0.07982540
## 25   2 147551751 rs11691040  C  T 0.5985507  0.3826837 0.07982540
## 26   2 147551802 rs11674017  G  A 0.5985507  0.3826837 0.07982540
## 27   2 147552307 rs10201767  A  T 0.5985507  0.3826837 0.07982540
## 28   2 147552592  rs7590223  C  T 0.5985507  0.3826837 0.07982540
## 29   2 147571339 rs13413754  C  A 0.5840580  0.4066055 0.08155988
## 30   2 147571830 rs13404881  C  T 0.5840580  0.4066055 0.08155988
## 31   2 147572239 rs12691759  G  A 0.5565217  0.4365917 0.07989172
## 32   2 147573800  rs4361065  A  G 0.5855072  0.4051134 0.08132119
## 33   2 147579262  rs1550316  C  T 0.5927536  0.4234348 0.08157517
## 34   2 147579526 rs11681804  A  C 0.5927536  0.4234348 0.08157517
## 35   2 147579844 rs12477396  G  A 0.5927536  0.4234348 0.08157517
## 36   2 147579987 rs12473660  C  T 0.5927536  0.4234348 0.08157517
## 37   2 147580536  rs2033825  A  G 0.5927536  0.4234348 0.08157517
## 38   9 108250136  rs1332299  C  T 0.7855072  0.4383475 0.09741950
## 39   9 108252016  rs7025969  G  C 0.7855072  0.4383475 0.09741950
## 40   9 108296877 rs10979308  A  T 0.8072464  0.5024661 0.09973708
## 41   9 108299426  rs1885973  T  A 0.7768116  0.5342126 0.09480874
## 42   9 108300235 rs10816656  G  A 0.7826087  0.5180805 0.09700395
## 43   9 108302318  rs1407849  T  A 0.8057971  0.4995299 0.09868402
## 44   9 108305442 rs16912866  G  A 0.7768116  0.5342126 0.09480874
## 45   9 108305644 rs16912868  G  A 0.7768116  0.5342126 0.09480874
## 46   9 108306203  rs1323384  A  C 0.8086957  0.4986394 0.09989172
## 47   9 108307394  rs7030371  G  A 0.7768116  0.5342126 0.09480874
##               p
## 1  2.319963e-07
## 2  2.319963e-07
## 3  2.319963e-07
## 4  3.716545e-06
## 5  3.716545e-06
## 6  2.319963e-07
## 7  2.319963e-07
## 8  2.319963e-07
## 9  2.319963e-07
## 10 2.319963e-07
## 11 2.453938e-06
## 12 2.453938e-06
## 13 2.453938e-06
## 14 2.453938e-06
## 15 2.453938e-06
## 16 2.453938e-06
## 17 2.453938e-06
## 18 2.453938e-06
## 19 2.453938e-06
## 20 2.453938e-06
## 21 2.453938e-06
## 22 2.453938e-06
## 23 2.453938e-06
## 24 2.453938e-06
## 25 2.453938e-06
## 26 2.453938e-06
## 27 2.453938e-06
## 28 2.453938e-06
## 29 9.901037e-07
## 30 9.901037e-07
## 31 9.011323e-08
## 32 1.007980e-06
## 33 3.622683e-07
## 34 3.622683e-07
## 35 3.622683e-07
## 36 3.622683e-07
## 37 3.622683e-07
## 38 9.377780e-06
## 39 9.377780e-06
## 40 7.678797e-07
## 41 3.699907e-08
## 42 1.702717e-07
## 43 6.832079e-07
## 44 3.699907e-08
## 45 3.699907e-08
## 46 9.598554e-07
## 47 3.699907e-08

Although most of these beta values are more sensible, the UVAF values are still significantly inflated. This indicates that there may be other confounders affecting results, other than population structure, age, and sex as these have been accounted for in the model. Some options to determine the cause of this artificial inflation may include, adding more components to the model, removing low frequency variants, or performing these association tests using a different tool.