This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # LD and kinship coeff | |
| ld <- .2 | |
| kin <- .1 | |
| snpgdsBED2GDS(bed.fn = "convertGDS.bed", bim.fn = "convertGDS.bim", | |
| fam.fn = "convertGDS.fam", out.gdsfn = "myGDS", | |
| cvt.chr = "char") | |
| genofile <- snpgdsOpen("myGDS", readonly = F) | |
| gds.ids <- read.gdsn(index.gdsn(genofile, "sample.id")) | |
| gds.ids <- sub("-1", "", gds.ids) | |
| add.gdsn(genofile, "sample.id", gds.ids, replace = T) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Sample call rate & heterozygosity | |
| callMat <- !is.na(genData$SNP) | |
| Sampstats <- row.summary(genData$SNP) | |
| hetExp <- callMat %*% (2 * SNPstats$MAF * (1 - SNPstats$MAF)) # Hardy-Weinberg heterozygosity (expected) | |
| hetObs <- with(Sampstats, Heterozygosity * (ncol(genData$SNP)) * Call.rate) | |
| Sampstats$hetF <- 1-(hetObs/hetExp) | |
| # Use sample call rate of 100%, het threshold of 0.1 (very stringent) | |
| het <- 0.1 # Set cutoff for inbreeding coefficient; | |
| het_call <- with(Sampstats, abs(hetF) < het & Call.rate == 1) | |
| genData$SNP <- genData$SNP[het_call,] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(snpStats) | |
| library(doParallel) | |
| library(SNPRelate) | |
| library(GenABEL) | |
| library(dplyr) | |
| source("GWASfunction.R") | |
| load("PhenoGenoMap.RData") | |
| # Use SNP call rate of 100%, MAF of 0.1 (very stringent) | |
| maf <- 0.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Load lipid datasets & match SNP-Lipidomics samples | |
| lipidsMalay <- read.delim("public/Lipidomic/117Malay_282lipids.txt", row.names = 1) | |
| lipidsIndian <- read.delim("public/Lipidomic/120Indian_282lipids.txt", row.names = 1) | |
| lipidsChinese <- read.delim("public/Lipidomic/122Chinese_282lipids.txt", row.names = 1) | |
| all(Reduce(intersect, list(colnames(lipidsMalay), | |
| colnames(lipidsIndian), | |
| colnames(lipidsChinese))) == colnames(lipidsMalay)) # TRUE | |
| lip <- rbind(lipidsMalay, lipidsIndian, lipidsChinese) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(snpStats) | |
| load("conversionTable.RData") | |
| pathM <- paste("public/Genomics/108Malay_2527458snps", c(".bed", ".bim", ".fam"), sep = "") | |
| SNP_M <- read.plink(pathM[1], pathM[2], pathM[3]) | |
| pathI <- paste("public/Genomics/105Indian_2527458snps", c(".bed", ".bim", ".fam"), sep = "") | |
| SNP_I <- read.plink(pathI[1], pathI[2], pathI[3]) | |
| pathC <- paste("public/Genomics/110Chinese_2527458snps", c(".bed", ".bim", ".fam"), sep = "") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| plot(finalModel) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dev.off() # Reset previous graphical pars | |
| # New GLM, updated from the first by estimating with REML | |
| GLM2 <- update(GLM, .~., method = "REML") | |
| # Plot side by side, beta with respective SEs | |
| plot(coef(GLM2), xlab = "Fixed Effects", ylab = expression(beta), axes = F, | |
| pch = 16, col = "black", ylim = c(-.9,2.2)) | |
| stdErrors <- coef(summary(GLM2))[,2] | |
| segments(x0 = 1:6, x1 = 1:6, y0 = coef(GLM2) - stdErrors, y1 = coef(GLM2) + stdErrors, | |
| col = "black") | |
| axis(2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| finalModel <- update(lmm6.2, .~., method = "REML") | |
| summary(finalModel) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| lmm8 <- update(lmm6.2, .~. + nutrient:amd) | |
| summary(lmm8) | |
| anova(lmm8, lmm6.2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| summary(lmm6.2) |