Mercurial > repos > bgruening > diffbind
comparison diffbind.R @ 7:681dedc42aca draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/diffbind commit affbc59222cde9be21e91fa1f9194930a070b830
author | iuc |
---|---|
date | Sun, 28 Jan 2018 04:26:11 -0500 |
parents | 9e9f85c20d99 |
children |
comparison
equal
deleted
inserted
replaced
6:6031247f61d4 | 7:681dedc42aca |
---|---|
1 ## Setup R error handling to go to stderr | 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 ) } ) | 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. | 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") | 4 Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") |
5 | 5 |
6 library('getopt'); | 6 suppressPackageStartupMessages({ |
7 library('getopt') | |
8 library('DiffBind') | |
9 }) | |
10 | |
7 options(stringAsfactors = FALSE, useFancyQuotes = FALSE) | 11 options(stringAsfactors = FALSE, useFancyQuotes = FALSE) |
8 args <- commandArgs(trailingOnly = TRUE) | 12 args <- commandArgs(trailingOnly = TRUE) |
9 | 13 |
10 #get options, using the spec as defined by the enclosed list. | 14 #get options, using the spec as defined by the enclosed list. |
11 #we read the options from the default: commandArgs(TRUE). | 15 #we read the options from the default: commandArgs(TRUE). |
13 'verbose', 'v', 2, "integer", | 17 'verbose', 'v', 2, "integer", |
14 'help' , 'h', 0, "logical", | 18 'help' , 'h', 0, "logical", |
15 'outfile' , 'o', 1, "character", | 19 'outfile' , 'o', 1, "character", |
16 'plots' , 'p', 2, "character", | 20 'plots' , 'p', 2, "character", |
17 'infile' , 'i', 1, "character", | 21 'infile' , 'i', 1, "character", |
18 'format', 'f', 1, 'character' | 22 'format', 'f', 1, "character", |
23 'th', 't', 1, "double", | |
24 'bmatrix', 'b', 0, "logical" | |
19 ), byrow=TRUE, ncol=4); | 25 ), byrow=TRUE, ncol=4); |
20 | 26 |
21 opt = getopt(spec); | 27 opt = getopt(spec); |
22 | 28 |
23 # if help was asked for print a friendly message | 29 # if help was asked for print a friendly message |
25 if ( !is.null(opt$help) ) { | 31 if ( !is.null(opt$help) ) { |
26 cat(getopt(spec, usage=TRUE)); | 32 cat(getopt(spec, usage=TRUE)); |
27 q(status=1); | 33 q(status=1); |
28 } | 34 } |
29 | 35 |
30 library('DiffBind') | |
31 | |
32 if ( !is.null(opt$plots) ) { | 36 if ( !is.null(opt$plots) ) { |
33 pdf(opt$plots) | 37 pdf(opt$plots) |
34 } | 38 } |
35 | |
36 | 39 |
37 sample = dba(sampleSheet=opt$infile, peakFormat='bed') | 40 sample = dba(sampleSheet=opt$infile, peakFormat='bed') |
38 sample_count = dba.count(sample) | 41 sample_count = dba.count(sample) |
39 sample_contrast = dba.contrast(sample_count, categories=DBA_CONDITION, minMembers=2) | 42 sample_contrast = dba.contrast(sample_count, categories=DBA_CONDITION, minMembers=2) |
40 sample_analyze = dba.analyze(sample_contrast) | 43 sample_analyze = dba.analyze(sample_contrast) |
42 orvals = dba.plotHeatmap(sample_analyze, contrast=1, correlations=FALSE) | 45 orvals = dba.plotHeatmap(sample_analyze, contrast=1, correlations=FALSE) |
43 | 46 |
44 resSorted <- diff_bind[order(diff_bind$FDR),] | 47 resSorted <- diff_bind[order(diff_bind$FDR),] |
45 write.table(as.data.frame(resSorted), file = opt$outfile, sep="\t", quote = FALSE, append=TRUE, row.names = FALSE, col.names = FALSE) | 48 write.table(as.data.frame(resSorted), file = opt$outfile, sep="\t", quote = FALSE, append=TRUE, row.names = FALSE, col.names = FALSE) |
46 | 49 |
50 # Output binding affinity scores | |
51 if (!is.null(opt$bmatrix)) { | |
52 bmat <- dba.peakset(sample_count, bRetrieve=TRUE, DataType=DBA_DATA_FRAME) | |
53 write.table(as.data.frame(bmat), file="bmatrix.tab", sep="\t", quote=FALSE, row.names=FALSE, col.names=FALSE) | |
54 } | |
47 | 55 |
48 dev.off() | 56 dev.off() |
49 sessionInfo() | 57 sessionInfo() |