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