diff findDMR/findDMR.R @ 10:7df2b7d79391 draft

Uploaded
author testtool
date Thu, 11 May 2017 11:15:33 -0400
parents bae8d90853b7
children 24ac6f93cc3e
line wrap: on
line diff
--- a/findDMR/findDMR.R	Tue Apr 25 13:35:53 2017 -0400
+++ b/findDMR/findDMR.R	Thu May 11 11:15:33 2017 -0400
@@ -1,22 +1,39 @@
-require("IlluminaHumanMethylation450kanno.ilmn12.hg19", quietly = TRUE)
-require("data.table", quietly = TRUE)
-require("minfi", 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]
 
-options(warn = -1)
-options("download.file.method"="wget")
+TAB = fread(GSMTable)
+
+IlmnInfo = fread(platform)
 
-args <- commandArgs(trailingOnly = TRUE)
+gmSet = fread(Data_Table)
+
+# bumphunter Run with processed data
+designMatrix <- model.matrix( ~ TAB$Phenotype)
 
-input1 = args[1]
-input2 = args[2]
-output = args[3]
-
-GRset <- get(load(input1))
+bumps <- bumphunter(
+  as.matrix(gmSet),
+  design = designMatrix,
+  pos = IlmnInfo$BP,
+  cutoff = cutoff,
+  chr = IlmnInfo$CHR
+)
 
-pheno <- fread(input2)
+# 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)
 
-designMatrix <- model.matrix(~ pheno$Phenotype)
+
 
-dmrs <- bumphunter(GRset, design = designMatrix,
-                   cutoff = 0.2, B=0, type="Beta")
-write.table(dmrs, output)
+write.table(
+  DMRInfo,
+  DMR,
+  quote = F,
+  sep = "\t",
+  row.names = F,
+  col.names = F
+)