annotate annotate_peak/annotatePeak.R @ 19:741b192da59c draft

Uploaded
author testtool
date Mon, 20 Mar 2017 07:19:42 -0400
parents 6a9b9694acbf
children 2044ad2c1c93
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
ee3fc24b2108 Uploaded
testtool
parents: 15
diff changeset
1 require("ChIPseeker", quietly = TRUE)
ee3fc24b2108 Uploaded
testtool
parents: 15
diff changeset
2 require("ChIPpeakAnno", quietly = TRUE)
ee3fc24b2108 Uploaded
testtool
parents: 15
diff changeset
3 require("EnsDb.Hsapiens.v75", quietly = TRUE)
19
741b192da59c Uploaded
testtool
parents: 18
diff changeset
4 require("EnsDb.Mmusculus.v75", quietly = TRUE)
16
ee3fc24b2108 Uploaded
testtool
parents: 15
diff changeset
5
12
54e19bceff70 Uploaded
testtool
parents:
diff changeset
6 options(warn = -1)
17
982a01524118 Uploaded
testtool
parents: 16
diff changeset
7 options("download.file.method"="wget")
982a01524118 Uploaded
testtool
parents: 16
diff changeset
8
19
741b192da59c Uploaded
testtool
parents: 18
diff changeset
9 args <- commandArgs(trailingOnly = TRUE)
12
54e19bceff70 Uploaded
testtool
parents:
diff changeset
10 DMR = args[1]
19
741b192da59c Uploaded
testtool
parents: 18
diff changeset
11 annoData = args[2]
741b192da59c Uploaded
testtool
parents: 18
diff changeset
12 bindingType = args[3]
741b192da59c Uploaded
testtool
parents: 18
diff changeset
13 upstream = as.numeric(args[4])
741b192da59c Uploaded
testtool
parents: 18
diff changeset
14 downstream = as.numeric(args[5])
741b192da59c Uploaded
testtool
parents: 18
diff changeset
15 ignore = args[6]
741b192da59c Uploaded
testtool
parents: 18
diff changeset
16 annoPeakTable = args[7]
12
54e19bceff70 Uploaded
testtool
parents:
diff changeset
17
19
741b192da59c Uploaded
testtool
parents: 18
diff changeset
18 #DMR <- ("test-data/DMR.bed")
741b192da59c Uploaded
testtool
parents: 18
diff changeset
19 DMRInfo = read.table(
12
54e19bceff70 Uploaded
testtool
parents:
diff changeset
20 DMR,
54e19bceff70 Uploaded
testtool
parents:
diff changeset
21 header = FALSE,
54e19bceff70 Uploaded
testtool
parents:
diff changeset
22 sep = "\t",
54e19bceff70 Uploaded
testtool
parents:
diff changeset
23 stringsAsFactors = FALSE,
54e19bceff70 Uploaded
testtool
parents:
diff changeset
24 quote = ""
54e19bceff70 Uploaded
testtool
parents:
diff changeset
25 )
54e19bceff70 Uploaded
testtool
parents:
diff changeset
26
14
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
27 peaks <- GRanges(seqnames = DMRInfo[, 1],
12
54e19bceff70 Uploaded
testtool
parents:
diff changeset
28 ranges = IRanges
54e19bceff70 Uploaded
testtool
parents:
diff changeset
29 (start = DMRInfo[, 2], end = DMRInfo[, 3]))
17
982a01524118 Uploaded
testtool
parents: 16
diff changeset
30
19
741b192da59c Uploaded
testtool
parents: 18
diff changeset
31
741b192da59c Uploaded
testtool
parents: 18
diff changeset
32 if (annoData == "human"){
741b192da59c Uploaded
testtool
parents: 18
diff changeset
33 annoData <- toGRanges(EnsDb.Hsapiens.v75)
741b192da59c Uploaded
testtool
parents: 18
diff changeset
34 } else {
741b192da59c Uploaded
testtool
parents: 18
diff changeset
35 annoData <- toGRanges(EnsDb.Mmusculus.v75)
741b192da59c Uploaded
testtool
parents: 18
diff changeset
36 }
14
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
37 seqlevelsStyle(peaks) <- seqlevelsStyle(annoData)
17
982a01524118 Uploaded
testtool
parents: 16
diff changeset
38
19
741b192da59c Uploaded
testtool
parents: 18
diff changeset
39 if (ignore == "true"){
741b192da59c Uploaded
testtool
parents: 18
diff changeset
40 x <- TRUE
741b192da59c Uploaded
testtool
parents: 18
diff changeset
41 } else {
741b192da59c Uploaded
testtool
parents: 18
diff changeset
42 x <- FALSE
741b192da59c Uploaded
testtool
parents: 18
diff changeset
43 }
741b192da59c Uploaded
testtool
parents: 18
diff changeset
44
17
982a01524118 Uploaded
testtool
parents: 16
diff changeset
45
19
741b192da59c Uploaded
testtool
parents: 18
diff changeset
46 if (bindingType =="startSite"){
741b192da59c Uploaded
testtool
parents: 18
diff changeset
47 anno <- annoPeaks(peaks, annoData=annoData, bindingType =c("startSite"), bindingRegion=c(upstream, downstream), ignore.peak.strand = x)
741b192da59c Uploaded
testtool
parents: 18
diff changeset
48 } else if (bindingType =="endSite"){
741b192da59c Uploaded
testtool
parents: 18
diff changeset
49 anno <- annoPeaks(peaks, annoData=annoData, bindingType =c("endSite"), bindingRegion=c(upstream, downstream), ignore.peak.strand = x)
741b192da59c Uploaded
testtool
parents: 18
diff changeset
50 } else {
741b192da59c Uploaded
testtool
parents: 18
diff changeset
51 anno <- annoPeaks(peaks, annoData=annoData, bindingType =c("fullRange"), bindingRegion=c(upstream, downstream), ignore.peak.strand = x)
741b192da59c Uploaded
testtool
parents: 18
diff changeset
52 }
741b192da59c Uploaded
testtool
parents: 18
diff changeset
53
741b192da59c Uploaded
testtool
parents: 18
diff changeset
54
741b192da59c Uploaded
testtool
parents: 18
diff changeset
55 write.table(anno, annoPeakTable, row.names = FALSE)