annotate ruvseq.R @ 1:c24765926774 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit 9ed3d83cc447ee897af867362bf1dd67af8a11c2
author iuc
date Tue, 26 Mar 2019 06:25:38 -0400
parents 61dffb20b6f9
children fed9d0350d72
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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)
1
c24765926774 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit 9ed3d83cc447ee897af867362bf1dd67af8a11c2
iuc
parents: 0
diff changeset
86 print(paste0("feature count before filtering :",nrow(count_values),"\n"))
c24765926774 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit 9ed3d83cc447ee897af867362bf1dd67af8a11c2
iuc
parents: 0
diff changeset
87 print(paste0("Filtering features which mean expression is less or eq. than ", min_mean_count, " counts\n"))
0
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
88 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
89 filtered <- count_values[filter,]
1
c24765926774 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit 9ed3d83cc447ee897af867362bf1dd67af8a11c2
iuc
parents: 0
diff changeset
90 print(paste0("feature count after filtering :",nrow(filtered),"\n"))
c24765926774 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit 9ed3d83cc447ee897af867362bf1dd67af8a11c2
iuc
parents: 0
diff changeset
91 set = newSeqExpressionSet(as.matrix(filtered),
0
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
92 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
93 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
94 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
95 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
96 return(set)
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
97 }
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
98
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
99 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
100 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
101 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
102 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
103 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
104 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
105 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
106 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
107 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
108 top <- topTags(lrt, n=nrow(set))$table
1
c24765926774 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit 9ed3d83cc447ee897af867362bf1dd67af8a11c2
iuc
parents: 0
diff changeset
109 top_rows <- rownames(top)[which(top$PValue < cutoff_p)]
0
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
110 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
111 return(empirical)
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
112 }
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
113
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
114 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
115 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
116 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
117 }
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
118 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
119 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
120 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
121 return(set)
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
122 }
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
123
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
124 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
125 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
126 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
127 # Initial edger residuals
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
128 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
129 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
130 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
131 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
132 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
133 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
134 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
135 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
136 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
137 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
138 return(set)
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
139 }
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
140
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
141 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
142 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
143 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
144 differences <- makeGroups(x)
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
145 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
146 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
147 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
148 return(set)
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
149 }
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
150
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
151 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
152 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
153 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
154 }
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
155
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
156 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
157 alpha <- opt$alpha
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
158 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
159 max_k <- opt$max_k
1
c24765926774 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit 9ed3d83cc447ee897af867362bf1dd67af8a11c2
iuc
parents: 0
diff changeset
160 min_c <- opt$min_mean_count
0
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
161 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
162 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
163 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
164 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
165 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
166 filename = sample_paths,
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
167 condition=condition)
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
168 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
169
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
170 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
171 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
172 pdf(opt$plots)
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
173 }
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
174
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
175 # Run through the ruvseq variants
1
c24765926774 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit 9ed3d83cc447ee897af867362bf1dd67af8a11c2
iuc
parents: 0
diff changeset
176 set <- create_seq_expression_set(dds, min_mean_count = min_c)
0
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
177 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
178 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
179 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
180 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
181 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
182 }
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
183
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
184 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
185 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
186 set <- result[[name]]
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
187 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
188 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
189 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
190 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
191 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
192 }
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
193 }
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
194
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
195 # 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
196 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
197 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
198 dev.off()
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
199 }
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
200
61dffb20b6f9 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ruvseq commit b95582cea8320d5488056a9576474f79cec53be8
iuc
parents:
diff changeset
201 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
202 sessionInfo()