view findDMR/findDMR.R @ 5:715d03e1fd83 draft

Uploaded
author testtool
date Mon, 20 Mar 2017 06:51:59 -0400
parents 0d1957068766
children a0e3f4efb03f
line wrap: on
line source

require("minfi", quietly = TRUE)
require("ChIPseeker", quietly = TRUE)
require("ChIPpeakAnno", quietly = TRUE)
require("data.table", quietly = TRUE)


args <- commandArgs(trailingOnly = TRUE)
GSMTable = args[1]
platform = args[2]
Data_Table = args[3]
cutoff = as.numeric(args[4])
clusterSize = as.numeric(args[5])
DMR = args[6]

TAB = fread(GSMTable)

IlmnInfo = fread(platform)

gmSet = fread(Data_Table)

# bumphunter Run with processed data
designMatrix <- model.matrix( ~ TAB$Phenotype)

bumps <- bumphunter(
  as.matrix(gmSet),
  design = designMatrix,
  pos = IlmnInfo$BP,
  cutoff = cutoff,
  chr = IlmnInfo$CHR
)

# choose DMR's of a certain length threshold
DMRTable <- bumps$table[which(bumps$table$L >= clusterSize), ]
DMRInfo <- data.table(DMRTable$chr, DMRTable$start, DMRTable$end)



write.table(
  DMRInfo,
  DMR,
  quote = F,
  sep = "\t",
  row.names = F,
  col.names = F
)