## ------------------------------------------------------------------------------------------------------------------ cpgset = list( chr1 = c(12L, 57L, 123L), chr2 = c(45L, 95L, 99L, 111L), chr3 = c(22L, 40L, 199L, 211L)) ## ----loadPackages, echo=FALSE, warning=FALSE, message=FALSE------------------- suppressPackageStartupMessages(library(ramwas))suppresspackagestArtupMessages(库(bsgenome.ecoli.ncbi.20080805))## ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------图书馆(Ramwas)图书馆(BSGENOME.ECOLI.NCBI.20080805)CPGSET = GETCPGSETCG(BSGENOME.ECOLI.NCBI.200808055)#第一个10 CPGS在NC_008253中:print(CPGSET $ NC__008253):10])## ---- getCpgSetAll1,eval = false,parning = false,message = false -------------------------------#library(bsgenome.hsapiens.ucsc。hg19)#library(snplocs.hsapiens.dbsnp144.grch37)#genome = injectSnps(hsapiens,“ snplocs.hsapiens.dbsnp144.grch37”)#cpggset = getcpgsetall(genome)#(sapply(cpgset [1:22],长度))## ---- echo = falSE ------------------------------------------------------------------------------------------- 42841152 ## -------------------------------------------------------------------------------------------------------------------------------------------------------------------#基因组[[“ CHR22”] =#injectsnpsmaf(#genSequence = bsgenome [[“ Chr22”],#frqcount =“ count_all_chr22.txt”,#maf = 0.01)###找到CPGS#CPGSET = getCPGSETALL(GETCPGSETALL(GENOME)## --------- save1,eart = false = false --------------------------------------------------------------------------------------------------------------------------------------- # saveRDS(file = "My_cpgset.rds", object = cpgset) ## ----insilicoFASTQ, eval=FALSE------------------------------------------------ # # Do for all chromosomes # insilicoFASTQ( # con="chr1.fastq.gz", # gensequence = BSGenome[["chr1"]], # fraglength=75) ## ----RaMWAS, eval=FALSE------------------------------------------------------- # library(ramwas) # chrset = paste0("chr",1:22) # targetcov = 75 # covtolerance = 10 # # param = ramwasParameters( # dirproject = ".", # dirbam = "./bams", # dirfilter = TRUE, # bamnames = chrset, # bam2sample = list(all_samples = chrset), # scoretag = "AS", # minscore = 100, # minfragmentsize = targetcov, # maxfragmentsize = targetcov, # minavgcpgcoverage = 0, # minnonzerosamples = 0, # # filecpgset - file with the CpG set being QC-ed # filecpgset = filecpgset # ) # param1 = parameterPreprocess(param) # ramwas1scanBams(param) # ramwas3normalizedCoverage(param) ## ----filter, eval=FALSE------------------------------------------------------- # # Preprocess parameters to learn the location of coverage matrix # param1 = parameterPreprocess(param) # # # Load the coverage matrix (vector) # cover = fm.load( paste0(param1$dircoveragenorm, "/Coverage")) # # # split the coverage by chromosomes # # `cpgset` - the CpG set being QC-ed # fac = rep(seq_along(cpgset), times = sapply(cpgset, length)) # levels(fac) = names(cpgset) # class(fac) = "factor" # cover = split(cover, fac) # # # filter CpGs on each chromosome by the coverage # cpgsetQC = cpgset # for( i in seq_along(cpgset) ){ # keep = # (cover[[i]] >= (targetcov - covtolerance)) & # (cover[[i]] <= (targetcov + covtolerance)) # cpgsetQC[[i]] = cpgset[[i]][ keep ] # } ## ----save2, eval=FALSE-------------------------------------------------------- # saveRDS(file = "My_cpgset_QC.rds", object = cpgsetQC)