annotate annotate_peak/annotatePeak.R @ 20:2044ad2c1c93 draft default tip

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