annotate diffbind.R @ 11:4c7ab9995f9e draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
author iuc
date Sat, 07 Apr 2018 15:45:41 -0400
parents d7725c5596ab
children 1de83981d43c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
1 ## Setup R error handling to go to stderr
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
2 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
3 # we need that to not crash galaxy with an UTF8 error on German LC settings.
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
4 Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
5
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
6 suppressPackageStartupMessages({
11
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
7 library('getopt')
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
8 library('DiffBind')
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
9 library('rjson')
9
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
10 })
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
11
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
12 options(stringAsfactors = FALSE, useFancyQuotes = FALSE)
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
13 args <- commandArgs(trailingOnly = TRUE)
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
14
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
15 #get options, using the spec as defined by the enclosed list.
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
16 #we read the options from the default: commandArgs(TRUE).
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
17 spec = matrix(c(
11
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
18 'infile' , 'i', 1, "character",
9
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
19 'outfile' , 'o', 1, "character",
11
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
20 'scorecol', 'n', 1, "integer",
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
21 'lowerbetter', 'l', 1, "logical",
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
22 'summits', 's', 1, "integer",
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
23 'th', 't', 1, "double",
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
24 'format', 'f', 1, "character",
9
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
25 'plots' , 'p', 2, "character",
10
d7725c5596ab planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit f970dcbe9d0e4c3714b1db74c404ea34223cf8ed
iuc
parents: 9
diff changeset
26 'bmatrix', 'b', 0, "logical",
11
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
27 "rdaOpt", "r", 0, "logical",
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
28 'infoOpt' , 'a', 0, "logical",
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
29 'verbose', 'v', 2, "integer",
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
30 'help' , 'h', 0, "logical"
9
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
31 ), byrow=TRUE, ncol=4);
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
32
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
33 opt = getopt(spec);
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
34
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
35 # if help was asked for print a friendly message
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
36 # and exit with a non-zero error code
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
37 if ( !is.null(opt$help) ) {
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
38 cat(getopt(spec, usage=TRUE));
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
39 q(status=1);
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
40 }
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
41
11
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
42 parser <- newJSONParser()
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
43 parser$addData(opt$infile)
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
44 factorList <- parser$getObject()
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
45 filenamesIn <- unname(unlist(factorList[[1]][[2]]))
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
46 peaks <- filenamesIn[grepl("peaks.bed", filenamesIn)]
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
47 bams <- filenamesIn[grepl("bamreads.bam", filenamesIn)]
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
48 ctrls <- filenamesIn[grepl("bamcontrol.bam", filenamesIn)]
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
49
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
50 # get the group and sample id from the peaks filenames
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
51 groups <- sapply(strsplit(peaks,"-"), `[`, 1)
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
52 samples <- sapply(strsplit(peaks,"-"), `[`, 2)
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
53
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
54 if ( length(ctrls) != 0 ) {
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
55 sampleTable <- data.frame(SampleID=samples,
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
56 Condition=groups,
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
57 bamReads=bams,
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
58 bamControl=ctrls,
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
59 Peaks=peaks,
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
60 Tissue=samples, # using "Tissue" column to display ids as labels in PCA plot
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
61 stringsAsFactors=FALSE)
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
62 } else {
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
63 sampleTable <- data.frame(SampleID=samples,
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
64 Replicate=samples,
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
65 Condition=groups,
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
66 bamReads=bams,
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
67 Peaks=peaks,
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
68 Tissue=samples,
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
69 stringsAsFactors=FALSE)
9
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
70 }
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
71
11
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
72 sample = dba(sampleSheet=sampleTable, peakFormat='bed', scoreCol=opt$scorecol, bLowerScoreBetter=opt$lowerbetter)
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
73
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
74 if ( !is.null(opt$summits) ) {
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
75 sample_count = dba.count(sample, summits=opt$summits)
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
76 } else {
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
77 sample_count = dba.count(sample)
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
78 }
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
79
9
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
80 sample_contrast = dba.contrast(sample_count, categories=DBA_CONDITION, minMembers=2)
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
81 sample_analyze = dba.analyze(sample_contrast)
11
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
82 diff_bind = dba.report(sample_analyze, th=opt$th)
9
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
83
11
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
84 # Generate plots
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
85 if ( !is.null(opt$plots) ) {
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
86 pdf(opt$plots)
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
87 orvals = dba.plotHeatmap(sample_analyze, contrast=1, correlations=FALSE, cexCol=0.8, th=opt$th)
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
88 dba.plotPCA(sample_analyze, contrast=1, th=opt$th, label=DBA_TISSUE, labelSize=0.3)
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
89 dba.plotMA(sample_analyze, th=opt$th)
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
90 dba.plotVolcano(sample_analyze, th=opt$th)
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
91 dba.plotBox(sample_analyze, th=opt$th)
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
92 dev.off()
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
93 }
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
94
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
95 # Output differential binding sites
9
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
96 resSorted <- diff_bind[order(diff_bind$FDR),]
11
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
97 write.table(as.data.frame(resSorted), file = opt$outfile, sep="\t", quote = FALSE, append=TRUE, row.names = FALSE)
9
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
98
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
99 # Output binding affinity scores
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
100 if (!is.null(opt$bmatrix)) {
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
101 bmat <- dba.peakset(sample_count, bRetrieve=TRUE, DataType=DBA_DATA_FRAME)
11
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
102 write.table(as.data.frame(bmat), file="bmatrix.tab", sep="\t", quote=FALSE, row.names=FALSE)
9
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
103 }
6171163112de planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit 9de99de5fb4c62f889814ea43b8800ce8d28eb83
iuc
parents:
diff changeset
104
11
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
105 # Output RData file
10
d7725c5596ab planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit f970dcbe9d0e4c3714b1db74c404ea34223cf8ed
iuc
parents: 9
diff changeset
106 if (!is.null(opt$rdaOpt)) {
d7725c5596ab planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit f970dcbe9d0e4c3714b1db74c404ea34223cf8ed
iuc
parents: 9
diff changeset
107 save.image(file = "DiffBind_analysis.RData")
d7725c5596ab planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit f970dcbe9d0e4c3714b1db74c404ea34223cf8ed
iuc
parents: 9
diff changeset
108 }
d7725c5596ab planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit f970dcbe9d0e4c3714b1db74c404ea34223cf8ed
iuc
parents: 9
diff changeset
109
11
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
110 # Output analysis info
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
111 if (!is.null(opt$infoOpt)) {
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
112 info <- "DiffBind_analysis_info.txt"
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
113 cat("dba.count Info\n\n", file=info, append = TRUE)
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
114 capture.output(sample, file=info, append=TRUE)
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
115 cat("\ndba.analyze Info\n\n", file=info, append = TRUE)
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
116 capture.output(sample_analyze, file=info, append=TRUE)
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
117 cat("\nSessionInfo\n\n", file=info, append = TRUE)
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
118 capture.output(sessionInfo(), file=info, append=TRUE)
4c7ab9995f9e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/diffbind commit cc4c1c4131518b9cbf986a1f252767ff73ca938e
iuc
parents: 10
diff changeset
119 }