# # - - - - -设置,包括= FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - knitr:: opts_chunk设置美元(呼应= TRUE,缓存= FALSE) # #消息= FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -库(bsseq)库(MethCP) # #——readData - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # 6的数据集是由样本。3 H2A样本。Z突变体#植物,3样品控制。sample_names < - c (paste0(“控制”,seq_len (3)), paste0(“治疗”,seq_len(3))) #的矢量文件路径和名称raw_files < -系统。文件(“extdata paste0 (sample_names . txt),包=“MethCP”) #加载数据bs_object < - createBsseqObject(文件= raw_files sample_names = sample_names chr_col =“空空”,pos_col = Pos, m_col =“M”, cov_col = ' x ') # #——showBSobject - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bs_object # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - dt < -阅读。表(raw_files [1], stringsAsFactors = FALSE,头= TRUE)头(dt) # #——calcStat - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #的样品名称两组比较。他们应该的子集名称提供#样品在创建“bsseq”对象。group1 < - paste0(“控制”,seq_len (3) group2 < - paste0(“治疗”,seq_len(3) #下面我们计算per-cytosine统计使用两个不同的#测试“DSS”和“methylKit”。用户可以选择其中一个的#应用程序。obj_DSS < - calcLociStat (bs_object, group1 group2、测试= DSS) obj_methylKit < - calcLociStat (bs_object, group1 group2、测试=“methylKit”) # #——obj_DSS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - obj_DSS # #——obj_methylKit - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - obj_methylKit # #——createmethcp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -数据< - data.frame(对应=代表(“Chr01”, 5), pos = c(2、5、9、10、18),效果。大小= c (1, - 1, NA, 9日正),pvals = c (NA 0, 0.1, 0.9, 0.02)) obj < MethCPFromStat(数据、test.name =“myTest pvals。场= " pvals " effect.size.field =”效应。”,seqnames大小。场=“空空”,pos.field =“pos”) # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - obj # #——分割- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - obj_DSS < segmentMethCP (obj_DSS bs_object,地区。测试=“weighted-coverage”) obj_methylKit < segmentMethCP (obj_methylKit bs_object,地区。test = "fisher") ## ----------------------------------------------------------------------------- obj_DSS ## ----------------------------------------------------------------------------- obj_methylKit ## ----------------------------------------------------------------------------- region_DSS <- getSigRegion(obj_DSS) head(region_DSS) ## ----------------------------------------------------------------------------- region_methylKit <- getSigRegion(obj_methylKit) head(region_methylKit) ## ----------------------------------------------------------------------------- meta_file <- system.file( "extdata", "meta_data.txt", package = "MethCP") meta <- read.table(meta_file, sep = "\t", header = TRUE) head(meta) ## ----------------------------------------------------------------------------- # Get the vector of file path and names raw_files <- system.file( "extdata", paste0(meta$SampleName, ".tsv"), package = "MethCP") # read files bs_object <- createBsseqObject( files = raw_files, sample_names = meta$SampleName, chr_col = 1, pos_col = 2, m_col = 4, cov_col = 5, header = TRUE) ## ----------------------------------------------------------------------------- groups <- split(seq_len(nrow(meta)), meta$Condition) coverages <- as.data.frame(getCoverage(bs_object, type = "Cov")) filter <- rowSums(coverages[, meta$SampleName[groups[[1]]]] != 0) >= 3 & rowSums(coverages[, meta$SampleName[groups[[2]]]] != 0) >= 3 bs_object <- bs_object[filter, ] ## ----------------------------------------------------------------------------- obj <- calcLociStatTimeCourse(bs_object, meta) ## ----------------------------------------------------------------------------- obj ## ----------------------------------------------------------------------------- obj <- segmentMethCP(obj, bs_object, region.test = "stouffer") ## ----------------------------------------------------------------------------- regions <- getSigRegion(obj) ## ----------------------------------------------------------------------------- head(regions) ## ----------------------------------------------------------------------------- sessionInfo()