| tags: [ Genomic Data Gaston ] categories: [Coding Experiments ]
Trying gaston to generate genetic relationship matrix
require(gaston)
Introduction
Gaston is an R package that allows for manipulation and analysis of SNP data. For this project, it will be used to estimate heritability of the phenotypes and perform the pedigree-based linear mixed model GWAS (https://cran.r-project.org/web/packages/gaston/vignettes/gaston.pdf).
Methods and Results
1. Re-filter the SNP data.
In the previous entry, I manually subsetted data for individuals before merging the data sets such that PLINK does not have to handle duplicate samples. In summary, I removed the SNP-array data for individuals with WGS. There are still 361 individuals (73 with WGS; 288 with SNP-array).
Since GLMNet does not handle missing data, we chose to apply a missing genotyping filter of 0% missing per SNV (no missing data).
plink1.9 --bfile plink_output/merged_nies_hwefilter --mind 0.05 --geno 0 --make-bed --out merged_nies_filtered
Output:
9,146,242 variants and 361 individuals loaded
2 individuals removed
5,236,165 variants removed
359 individuals and 3,910,077 variants pass QC and filters
This data set will be entered into Gaston for generating genetic relationship matrix (GRM), estimating heritability, and performing the pedigree-based GWAS.
2. Check allele frequency distribution of this final data set
plink1.9 --bfile merged_nies_filtered -freq --out plink_output/merged_nies_final_freq
merged_nies_final_freq <- read.table('C:/Users/Martha/Documents/Honours/Project/honours.project/Data/plink_output/merged_nies_final_freq.frq', header = T)
hist(merged_nies_final_freq$MAF, main = "Allele Frequency Distributions of NIES genomic data", xlab = "Minor Allele Frequency", xlim = c(0.0, 0.5), col = "skyblue1")
3. Perform PCA on filtered data set
plink1.9 --bfile merged_nies_filtered --pca 180 var-wts --out plink_output/merged_nies_pca
4. Load eigenvalue file
merged_nies_eigenval <- read.table('C:/Users/Martha/Documents/Honours/Project/honours.project/Data/plink_output/merged_nies_pca.eigenval', header = F)
head(merged_nies_eigenval)
## V1
## 1 5.76593
## 2 4.66469
## 3 4.47463
## 4 4.21418
## 5 3.89408
## 6 3.59091
There are 116 PCs with eigenvalue >1.
5. Generate screeplot
barplot(merged_nies_eigenval$V1,
names.arg = 1:nrow(merged_nies_eigenval),
main = "NIES PCA Eigenvalue",
xlab = "Principal Components",
ylab = "Eigenvalue",
col ="lightskyblue2")
lines(x = 1:nrow(merged_nies_eigenval), merged_nies_eigenval$V1,
type = "b", pch = 19, col = "red")
6. Load eigenvector files
merged_nies_eigenvec <- read.table('C:/Users/Martha/Documents/Honours/Project/honours.project/Data/plink_output/merged_nies_pca.eigenvec', header = F)
head(merged_nies_eigenvec)
## V1 V2 V3 V4 V5 V6 V7
## 1 1 110150 0.0589467 -8.75477e-04 -0.02239540 0.011630000 -0.00446339
## 2 1 110160 0.0630933 -6.06496e-05 -0.02845090 0.000941576 -0.00266674
## 3 1 110500 -0.0590490 1.85539e-02 0.00354376 -0.018948600 0.02745420
## 4 1 110650 -0.1204940 3.44369e-02 0.00411882 0.110179000 -0.06427270
## 5 1 110820 -0.0114585 3.15638e-03 -0.00365303 0.030081900 0.01194950
## 6 1 111280 0.0676306 -2.37883e-04 -0.02430370 0.010551900 -0.01317740
## V8 V9 V10 V11 V12 V13
## 1 0.01652320 -0.01062430 0.006164140 -0.0101151 0.01203500 0.00166448
## 2 0.02925790 -0.01885220 0.007859530 -0.0479928 -0.01318040 0.02782950
## 3 0.00658647 -0.01480050 0.010809400 -0.0980730 -0.02284710 0.04798120
## 4 -0.03866080 0.03499620 -0.006655810 0.0499171 0.00393245 -0.00698922
## 5 0.02959080 0.00938257 -0.000533828 -0.0144718 0.06723630 -0.03078730
## 6 0.03175020 -0.00755970 0.004344620 -0.0133364 0.00738583 -0.00370461
## V14 V15 V16 V17 V18 V19
## 1 0.00126558 -0.008962510 0.00598374 -0.00137634 0.00455659 0.0184699
## 2 -0.03912530 -0.005327640 -0.00784928 -0.05500860 0.02858860 0.1129630
## 3 -0.03341740 0.000983514 -0.01496270 0.03868470 -0.00220041 0.0892056
## 4 -0.00466462 0.011230400 0.00628265 -0.05751430 0.02797210 0.0267896
## 5 0.03264530 -0.008751850 0.04248090 0.12498200 0.03559850 -0.0178627
## 6 0.00176824 -0.008924150 0.01920700 -0.01492780 0.01740460 0.0135851
## V20 V21 V22 V23 V24 V25
## 1 -0.00171067 0.01542700 -0.0144975 -3.35676e-03 0.000728472 -0.00427197
## 2 -0.01195010 -0.12347700 -0.0130687 2.96403e-03 -0.001943390 -0.01937610
## 3 0.00936671 0.00849875 0.1345610 4.54932e-02 -0.001483280 0.04648680
## 4 -0.00419117 -0.00329635 0.0149048 4.80046e-03 0.017135400 -0.01046060
## 5 -0.05799860 -0.06769530 -0.0145805 -6.42205e-05 -0.036783300 -0.00377962
## 6 0.00434048 0.01019820 -0.0126306 -1.19097e-03 -0.002636720 0.01352270
## V26 V27 V28 V29 V30
## 1 0.01355910 0.00804555 0.00827498 -0.00416186 0.004529590
## 2 -0.02226850 -0.01989330 0.00739973 -0.01614170 -0.036153600
## 3 -0.03884530 -0.04697480 -0.04356600 0.14768000 0.049333600
## 4 -0.01233010 0.02142380 0.01870980 -0.00694316 -0.000436555
## 5 0.00187302 0.03033550 0.06003480 0.10391700 0.004908620
## 6 0.04121570 0.00846220 0.03088760 -0.02406410 0.025757500
## V31 V32 V33 V34 V35 V36
## 1 -4.26630e-04 0.0161607 -0.00348807 -0.00293219 0.01433580 0.000176975
## 2 -1.18131e-02 -0.0270243 0.01541240 -0.03121210 -0.01527210 0.002112730
## 3 1.26245e-01 0.2006470 -0.12380200 0.20890600 0.00767486 0.103625000
## 4 -4.67718e-02 -0.0037876 0.05177640 0.01788190 0.00682486 -0.012790600
## 5 -5.68622e-02 -0.0547498 0.03996180 0.01924570 -0.00955590 0.017652000
## 6 4.44715e-05 0.0499910 -0.04589930 0.01402660 0.02453760 -0.010332600
## V37 V38 V39 V40 V41 V42
## 1 0.00570399 0.00962233 0.018501700 0.01473480 0.00911845 -0.02144770
## 2 0.01067520 -0.02337590 0.002260830 0.02091360 -0.00548545 -0.00328948
## 3 0.11803400 -0.06520700 -0.066523800 0.08391030 -0.02044670 0.02263410
## 4 0.08005870 0.03012560 0.000264145 0.00369207 0.00264651 -0.01811800
## 5 -0.02960330 0.01393150 -0.030356200 0.02628550 0.03752720 -0.00809427
## 6 -0.05347920 0.03476800 -0.025400200 0.03346930 -0.06301130 -0.11356900
## V43 V44 V45 V46 V47 V48
## 1 -0.01833420 0.0298067 0.000987215 -0.00156155 -0.00687218 0.01220970
## 2 -0.01276070 -0.0194769 0.006328620 -0.00485582 -0.01490440 -0.02014150
## 3 -0.00621866 0.0763932 0.067647200 -0.06762160 -0.02094400 0.00876969
## 4 -0.02826070 -0.0346261 0.015720900 0.01145530 -0.00171528 0.04200630
## 5 0.00121108 -0.0248832 0.026977800 -0.00799401 0.01003530 0.00609704
## 6 0.00773227 -0.0154565 -0.067094000 -0.14366500 -0.60464200 0.36435100
## V49 V50 V51 V52 V53 V54
## 1 -0.015154100 -0.01243880 0.00879049 0.00619351 0.00985860 0.01621890
## 2 0.000725686 -0.00815864 -0.01862910 -0.00714862 0.00672019 -0.00169911
## 3 -0.055554000 -0.05436950 -0.02826800 -0.02439650 -0.03975600 -0.01574240
## 4 0.004263100 0.01423810 0.01546860 0.06110500 0.10122600 0.02088090
## 5 -0.061800800 0.03318640 0.02906940 -0.04794020 0.01188930 0.02324840
## 6 0.048171800 0.29270700 0.37664500 0.20402100 -0.25426600 -0.08920100
## V55 V56 V57 V58 V59 V60
## 1 -0.0179855 0.0100564 -0.01245030 0.0106414 -1.55285e-04 0.00499858
## 2 0.0108328 0.0339722 0.00615317 -0.0234206 4.63828e-04 0.03108680
## 3 -0.0176024 -0.0223306 0.03280030 0.0168819 -2.48811e-02 0.01848250
## 4 -0.0134469 -0.0324929 0.07524070 -0.0127306 1.29098e-01 -0.10621600
## 5 0.0293657 0.0620289 -0.04024050 -0.0154988 1.30442e-06 -0.01118860
## 6 -0.0904355 0.0176160 -0.05240700 0.0642813 -7.18852e-02 -0.19718600
## V61 V62 V63 V64 V65 V66
## 1 0.01115510 -0.01444050 0.0115646 -0.00218601 -0.01487300 -0.00166796
## 2 0.00146458 0.05309400 0.0384528 -0.01289740 -0.01722160 0.02418550
## 3 -0.02911390 -0.01737520 0.0298157 0.00784034 0.00446593 0.02024900
## 4 -0.00276366 0.00232741 -0.0454118 -0.00186605 0.14836100 0.11193100
## 5 0.01657940 0.00989671 -0.0271948 -0.02747970 -0.06204820 0.04541640
## 6 -0.03010710 0.06071550 -0.0429288 0.02219800 0.03913570 -0.04445350
## V67 V68 V69 V70 V71 V72
## 1 -0.00493521 -0.02549290 -0.00899416 -0.00648844 -0.007331280 0.00937977
## 2 -0.03260960 -0.06514790 -0.00273753 -0.05847170 -0.080691400 0.13095400
## 3 0.01942920 -0.03499140 0.02221300 -0.01291010 0.019114700 -0.02142200
## 4 -0.05229150 -0.16135200 -0.05094340 -0.02461980 -0.075945200 0.01380950
## 5 -0.03820280 0.03735240 0.02964820 -0.03438620 -0.000227141 -0.04695380
## 6 0.02606350 -0.00640613 -0.02302220 0.01576580 -0.017009300 -0.01841170
## V73 V74 V75 V76 V77 V78
## 1 -0.00773726 -0.00941854 -0.01767510 0.02088780 0.00116963 -0.01536270
## 2 0.01444120 0.07994720 -0.12546200 -0.06043890 0.01040170 0.04630530
## 3 -0.02547030 0.01713160 -0.01591700 -0.02941740 0.00483561 -0.01028990
## 4 0.05526400 0.04456600 0.01673210 0.03870600 0.00384774 -0.02440060
## 5 0.07993220 -0.03294970 -0.00956522 -0.00771704 0.03801400 0.00986381
## 6 0.03772950 -0.00306976 -0.02288260 -0.03513110 -0.02391450 0.01720470
## V79 V80 V81 V82 V83 V84
## 1 -0.00299167 -0.0194361 0.01598150 0.000864562 -0.0181468 0.00446740
## 2 -0.06368520 0.0383434 -0.03014280 -0.003438960 0.0248572 0.00400366
## 3 0.05380230 -0.0356980 -0.00223894 0.018875200 -0.0253184 0.03057380
## 4 0.07955770 -0.0800217 0.11066000 0.014719600 -0.0931714 0.06882340
## 5 -0.01660540 -0.0725649 -0.11222500 0.142319000 -0.1252370 0.15215700
## 6 -0.00946755 0.0364890 -0.00514297 0.003298680 0.0283977 0.00431752
## V85 V86 V87 V88 V89 V90
## 1 -0.01289470 0.01142200 -0.01805600 0.00580319 0.02199500 -0.02394140
## 2 0.02700790 0.00991711 -0.04058380 -0.05023470 -0.01643940 -0.04141480
## 3 -0.01559320 -0.01851730 0.00689590 0.03833470 -0.01026490 0.02098990
## 4 0.08110020 -0.02479620 -0.04222840 -0.03727320 0.03118050 -0.02145530
## 5 -0.00629977 -0.06553180 -0.03385070 0.11505800 -0.08190610 0.08031060
## 6 0.00672799 0.02338550 -0.00948156 -0.00654986 -0.00441948 0.00590629
## V91 V92 V93 V94 V95 V96
## 1 -0.03731440 0.00900841 -0.00561013 -0.0128886 0.05364630 -0.01498190
## 2 0.03998680 0.06964990 -0.06699350 -0.0409537 -0.04042330 0.05456320
## 3 -0.00960275 -0.02086650 -0.00407492 -0.0178235 0.01869100 0.00431680
## 4 -0.10161200 -0.05203960 0.06572370 0.0302511 0.00800936 0.00559744
## 5 0.10719400 -0.02762060 -0.15913000 -0.0480193 0.09665990 -0.00562502
## 6 0.01977220 0.01035040 -0.00844279 -0.0179225 -0.00298542 -0.00341662
## V97 V98 V99 V100 V101 V102
## 1 0.00929608 0.01621390 0.02224820 0.03638790 0.03835890 -0.01592360
## 2 0.03247480 0.08273890 -0.03439590 0.01696910 0.05951150 0.02022830
## 3 0.01510120 -0.03038040 0.01966080 -0.00368429 -0.01601920 -0.00977669
## 4 -0.02787650 -0.02926860 0.02853930 0.00190991 -0.00168102 0.07942600
## 5 0.07583570 0.11393400 0.04187290 -0.03385090 -0.22757900 -0.01408400
## 6 0.00158611 -0.00205935 -0.00107714 -0.02480470 -0.01647210 -0.01389630
## V103 V104 V105 V106 V107 V108
## 1 -0.0709797 -0.11571200 -0.02552060 0.14439300 0.00576447 -0.01093070
## 2 0.0430267 -0.01671450 0.00895643 0.00569741 -0.03440690 0.00269152
## 3 0.0283567 -0.00256400 0.01934860 -0.03310160 0.01250000 -0.04113450
## 4 -0.0202584 0.02736280 0.07916150 0.01777440 0.01210800 -0.01757980
## 5 -0.0825804 -0.00639613 0.13109900 0.07262150 -0.02259710 0.04625710
## 6 0.0231165 -0.00478870 0.00378914 -0.03117100 0.02707670 0.01359800
## V109 V110 V111 V112 V113
## 1 -0.07633590 -0.04046120 -0.02575730 0.003195280 0.12367600
## 2 0.01258190 -0.06828900 0.01494880 0.046861100 -0.02160030
## 3 0.02157430 0.03129010 0.01261370 -0.000863861 -0.00709363
## 4 0.03845160 0.00551700 -0.04843010 -0.050813600 -0.02657820
## 5 -0.07421100 0.00592317 0.01995720 -0.087822300 -0.08176300
## 6 0.00432956 0.01178630 0.00217481 -0.006437040 -0.00956196
## V114 V115 V116 V117 V118 V119
## 1 0.112338000 -0.078012900 0.15514200 -0.0367916 0.21210100 -0.21727700
## 2 0.000953629 0.105998000 0.00941520 -0.0449914 0.00549195 0.01406440
## 3 -0.001630040 -0.000874683 0.01787950 0.0193293 0.06542150 -0.02830210
## 4 -0.019458700 0.004241160 -0.05141400 0.0722224 0.04351910 0.00562061
## 5 0.042890300 0.035227500 -0.02197880 -0.0329143 0.02605530 0.02351080
## 6 0.008859760 -0.002955760 0.00512574 0.0102950 -0.01486860 -0.00461027
## V120 V121 V122 V123 V124 V125
## 1 0.38699300 -0.04623270 0.01729270 -0.00181961 0.160022000 0.32635100
## 2 0.05920540 0.07551680 -0.04552250 -0.05265830 -0.056153100 -0.02347580
## 3 0.00466378 0.02415160 0.01026850 -0.06291170 0.001957850 -0.02927380
## 4 -0.02276570 0.03489970 0.02088480 0.01699550 0.021085300 0.03755880
## 5 0.03357260 -0.01795730 0.03429910 0.03864910 -0.023216500 0.05386200
## 6 -0.00772873 -0.00530803 -0.00443257 0.00608943 -0.000475472 -0.00690531
## V126 V127 V128 V129 V130 V131
## 1 0.349473000 -0.07290130 0.17489100 0.11776200 0.01021720 0.01581120
## 2 -0.014398800 -0.01823590 -0.02731020 0.01270940 -0.03907020 0.00378668
## 3 -0.012727900 -0.01144760 0.01273460 -0.01542490 0.00815200 0.02661030
## 4 -0.000318816 -0.02907820 -0.01881430 0.02578490 -0.09907310 -0.00666158
## 5 -0.042775600 -0.02097760 -0.01802300 -0.01170760 -0.03107880 -0.02005210
## 6 0.004686740 0.00727006 0.00265084 -0.00370603 0.00231812 0.00359954
## V132 V133 V134 V135 V136 V137
## 1 0.03445470 -0.17411800 0.03567230 -0.25196200 -0.18306000 0.11310900
## 2 0.00168500 -0.01863870 -0.02424360 0.03583810 0.02571650 0.07506360
## 3 -0.00345200 -0.02947180 0.01718600 0.01024490 0.03119760 0.04352050
## 4 0.00337775 -0.01300430 0.06269380 0.00318891 0.01748450 -0.00507515
## 5 0.00794688 0.04080040 0.00986181 -0.00948019 0.02548200 -0.00366914
## 6 -0.00193835 0.00960114 -0.00820553 -0.00639843 0.00235273 0.01125620
## V138 V139 V140 V141 V142 V143
## 1 0.03018670 -0.023296400 0.04301310 -0.09480090 0.04399800 0.01639120
## 2 -0.03186400 0.021842100 0.01777500 -0.00161466 0.02455900 -0.06561430
## 3 0.01000370 -0.005190230 0.00648526 0.01388940 0.00560739 -0.01873380
## 4 -0.01108810 0.052133000 0.01069780 -0.02247100 0.00976418 -0.00158226
## 5 0.01190420 0.000184346 -0.02822690 -0.02535240 0.02159280 0.00731288
## 6 0.00714551 -0.009634980 0.00539325 -0.00484187 -0.01142750 0.00285809
## V144 V145 V146 V147 V148
## 1 -0.08563650 -0.107228000 0.15406800 -0.03148810 -0.09216150
## 2 0.02938980 -0.058275300 0.04328980 0.04570890 0.01794260
## 3 0.04284470 0.001933080 -0.01120640 0.03008830 -0.01635970
## 4 0.01389250 0.000705828 -0.00923344 -0.04890490 -0.00401916
## 5 0.04018530 -0.027360600 0.01640270 -0.00376478 0.01771260
## 6 -0.00501583 0.003739230 -0.01460930 -0.01173710 0.00128129
## V149 V150 V151 V152 V153 V154
## 1 9.60356e-02 0.03910820 0.0479366 -0.15232000 -0.078465500 0.00729046
## 2 -8.60984e-02 -0.14227500 -0.0435035 0.06136790 0.069668900 0.18166400
## 3 -8.60475e-03 0.01719180 0.0118971 0.04113510 0.000883443 -0.00618846
## 4 -3.47958e-03 -0.06842200 -0.0261922 -0.04561700 0.018574800 0.01371290
## 5 1.85095e-04 0.00521006 0.0121822 0.00999297 0.041675000 0.01129440
## 6 3.30225e-05 -0.01159940 -0.0033066 0.00944173 0.005998840 -0.00896851
## V155 V156 V157 V158 V159 V160
## 1 -0.04732430 0.03523190 -0.10953700 0.07420140 0.01607450 0.01430480
## 2 0.03350730 -0.10456200 -0.05472440 0.08417950 0.12772300 -0.00416176
## 3 -0.00665522 0.03963680 -0.01317680 0.00614684 0.00882357 0.00536904
## 4 -0.05149720 0.01133530 -0.00326855 -0.03747390 -0.06011580 -0.02051250
## 5 -0.01648170 0.02918670 -0.02028460 0.02562140 0.00487212 0.00409429
## 6 -0.00582000 -0.00677328 0.00373055 0.00267339 0.00879544 -0.00642719
## V161 V162 V163 V164 V165 V166
## 1 -0.0278015 0.00403856 0.00531826 -0.01140840 0.03367980 0.04991770
## 2 0.0184757 -0.01682160 -0.05878650 0.01725450 -0.03592310 0.11769900
## 3 0.0151284 -0.02019030 0.00334550 0.01853420 -0.00401535 -0.03339510
## 4 0.0233604 0.03862010 -0.04207160 -0.01171660 -0.00689034 -0.00143045
## 5 0.0129426 -0.02169120 -0.00321022 -0.02370330 -0.00557247 0.00265787
## 6 -0.0059354 0.00224601 -0.00152022 0.00847711 0.00870464 0.00780844
## V167 V168 V169 V170 V171 V172
## 1 -0.01760940 0.00961379 0.001985850 -0.03372050 -0.09473020 0.00511538
## 2 -0.10830900 -0.07670010 0.040787400 0.09972870 0.03568950 0.02024080
## 3 0.00698243 -0.00112616 -0.022666200 -0.02865370 -0.00383540 0.04309770
## 4 -0.03832280 0.05278350 -0.026355400 0.01766480 -0.01785260 0.04580620
## 5 0.01482320 0.01737950 -0.011456100 -0.02243630 0.01492530 0.01728920
## 6 0.00408335 0.00174240 -0.000747272 0.00247075 -0.00631177 -0.00455355
## V173 V174 V175 V176 V177 V178
## 1 -0.006647940 -0.06004850 0.03281990 -0.0179610 -0.04477090 -0.00910452
## 2 -0.107322000 0.11337600 0.02111610 0.1424270 -0.20204600 -0.05994550
## 3 -0.004438730 0.03167530 -0.00795701 0.0283691 -0.00558279 -0.01918230
## 4 0.038660200 -0.01903990 0.01790210 0.0377134 -0.02738700 -0.03045680
## 5 0.015132200 0.00686495 -0.01913900 -0.0208588 0.02514090 0.02141340
## 6 0.000949717 0.00238564 -0.00745173 -0.0041987 -0.00163764 -0.00188696
## V179 V180 V181 V182
## 1 -0.01040800 -0.05245650 -0.00606280 -4.00193e-02
## 2 -0.08078110 -0.35421900 -0.29752800 1.62800e-01
## 3 0.01654460 -0.00352491 0.01111330 1.34426e-02
## 4 -0.01752540 -0.01369800 -0.00527637 7.30360e-03
## 5 0.00815394 0.00822977 0.01513980 2.45535e-05
## 6 -0.01388720 -0.00103436 -0.00288065 3.23107e-03
7. Generate PCA plots
plot(merged_nies_eigenvec$V3, merged_nies_eigenvec$V4, xlab = "PC1", ylab = "PC2", main = "PC1 vs PC2 eigenvectors") #PC1 vs PC2
plot(merged_nies_eigenvec$V4, merged_nies_eigenvec$V5, xlab = "PC2", ylab = "PC3", main = "PC2 vs PC3 eigenvectors") #PC2 vs PC3
plot(merged_nies_eigenvec$V4, merged_nies_eigenvec$V6, xlab = "PC2", ylab = "PC4", main = "PC2 vs PC4 eigenvectors") #PC2 vs PC4
plot(merged_nies_eigenvec$V5, merged_nies_eigenvec$V6, xlab = "PC3", ylab = "PC4", main = "PC3 vs PC4 eigenvectors") #PC3 vs PC4
These PCA plots have changed after excluding duplicate samples. However, there appears to be one individual that is an outlier ?
8. Load “gaston” package
require(gaston)
9. Load merged_nies_filtered files
merged_nies <- read.bed.matrix("C:/Users/Martha/Documents/Honours/Project/honours.project/Data/merged_nies/merged_nies_filtered.bed")
## Reading C:/Users/Martha/Documents/Honours/Project/honours.project/Data/merged_nies/merged_nies_filtered.fam
## Reading C:/Users/Martha/Documents/Honours/Project/honours.project/Data/merged_nies/merged_nies_filtered.bim
## Reading C:/Users/Martha/Documents/Honours/Project/honours.project/Data/merged_nies/merged_nies_filtered.bed
## ped stats and snps stats have been set.
## 'p' has been set.
## 'mu' and 'sigma' have been set.
10. Generate genetic relationship matrix (kinship matrix/GRM)
merged_nies_GRM <- GRM(merged_nies)
head(merged_nies_GRM)
## 110150 110160 110500 110650 110820
## 110150 0.977154136 0.01831282 -0.016187528 -0.029204521 0.002743251
## 110160 0.018312816 0.90508360 -0.016804561 -0.040735368 -0.011914639
## 110500 -0.016187528 -0.01680456 0.946581721 0.004033460 -0.003755704
## 110650 -0.029204521 -0.04073537 0.004033460 0.820495605 -0.003417064
## 110820 0.002743251 -0.01191464 -0.003755704 -0.003417064 0.839923978
## 111280 0.027842626 0.01132849 -0.020756746 -0.030984566 -0.010407919
## 111280 111440 111460 111750 111770
## 110150 0.02784263 -0.014135579 -0.022691507 0.031414349 0.013674585
## 110160 0.01132849 -0.019051932 -0.033589736 0.033953477 0.012714203
## 110500 -0.02075675 0.018513432 0.025560116 -0.008117734 -0.024166144
## 110650 -0.03098457 -0.004477389 0.005999879 -0.039252020 -0.026501579
## 110820 -0.01040792 -0.010232272 -0.007388396 -0.004608844 -0.002295749
## 111280 1.65637732 -0.018072939 -0.023818713 0.021109378 0.014821051
## 111830 124230 124250 124480 124550
## 110150 0.023737585 0.0102182496 -0.001082547 -0.0117469104 -0.002446266
## 110160 0.021720216 0.0008482425 -0.006926686 -0.0123960096 -0.009739782
## 110500 -0.016962767 -0.0071935235 0.031066267 -0.0106151337 -0.005837332
## 110650 -0.044965897 -0.0058077318 -0.017021574 0.0062339129 -0.020828553
## 110820 -0.004433294 -0.0097562093 0.007771998 0.0052674725 -0.015560418
## 111280 0.028480748 0.0044461181 -0.000504423 -0.0006393922 -0.006867119
## 124670 124720 124820 125270 125580
## 110150 -0.0124035776 -0.009157396 0.02546348 -0.006834933 -0.013527735
## 110160 -0.0107643288 -0.004823131 0.02080608 -0.015239348 -0.017053200
## 110500 0.2790596187 0.002550159 -0.02099631 0.004157585 0.006791867
## 110650 -0.0007603313 -0.005740339 -0.03660205 0.005559403 0.014560117
## 110820 -0.0223483983 0.002362015 -0.00201274 -0.007243009 -0.016314125
## 111280 -0.0190399643 -0.022423225 0.01658027 -0.009700268 -0.013632444
## 136110 168180 168230 168420 168600
## 110150 0.001987464 0.0045867660 -0.042496186 -0.009503459 0.006322194
## 110160 -0.008225115 -0.0066113565 -0.049511909 -0.020469867 -0.014806999
## 110500 -0.012128055 -0.0007886803 0.010773757 0.006968840 -0.001030997
## 110650 -0.017982919 0.0197421852 0.038223945 0.023401869 0.086542249
## 110820 0.001692195 -0.0150090996 0.008901604 -0.006402422 0.007869485
## 111280 -0.005145262 -0.0095552281 -0.049306046 -0.021198148 -0.018460955
## 168830 168860 169070 169270 169600
## 110150 -0.00490006 -0.0073945024 -0.003225017 -8.599035e-05 -0.0022101775
## 110160 -0.01184687 -0.0117904553 0.194591552 -8.512650e-03 0.0008582732
## 110500 -0.02280041 -0.0004801017 0.036087561 -1.563584e-02 -0.0053465171
## 110650 0.01235818 -0.0196983702 0.016329620 -2.235137e-02 -0.0087288581
## 110820 -0.01308947 -0.0080641368 -0.017007489 -8.219382e-03 -0.0003114732
## 111280 -0.01582675 -0.0063626575 -0.013366225 2.854440e-03 0.0031396549
## 169670 201009 210660 211340 211720
## 110150 -0.028867476 -0.0002726081 0.010491225 -0.040643107 0.001369796
## 110160 -0.026446642 0.0088661592 0.016590782 -0.038642053 -0.007702074
## 110500 -0.003446528 -0.0136101209 -0.019279759 0.012841640 0.013557675
## 110650 0.016586464 -0.0198514257 -0.039162636 0.060856640 -0.005879797
## 110820 -0.023737509 -0.0044103540 -0.006886918 0.003111329 -0.000626767
## 111280 -0.024120603 0.0025950845 0.007554348 -0.040010788 -0.015391486
## 211790 211880 212771 213040 213861
## 110150 0.02239294 -0.03644340 0.008794399 0.009435582 0.017082803
## 110160 0.01553093 -0.03738015 0.001580172 -0.002599242 0.029633468
## 110500 -0.02817558 0.04790410 -0.016021295 -0.008865232 -0.025045428
## 110650 -0.03578128 0.02949908 -0.031885028 -0.029297810 -0.030718256
## 110820 -0.01016947 -0.01543801 -0.011544663 -0.012284501 -0.004465738
## 111280 0.02510495 -0.03074948 0.007675235 0.006866371 0.026959397
## 214050 216170 216171 216261 216304
## 110150 -0.0008853947 -0.005605975 0.0219278671 -0.019953026 0.028157640
## 110160 0.0059999940 -0.009745623 0.0242129564 -0.029971177 0.007903070
## 110500 -0.0070202267 0.003141627 -0.0208058357 0.007263076 -0.022362821
## 110650 -0.0043528322 0.003052105 -0.0355399027 0.033136617 -0.034360506
## 110820 -0.0018919361 -0.001355749 -0.0000247461 -0.010494978 -0.002818112
## 111280 0.0031260911 -0.021457167 0.0174404141 -0.026742734 0.007895417
## 216640 217310 217421 217790 217880
## 110150 5.236568e-03 0.009023266 -0.031749718 -0.005972371 -0.004857258
## 110160 4.671432e-03 0.013291338 -0.041328203 -0.008922082 -0.004909771
## 110500 4.953035e-03 -0.016947411 -0.001652774 -0.008230105 -0.011716916
## 110650 -1.711318e-02 -0.020227049 0.215080291 -0.003568691 -0.009131212
## 110820 -1.457300e-02 0.035751346 -0.008906226 0.026953306 0.010413027
## 111280 -1.463061e-05 0.014567787 -0.029639881 -0.008227357 -0.014561060
## 217940 218290 219960 220310 222581
## 110150 0.004873024 0.024901167 0.0028778501 0.024846423 0.016547894
## 110160 -0.001804720 0.018697014 0.0161930621 0.017071201 0.023122918
## 110500 -0.012683819 -0.018101070 -0.0099572716 -0.024856830 -0.016998379
## 110650 -0.035435554 -0.036391545 -0.0287948642 -0.042402014 -0.034396179
## 110820 -0.002972901 -0.001442909 -0.0002959906 -0.007344882 -0.007850497
## 111280 -0.005515800 0.020397859 -0.0002470634 0.007191030 0.021693908
## 225990 225991 227220 228260 229680
## 110150 0.020513484 -0.008282499 -0.018691324 -0.03256094 -0.012479805
## 110160 0.019457560 -0.012740398 -0.018516930 -0.03063870 -0.009359655
## 110500 -0.026911777 -0.011146972 0.012181596 0.04300205 -0.019367812
## 110650 -0.039646715 -0.008972252 0.008632492 0.03221169 0.008095108
## 110820 0.001774016 -0.001075909 -0.016348965 -0.00272952 -0.006396670
## 111280 0.022702584 -0.011305438 -0.022573775 -0.02954929 -0.010227753
## 230381 230831 231450 232080 232110
## 110150 -0.018678954 0.0057195770 0.027555602 0.008708715 0.0001808802
## 110160 -0.009272253 0.0015005593 0.004942669 0.013905403 0.0013487225
## 110500 -0.005172753 -0.0006733162 -0.015630236 -0.018415587 -0.0005222589
## 110650 0.004456183 -0.0217113886 -0.026734337 -0.029754933 -0.0195905995
## 110820 0.004021345 -0.0066123968 -0.013068087 -0.003776173 -0.0106671052
## 111280 -0.004394549 -0.0071336576 0.006504306 0.005605272 0.0109400535
## 233400 233710 234850 235840 236330
## 110150 -0.01500945 0.0032610996 0.040229883 -0.007771615 0.01996364
## 110160 -0.00704722 -0.0007989720 0.015277716 -0.005986007 0.01266790
## 110500 0.02915931 -0.0109573165 -0.021836365 0.008901457 -0.01275058
## 110650 -0.01378815 -0.0086039957 -0.039970130 0.006419631 -0.03857848
## 110820 -0.01154417 -0.0064206170 -0.001971403 -0.002117776 -0.00219890
## 111280 -0.01860281 0.0009253012 0.017346723 -0.003207244 0.02012951
## 243541 243990 245120 248221 250921
## 110150 0.013646623 6.750572e-03 -0.0411398485 -0.01221930 -0.0133752851
## 110160 0.003428212 -1.499212e-03 -0.0505142584 -0.01043655 -0.0139820063
## 110500 -0.007741185 -2.436519e-02 0.0183596835 0.01754560 0.0002478569
## 110650 -0.003329075 -2.095555e-02 0.0222536568 0.01324025 -0.0003475795
## 110820 -0.007834683 8.008131e-05 -0.0007923484 -0.01554932 -0.0045321477
## 111280 0.007398387 6.919370e-04 -0.0407740362 -0.01757208 -0.0127094826
## 253160 253810 255670 255711 269490
## 110150 0.002015199 -0.03942489 -0.011491930 -0.008225998 0.003955901
## 110160 -0.002196262 -0.03851222 -0.028805278 -0.008061485 0.004951866
## 110500 -0.009232221 0.02672803 -0.009225580 -0.010132298 0.011264079
## 110650 -0.013025058 0.22463602 0.120943993 0.003034854 -0.010777886
## 110820 -0.005511066 0.01155359 0.001675402 -0.014348449 -0.001513843
## 111280 0.009769648 -0.03642223 -0.024705084 -0.011214797 0.007733794
## 273431 275000 301000 301004 310050
## 110150 0.015783897 0.002144185 0.007259707 -0.012194623 0.0093998797
## 110160 0.008402528 0.006862031 0.133975968 -0.006501274 0.0006656008
## 110500 -0.018353503 -0.030738637 -0.001029940 -0.012186593 -0.0034752253
## 110650 -0.044016618 -0.023645990 -0.027847879 -0.005217326 -0.0179955252
## 110820 -0.018715426 -0.006537847 -0.011410577 -0.010885670 -0.0083674518
## 111280 0.019150572 0.007886308 0.007859673 -0.013826823 0.0044069430
## 310121 310291 310300 310480 310601
## 110150 -0.011510254 0.023289226 -0.01152961 0.001925629 -0.030272702
## 110160 -0.018016625 0.023535348 -0.01742438 0.001872363 -0.039769541
## 110500 -0.004381006 -0.023987362 0.02312184 -0.018470541 0.020504046
## 110650 0.005531087 -0.032698248 0.01323662 -0.025175530 0.032549400
## 110820 -0.003797122 -0.008435468 -0.01843896 -0.010534553 -0.008105352
## 111280 -0.013286480 0.017139466 -0.01869754 0.003606211 -0.033914890
## 310620 310711 310820 310881 310920
## 110150 -0.026482131 -0.035777707 -0.002909695 0.038828772 0.004728731
## 110160 -0.026443720 -0.040727634 -0.011784215 0.019536210 0.006392670
## 110500 0.008730807 0.019995255 0.041355170 -0.015480909 -0.009527815
## 110650 0.011508190 0.047253419 -0.005565864 -0.037440941 -0.024147542
## 110820 -0.001406232 0.007255623 -0.012972906 -0.009810018 -0.007883099
## 111280 -0.024354577 -0.037395641 -0.003795231 0.008917380 -0.004780614
## 311010 311020 311021 311070 311071
## 110150 -0.0004488228 -0.036281690 0.016723208 -0.015856761 -0.03405326
## 110160 0.0018657481 -0.038116220 0.015127477 -0.016238423 -0.03332258
## 110500 -0.0117145879 0.008657553 -0.011265211 0.001451200 0.01730744
## 110650 -0.0057144132 0.059056282 -0.028601279 0.008311351 0.02342722
## 110820 -0.0086385272 0.001910150 -0.007115107 0.003811747 -0.01197149
## 111280 -0.0012490965 -0.037220012 0.024874272 -0.011286303 -0.02605182
## 311160 311170 311280 311410 311411
## 110150 -0.008548162 -0.004024371 -0.040770587 0.017283583 0.018971642
## 110160 -0.009929011 -0.004684436 -0.042936742 0.015612772 0.029826032
## 110500 0.005431679 -0.003276734 0.014265342 -0.011544907 -0.026485115
## 110650 -0.012966480 0.006256179 0.078560852 -0.032657359 -0.042046741
## 110820 -0.004876304 -0.005297065 0.001040553 -0.007569116 -0.006719337
## 111280 -0.015410928 -0.002877224 -0.041124281 0.028001759 0.016458528
## 311660 311700 311760 312370 312371
## 110150 0.001918449 -0.012072094 -0.02132787 -0.011746987 -0.002043957
## 110160 -0.005724820 -0.004767484 -0.02910804 -0.011522131 -0.001923508
## 110500 -0.016875228 0.004868453 -0.00489327 -0.011146188 -0.020585446
## 110650 0.037524320 0.015088689 0.06817544 0.015291158 -0.004311393
## 110820 -0.003590417 0.050503690 0.01288478 -0.005002584 -0.011699427
## 111280 -0.003060391 -0.013736147 -0.03907533 0.001915174 -0.009265262
## 312481 312531 312590 312761 312800
## 110150 -0.035374369 -0.006742733 0.014396155 0.026564125 -0.012717876
## 110160 -0.037851479 -0.010745093 0.017312329 0.018904867 -0.012696266
## 110500 -0.003974936 -0.018583389 -0.013061374 -0.017041139 -0.007016187
## 110650 -0.003340627 -0.008535760 -0.041469783 -0.034506381 0.001156984
## 110820 -0.007511139 -0.016802343 -0.003129545 -0.004402094 -0.013964136
## 111280 -0.031375568 -0.012820976 0.019287558 0.020158829 -0.003719789
## 312801 312930 312960 313051 313180
## 110150 -0.01704937 -0.015662393 -0.006863845 0.017282477 -0.024489261
## 110160 -0.02898743 -0.017112987 -0.013645723 0.008672454 -0.018886197
## 110500 -0.02865896 -0.029967694 -0.032580320 -0.017593088 0.002241198
## 110650 0.20015784 -0.032483552 -0.023689350 -0.039770782 0.011638706
## 110820 0.00506494 -0.010929260 -0.008821026 -0.001512489 -0.029291349
## 111280 -0.02191354 -0.005445947 -0.007263370 0.015774140 -0.016764298
## 313181 313200 313211 313570 313651
## 110150 -0.003649736 0.016254865 0.005795633 -0.011756070 -0.006009821
## 110160 -0.015261599 0.019904597 0.001089469 -0.005490586 -0.010383910
## 110500 0.031730223 -0.022499358 -0.013615863 0.005857133 -0.005134792
## 110650 -0.001801415 -0.041028138 -0.030718571 0.005385030 0.013649656
## 110820 -0.009384481 -0.007020129 -0.008575455 -0.015562017 -0.002493209
## 111280 -0.026508063 0.018031223 -0.004295975 -0.013681164 -0.004703814
## 313840 313851 313870 314200 314201
## 110150 0.006026030 0.03071103 -0.0051883315 0.025689520 0.013247842
## 110160 -0.005814854 0.02076715 -0.0099675898 0.022340886 0.011058316
## 110500 0.005459669 -0.02188690 -0.0106730331 -0.021594705 -0.022335052
## 110650 -0.032772154 -0.04025918 -0.0262767710 -0.036958102 -0.016540999
## 110820 -0.006689305 -0.01362600 -0.0066247685 0.001802669 -0.012233677
## 111280 -0.001419083 0.02412242 -0.0001145088 0.016489871 0.001505871
## 314210 314310 314471 314910 315031
## 110150 0.004343926 0.021856498 -0.02061914 0.003394435 0.010329140
## 110160 -0.004076876 0.026449636 -0.01394252 0.012191324 0.009784768
## 110500 -0.009552351 -0.019805918 -0.01122935 0.002851960 -0.019034553
## 110650 -0.019230757 -0.039490514 -0.02323679 -0.011499329 -0.039876182
## 110820 -0.007974533 -0.004880711 -0.03124607 -0.007394049 0.019339371
## 111280 0.002985587 0.014886895 -0.01117223 0.010424880 0.012338321
## 315040 315290 315560 315780 315860
## 110150 0.019148115 0.024127329 -0.0031777371 0.018769132 0.0024504836
## 110160 0.027304487 0.021677932 0.0005635413 0.032623637 0.0108215334
## 110500 -0.019312626 -0.014729486 -0.0009730599 -0.019402070 -0.0072296979
## 110650 -0.035653312 -0.031422123 -0.0083277365 -0.033698678 -0.0255986862
## 110820 -0.006406488 -0.001716792 -0.0130567765 -0.004401762 0.0152117657
## 111280 0.017060073 0.021745220 0.0024580806 0.014728006 -0.0003319744
## 315861 315981 316131 316160 316180
## 110150 0.001550467 -0.010276123 -0.001180770 -0.004309692 -0.012878357
## 110160 0.009627724 -0.011711354 -0.001960889 -0.010781345 -0.016617985
## 110500 -0.015570508 0.006425022 -0.010905281 -0.023657754 -0.003312312
## 110650 -0.024048746 -0.020606618 -0.026248550 -0.031091286 -0.003973734
## 110820 -0.010898546 0.012329119 -0.008788867 -0.017376199 0.024950959
## 111280 -0.002140799 -0.008962578 -0.002268027 -0.010079927 -0.013821084
## 316301 316320 316400 316401 316740
## 110150 -0.03471802 -0.011138189 -0.036124974 0.013263483 0.012991325
## 110160 -0.03454446 -0.008128305 -0.033790290 0.017539363 0.007027124
## 110500 0.02840039 0.005458225 0.046828061 -0.011844751 -0.011468243
## 110650 0.04953027 0.007803757 0.029039036 -0.040606670 -0.029314267
## 110820 -0.01169714 -0.006491303 -0.006530252 -0.001912545 0.003577422
## 111280 -0.04343513 -0.010771259 -0.036581721 0.006390985 0.004736193
## 316840 316841 316870 316910 316960
## 110150 -0.0001679552 -0.011213931 -0.003070361 -0.028165976 0.003971403
## 110160 -0.0036268039 -0.008066297 -0.009446244 -0.030893659 -0.003791788
## 110500 -0.0138302539 -0.007104336 0.002460269 -0.004779220 -0.022672197
## 110650 -0.0040004905 -0.001363936 0.038417481 -0.008265771 -0.033206161
## 110820 -0.0050226711 -0.005239071 0.024176035 -0.008881848 -0.003956247
## 111280 0.0014143978 0.001932846 -0.002672698 -0.029797575 0.002642391
## 316981 317590 317611 317650 317671
## 110150 0.012877193 0.008699142 0.028463043 -0.029019659 0.023810696
## 110160 0.012942334 -0.009910821 0.013195146 -0.022543339 0.019141257
## 110500 -0.016789913 -0.007983330 -0.010659947 0.026880082 -0.034128260
## 110650 -0.029728986 -0.030126411 -0.033749122 0.022846986 -0.034264799
## 110820 -0.005640047 -0.017563958 -0.001698718 0.001792252 -0.006217434
## 111280 0.015086748 0.003391199 0.023938769 -0.018950835 0.023429027
## 317690 317710 317740 317741 317771
## 110150 -0.014258427 -0.029484285 -0.01396137 0.016806424 0.03520523
## 110160 -0.019251786 -0.035685923 0.21046843 0.024495106 0.01496493
## 110500 -0.012497863 0.006750994 0.04105210 -0.014111447 -0.01407881
## 110650 0.022583200 0.044601284 0.01088540 -0.040307462 -0.02642565
## 110820 -0.003945722 0.187876344 -0.01730612 -0.007010915 -0.01105042
## 111280 -0.010629513 -0.034862433 -0.01024141 0.017167227 0.01168970
## 317801 317830 317831 317840 317850
## 110150 -0.0002807619 0.002645010 -0.009478072 -0.006320196 -0.0016707857
## 110160 -0.0123561686 0.006150973 -0.011009895 -0.005059805 -0.0051852507
## 110500 -0.0228307806 -0.005009042 -0.017542602 -0.018419182 -0.0200972147
## 110650 -0.0264783520 -0.023488674 -0.011731102 -0.029380333 -0.0186556745
## 110820 -0.0108590992 -0.007302713 -0.013455594 -0.004312374 0.0005928245
## 111280 -0.0075706369 -0.002782034 -0.011193617 -0.008414913 -0.0104669202
## 317941 318090 318471 318480 318760
## 110150 -0.0051330281 -0.004151041 -0.021538982 0.015263312 -0.016465094
## 110160 0.0051583205 -0.010780601 -0.020725191 0.006953249 -0.018118570
## 110500 -0.0150109865 -0.018026998 -0.005278949 -0.008970985 -0.003722242
## 110650 -0.0300177950 0.036931369 0.002980009 -0.007572583 -0.015090344
## 110820 -0.0110482620 0.005305235 -0.027937103 -0.007215843 -0.002543078
## 111280 0.0004048626 -0.009927765 -0.023057904 0.012042039 -0.023577740
## 318770 318960 318961 319011 319271
## 110150 0.0027443226 -0.02879228 0.029670728 0.01258039 0.0248154439
## 110160 -0.0037294351 -0.03252907 0.024885258 0.01241422 0.0279402975
## 110500 -0.0143041061 0.03820885 -0.012280780 -0.01829016 -0.0179606713
## 110650 -0.0267332662 0.04575127 -0.023787493 -0.02287603 -0.0321614891
## 110820 -0.0003065505 0.00355170 -0.003452687 -0.01157632 -0.0005917076
## 111280 0.0056140567 -0.03021713 0.029017558 0.01966848 0.0172374677
## 319280 319420 319641 319731 319970
## 110150 0.021419778 -0.000912161 0.015727647 -0.013595892 -0.0188163277
## 110160 0.224907726 0.009088274 0.009978061 0.001282205 -0.0117479526
## 110500 -0.020559413 -0.025661429 -0.030899039 -0.018648991 0.0060773306
## 110650 -0.034146879 -0.033503611 -0.036674965 0.017649494 -0.0014193926
## 110820 -0.005877325 -0.010706675 0.025747323 0.006021283 -0.0004343828
## 111280 0.017876649 -0.001626244 0.013514858 -0.005451874 -0.0227483176
## 320320 320321 320350 320450 320470
## 110150 -0.02644334 0.02188996 -0.006842237 -0.028650964 -0.01152609
## 110160 -0.03056676 0.01957291 -0.005156421 -0.028216671 -0.01006051
## 110500 0.01201253 -0.01699855 -0.009189040 -0.006802545 -0.00724395
## 110650 0.04117886 -0.03342690 -0.003900878 -0.010241332 -0.02742362
## 110820 0.19259201 -0.00841077 0.099883072 -0.024907617 -0.02016174
## 111280 -0.03127697 0.01981125 -0.004454517 -0.028598972 -0.01216209
## 320490 320511 320620 321130 323200
## 110150 0.008040952 -0.005709734 -0.008385949 -0.0102435919 0.018788882
## 110160 0.002051670 -0.001955433 -0.002621945 0.0024436289 0.006916703
## 110500 -0.009361488 -0.021926109 -0.011478001 -0.0241345447 -0.009847967
## 110650 -0.029113296 0.016049240 0.008439525 0.0000154114 -0.032771952
## 110820 -0.016648196 -0.001545688 0.008232547 -0.0019758982 -0.018874155
## 111280 -0.001227903 -0.007557079 0.008249561 -0.0134170232 -0.004278639
## 324590 327190 328580 328820 328980
## 110150 -0.0046311263 -0.013300397 -0.008890530 0.010995117 -0.008975437
## 110160 -0.0043458440 -0.007600865 -0.014492292 0.009283028 -0.012664286
## 110500 -0.0117761521 -0.015769543 -0.006061504 -0.009427273 0.003413530
## 110650 -0.0166577641 -0.002396582 0.018208899 -0.016048877 0.012680818
## 110820 -0.0098714391 -0.007304349 0.002060450 -0.006769442 -0.018940967
## 111280 -0.0006336385 -0.012877380 -0.009969623 -0.002034901 -0.009781812
## 329180 329210 329350 329480 330050
## 110150 0.01215314 -0.006640227 -0.01722061 -0.007922916 -0.039329782
## 110160 0.01655049 -0.017976524 -0.01307345 -0.016433591 -0.041150887
## 110500 -0.01270023 0.022736004 -0.01190519 -0.005305880 0.013187832
## 110650 -0.03568748 0.009203300 -0.02119551 -0.012150945 0.046968788
## 110820 -0.01207796 0.090187304 -0.03177970 0.003754491 -0.008522034
## 111280 0.01974176 -0.012064653 -0.01378591 -0.016490277 -0.040078674
## 330200 331100 332031 333130 333760
## 110150 -0.001401477 -0.010369139 -0.012864829 0.015093221 0.011897648
## 110160 0.007755280 -0.001591086 -0.017149262 0.004876599 0.007219680
## 110500 -0.020155523 -0.021608338 0.420908689 -0.031816013 -0.026455732
## 110650 -0.035256512 -0.019416289 0.004808119 -0.030070974 -0.030725999
## 110820 -0.012890988 -0.013995240 -0.006466585 -0.011420838 -0.012939699
## 111280 0.004534322 -0.006254544 -0.013484454 0.009516103 0.008456595
## 333820 334550 335330 336390 336641
## 110150 -0.005223880 0.011392138 -0.007849352 -0.0009171631 0.011071037
## 110160 -0.006770591 0.003100227 -0.010078378 -0.0069632120 -0.003319771
## 110500 0.013671803 -0.026114644 0.010769980 -0.0229002535 -0.019283056
## 110650 -0.007573698 -0.027112110 -0.005854039 -0.0286663435 -0.029103961
## 110820 -0.012582725 0.002406086 0.086943656 0.0048766616 -0.003999171
## 111280 -0.007189594 0.001327549 -0.006380373 -0.0013148147 0.004592466
## 337060 337200 337690 338630 344050
## 110150 0.0018557680 0.006222253 0.01757523 0.02312485 -0.008427780
## 110160 0.0003748410 0.003686385 0.01753478 0.01027200 -0.005046267
## 110500 -0.0222025942 -0.005465199 -0.01397760 -0.02567074 -0.003780773
## 110650 -0.0300394092 -0.015986344 -0.03704123 -0.03183515 -0.013161696
## 110820 -0.0077543133 -0.006334406 -0.01194996 -0.01394022 0.005953655
## 111280 0.0008494736 -0.005486187 0.02248118 0.02114233 -0.014288496
## 344870 345020 345601 356930 358480
## 110150 -0.0174501743 0.010130396 0.005178113 0.001434402 -0.0108409049
## 110160 -0.0199024752 0.006291443 0.008156545 0.011313475 -0.0120288413
## 110500 -0.0247694030 -0.018735789 -0.025566947 -0.009822182 0.0134428916
## 110650 0.0088903746 -0.014085494 -0.035441469 -0.023416888 0.0008787725
## 110820 0.0002250192 -0.005878642 -0.002154367 0.000613243 0.0009792170
## 111280 -0.0082589947 0.009558402 0.011541084 0.002038875 -0.0104773343
## 358630 362060 362911 363990 364020
## 110150 0.017201427 0.0052868086 -0.035610277 0.021484762 -0.01024356
## 110160 0.013637658 -0.0007593153 -0.035717856 0.020375447 -0.01598345
## 110500 -0.001833398 -0.0148594165 0.006505366 -0.021159939 -0.02215225
## 110650 -0.004888085 0.0382927358 0.418670654 -0.030564135 -0.02395198
## 110820 -0.007129896 0.0098348493 0.011340550 -0.001638521 -0.01149406
## 111280 0.008856833 -0.0072384896 -0.034962498 0.028149527 -0.01010536
## 368910 375490 375731 382610 387110
## 110150 0.003001598 0.009891159 -0.0024579242 0.0085348152 0.0024341659
## 110160 -0.006807907 0.011510331 -0.0109841153 -0.0136053832 0.0108031379
## 110500 -0.021797163 -0.009960479 -0.0123603670 0.0337448716 -0.0066665839
## 110650 -0.035240281 -0.004391257 0.0766502321 -0.0007521686 -0.0256742500
## 110820 -0.015606664 -0.006663109 -0.0071064411 0.0196413696 0.0151865222
## 111280 -0.002805588 0.014444930 0.0001177236 -0.0036364438 -0.0003869878
## 387111 388290 400011 400013 400024
## 110150 0.000503453 -0.013323876 -0.004781612 -0.02722096 -0.04535324
## 110160 -0.010753690 -0.017595327 -0.008185297 -0.03089093 -0.04726985
## 110500 0.022785977 -0.003036848 -0.002011567 0.01822058 -0.00304533
## 110650 0.002844240 -0.003259023 -0.013054426 0.03452430 0.03330520
## 110820 -0.007690518 -0.010639320 -0.007419274 -0.02202391 0.00627470
## 111280 -0.001336734 -0.020941302 0.001511849 -0.02767942 -0.04265352
## 400038 400042 400045 400055 400070
## 110150 0.007222762 -0.008571097 0.008560102 -0.021030238 -0.006820523
## 110160 0.007355900 -0.007871738 0.001959099 -0.013451941 -0.012628671
## 110500 -0.026291071 -0.004982373 -0.008262353 -0.013560152 -0.026849609
## 110650 -0.028531320 -0.009137030 -0.010798948 0.012583951 -0.023030510
## 110820 -0.006115662 0.030563092 0.001568486 -0.006271585 -0.015812287
## 111280 0.003210449 -0.002674333 0.010491873 -0.015670737 -0.011824616
## 400072 400073 400074 400083 400093
## 110150 0.001929712 -0.017019454 -0.006227623 0.002985555 -0.01043670
## 110160 0.003954806 -0.011410010 -0.010297085 0.012958582 -0.02239379
## 110500 0.004943134 0.004685392 -0.019048804 -0.004006009 0.01523727
## 110650 -0.003655827 0.012331870 -0.032459337 -0.026604623 -0.01228978
## 110820 0.004298862 -0.009793146 -0.008795418 -0.013289045 0.01283506
## 111280 0.016018389 -0.015017815 -0.009844647 0.002912495 -0.02297239
## 400096 400101 400104 400107 400157
## 110150 -0.037007555 0.005672394 -0.03365623 -0.045048341 -0.001502545
## 110160 -0.041034427 0.104205362 -0.04529474 -0.047732387 -0.008613947
## 110500 0.018203603 0.008236861 0.07526571 0.022328159 0.007581268
## 110650 0.059346668 -0.023436386 0.01780559 0.052482147 0.021689292
## 110820 -0.004180408 -0.011686598 -0.01106482 0.005161539 -0.016109549
## 111280 -0.041217357 0.001434839 -0.04504948 -0.044452794 -0.020656940
## 400162 400165 400182 400187 400194
## 110150 -0.030462630 0.005456207 0.015163771 0.017833309 0.0104833767
## 110160 -0.036264639 0.005607688 0.019393114 0.011708865 0.0154677015
## 110500 0.413798273 -0.014326419 -0.029741708 -0.011750977 -0.0104478858
## 110650 0.014198727 -0.021938842 -0.032665960 -0.028116096 -0.0126824966
## 110820 -0.007186675 -0.004408717 0.005237865 -0.007302563 -0.0009511409
## 111280 -0.031684574 0.007686249 0.023459746 0.016392006 0.0092472611
## 400208 400211 400218 400221
## 110150 -0.0145363361 0.0024447213 -0.0008648576 -2.083034e-05
## 110160 -0.0244096890 -0.0005776382 -0.0104938578 -2.890556e-03
## 110500 -0.0006057158 -0.0086456193 -0.0016437611 -4.648621e-03
## 110650 -0.0073011899 -0.0268671792 -0.0078488961 8.126539e-03
## 110820 -0.0058174436 -0.0195129272 -0.0166624337 -8.521337e-03
## 111280 -0.0171468891 0.0012964691 -0.0172431637 -5.157812e-03
## 400226 400232 400235 400263 400265
## 110150 -0.026896408 -0.012800300 -0.014274563 0.02084746 0.017404217
## 110160 -0.030562449 -0.019235564 -0.015951784 0.01581776 0.014651100
## 110500 0.004582310 -0.012867189 -0.008752250 -0.01869646 -0.008921656
## 110650 0.416481018 -0.014637437 0.005708026 -0.03143923 -0.020820912
## 110820 -0.007306988 -0.003877003 -0.004025829 -0.01111176 0.002853333
## 111280 -0.029002391 -0.002253960 -0.006458372 0.01746867 0.011827257
## 400301 400304 400305 400310 400311
## 110150 0.005864988 -0.004268778 0.000637251 0.003203502 -0.01884054
## 110160 -0.008191202 -0.007495108 -0.008687112 0.011426181 -0.01594501
## 110500 -0.009697266 -0.009593454 -0.018975414 -0.013463224 -0.00357970
## 110650 -0.020172909 -0.028233759 0.077286758 -0.017309362 -0.01549350
## 110820 -0.007526862 -0.006215414 -0.002804419 -0.019221695 -0.01577309
## 111280 -0.010168832 0.001694485 -0.002593615 0.006479689 -0.01765151
## 400315 400322 400324 400336 400340
## 110150 -0.01737943 -0.003983923 0.001888237 0.0002690845 0.0048396215
## 110160 -0.01507504 0.004873227 0.015597518 -0.0035032462 0.0043831542
## 110500 0.01079513 -0.017622136 -0.014929288 -0.0056903190 0.0002282139
## 110650 -0.01539081 0.005874425 -0.037018925 -0.0244702492 -0.0096437987
## 110820 -0.00932296 -0.011884875 -0.008120131 -0.0099704098 -0.0102993650
## 111280 -0.02296408 -0.005074372 0.005531964 0.0028454736 -0.0010312235
## 400341 400343 400366 400370 400381
## 110150 -0.0078046201 -0.04193608 -0.047090776 -0.043904614 -0.0127153201
## 110160 -0.0119949607 -0.04527842 -0.046769775 -0.044184592 -0.0094876271
## 110500 -0.0172389150 0.01726019 0.009641899 0.014342199 -0.0018556849
## 110650 0.0968747288 0.06839117 0.020318048 0.032889884 0.0001363529
## 110820 -0.0145901050 -0.01292094 -0.031518187 -0.001175436 0.0085516013
## 111280 0.0002016774 -0.04251099 -0.047389258 -0.041775003 -0.0088160690
## 400382 400389 400397 400399 400418
## 110150 -0.011798863 0.022102417 0.008620355 -0.02143627 -0.0027128512
## 110160 -0.010818513 0.021923445 -0.002064218 -0.01657782 -0.0046787350
## 110500 -0.006488534 -0.018660087 -0.018310178 0.02316203 -0.0122655230
## 110650 0.006890677 -0.038417339 -0.012567230 0.01646453 -0.0172330886
## 110820 -0.012835039 -0.006209464 0.004421606 -0.01025132 -0.0125279063
## 111280 -0.014928722 0.025942594 0.002559633 -0.01692509 -0.0001366313
## 400419 400420 400425 400426 400447
## 110150 -0.026968684 -0.0129635185 0.001587243 -0.013183760 0.02049739
## 110160 -0.018524192 -0.0116169080 0.009150141 -0.017421760 0.01600129
## 110500 0.022140868 -0.0062372452 -0.016778039 -0.006518593 -0.03132502
## 110650 0.004517526 -0.0007177001 -0.036061801 -0.013391034 -0.04128839
## 110820 -0.008575762 -0.0005933582 -0.021792574 -0.030853171 -0.01006480
## 111280 -0.017962532 -0.0120473206 0.005534423 -0.019103713 0.01739500
## 400464 400467 400470 400475 400497
## 110150 0.003648438 0.004302291 -0.006835693 -0.001687523 -0.0051333192
## 110160 0.001517724 0.002365687 -0.011687488 -0.009642553 -0.0040900391
## 110500 -0.019322652 -0.011105701 -0.005198441 -0.006370662 -0.0107075050
## 110650 -0.036058344 -0.010198923 0.029642314 -0.012504085 -0.0002466875
## 110820 -0.012534882 -0.004981775 0.003614008 -0.008502229 -0.0114365881
## 111280 0.004867582 0.002432810 -0.007424405 -0.004565589 -0.0040651392
## 400499 400501 400516 400519 400520
## 110150 0.006101164 0.0012100593 0.006440366 -0.0288265888 -0.023093615
## 110160 0.003704871 0.0045288014 0.002979010 -0.0376164764 -0.034539517
## 110500 -0.006845940 -0.0034842975 -0.018148469 0.0021161032 -0.006459387
## 110650 -0.012847144 -0.0207045916 -0.018907335 0.1909033656 0.227794662
## 110820 -0.004056403 -0.0073642982 -0.003412971 -0.0004412049 -0.007645797
## 111280 0.016331293 0.0008018567 0.004074349 -0.0343100429 -0.024628324
## 400521 400523 400528 400529 400531
## 110150 -0.006944096 -0.002825476 -0.018136660 -0.016741784 -0.0183218569
## 110160 -0.014872005 0.009537830 -0.028203167 -0.024142964 -0.0155133400
## 110500 -0.012670211 -0.010304721 0.006937514 0.002365760 -0.0085280482
## 110650 0.007044615 -0.005054822 0.003051881 0.007467563 0.0073431190
## 110820 -0.008715013 -0.005759679 -0.016956931 -0.015237343 0.0009137709
## 111280 -0.013662207 -0.004276300 -0.028362677 -0.023104357 -0.0206884407
## 400535 400543 400547 400551 400554
## 110150 0.01110908 -0.049007084 0.013088057 -0.004252313 -0.009508532
## 110160 0.01561046 -0.052737720 0.008652860 -0.006014740 -0.001945519
## 110500 -0.01738412 0.037309546 -0.003929148 -0.004524941 0.218290418
## 110650 -0.03272026 0.047139913 -0.011789254 0.028089514 -0.006508246
## 110820 -0.01201605 0.004138079 -0.013369187 -0.006263365 -0.017846184
## 111280 0.01338544 -0.046744477 0.005356268 -0.008271879 -0.002932574
## 400558 400560 400563 400577 400580
## 110150 -0.013051883 0.007095530 -0.03267932 -0.009612076 -0.009540798
## 110160 -0.015326166 0.012431812 -0.03898779 -0.008880415 -0.013122095
## 110500 -0.004557936 -0.019875640 0.00157815 -0.017335206 -0.003454193
## 110650 0.008580420 -0.031080179 -0.01239466 -0.019503016 -0.003460341
## 110820 -0.009125213 -0.005227568 -0.01479890 -0.017699283 -0.003331317
## 111280 -0.015030791 0.007278902 -0.03541263 -0.011470785 -0.012784962
## 400582 400589 400592 400605 400616
## 110150 -0.0014990339 -0.022550823 0.0005206877 0.009193035 0.001064481
## 110160 -0.0009484687 -0.035792135 -0.0068717944 0.016610868 0.003882811
## 110500 -0.0177929197 0.003448341 -0.0113186762 -0.011229125 -0.003855756
## 110650 -0.0404364653 0.039804690 -0.0356129631 -0.011260303 -0.018480029
## 110820 -0.0183123052 0.105166122 -0.0094855987 0.004083862 -0.005672214
## 111280 0.0087207770 -0.030288350 -0.0098785395 0.004828235 0.005406797
## 400619 400620 400630 400631 400632
## 110150 0.001625150 0.004123859 0.007485576 -0.008885872 -0.02828997
## 110160 0.002046640 0.009691466 0.003212207 -0.010517584 -0.04246542
## 110500 -0.010089571 0.003641311 -0.016700331 -0.018460285 0.03305570
## 110650 -0.021817720 -0.003797512 -0.015883679 -0.026597232 0.03909460
## 110820 -0.005665558 -0.002152578 -0.009973025 -0.026231455 -0.01995771
## 111280 0.003077633 0.001203210 0.004893408 -0.016479913 -0.02981970
## 400633 400634 400635 400639 400643
## 110150 -0.01203700 0.016434312 0.017576015 0.008002961 -0.007470838
## 110160 -0.01421089 0.006191020 0.026307976 0.005251345 -0.015357000
## 110500 -0.01226675 -0.011178519 -0.024048548 -0.024319891 0.006863446
## 110650 -0.02901472 -0.024261754 -0.037608132 -0.007515993 0.014970102
## 110820 -0.02101686 -0.005441751 -0.004129181 -0.004349547 0.035351373
## 111280 -0.01662179 0.003908991 0.026018847 0.003246761 -0.008062919
## 400644 400646 400647 400648 400653
## 110150 0.0062778322 0.001945672 -0.004522003 -0.007330553 -0.003538142
## 110160 -0.0003369632 -0.008792134 -0.003126209 -0.011530126 -0.006988198
## 110500 -0.0041647982 -0.002366839 -0.021601653 -0.016891463 -0.011418667
## 110650 -0.0204556193 -0.010229664 -0.017348036 0.085038744 -0.018684193
## 110820 0.0005922223 -0.004715758 -0.011583316 -0.003167826 -0.007530089
## 111280 -0.0012462741 0.004566817 -0.003075998 -0.005670090 -0.009667150
## 400656 400660 400662 400670 400671
## 110150 0.0149010597 5.862635e-05 -0.002751291 -0.0007745834 0.00691297
## 110160 0.0159246847 6.447064e-04 0.004309817 0.0030298210 0.01146823
## 110500 -0.0085945111 -1.583024e-03 -0.017514944 -0.0152127063 -0.01056238
## 110650 -0.0153755061 -6.473558e-03 -0.003288263 0.0223996881 -0.02398438
## 110820 -0.0044816150 -1.128149e-02 -0.010221776 -0.0044238260 0.39506900
## 111280 -0.0004765095 -3.762482e-03 0.001985769 0.0098394258 0.01225407
## 400672 400677 400696 400698 400712
## 110150 -0.02362540 0.010261377 0.016303532 -0.0107958000 -0.0065261447
## 110160 -0.01667047 0.011157782 0.011281720 -0.0008539196 -0.0051663471
## 110500 0.01100512 -0.020232711 -0.020634694 -0.0231052153 -0.0047618602
## 110650 0.01652073 -0.024151677 -0.031195456 -0.0248585064 0.0135012344
## 110820 0.02697119 -0.010225830 -0.002504300 -0.0233688951 -0.0063020336
## 111280 -0.02562209 0.005404431 0.006278595 0.0073675467 -0.0009740453
## 400713 400752 400785 400792 400799
## 110150 0.010291322 0.0042664302 0.007089582 -0.0055461358 -0.009672002
## 110160 0.011119937 -0.0079546887 0.002457072 -0.0018884395 -0.016442036
## 110500 -0.024327032 -0.0134135420 -0.019570319 -0.0028980032 -0.010729714
## 110650 -0.022296758 -0.0234538056 -0.015865693 0.0024604991 0.002874127
## 110820 -0.007043783 -0.0003540265 -0.004770340 0.0005022149 0.023497609
## 111280 0.008614318 -0.0120221628 0.004849532 -0.0088143758 -0.009000867
## 400800 400801 400802 400803 400804
## 110150 0.007168773 -0.007561081 0.03359517 0.005824198 0.0008487150
## 110160 0.013332737 -0.003368088 0.01530312 0.006454158 0.0007765358
## 110500 -0.004280529 -0.023707669 -0.01967451 -0.016743584 -0.0002215243
## 110650 -0.009813254 -0.029918550 -0.01557937 -0.010939614 -0.0384615920
## 110820 -0.003211029 -0.023044450 -0.01165146 -0.010269737 -0.0173523072
## 111280 0.006056390 0.000790625 0.01608523 0.001336683 0.0010151991
11. Compute eigen decomposition
merged_nies_eiK <- eigen(merged_nies_GRM)
head(merged_nies_eiK$values)
## [1] 5.756455 4.630068 4.447051 4.199365 3.878659 3.575725
12. Deal with small negative eigenvalues
merged_nies_eiK$values[ merged_nies_eiK$values < 0] <- 0
13. Perform PCA on GRM
merged_nies_PC <- sweep(merged_nies_eiK$vectors, 2, sqrt(merged_nies_eiK$values), "*")
14. Plot PC1 vs PC2
plot(merged_nies_PC[,1], merged_nies_PC[,2], xlab = "PC1", ylab = "PC2", main = "GRM PC1 vs PC2")
15. Plot PC1 vs PC2 and colour code by gender
plot(merged_nies_PC[,1], merged_nies_PC[,2], col = merged_nies@ped$sex, xlab = "PC1", ylab = "PC2", main = "GRM PC1 vs PC2")