Mercurial > repos > testtool > annotate_peak
comparison annotate_peak/annotatePeak.R @ 19:741b192da59c draft
Uploaded
author | testtool |
---|---|
date | Mon, 20 Mar 2017 07:19:42 -0400 |
parents | 6a9b9694acbf |
children | 2044ad2c1c93 |
comparison
equal
deleted
inserted
replaced
18:6a9b9694acbf | 19:741b192da59c |
---|---|
1 require("ChIPseeker", quietly = TRUE) | 1 require("ChIPseeker", quietly = TRUE) |
2 require("ChIPpeakAnno", quietly = TRUE) | 2 require("ChIPpeakAnno", quietly = TRUE) |
3 require("EnsDb.Hsapiens.v75", quietly = TRUE) | 3 require("EnsDb.Hsapiens.v75", quietly = TRUE) |
4 require("data.table", quietly = TRUE) | 4 require("EnsDb.Mmusculus.v75", quietly = TRUE) |
5 | 5 |
6 options(warn = -1) | 6 options(warn = -1) |
7 options("download.file.method"="wget") | 7 options("download.file.method"="wget") |
8 | 8 |
9 args <- commandArgs(trailingOnly = TRUE) | 9 args <- commandArgs(trailingOnly = TRUE) |
10 DMR = args[1] | 10 DMR = args[1] |
11 annoPeakTable = args[2] | 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 |
13 DMRInfo = fread( | 18 #DMR <- ("test-data/DMR.bed") |
19 DMRInfo = read.table( | |
14 DMR, | 20 DMR, |
15 header = FALSE, | 21 header = FALSE, |
16 sep = "\t", | 22 sep = "\t", |
17 stringsAsFactors = FALSE, | 23 stringsAsFactors = FALSE, |
18 quote = "" | 24 quote = "" |
20 | 26 |
21 peaks <- GRanges(seqnames = DMRInfo[, 1], | 27 peaks <- GRanges(seqnames = DMRInfo[, 1], |
22 ranges = IRanges | 28 ranges = IRanges |
23 (start = DMRInfo[, 2], end = DMRInfo[, 3])) | 29 (start = DMRInfo[, 2], end = DMRInfo[, 3])) |
24 | 30 |
25 annoData <- toGRanges(EnsDb.Hsapiens.v75) | 31 |
32 if (annoData == "human"){ | |
33 annoData <- toGRanges(EnsDb.Hsapiens.v75) | |
34 } else { | |
35 annoData <- toGRanges(EnsDb.Mmusculus.v75) | |
36 } | |
26 seqlevelsStyle(peaks) <- seqlevelsStyle(annoData) | 37 seqlevelsStyle(peaks) <- seqlevelsStyle(annoData) |
27 | 38 |
28 anno <- annoPeaks(peaks, annoData=annoData,bindingType ="startSite") | 39 if (ignore == "true"){ |
40 x <- TRUE | |
41 } else { | |
42 x <- FALSE | |
43 } | |
44 | |
45 | |
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 | |
29 | 54 |
30 write.table(anno, annoPeakTable, row.names = FALSE) | 55 write.table(anno, annoPeakTable, row.names = FALSE) |