forked from uhkniazi/dismiss
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdismiss_macs2_extractor.R
42 lines (30 loc) · 1.2 KB
/
dismiss_macs2_extractor.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File: dismiss_macs2_extractor.R
# Auth: [email protected], [email protected]
# DESC: main script called from command line
# 1 - takes excel file name and bam file names are command line arguments
# arg1 = excel file name
# arg2 = bam file name (index file for bam should be in same directory)
# arg3 = p (for paired end data) or s (for single end data)
# Date: 24/10/2014
# get command line arguments
args = commandArgs(trailingOnly = TRUE)
csHelp = 'Run script with: \nRscript dismiss_macs2_extractor.R MACS2_result.xls File.bam File.bai [p or s]'
# check argument size
if (args[1] == 'h' || args[1] == 'help' || length(args) != 4) stop(paste(csHelp))
# variable setting and some error checking
macs = args[1]
bam = args[2]
bai = args[3]
paired = NA
if (args[4] == 'p') { paired = TRUE
} else if (args[4] == 's') paired = FALSE
if (is.na(paired)) stop(paste(csHelp))
# header file with functions
source(file='dismiss_header.R')
oGRdismiss = f_oGRMACS2toGRanges(macs)
oGRdismiss = f_oGRSeparateStrands(oGRdismiss, bam, bai, paired)
# save output to granges object
name.out = paste('oGRdismiss.rds', sep='')
save(oGRdismiss, file = name.out)
# save output as gff3 files
f_WriteGff3(oGRdismiss)