require("IlluminaHumanMethylation450kanno.ilmn12.hg19", quietly = TRUE)
require("IlluminaHumanMethylation450kanno.ilmn12.hg19", quietly = TRUE)
require("minfi", quietly = TRUE)

options(warn = -1)
options("download.file.method"="wget")

args <- commandArgs(trailingOnly = TRUE)

input1 = args[1]
input2 = args[2]
output = args[3]

GRset <- get(load(input1))

pheno <- fread(input2)

designMatrix <- model.matrix(~ pheno$Phenotype)

dmrs <- bumphunter(GRset, design = designMatrix,
                   cutoff = 0.2, B=0, type="Beta")
write.table(dmrs, output)
