annotate annotate_peak/annotatePeak.R @ 15:53df7871db21 draft

Uploaded
author testtool
date Thu, 16 Mar 2017 11:03:24 -0400
parents 4a489b0d247f
children ee3fc24b2108
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
54e19bceff70 Uploaded
testtool
parents:
diff changeset
1 options(warn = -1)
54e19bceff70 Uploaded
testtool
parents:
diff changeset
2 args <- commandArgs(trailingOnly = TRUE)
54e19bceff70 Uploaded
testtool
parents:
diff changeset
3 DMR = args[1]
54e19bceff70 Uploaded
testtool
parents:
diff changeset
4 annoPeakTable = args[2]
54e19bceff70 Uploaded
testtool
parents:
diff changeset
5
15
53df7871db21 Uploaded
testtool
parents: 14
diff changeset
6 #DMR <- ("test-data/DMR.bed")
12
54e19bceff70 Uploaded
testtool
parents:
diff changeset
7 DMRInfo = read.table(
54e19bceff70 Uploaded
testtool
parents:
diff changeset
8 DMR,
54e19bceff70 Uploaded
testtool
parents:
diff changeset
9 header = FALSE,
54e19bceff70 Uploaded
testtool
parents:
diff changeset
10 sep = "\t",
54e19bceff70 Uploaded
testtool
parents:
diff changeset
11 stringsAsFactors = FALSE,
54e19bceff70 Uploaded
testtool
parents:
diff changeset
12 quote = ""
54e19bceff70 Uploaded
testtool
parents:
diff changeset
13 )
54e19bceff70 Uploaded
testtool
parents:
diff changeset
14
14
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
15 peaks <- GRanges(seqnames = DMRInfo[, 1],
12
54e19bceff70 Uploaded
testtool
parents:
diff changeset
16 ranges = IRanges
54e19bceff70 Uploaded
testtool
parents:
diff changeset
17 (start = DMRInfo[, 2], end = DMRInfo[, 3]))
14
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
18 peaks[1:2]
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
19 ## try http:// if https:// URLs are not supported
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
20 source("https://bioconductor.org/biocLite.R")
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
21 biocLite("EnsDb.Hsapiens.v75")
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
22 library(EnsDb.Hsapiens.v75)
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
23 annoData <- toGRanges(EnsDb.Hsapiens.v75)
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
24 annoData[1:2]
12
54e19bceff70 Uploaded
testtool
parents:
diff changeset
25
14
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
26 ## keep the seqnames in the same style
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
27 seqlevelsStyle(peaks) <- seqlevelsStyle(annoData)
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
28 ## do annotation by nearest TSS
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
29 anno <- annotatePeakInBatch(peaks, AnnotationData=annoData)
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
30 anno[1:2]
15
53df7871db21 Uploaded
testtool
parents: 14
diff changeset
31 #annoPeakTable <- ('test-data/ChIPPeak.csv')
14
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
32 write.csv(anno, annoPeakTable, row.names = FALSE)
12
54e19bceff70 Uploaded
testtool
parents:
diff changeset
33
14
4a489b0d247f Uploaded
testtool
parents: 13
diff changeset
34