annotate annotate_peak/annotatePeak.R @ 16:ee3fc24b2108 draft

Uploaded
author testtool
date Thu, 16 Mar 2017 11:23:38 -0400
parents 53df7871db21
children 982a01524118
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)
ee3fc24b2108 Uploaded
testtool
parents: 15
diff changeset
4 require("GenomicRanges", quietly = TRUE)
ee3fc24b2108 Uploaded
testtool
parents: 15
diff changeset
5
12
54e19bceff70 Uploaded
testtool
parents:
diff changeset
6 options(warn = -1)
54e19bceff70 Uploaded
testtool
parents:
diff changeset
7 args <- commandArgs(trailingOnly = TRUE)
54e19bceff70 Uploaded
testtool
parents:
diff changeset
8 DMR = args[1]
54e19bceff70 Uploaded
testtool
parents:
diff changeset
9 annoPeakTable = args[2]
54e19bceff70 Uploaded
testtool
parents:
diff changeset
10
15
53df7871db21 Uploaded
testtool
parents: 14
diff changeset
11 #DMR <- ("test-data/DMR.bed")
12
54e19bceff70 Uploaded
testtool
parents:
diff changeset
12 DMRInfo = read.table(
54e19bceff70 Uploaded
testtool
parents:
diff changeset
13 DMR,
54e19bceff70 Uploaded
testtool
parents:
diff changeset
14 header = FALSE,
54e19bceff70 Uploaded
testtool
parents:
diff changeset
15 sep = "\t",
54e19bceff70 Uploaded
testtool
parents:
diff changeset
16 stringsAsFactors = FALSE,
54e19bceff70 Uploaded
testtool
parents:
diff changeset
17 quote = ""
54e19bceff70 Uploaded
testtool
parents:
diff changeset
18 )
54e19bceff70 Uploaded
testtool
parents:
diff changeset
19
14
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
20 peaks <- GRanges(seqnames = DMRInfo[, 1],
12
54e19bceff70 Uploaded
testtool
parents:
diff changeset
21 ranges = IRanges
54e19bceff70 Uploaded
testtool
parents:
diff changeset
22 (start = DMRInfo[, 2], end = DMRInfo[, 3]))
14
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
23 peaks[1:2]
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
24 annoData <- toGRanges(EnsDb.Hsapiens.v75)
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
25 annoData[1:2]
12
54e19bceff70 Uploaded
testtool
parents:
diff changeset
26
14
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
27 ## keep the seqnames in the same style
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
28 seqlevelsStyle(peaks) <- seqlevelsStyle(annoData)
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
29 ## do annotation by nearest TSS
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
30 anno <- annotatePeakInBatch(peaks, AnnotationData=annoData)
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
31 anno[1:2]
15
53df7871db21 Uploaded
testtool
parents: 14
diff changeset
32 #annoPeakTable <- ('test-data/ChIPPeak.csv')
14
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
33 write.csv(anno, annoPeakTable, row.names = FALSE)
12
54e19bceff70 Uploaded
testtool
parents:
diff changeset
34
14
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
35