view findDMR/findDMR.R @ 4:0d1957068766 draft

Uploaded
author testtool
date Mon, 20 Feb 2017 08:32:26 -0500
parents ca66a1487d4a
children 715d03e1fd83
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]

#GSMTable<-("test-data/input.csv")
TAB = fread(GSMTable)
#IlmnTable <- ("test-data/IlmnTable.csv")
IlmnInfo = fread(platform)
#gmTable<-("test-data/gmTable.csv")
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)


#DMR<-("test-data/DMR.bed")
write.table(
  DMRInfo,
  DMR,
  quote = F,
  sep = "\t",
  row.names = F,
  col.names = F
)