16
|
1 require("ChIPpeakAnno", quietly = TRUE)
|
|
2 require("EnsDb.Hsapiens.v75", quietly = TRUE)
|
19
|
3 require("EnsDb.Mmusculus.v75", quietly = TRUE)
|
16
|
4
|
12
|
5 options(warn = -1)
|
17
|
6 options("download.file.method"="wget")
|
|
7
|
19
|
8 args <- commandArgs(trailingOnly = TRUE)
|
12
|
9 DMR = args[1]
|
19
|
10 annoData = args[2]
|
|
11 bindingType = args[3]
|
|
12 upstream = as.numeric(args[4])
|
|
13 downstream = as.numeric(args[5])
|
|
14 ignore = args[6]
|
|
15 annoPeakTable = args[7]
|
12
|
16
|
19
|
17 #DMR <- ("test-data/DMR.bed")
|
|
18 DMRInfo = read.table(
|
12
|
19 DMR,
|
|
20 header = FALSE,
|
|
21 sep = "\t",
|
|
22 stringsAsFactors = FALSE,
|
|
23 quote = ""
|
|
24 )
|
|
25
|
14
|
26 peaks <- GRanges(seqnames = DMRInfo[, 1],
|
12
|
27 ranges = IRanges
|
|
28 (start = DMRInfo[, 2], end = DMRInfo[, 3]))
|
17
|
29
|
19
|
30
|
|
31 if (annoData == "human"){
|
|
32 annoData <- toGRanges(EnsDb.Hsapiens.v75)
|
|
33 } else {
|
|
34 annoData <- toGRanges(EnsDb.Mmusculus.v75)
|
|
35 }
|
14
|
36 seqlevelsStyle(peaks) <- seqlevelsStyle(annoData)
|
17
|
37
|
19
|
38 if (ignore == "true"){
|
|
39 x <- TRUE
|
|
40 } else {
|
|
41 x <- FALSE
|
|
42 }
|
|
43
|
17
|
44
|
19
|
45 if (bindingType =="startSite"){
|
|
46 anno <- annoPeaks(peaks, annoData=annoData, bindingType =c("startSite"), bindingRegion=c(upstream, downstream), ignore.peak.strand = x)
|
|
47 } else if (bindingType =="endSite"){
|
|
48 anno <- annoPeaks(peaks, annoData=annoData, bindingType =c("endSite"), bindingRegion=c(upstream, downstream), ignore.peak.strand = x)
|
|
49 } else {
|
|
50 anno <- annoPeaks(peaks, annoData=annoData, bindingType =c("fullRange"), bindingRegion=c(upstream, downstream), ignore.peak.strand = x)
|
|
51 }
|
|
52
|
|
53
|
|
54 write.table(anno, annoPeakTable, row.names = FALSE)
|