Mercurial > repos > bgruening > diffbind
comparison diffbind.R @ 0:8d48d5591389 draft
Uploaded
author | bgruening |
---|---|
date | Mon, 13 Jan 2014 17:20:14 -0500 |
parents | |
children | fa67bcb732f6 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:8d48d5591389 |
---|---|
1 ## Setup R error handling to go to stderr | |
2 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) | |
3 # we need that to not crash galaxy with an UTF8 error on German LC settings. | |
4 Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") | |
5 | |
6 library('getopt'); | |
7 options(stringAsfactors = FALSE, useFancyQuotes = FALSE) | |
8 args <- commandArgs(trailingOnly = TRUE) | |
9 | |
10 #get options, using the spec as defined by the enclosed list. | |
11 #we read the options from the default: commandArgs(TRUE). | |
12 spec = matrix(c( | |
13 'verbose', 'v', 2, "integer", | |
14 'help' , 'h', 0, "logical", | |
15 'outfile' , 'o', 1, "character", | |
16 'plots' , 'p', 2, "character", | |
17 'infile' , 'i', 1, "character", | |
18 'format', 'f', 1, 'character', | |
19 ), byrow=TRUE, ncol=4); | |
20 opt = getopt(spec); | |
21 | |
22 # if help was asked for print a friendly message | |
23 # and exit with a non-zero error code | |
24 if ( !is.null(opt$help) ) { | |
25 cat(getopt(spec, usage=TRUE)); | |
26 q(status=1); | |
27 } | |
28 | |
29 | |
30 library(DiffBind) | |
31 # used to save to BED, GFF or WIG format | |
32 library(rtracklayer) | |
33 | |
34 if ( !is.null(opt$plots) ) { | |
35 pdf(opt$plots) | |
36 } | |
37 | |
38 | |
39 sample = dba(sampleSheet=opt$infile) | |
40 sample_count = dba.count(sample) | |
41 sample_contrast = dba.contrast(sample_count, categories=DBA_CONDITION) | |
42 sample_analyze = dba.analyze(sample_contrast) | |
43 diff_bind = dba.report(sample_analyze) | |
44 | |
45 | |
46 export(diff_bind, opt$outfile, format=opt$format) | |
47 | |
48 dev.off() | |
49 sessionInfo() |