Mercurial > repos > iuc > ruvseq
annotate ruvseq.R @ 0:61dffb20b6f9 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
author | iuc |
---|---|
date | Wed, 05 Sep 2018 15:54:16 -0400 |
parents | |
children | c24765926774 |
rev | line source |
---|---|
0
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
1 # setup R error handling to go to stderr |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
2 library("getopt") |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
3 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } ) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
4 options(stringAsFactors = FALSE, useFancyQuotes = FALSE) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
5 |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
6 setup_cmdline_options <- function() { |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
7 args <- commandArgs(trailingOnly = TRUE) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
8 spec <- matrix(c( |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
9 "help", "h", 0, "logical", |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
10 "alpha", "a", 1, "double", |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
11 "min_mean_count", "min_c", 1, "double", |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
12 "min_k", "min_k", 1, "double", |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
13 "max_k", "max_k", 1, "double", |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
14 "sample_json", "s", 1, "character", |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
15 "plots" , "p", 1, "character", |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
16 "header", "H", 0, "logical", |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
17 "txtype", "y", 1, "character", |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
18 "tx2gene", "x", 1, "character"), # a space-sep tx-to-gene map or GTF file (auto detect .gtf/.GTF) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
19 byrow=TRUE, ncol=4) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
20 |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
21 opt <- getopt(spec) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
22 # if help was asked for print a friendly message |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
23 # and exit with a non-zero error code |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
24 if (!is.null(opt$help)) { |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
25 cat(getopt(spec, usage=TRUE)) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
26 q(status=1) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
27 } else { |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
28 load_libraries() |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
29 } |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
30 return(opt) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
31 } |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
32 |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
33 load_libraries <- function() { |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
34 # Allows displaying help without waiting for libraries to load |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
35 library("tools") |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
36 library("jsonlite") |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
37 library("reshape2") |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
38 library("RUVSeq") |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
39 library("RColorBrewer") |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
40 library("tximport") |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
41 library("DESeq2") |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
42 library("ggrepel") |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
43 } |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
44 |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
45 source_local <- function(fname){ |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
46 argv <- commandArgs(trailingOnly = FALSE) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
47 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
48 source(paste(base_dir, fname, sep="/")) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
49 } |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
50 |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
51 # Source get_deseq_dataset.R for getting deseq dataset from htseq/featurecounts/tximport |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
52 source_local('get_deseq_dataset.R') |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
53 |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
54 # RUVseq function definitions |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
55 |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
56 plot_pca_rle <- function (set, title) { |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
57 x <- pData(set)[,1] |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
58 colors <- brewer.pal(3, "Set2") |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
59 label <- paste0(' for ', title) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
60 plotRLE(set, outline=FALSE, ylim=c(-4, 4), col=colors[x]) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
61 title(main=paste0("RLE", label)) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
62 plotPCA(set, col=colors[x], cex=1.2) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
63 title(main=paste0("PCA", label)) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
64 } |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
65 |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
66 plot_factors_of_unwanted_variation <- function(set, method, k){ |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
67 pd <- pData(set) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
68 pd['sample'] <- row.names(pd) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
69 colnames(pd)[1] <- 'condition' |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
70 d = melt(pd, id.vars = c('sample', 'condition')) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
71 d['x'] <- 1 # There is no information on the X, so we just fake it to be able to do a scatterplot |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
72 print(ggplot(d, aes(x=x, y=value, color=condition, label=sample)) + |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
73 geom_point() + |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
74 ggtitle(paste0('Factors of unwanted variation for method: ', method, ", k=", k)) + |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
75 facet_wrap( ~ variable, scales = "free_x") + |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
76 geom_text_repel() + |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
77 theme(axis.title.x=element_blank(), |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
78 axis.text.x=element_blank(), |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
79 axis.ticks.x=element_blank(), |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
80 plot.title = element_text(hjust = 0.5)) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
81 ) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
82 } |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
83 |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
84 create_seq_expression_set <- function (dds, min_mean_count) { |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
85 count_values <- counts(dds) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
86 filter <- apply(count_values, 1, function(x) mean(x) > min_mean_count) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
87 filtered <- count_values[filter,] |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
88 set = newSeqExpressionSet(as.matrix(count_values), |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
89 phenoData = data.frame(colData(dds)$condition, row.names=colnames(filtered))) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
90 plot_pca_rle(set = set, title = 'raw data') |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
91 set <- betweenLaneNormalization(set, which="upper") |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
92 plot_pca_rle(set = set, title = 'upper quartile normalized') |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
93 return(set) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
94 } |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
95 |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
96 get_empirical_control_genes <- function(set, cutoff_p) { |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
97 x <- pData(set)[,1] |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
98 design <- model.matrix(~x, data=pData(set)) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
99 y <- DGEList(counts=counts(set), group=x) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
100 y <- calcNormFactors(y, method="upperquartile") |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
101 y <- estimateGLMCommonDisp(y, design) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
102 y <- estimateGLMTagwiseDisp(y, design) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
103 fit <- glmFit(y, design) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
104 lrt <- glmLRT(fit, coef=2) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
105 top <- topTags(lrt, n=nrow(set))$table |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
106 top_rows <- rownames(top)[which(top$PValue > cutoff_p)] |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
107 empirical <- rownames(set)[which(!(rownames(set) %in% top_rows))] |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
108 return(empirical) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
109 } |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
110 |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
111 ruv_control_gene_method <- function(set, k, control_genes='empirical', cutoff_p=0.2) { |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
112 if (control_genes == 'empirical') { |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
113 control_genes = get_empirical_control_genes(set, cutoff_p=cutoff_p) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
114 } |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
115 set <- RUVg(set, control_genes, k=k) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
116 plot_pca_rle(set, paste0("RUVg with empirical control genes, k=", k)) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
117 plot_factors_of_unwanted_variation(set, method="RUVg with empirical control genes", k=k) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
118 return(set) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
119 } |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
120 |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
121 ruv_residual_method <- function(set, k) { |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
122 genes <- rownames(counts(set)) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
123 x <- pData(set)[,1] |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
124 # Initial edger residuals |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
125 design <- model.matrix(~x, data=pData(set)) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
126 y <- DGEList(counts=counts(set), group=x) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
127 y <- calcNormFactors(y, method="upperquartile") |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
128 y <- estimateGLMCommonDisp(y, design) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
129 y <- estimateGLMTagwiseDisp(y, design) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
130 fit <- glmFit(y, design) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
131 res <- residuals(fit, type="deviance") |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
132 set <- RUVr(set, genes, k=k, res) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
133 plot_pca_rle(set = set, title = paste0('RUVr using residuals, k=', k)) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
134 plot_factors_of_unwanted_variation(set, method="RUVr using residuals", k=k) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
135 return(set) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
136 } |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
137 |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
138 ruv_replicate_method <- function (set, k) { |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
139 genes <- rownames(counts(set)) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
140 x <- pData(set)[,1] |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
141 differences <- makeGroups(x) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
142 set <- RUVs(set, genes, k=k, differences) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
143 plot_pca_rle(set, paste0('RUVs with replicate samples, k=', k)) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
144 plot_factors_of_unwanted_variation(set, method="RUVs using replicates", k=k) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
145 return(set) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
146 } |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
147 |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
148 get_differentially_expressed_genes <- function(dds, contrast, alpha=0.01) { |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
149 r <- results(dds, contrast=contrast, alpha=alpha) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
150 return(rownames(r[which(r$padj < alpha),])) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
151 } |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
152 |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
153 opt <- setup_cmdline_options() |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
154 alpha <- opt$alpha |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
155 min_k <- opt$min_k |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
156 max_k <- opt$max_k |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
157 sample_json <- fromJSON(opt$sample_json) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
158 sample_paths <- sample_json$path |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
159 sample_names <- sample_json$label |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
160 condition <- as.factor(sample_json$condition) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
161 sampleTable <- data.frame(samplename=sample_names, |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
162 filename = sample_paths, |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
163 condition=condition) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
164 rownames(sampleTable) <- sample_names |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
165 |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
166 dds <- get_deseq_dataset(sampleTable, header=opt$header, designFormula= ~ condition, tximport=opt$txtype, txtype=opt$txtype, tx2gene=opt$tx2gene) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
167 if (!is.null(opt$plots)) { |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
168 pdf(opt$plots) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
169 } |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
170 |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
171 # Run through the ruvseq variants |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
172 set <- create_seq_expression_set(dds, min_mean_count = opt$min_mean_count) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
173 result <- list(no_correction = set) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
174 for (k in seq(min_k, max_k)) { |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
175 result[[paste0('residual_method_k', k)]] <- ruv_residual_method(set, k=k) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
176 result[[paste0('replicate_method_k', k)]] <- ruv_replicate_method(set, k=k) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
177 result[[paste0('control_method_k', k)]] <- ruv_control_gene_method(set, k=k, cutoff_p=0.5) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
178 } |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
179 |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
180 for (name in names(result)) { |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
181 if (!startsWith(name, "no_correction")) { |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
182 set <- result[[name]] |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
183 unwanted_variation <- pData(set) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
184 df <- data.frame(identifier = rownames(unwanted_variation)) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
185 df <- cbind(df, unwanted_variation) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
186 colnames(df)[2] <- 'condition' |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
187 write.table(df, file=paste0("batch_effects_", name, ".tabular"), sep="\t", quote=F, row.names=F) |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
188 } |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
189 } |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
190 |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
191 # close the plot device |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
192 if (!is.null(opt$plots)) { |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
193 cat("closing plot device\n") |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
194 dev.off() |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
195 } |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
196 |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
197 cat("Session information:\n\n") |
61dffb20b6f9
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff
changeset
|
198 sessionInfo() |