Mercurial > repos > iuc > deseq2
annotate deseq2.R @ 24:71bacea10eee draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 29f5fd6ec10122f7b241c8d36d648b105ed4275a"
author | iuc |
---|---|
date | Sat, 29 Feb 2020 17:08:08 -0500 |
parents | a6fc9228e1a0 |
children | de44f8eff84a |
rev | line source |
---|---|
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
1 #!/usr/bin/env Rscript |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
2 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
3 # A command-line interface to DESeq2 for use with Galaxy |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
4 # written by Bjoern Gruening and modified by Michael Love 2016.03.30 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
5 # |
14
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
6 # This argument is required: |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
7 # |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
8 # 'factors' a JSON list object from Galaxy |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
9 # |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
10 # the output file has columns: |
15
9a616afdbda5
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 83eb5b2665d87c02b270596f8175499e69061032
iuc
parents:
14
diff
changeset
|
11 # |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
12 # baseMean (mean normalized count) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
13 # log2FoldChange (by default a moderated LFC estimate) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
14 # lfcSE (the standard error) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
15 # stat (the Wald statistic) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
16 # pvalue (p-value from comparison of Wald statistic to a standard Normal) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
17 # padj (adjusted p-value, Benjamini Hochberg correction on genes which pass the mean count filter) |
15
9a616afdbda5
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 83eb5b2665d87c02b270596f8175499e69061032
iuc
parents:
14
diff
changeset
|
18 # |
14
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
19 # the first variable in 'factors' will be the primary factor. |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
20 # the levels of the primary factor are used in the order of appearance in factors. |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
21 # |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
22 # by default, levels in the order A,B,C produces a single comparison of B vs A, to a single file 'outfile' |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
23 # |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
24 # for the 'many_contrasts' flag, levels in the order A,B,C produces comparisons C vs A, B vs A, C vs B, |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
25 # to a number of files using the 'outfile' prefix: 'outfile.condition_C_vs_A' etc. |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
26 # all plots will still be sent to a single PDF, named by the arg 'plots', with extra pages. |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
27 # |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
28 # fit_type is an integer valued argument, with the options from ?estimateDisperions |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
29 # 1 "parametric" |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
30 # 2 "local" |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
31 # 3 "mean" |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
32 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
33 # setup R error handling to go to stderr |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
34 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
35 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
36 # we need that to not crash galaxy with an UTF8 error on German LC settings. |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
37 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
38 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
39 library("getopt") |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
40 library("tools") |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
41 options(stringAsFactors = FALSE, useFancyQuotes = FALSE) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
42 args <- commandArgs(trailingOnly = TRUE) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
43 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
44 # get options, using the spec as defined by the enclosed list. |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
45 # we read the options from the default: commandArgs(TRUE). |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
46 spec <- matrix(c( |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
47 "quiet", "q", 0, "logical", |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
48 "help", "h", 0, "logical", |
21
a6fc9228e1a0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 05bc13637dc9f8e523bc72844ff6eb0794f98ad3
iuc
parents:
19
diff
changeset
|
49 "cores", "s", 0, "integer", |
a6fc9228e1a0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 05bc13637dc9f8e523bc72844ff6eb0794f98ad3
iuc
parents:
19
diff
changeset
|
50 "batch_factors", "w", 1, "character", |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
51 "outfile", "o", 1, "character", |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
52 "countsfile", "n", 1, "character", |
18
3bf1b3ec1ddf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 448dccb0c02aba00d8301247b0f0f406ab3d4fa2
iuc
parents:
17
diff
changeset
|
53 "rlogfile", "r", 1, "character", |
3bf1b3ec1ddf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 448dccb0c02aba00d8301247b0f0f406ab3d4fa2
iuc
parents:
17
diff
changeset
|
54 "vstfile", "v", 1, "character", |
15
9a616afdbda5
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 83eb5b2665d87c02b270596f8175499e69061032
iuc
parents:
14
diff
changeset
|
55 "header", "H", 0, "logical", |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
56 "factors", "f", 1, "character", |
12
bd06df00180a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 62e9101c1e7b8467e395f31ccbd9321de01a6418
iuc
parents:
11
diff
changeset
|
57 "files_to_labels", "l", 1, "character", |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
58 "plots" , "p", 1, "character", |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
59 "tximport", "i", 0, "logical", |
11
25204a860b79
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 0a56599c36b4968095ec5a3cb589f94fb139466c
iuc
parents:
9
diff
changeset
|
60 "txtype", "y", 1, "character", |
19
c56e0689e46e
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 5b6dc96c6e14582d5bb1dc213ac8d26dc7b2829e
iuc
parents:
18
diff
changeset
|
61 "tx2gene", "x", 1, "character", # a space-sep tx-to-gene map or GTF/GFF3 file |
18
3bf1b3ec1ddf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 448dccb0c02aba00d8301247b0f0f406ab3d4fa2
iuc
parents:
17
diff
changeset
|
62 "esf", "e", 1, "character", |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
63 "fit_type", "t", 1, "integer", |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
64 "many_contrasts", "m", 0, "logical", |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
65 "outlier_replace_off" , "a", 0, "logical", |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
66 "outlier_filter_off" , "b", 0, "logical", |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
67 "auto_mean_filter_off", "c", 0, "logical", |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
68 "beta_prior_off", "d", 0, "logical"), |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
69 byrow=TRUE, ncol=4) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
70 opt <- getopt(spec) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
71 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
72 # if help was asked for print a friendly message |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
73 # and exit with a non-zero error code |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
74 if (!is.null(opt$help)) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
75 cat(getopt(spec, usage=TRUE)) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
76 q(status=1) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
77 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
78 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
79 # enforce the following required arguments |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
80 if (is.null(opt$outfile)) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
81 cat("'outfile' is required\n") |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
82 q(status=1) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
83 } |
14
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
84 if (is.null(opt$factors)) { |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
85 cat("'factors' is required\n") |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
86 q(status=1) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
87 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
88 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
89 verbose <- if (is.null(opt$quiet)) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
90 TRUE |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
91 } else { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
92 FALSE |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
93 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
94 |
17
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
95 source_local <- function(fname){ |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
96 argv <- commandArgs(trailingOnly = FALSE) |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
97 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)) |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
98 source(paste(base_dir, fname, sep="/")) |
15
9a616afdbda5
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 83eb5b2665d87c02b270596f8175499e69061032
iuc
parents:
14
diff
changeset
|
99 } |
9a616afdbda5
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 83eb5b2665d87c02b270596f8175499e69061032
iuc
parents:
14
diff
changeset
|
100 |
17
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
101 source_local('get_deseq_dataset.R') |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
102 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
103 suppressPackageStartupMessages({ |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
104 library("DESeq2") |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
105 library("RColorBrewer") |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
106 library("gplots") |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
107 }) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
108 |
21
a6fc9228e1a0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 05bc13637dc9f8e523bc72844ff6eb0794f98ad3
iuc
parents:
19
diff
changeset
|
109 if (opt$cores > 1) { |
a6fc9228e1a0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 05bc13637dc9f8e523bc72844ff6eb0794f98ad3
iuc
parents:
19
diff
changeset
|
110 library("BiocParallel") |
a6fc9228e1a0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 05bc13637dc9f8e523bc72844ff6eb0794f98ad3
iuc
parents:
19
diff
changeset
|
111 register(MulticoreParam(opt$cores)) |
a6fc9228e1a0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 05bc13637dc9f8e523bc72844ff6eb0794f98ad3
iuc
parents:
19
diff
changeset
|
112 parallel = TRUE |
a6fc9228e1a0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 05bc13637dc9f8e523bc72844ff6eb0794f98ad3
iuc
parents:
19
diff
changeset
|
113 } else { |
a6fc9228e1a0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 05bc13637dc9f8e523bc72844ff6eb0794f98ad3
iuc
parents:
19
diff
changeset
|
114 parallel = FALSE |
a6fc9228e1a0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 05bc13637dc9f8e523bc72844ff6eb0794f98ad3
iuc
parents:
19
diff
changeset
|
115 } |
a6fc9228e1a0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 05bc13637dc9f8e523bc72844ff6eb0794f98ad3
iuc
parents:
19
diff
changeset
|
116 |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
117 # build or read sample table |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
118 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
119 trim <- function (x) gsub("^\\s+|\\s+$", "", x) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
120 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
121 # switch on if 'factors' was provided: |
14
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
122 library("rjson") |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
123 parser <- newJSONParser() |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
124 parser$addData(opt$factors) |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
125 factorList <- parser$getObject() |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
126 filenames_to_labels <- fromJSON(opt$files_to_labels) |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
127 factors <- sapply(factorList, function(x) x[[1]]) |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
128 primaryFactor <- factors[1] |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
129 filenamesIn <- unname(unlist(factorList[[1]][[2]])) |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
130 labs = unname(unlist(filenames_to_labels[basename(filenamesIn)])) |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
131 sampleTable <- data.frame(sample=basename(filenamesIn), |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
132 filename=filenamesIn, |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
133 row.names=filenamesIn, |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
134 stringsAsFactors=FALSE) |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
135 for (factor in factorList) { |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
136 factorName <- trim(factor[[1]]) |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
137 sampleTable[[factorName]] <- character(nrow(sampleTable)) |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
138 lvls <- sapply(factor[[2]], function(x) names(x)) |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
139 for (i in seq_along(factor[[2]])) { |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
140 files <- factor[[2]][[i]][[1]] |
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
141 sampleTable[files,factorName] <- trim(lvls[i]) |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
142 } |
14
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
143 sampleTable[[factorName]] <- factor(sampleTable[[factorName]], levels=lvls) |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
144 } |
14
d0c39b5e78cf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit e811a7887db870f4f94f620f52bce656c8d5ba23
iuc
parents:
12
diff
changeset
|
145 rownames(sampleTable) <- labs |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
146 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
147 primaryFactor <- factors[1] |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
148 designFormula <- as.formula(paste("~", paste(rev(factors), collapse=" + "))) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
149 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
150 # these are plots which are made once for each analysis |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
151 generateGenericPlots <- function(dds, factors) { |
12
bd06df00180a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 62e9101c1e7b8467e395f31ccbd9321de01a6418
iuc
parents:
11
diff
changeset
|
152 library("ggplot2") |
bd06df00180a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 62e9101c1e7b8467e395f31ccbd9321de01a6418
iuc
parents:
11
diff
changeset
|
153 library("ggrepel") |
bd06df00180a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 62e9101c1e7b8467e395f31ccbd9321de01a6418
iuc
parents:
11
diff
changeset
|
154 library("pheatmap") |
bd06df00180a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 62e9101c1e7b8467e395f31ccbd9321de01a6418
iuc
parents:
11
diff
changeset
|
155 |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
156 rld <- rlog(dds) |
12
bd06df00180a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 62e9101c1e7b8467e395f31ccbd9321de01a6418
iuc
parents:
11
diff
changeset
|
157 p <- plotPCA(rld, intgroup=rev(factors)) |
bd06df00180a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 62e9101c1e7b8467e395f31ccbd9321de01a6418
iuc
parents:
11
diff
changeset
|
158 print(p + geom_text_repel(aes_string(x = "PC1", y = "PC2", label = factor(colnames(dds))), size=3) + geom_point()) |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
159 dat <- assay(rld) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
160 distsRL <- dist(t(dat)) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
161 mat <- as.matrix(distsRL) |
12
bd06df00180a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 62e9101c1e7b8467e395f31ccbd9321de01a6418
iuc
parents:
11
diff
changeset
|
162 colors <- colorRampPalette( rev(brewer.pal(9, "Blues")) )(255) |
bd06df00180a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 62e9101c1e7b8467e395f31ccbd9321de01a6418
iuc
parents:
11
diff
changeset
|
163 pheatmap(mat, |
bd06df00180a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 62e9101c1e7b8467e395f31ccbd9321de01a6418
iuc
parents:
11
diff
changeset
|
164 clustering_distance_rows=distsRL, |
bd06df00180a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 62e9101c1e7b8467e395f31ccbd9321de01a6418
iuc
parents:
11
diff
changeset
|
165 clustering_distance_cols=distsRL, |
bd06df00180a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 62e9101c1e7b8467e395f31ccbd9321de01a6418
iuc
parents:
11
diff
changeset
|
166 col=colors, |
bd06df00180a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 62e9101c1e7b8467e395f31ccbd9321de01a6418
iuc
parents:
11
diff
changeset
|
167 main="Sample-to-sample distances") |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
168 plotDispEsts(dds, main="Dispersion estimates") |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
169 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
170 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
171 # these are plots which can be made for each comparison, e.g. |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
172 # once for C vs A and once for B vs A |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
173 generateSpecificPlots <- function(res, threshold, title_suffix) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
174 use <- res$baseMean > threshold |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
175 if (sum(!use) == 0) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
176 h <- hist(res$pvalue, breaks=0:50/50, plot=FALSE) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
177 barplot(height = h$counts, |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
178 col = "powderblue", space = 0, xlab="p-values", ylab="frequency", |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
179 main=paste("Histogram of p-values for",title_suffix)) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
180 text(x = c(0, length(h$counts)), y = 0, label=paste(c(0,1)), adj=c(0.5,1.7), xpd=NA) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
181 } else { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
182 h1 <- hist(res$pvalue[!use], breaks=0:50/50, plot=FALSE) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
183 h2 <- hist(res$pvalue[use], breaks=0:50/50, plot=FALSE) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
184 colori <- c("filtered (low count)"="khaki", "not filtered"="powderblue") |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
185 barplot(height = rbind(h1$counts, h2$counts), beside = FALSE, |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
186 col = colori, space = 0, xlab="p-values", ylab="frequency", |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
187 main=paste("Histogram of p-values for",title_suffix)) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
188 text(x = c(0, length(h1$counts)), y = 0, label=paste(c(0,1)), adj=c(0.5,1.7), xpd=NA) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
189 legend("topright", fill=rev(colori), legend=rev(names(colori)), bg="white") |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
190 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
191 plotMA(res, main= paste("MA-plot for",title_suffix), ylim=range(res$log2FoldChange, na.rm=TRUE)) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
192 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
193 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
194 if (verbose) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
195 cat(paste("primary factor:",primaryFactor,"\n")) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
196 if (length(factors) > 1) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
197 cat(paste("other factors in design:",paste(factors[-length(factors)],collapse=","),"\n")) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
198 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
199 cat("\n---------------------\n") |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
200 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
201 |
17
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
202 dds <- get_deseq_dataset(sampleTable, header=opt$header, designFormula=designFormula, tximport=opt$tximport, txtype=opt$txtype, tx2gene=opt$tx2gene) |
18
3bf1b3ec1ddf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 448dccb0c02aba00d8301247b0f0f406ab3d4fa2
iuc
parents:
17
diff
changeset
|
203 # estimate size factors for the chosen method |
3bf1b3ec1ddf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 448dccb0c02aba00d8301247b0f0f406ab3d4fa2
iuc
parents:
17
diff
changeset
|
204 if(!is.null(opt$esf)){ |
3bf1b3ec1ddf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 448dccb0c02aba00d8301247b0f0f406ab3d4fa2
iuc
parents:
17
diff
changeset
|
205 dds <- estimateSizeFactors(dds, type=opt$esf) |
3bf1b3ec1ddf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 448dccb0c02aba00d8301247b0f0f406ab3d4fa2
iuc
parents:
17
diff
changeset
|
206 } |
17
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
207 apply_batch_factors <- function (dds, batch_factors) { |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
208 rownames(batch_factors) <- batch_factors$identifier |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
209 batch_factors <- subset(batch_factors, select = -c(identifier, condition)) |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
210 dds_samples <- colnames(dds) |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
211 batch_samples <- rownames(batch_factors) |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
212 if (!setequal(batch_samples, dds_samples)) { |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
213 stop("Batch factor names don't correspond to input sample names, check input files") |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
214 } |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
215 dds_data <- colData(dds) |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
216 # Merge dds_data with batch_factors using indexes, which are sample names |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
217 # Set sort to False, which maintains the order in dds_data |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
218 reordered_batch <- merge(dds_data, batch_factors, by.x = 0, by.y = 0, sort=F) |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
219 batch_factors <- reordered_batch[, ncol(dds_data):ncol(reordered_batch)] |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
220 for (factor in colnames(batch_factors)) { |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
221 dds[[factor]] <- batch_factors[[factor]] |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
222 } |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
223 colnames(dds) <- reordered_batch[,1] |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
224 return(dds) |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
225 } |
15
9a616afdbda5
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 83eb5b2665d87c02b270596f8175499e69061032
iuc
parents:
14
diff
changeset
|
226 |
17
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
227 if (!is.null(opt$batch_factors)) { |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
228 batch_factors <- read.table(opt$batch_factors, sep="\t", header=T) |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
229 dds <- apply_batch_factors(dds = dds, batch_factors = batch_factors) |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
230 batch_design <- colnames(batch_factors)[-c(1,2)] |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
231 designFormula <- as.formula(paste("~", paste(c(batch_design, rev(factors)), collapse=" + "))) |
d9e5cadc7f0b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
16
diff
changeset
|
232 design(dds) <- designFormula |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
233 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
234 |
15
9a616afdbda5
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 83eb5b2665d87c02b270596f8175499e69061032
iuc
parents:
14
diff
changeset
|
235 if (verbose) { |
9a616afdbda5
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 83eb5b2665d87c02b270596f8175499e69061032
iuc
parents:
14
diff
changeset
|
236 cat("DESeq2 run information\n\n") |
9a616afdbda5
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 83eb5b2665d87c02b270596f8175499e69061032
iuc
parents:
14
diff
changeset
|
237 cat("sample table:\n") |
9a616afdbda5
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 83eb5b2665d87c02b270596f8175499e69061032
iuc
parents:
14
diff
changeset
|
238 print(sampleTable[,-c(1:2),drop=FALSE]) |
9a616afdbda5
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 83eb5b2665d87c02b270596f8175499e69061032
iuc
parents:
14
diff
changeset
|
239 cat("\ndesign formula:\n") |
9a616afdbda5
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 83eb5b2665d87c02b270596f8175499e69061032
iuc
parents:
14
diff
changeset
|
240 print(designFormula) |
9a616afdbda5
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 83eb5b2665d87c02b270596f8175499e69061032
iuc
parents:
14
diff
changeset
|
241 cat("\n\n") |
9a616afdbda5
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 83eb5b2665d87c02b270596f8175499e69061032
iuc
parents:
14
diff
changeset
|
242 cat(paste(ncol(dds), "samples with counts over", nrow(dds), "genes\n")) |
9a616afdbda5
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 83eb5b2665d87c02b270596f8175499e69061032
iuc
parents:
14
diff
changeset
|
243 } |
9a616afdbda5
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 83eb5b2665d87c02b270596f8175499e69061032
iuc
parents:
14
diff
changeset
|
244 |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
245 # optional outlier behavior |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
246 if (is.null(opt$outlier_replace_off)) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
247 minRep <- 7 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
248 } else { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
249 minRep <- Inf |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
250 if (verbose) cat("outlier replacement off\n") |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
251 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
252 if (is.null(opt$outlier_filter_off)) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
253 cooksCutoff <- TRUE |
15
9a616afdbda5
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 83eb5b2665d87c02b270596f8175499e69061032
iuc
parents:
14
diff
changeset
|
254 } else { |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
255 cooksCutoff <- FALSE |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
256 if (verbose) cat("outlier filtering off\n") |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
257 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
258 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
259 # optional automatic mean filtering |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
260 if (is.null(opt$auto_mean_filter_off)) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
261 independentFiltering <- TRUE |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
262 } else { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
263 independentFiltering <- FALSE |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
264 if (verbose) cat("automatic filtering on the mean off\n") |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
265 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
266 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
267 # shrinkage of LFCs |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
268 if (is.null(opt$beta_prior_off)) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
269 betaPrior <- TRUE |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
270 } else { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
271 betaPrior <- FALSE |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
272 if (verbose) cat("beta prior off\n") |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
273 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
274 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
275 # dispersion fit type |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
276 if (is.null(opt$fit_type)) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
277 fitType <- "parametric" |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
278 } else { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
279 fitType <- c("parametric","local","mean")[opt$fit_type] |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
280 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
281 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
282 if (verbose) cat(paste("using disperion fit type:",fitType,"\n")) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
283 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
284 # run the analysis |
21
a6fc9228e1a0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 05bc13637dc9f8e523bc72844ff6eb0794f98ad3
iuc
parents:
19
diff
changeset
|
285 dds <- DESeq(dds, fitType=fitType, betaPrior=betaPrior, minReplicatesForReplace=minRep, parallel=parallel) |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
286 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
287 # create the generic plots and leave the device open |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
288 if (!is.null(opt$plots)) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
289 if (verbose) cat("creating plots\n") |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
290 pdf(opt$plots) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
291 generateGenericPlots(dds, factors) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
292 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
293 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
294 n <- nlevels(colData(dds)[[primaryFactor]]) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
295 allLevels <- levels(colData(dds)[[primaryFactor]]) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
296 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
297 if (!is.null(opt$countsfile)) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
298 normalizedCounts<-counts(dds,normalized=TRUE) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
299 write.table(normalizedCounts, file=opt$countsfile, sep="\t", col.names=NA, quote=FALSE) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
300 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
301 |
18
3bf1b3ec1ddf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 448dccb0c02aba00d8301247b0f0f406ab3d4fa2
iuc
parents:
17
diff
changeset
|
302 if (!is.null(opt$rlogfile)) { |
3bf1b3ec1ddf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 448dccb0c02aba00d8301247b0f0f406ab3d4fa2
iuc
parents:
17
diff
changeset
|
303 rLogNormalized <-rlogTransformation(dds) |
3bf1b3ec1ddf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 448dccb0c02aba00d8301247b0f0f406ab3d4fa2
iuc
parents:
17
diff
changeset
|
304 rLogNormalizedMat <- assay(rLogNormalized) |
3bf1b3ec1ddf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 448dccb0c02aba00d8301247b0f0f406ab3d4fa2
iuc
parents:
17
diff
changeset
|
305 write.table(rLogNormalizedMat, file=opt$rlogfile, sep="\t", col.names=NA, quote=FALSE) |
3bf1b3ec1ddf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 448dccb0c02aba00d8301247b0f0f406ab3d4fa2
iuc
parents:
17
diff
changeset
|
306 } |
3bf1b3ec1ddf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 448dccb0c02aba00d8301247b0f0f406ab3d4fa2
iuc
parents:
17
diff
changeset
|
307 |
3bf1b3ec1ddf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 448dccb0c02aba00d8301247b0f0f406ab3d4fa2
iuc
parents:
17
diff
changeset
|
308 if (!is.null(opt$vstfile)) { |
3bf1b3ec1ddf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 448dccb0c02aba00d8301247b0f0f406ab3d4fa2
iuc
parents:
17
diff
changeset
|
309 vstNormalized<-varianceStabilizingTransformation(dds) |
3bf1b3ec1ddf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 448dccb0c02aba00d8301247b0f0f406ab3d4fa2
iuc
parents:
17
diff
changeset
|
310 vstNormalizedMat <- assay(vstNormalized) |
3bf1b3ec1ddf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 448dccb0c02aba00d8301247b0f0f406ab3d4fa2
iuc
parents:
17
diff
changeset
|
311 write.table(vstNormalizedMat, file=opt$vstfile, sep="\t", col.names=NA, quote=FALSE) |
3bf1b3ec1ddf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 448dccb0c02aba00d8301247b0f0f406ab3d4fa2
iuc
parents:
17
diff
changeset
|
312 } |
3bf1b3ec1ddf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 448dccb0c02aba00d8301247b0f0f406ab3d4fa2
iuc
parents:
17
diff
changeset
|
313 |
3bf1b3ec1ddf
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 448dccb0c02aba00d8301247b0f0f406ab3d4fa2
iuc
parents:
17
diff
changeset
|
314 |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
315 if (is.null(opt$many_contrasts)) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
316 # only contrast the first and second level of the primary factor |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
317 ref <- allLevels[1] |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
318 lvl <- allLevels[2] |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
319 res <- results(dds, contrast=c(primaryFactor, lvl, ref), |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
320 cooksCutoff=cooksCutoff, |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
321 independentFiltering=independentFiltering) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
322 if (verbose) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
323 cat("summary of results\n") |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
324 cat(paste0(primaryFactor,": ",lvl," vs ",ref,"\n")) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
325 print(summary(res)) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
326 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
327 resSorted <- res[order(res$padj),] |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
328 outDF <- as.data.frame(resSorted) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
329 outDF$geneID <- rownames(outDF) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
330 outDF <- outDF[,c("geneID", "baseMean", "log2FoldChange", "lfcSE", "stat", "pvalue", "padj")] |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
331 filename <- opt$outfile |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
332 write.table(outDF, file=filename, sep="\t", quote=FALSE, row.names=FALSE, col.names=FALSE) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
333 if (independentFiltering) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
334 threshold <- unname(attr(res, "filterThreshold")) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
335 } else { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
336 threshold <- 0 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
337 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
338 title_suffix <- paste0(primaryFactor,": ",lvl," vs ",ref) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
339 if (!is.null(opt$plots)) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
340 generateSpecificPlots(res, threshold, title_suffix) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
341 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
342 } else { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
343 # rotate through the possible contrasts of the primary factor |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
344 # write out a sorted table of results with the contrast as a suffix |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
345 # add contrast specific plots to the device |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
346 for (i in seq_len(n-1)) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
347 ref <- allLevels[i] |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
348 contrastLevels <- allLevels[(i+1):n] |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
349 for (lvl in contrastLevels) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
350 res <- results(dds, contrast=c(primaryFactor, lvl, ref), |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
351 cooksCutoff=cooksCutoff, |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
352 independentFiltering=independentFiltering) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
353 resSorted <- res[order(res$padj),] |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
354 outDF <- as.data.frame(resSorted) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
355 outDF$geneID <- rownames(outDF) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
356 outDF <- outDF[,c("geneID", "baseMean", "log2FoldChange", "lfcSE", "stat", "pvalue", "padj")] |
24
71bacea10eee
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 29f5fd6ec10122f7b241c8d36d648b105ed4275a"
iuc
parents:
21
diff
changeset
|
357 filename <- paste0(primaryFactor,"_",lvl,"_vs_",ref) |
6
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
358 write.table(outDF, file=filename, sep="\t", quote=FALSE, row.names=FALSE, col.names=FALSE) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
359 if (independentFiltering) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
360 threshold <- unname(attr(res, "filterThreshold")) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
361 } else { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
362 threshold <- 0 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
363 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
364 title_suffix <- paste0(primaryFactor,": ",lvl," vs ",ref) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
365 if (!is.null(opt$plots)) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
366 generateSpecificPlots(res, threshold, title_suffix) |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
367 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
368 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
369 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
370 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
371 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
372 # close the plot device |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
373 if (!is.null(opt$plots)) { |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
374 cat("closing plot device\n") |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
375 dev.off() |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
376 } |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
377 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
378 cat("Session information:\n\n") |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
379 |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
380 sessionInfo() |
4939397c4706
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit 3bc8d91ee546682ef8e9303bd1044bb14cf21b07
iuc
parents:
diff
changeset
|
381 |