## ----设置,包括= false --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- knitr::opts_chunk$set(echo = TRUE, message = FALSE) ## ---- echo=FALSE, results='hide'----------------------------------------------------------库(Genesis)库(Gwastools)#文件GDS FILE GDSFILE <-system.file(“ extdata”,“ hapmap_asw_mxl_geno.gds”,package =“ genesis”)#读取GDS数据hapmap_geno <-gdsgenotypereader(fileName = gdsEname = gdseTypePedata class object oggithgeda <---GenotypeData(HapMap_geno) # load saved matrix of KING-robust estimates data("HapMap_ASW_MXL_KINGmat") # run PC-AiR mypcair <- pcair(HapMap_genoData, kinobj = HapMap_ASW_MXL_KINGmat, divobj = HapMap_ASW_MXL_KINGmat, verbose = FALSE) mypcs <- mypcair$vectors[,1,drop=FALSE] # create a GenotypeBlockIterator object HapMap_genoData <- GenotypeBlockIterator(HapMap_genoData) # run PC-Relate mypcrel <- pcrelate(HapMap_genoData, pcs = mypcs, training.set = mypcair$unrels, BPPARAM = BiocParallel::SerialParam(),详细= false)#生成表型套装。种子(4)pheto <-0.2*mypcs + rnorm(mypcair $ nsamp,均值= 0,sd = 1)## ----------------------------------------------------------------------------------------------------------------------------------------------------------#mypCair包含先前的PC-AAR分析中的PCS#PENO是表型值的向量#制作data.frame mydat <-data.frame(scanid = mypcair $ sample)。id,pc1 = mypcair $ vectors [,1],pheno = pheno)头(mydat)#制作scanAnnotationDataFrame scanannot <-ScanAnnotationDataFrame(mydat)scanannot ## -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #geno < - matrixgenotypereader(genotype =基因型,snpid = snpid,#Chromosome = Chromosome =染色体,位置=位置,#scanid = scanid = Scanid)#genodata <-Genotypedata(geno)(geno)## ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------#geno <-gdsgenotypereader(filename =“ genotype.gds”)#genodata < - genotypedata(geno)## --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #snpgdsbed2gds(床.fn =“ genotype.bed”,#bim.fn =“ genotype.bim”,#fam.fn =“ genotype.fam”,#out.gdsfn =“ genotype.gds.gds”)## ---------------------------------------------------------------------------------------错误的 - - - - - - - - - - - - - - - - - - - - - - - - --------------------##在GDS数据中读取#gdsfile <-system.file(“ extdata”,“ hapmap_asw_mxl_geno.ggds”,package =“ genesis”)#hapmap_geno <-gdsgenotypereader(fileName) = gdsfile) ## ----------------------------------------------------------------------------- # create a GenotypeData class object with paired ScanAnnotationDataFrame HapMap_genoData <- GenotypeData(HapMap_geno, scanAnnot = scanAnnot) HapMap_genoData ## ----------------------------------------------------------------------------- # mypcrel contains Kinship Estimates from a previous PC-Relate analysis myGRM <- pcrelateToMatrix(mypcrel) myGRM[1:5,1:5] ## ----------------------------------------------------------------------------- # fit the null mixed model nullmod <- fitNullModel(scanAnnot, outcome = "pheno", covars = "pc1", cov.mat = myGRM, family = "gaussian") ## ---- eval=FALSE-------------------------------------------------------------- # nullmod <- fitNullModel(scanAnnot, outcome = "pheno", # covars = c("pc1","pc2","sex","age"), # cov.mat = myGRM, family = "gaussian") ## ---- eval=FALSE-------------------------------------------------------------- # nullmod <- fitNullModel(scanAnnot, outcome = "pheno", covars = "pc1", # cov.mat = list("GRM" = myGRM, "House" = H), # family = "gaussian") ## ---- eval=FALSE-------------------------------------------------------------- # nullmod <- fitNullModel(scanAnnot, outcome = "pheno", covars = "pc1", # cov.mat = myGRM, family = "gaussian", # group.var = "study") ## ---- eval=FALSE-------------------------------------------------------------- # nullmod <- fitNullModel(scanAnnot, outcome = "pheno", covars = "pc1", # cov.mat = myGRM, family = "binomial") ## ----------------------------------------------------------------------------- genoIterator <- GenotypeBlockIterator(HapMap_genoData, snpBlock=5000) ## ----------------------------------------------------------------------------- assoc <- assocTestSingle(genoIterator, null.model = nullmod, BPPARAM = BiocParallel::SerialParam()) ## ---- eval = FALSE------------------------------------------------------------ # # mysnps is a vector of snpID values for the SNPs we want to test # genoIterator <- GenotypeBlockIterator(HapMap_genoData, snpInclude=mysnps) # assoc <- assocTestSingle(genoIterator, null.model = nullmod) ## ----------------------------------------------------------------------------- head(assoc) ## ----------------------------------------------------------------------------- varCompCI(nullmod, prop = TRUE) ## ---- echo=FALSE-------------------------------------------------------------- close(genoIterator)