annotate findDMR/findDMR.R @ 12:083895dbc289 draft

Uploaded
author testtool
date Mon, 12 Jun 2017 11:05:04 -0400
parents 24ac6f93cc3e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
1 require("minfi", quietly = TRUE)
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
2
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
3 options(warn = -1)
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
4 options("download.file.method"="wget")
11
24ac6f93cc3e Uploaded
testtool
parents: 10
diff changeset
5
10
7df2b7d79391 Uploaded
testtool
parents: 9
diff changeset
6 args <- commandArgs(trailingOnly = TRUE)
12
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
7 input1 = args[1]
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
8 input2 = args[2]
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
9 cutoff = as.numeric(args[3])
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
10 B = as.numeric(args[4])
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
11 pickCutoffQ = as.numeric(args[5])
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
12 output1 = args[6]
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
13 output2 = args[7]
0
ca66a1487d4a Uploaded
testtool
parents:
diff changeset
14
12
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
15 GRset <- get(load(input1))
0
ca66a1487d4a Uploaded
testtool
parents:
diff changeset
16
12
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
17 pheno <- fread(input2)
10
7df2b7d79391 Uploaded
testtool
parents: 9
diff changeset
18
12
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
19 designMatrix <- model.matrix(~ pheno$Phenotype)
0
ca66a1487d4a Uploaded
testtool
parents:
diff changeset
20
12
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
21 dmrs <- bumphunter(GRset, design = designMatrix,
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
22 cutoff =cutoff, B=B, type="Beta", pickCutoff=TRUE,
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
23 pickCutoffQ=pickCutoffQ)
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
24
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
25 DMRTable <- dmrs$table
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
26
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
27 write.table(DMRTable, output1)
0
ca66a1487d4a Uploaded
testtool
parents:
diff changeset
28
12
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
29 sign=sign(DMRTable$value)
10
7df2b7d79391 Uploaded
testtool
parents: 9
diff changeset
30
12
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
31 sign[sign==-1]="-"
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
32 sign[sign==1]="+"
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
33
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
34 dmr_track<-cbind(as.character(DMRTable$chr),DMRTable$start,DMRTable$end,sign)
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
35
083895dbc289 Uploaded
testtool
parents: 11
diff changeset
36 write.table(dmr_track,output2,quote = FALSE, sep = "\t\t\t\t",row.names = FALSE, col.names = FALSE,append=TRUE)