annotate edger.R @ 3:d79ed3ec25fe draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
author iuc
date Sun, 06 May 2018 13:38:41 -0400
parents a1634a9c2ee1
children 4730985c816f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
1 # This tool takes in a matrix of feature counts as well as gene annotations and
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
2 # outputs a table of top expressions as well as various plots for differential
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
3 # expression analysis
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
4 #
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
5 # ARGS: htmlPath", "R", 1, "character" -Path to html file linking to other outputs
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
6 # outPath", "o", 1, "character" -Path to folder to write all output to
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
7 # filesPath", "j", 2, "character" -JSON list object if multiple files input
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
8 # matrixPath", "m", 2, "character" -Path to count matrix
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
9 # factFile", "f", 2, "character" -Path to factor information file
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
10 # factInput", "i", 2, "character" -String containing factors if manually input
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
11 # annoPath", "a", 2, "character" -Path to input containing gene annotations
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
12 # contrastData", "C", 1, "character" -String containing contrasts of interest
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
13 # cpmReq", "c", 2, "double" -Float specifying cpm requirement
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
14 # cntReq", "z", 2, "integer" -Integer specifying minimum total count requirement
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
15 # sampleReq", "s", 2, "integer" -Integer specifying cpm requirement
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
16 # normCounts", "x", 0, "logical" -String specifying if normalised counts should be output
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
17 # rdaOpt", "r", 0, "logical" -String specifying if RData should be output
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
18 # lfcReq", "l", 1, "double" -Float specifying the log-fold-change requirement
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
19 # pValReq", "p", 1, "double" -Float specifying the p-value requirement
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
20 # pAdjOpt", "d", 1, "character" -String specifying the p-value adjustment method
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
21 # normOpt", "n", 1, "character" -String specifying type of normalisation used
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
22 # robOpt", "b", 0, "logical" -String specifying if robust options should be used
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
23 # lrtOpt", "t", 0, "logical" -String specifying whether to perform LRT test instead
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
24 #
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
25 # OUT:
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
26 # MDS Plot
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
27 # BCV Plot
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
28 # QL Plot
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
29 # MD Plot
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
30 # Expression Table
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
31 # HTML file linking to the ouputs
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
32 # Optional:
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
33 # Normalised counts Table
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
34 # RData file
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
35 #
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
36 # Author: Shian Su - registertonysu@gmail.com - Jan 2014
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
37 # Modified by: Maria Doyle - Oct 2017 (some code taken from the DESeq2 wrapper)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
38
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
39 # Record starting time
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
40 timeStart <- as.character(Sys.time())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
41
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
42 # setup R error handling to go to stderr
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
43 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
44
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
45 # we need that to not crash galaxy with an UTF8 error on German LC settings.
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
46 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
47
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
48 # Load all required libraries
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
49 library(methods, quietly=TRUE, warn.conflicts=FALSE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
50 library(statmod, quietly=TRUE, warn.conflicts=FALSE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
51 library(splines, quietly=TRUE, warn.conflicts=FALSE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
52 library(edgeR, quietly=TRUE, warn.conflicts=FALSE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
53 library(limma, quietly=TRUE, warn.conflicts=FALSE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
54 library(scales, quietly=TRUE, warn.conflicts=FALSE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
55 library(getopt, quietly=TRUE, warn.conflicts=FALSE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
56
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
57 ################################################################################
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
58 ### Function Delcaration
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
59 ################################################################################
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
60 # Function to sanitise contrast equations so there are no whitespaces
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
61 # surrounding the arithmetic operators, leading or trailing whitespace
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
62 sanitiseEquation <- function(equation) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
63 equation <- gsub(" *[+] *", "+", equation)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
64 equation <- gsub(" *[-] *", "-", equation)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
65 equation <- gsub(" *[/] *", "/", equation)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
66 equation <- gsub(" *[*] *", "*", equation)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
67 equation <- gsub("^\\s+|\\s+$", "", equation)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
68 return(equation)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
69 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
70
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
71 # Function to sanitise group information
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
72 sanitiseGroups <- function(string) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
73 string <- gsub(" *[,] *", ",", string)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
74 string <- gsub("^\\s+|\\s+$", "", string)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
75 return(string)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
76 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
77
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
78 # Function to change periods to whitespace in a string
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
79 unmake.names <- function(string) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
80 string <- gsub(".", " ", string, fixed=TRUE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
81 return(string)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
82 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
83
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
84 # Generate output folder and paths
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
85 makeOut <- function(filename) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
86 return(paste0(opt$outPath, "/", filename))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
87 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
88
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
89 # Generating design information
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
90 pasteListName <- function(string) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
91 return(paste0("factors$", string))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
92 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
93
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
94 # Create cata function: default path set, default seperator empty and appending
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
95 # true by default (Ripped straight from the cat function with altered argument
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
96 # defaults)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
97 cata <- function(..., file=opt$htmlPath, sep="", fill=FALSE, labels=NULL,
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
98 append=TRUE) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
99 if (is.character(file))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
100 if (file == "")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
101 file <- stdout()
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
102 else if (substring(file, 1L, 1L) == "|") {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
103 file <- pipe(substring(file, 2L), "w")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
104 on.exit(close(file))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
105 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
106 else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
107 file <- file(file, ifelse(append, "a", "w"))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
108 on.exit(close(file))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
109 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
110 .Internal(cat(list(...), file, sep, fill, labels, append))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
111 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
112
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
113 # Function to write code for html head and title
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
114 HtmlHead <- function(title) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
115 cata("<head>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
116 cata("<title>", title, "</title>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
117 cata("</head>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
118 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
119
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
120 # Function to write code for html links
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
121 HtmlLink <- function(address, label=address) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
122 cata("<a href=\"", address, "\" target=\"_blank\">", label, "</a><br />\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
123 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
124
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
125 # Function to write code for html images
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
126 HtmlImage <- function(source, label=source, height=600, width=600) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
127 cata("<img src=\"", source, "\" alt=\"", label, "\" height=\"", height)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
128 cata("\" width=\"", width, "\"/>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
129 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
130
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
131 # Function to write code for html list items
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
132 ListItem <- function(...) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
133 cata("<li>", ..., "</li>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
134 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
135
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
136 TableItem <- function(...) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
137 cata("<td>", ..., "</td>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
138 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
139
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
140 TableHeadItem <- function(...) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
141 cata("<th>", ..., "</th>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
142 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
143
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
144 ################################################################################
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
145 ### Input Processing
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
146 ################################################################################
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
147
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
148 # Collect arguments from command line
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
149 args <- commandArgs(trailingOnly=TRUE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
150
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
151 # Get options, using the spec as defined by the enclosed list.
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
152 # Read the options from the default: commandArgs(TRUE).
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
153 spec <- matrix(c(
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
154 "htmlPath", "R", 1, "character",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
155 "outPath", "o", 1, "character",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
156 "filesPath", "j", 2, "character",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
157 "matrixPath", "m", 2, "character",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
158 "factFile", "f", 2, "character",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
159 "factInput", "i", 2, "character",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
160 "annoPath", "a", 2, "character",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
161 "contrastData", "C", 1, "character",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
162 "cpmReq", "c", 1, "double",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
163 "totReq", "y", 0, "logical",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
164 "cntReq", "z", 1, "integer",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
165 "sampleReq", "s", 1, "integer",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
166 "normCounts", "x", 0, "logical",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
167 "rdaOpt", "r", 0, "logical",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
168 "lfcReq", "l", 1, "double",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
169 "pValReq", "p", 1, "double",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
170 "pAdjOpt", "d", 1, "character",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
171 "normOpt", "n", 1, "character",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
172 "robOpt", "b", 0, "logical",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
173 "lrtOpt", "t", 0, "logical"),
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
174 byrow=TRUE, ncol=4)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
175 opt <- getopt(spec)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
176
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
177
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
178 if (is.null(opt$matrixPath) & is.null(opt$filesPath)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
179 cat("A counts matrix (or a set of counts files) is required.\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
180 q(status=1)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
181 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
182
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
183 if (is.null(opt$cpmReq)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
184 filtCPM <- FALSE
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
185 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
186 filtCPM <- TRUE
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
187 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
188
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
189 if (is.null(opt$cntReq) || is.null(opt$sampleReq)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
190 filtSmpCount <- FALSE
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
191 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
192 filtSmpCount <- TRUE
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
193 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
194
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
195 if (is.null(opt$totReq)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
196 filtTotCount <- FALSE
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
197 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
198 filtTotCount <- TRUE
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
199 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
200
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
201 if (is.null(opt$lrtOpt)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
202 wantLRT <- FALSE
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
203 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
204 wantLRT <- TRUE
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
205 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
206
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
207 if (is.null(opt$rdaOpt)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
208 wantRda <- FALSE
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
209 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
210 wantRda <- TRUE
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
211 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
212
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
213 if (is.null(opt$annoPath)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
214 haveAnno <- FALSE
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
215 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
216 haveAnno <- TRUE
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
217 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
218
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
219 if (is.null(opt$normCounts)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
220 wantNorm <- FALSE
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
221 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
222 wantNorm <- TRUE
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
223 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
224
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
225 if (is.null(opt$robOpt)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
226 wantRobust <- FALSE
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
227 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
228 wantRobust <- TRUE
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
229 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
230
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
231
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
232 if (!is.null(opt$filesPath)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
233 # Process the separate count files (adapted from DESeq2 wrapper)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
234 library("rjson")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
235 parser <- newJSONParser()
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
236 parser$addData(opt$filesPath)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
237 factorList <- parser$getObject()
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
238 factors <- sapply(factorList, function(x) x[[1]])
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
239 filenamesIn <- unname(unlist(factorList[[1]][[2]]))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
240 sampleTable <- data.frame(sample=basename(filenamesIn),
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
241 filename=filenamesIn,
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
242 row.names=filenamesIn,
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
243 stringsAsFactors=FALSE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
244 for (factor in factorList) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
245 factorName <- factor[[1]]
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
246 sampleTable[[factorName]] <- character(nrow(sampleTable))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
247 lvls <- sapply(factor[[2]], function(x) names(x))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
248 for (i in seq_along(factor[[2]])) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
249 files <- factor[[2]][[i]][[1]]
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
250 sampleTable[files,factorName] <- lvls[i]
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
251 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
252 sampleTable[[factorName]] <- factor(sampleTable[[factorName]], levels=lvls)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
253 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
254 rownames(sampleTable) <- sampleTable$sample
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
255 rem <- c("sample","filename")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
256 factors <- sampleTable[, !(names(sampleTable) %in% rem), drop=FALSE]
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
257
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
258 #read in count files and create single table
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
259 countfiles <- lapply(sampleTable$filename, function(x){read.delim(x, row.names=1)})
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
260 counts <- do.call("cbind", countfiles)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
261
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
262 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
263 # Process the single count matrix
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
264 counts <- read.table(opt$matrixPath, header=TRUE, sep="\t", stringsAsFactors=FALSE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
265 row.names(counts) <- counts[, 1]
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
266 counts <- counts[ , -1]
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
267 countsRows <- nrow(counts)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
268
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
269 # Process factors
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
270 if (is.null(opt$factInput)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
271 factorData <- read.table(opt$factFile, header=TRUE, sep="\t")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
272 factors <- factorData[, -1, drop=FALSE]
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
273 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
274 factors <- unlist(strsplit(opt$factInput, "|", fixed=TRUE))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
275 factorData <- list()
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
276 for (fact in factors) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
277 newFact <- unlist(strsplit(fact, split="::"))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
278 factorData <- rbind(factorData, newFact)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
279 } # Factors have the form: FACT_NAME::LEVEL,LEVEL,LEVEL,LEVEL,... The first factor is the Primary Factor.
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
280
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
281 # Set the row names to be the name of the factor and delete first row
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
282 row.names(factorData) <- factorData[, 1]
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
283 factorData <- factorData[, -1]
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
284 factorData <- sapply(factorData, sanitiseGroups)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
285 factorData <- sapply(factorData, strsplit, split=",")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
286 factorData <- sapply(factorData, make.names)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
287 # Transform factor data into data frame of R factor objects
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
288 factors <- data.frame(factorData)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
289 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
290 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
291
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
292 # if annotation file provided
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
293 if (haveAnno) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
294 geneanno <- read.table(opt$annoPath, header=TRUE, sep="\t", stringsAsFactors=FALSE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
295 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
296
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
297 #Create output directory
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
298 dir.create(opt$outPath, showWarnings=FALSE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
299
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
300 # Split up contrasts separated by comma into a vector then sanitise
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
301 contrastData <- unlist(strsplit(opt$contrastData, split=","))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
302 contrastData <- sanitiseEquation(contrastData)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
303 contrastData <- gsub(" ", ".", contrastData, fixed=TRUE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
304
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
305 bcvOutPdf <- makeOut("bcvplot.pdf")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
306 bcvOutPng <- makeOut("bcvplot.png")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
307 qlOutPdf <- makeOut("qlplot.pdf")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
308 qlOutPng <- makeOut("qlplot.png")
3
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
309 mdsOutPdf <- character() # Initialise character vector
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
310 mdsOutPng <- character()
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
311 for (i in 1:ncol(factors)) {
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
312 mdsOutPdf[i] <- makeOut(paste0("mdsplot_", names(factors)[i], ".pdf"))
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
313 mdsOutPng[i] <- makeOut(paste0("mdsplot_", names(factors)[i], ".png"))
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
314 }
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
315 mdOutPdf <- character()
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
316 mdOutPng <- character()
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
317 topOut <- character()
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
318 for (i in 1:length(contrastData)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
319 mdOutPdf[i] <- makeOut(paste0("mdplot_", contrastData[i], ".pdf"))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
320 mdOutPng[i] <- makeOut(paste0("mdplot_", contrastData[i], ".png"))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
321 topOut[i] <- makeOut(paste0("edgeR_", contrastData[i], ".tsv"))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
322 } # Save output paths for each contrast as vectors
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
323 normOut <- makeOut("edgeR_normcounts.tsv")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
324 rdaOut <- makeOut("edgeR_analysis.RData")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
325 sessionOut <- makeOut("session_info.txt")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
326
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
327 # Initialise data for html links and images, data frame with columns Label and
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
328 # Link
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
329 linkData <- data.frame(Label=character(), Link=character(), stringsAsFactors=FALSE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
330 imageData <- data.frame(Label=character(), Link=character(), stringsAsFactors=FALSE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
331
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
332 # Initialise vectors for storage of up/down/neutral regulated counts
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
333 upCount <- numeric()
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
334 downCount <- numeric()
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
335 flatCount <- numeric()
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
336
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
337 ################################################################################
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
338 ### Data Processing
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
339 ################################################################################
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
340
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
341 # Extract counts and annotation data
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
342 data <- list()
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
343 data$counts <- counts
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
344 if (haveAnno) {
3
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
345 # order annotation by genes in counts (assumes gene ids are in 1st column of geneanno)
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
346 annoord <- geneanno[match(row.names(counts), geneanno[,1]), ]
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
347 data$genes <- annoord
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
348 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
349 data$genes <- data.frame(GeneID=row.names(counts))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
350 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
351
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
352 # If filter crieteria set, filter out genes that do not have a required cpm/counts in a required number of
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
353 # samples. Default is no filtering
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
354 preFilterCount <- nrow(data$counts)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
355
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
356 if (filtCPM || filtSmpCount || filtTotCount) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
357
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
358 if (filtTotCount) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
359 keep <- rowSums(data$counts) >= opt$cntReq
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
360 } else if (filtSmpCount) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
361 keep <- rowSums(data$counts >= opt$cntReq) >= opt$sampleReq
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
362 } else if (filtCPM) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
363 keep <- rowSums(cpm(data$counts) >= opt$cpmReq) >= opt$sampleReq
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
364 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
365
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
366 data$counts <- data$counts[keep, ]
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
367 data$genes <- data$genes[keep, , drop=FALSE]
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
368 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
369
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
370 postFilterCount <- nrow(data$counts)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
371 filteredCount <- preFilterCount-postFilterCount
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
372
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
373 # Creating naming data
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
374 samplenames <- colnames(data$counts)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
375 sampleanno <- data.frame("sampleID"=samplenames, factors)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
376
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
377
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
378 # Generating the DGEList object "data"
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
379 data$samples <- sampleanno
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
380 data$samples$lib.size <- colSums(data$counts)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
381 data$samples$norm.factors <- 1
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
382 row.names(data$samples) <- colnames(data$counts)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
383 data <- new("DGEList", data)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
384
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
385 # Name rows of factors according to their sample
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
386 row.names(factors) <- names(data$counts)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
387 factorList <- sapply(names(factors), pasteListName)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
388
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
389 formula <- "~0"
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
390 for (i in 1:length(factorList)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
391 formula <- paste(formula, factorList[i], sep="+")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
392 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
393
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
394 formula <- formula(formula)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
395 design <- model.matrix(formula)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
396
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
397 for (i in 1:length(factorList)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
398 colnames(design) <- gsub(factorList[i], "", colnames(design), fixed=TRUE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
399 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
400
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
401 # Calculating normalising factor, estimating dispersion
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
402 data <- calcNormFactors(data, method=opt$normOpt)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
403
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
404 if (wantRobust) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
405 data <- estimateDisp(data, design=design, robust=TRUE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
406 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
407 data <- estimateDisp(data, design=design)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
408 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
409
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
410 # Generate contrasts information
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
411 contrasts <- makeContrasts(contrasts=contrastData, levels=design)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
412
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
413 ################################################################################
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
414 ### Data Output
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
415 ################################################################################
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
416
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
417 # Plot MDS
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
418 labels <- names(counts)
3
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
419
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
420 # MDS plot
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
421 png(mdsOutPng, width=600, height=600)
3
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
422 plotMDS(data, labels=labels, col=as.numeric(factors[, 1]), cex=0.8, main=paste("MDS Plot:", names(factors)[1]))
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
423 imgName <- paste0("MDS Plot_", names(factors)[1], ".png")
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
424 imgAddr <- paste0("mdsplot_", names(factors)[1], ".png")
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
425 imageData[1, ] <- c(imgName, imgAddr)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
426 invisible(dev.off())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
427
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
428 pdf(mdsOutPdf)
3
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
429 plotMDS(data, labels=labels, col=as.numeric(factors[, 1]), cex=0.8, main=paste("MDS Plot:", names(factors)[1]))
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
430 linkName <- paste0("MDS Plot_", names(factors)[1], ".pdf")
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
431 linkAddr <- paste0("mdsplot_", names(factors)[1], ".pdf")
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
432 linkData[1, ] <- c(linkName, linkAddr)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
433 invisible(dev.off())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
434
3
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
435 # If additional factors create additional MDS plots coloured by factor
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
436 if (ncol(factors) > 1) {
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
437 for (i in 2:ncol(factors)) {
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
438 png(mdsOutPng[i], width=600, height=600)
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
439 plotMDS(data, labels=labels, col=as.numeric(factors[, i]), cex=0.8, main=paste("MDS Plot:", names(factors)[i]))
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
440 imgName <- paste0("MDS Plot_", names(factors)[i], ".png")
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
441 imgAddr <- paste0("mdsplot_", names(factors)[i], ".png")
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
442 imageData <- rbind(imageData, c(imgName, imgAddr))
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
443 invisible(dev.off())
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
444
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
445 pdf(mdsOutPdf[i])
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
446 plotMDS(data, labels=labels, col=as.numeric(factors[, i]), cex=0.8, main=paste("MDS Plot:", names(factors)[i]))
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
447 linkName <- paste0("MDS Plot_", names(factors)[i], ".pdf")
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
448 linkAddr <- paste0("mdsplot_", names(factors)[i], ".pdf")
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
449 linkData <- rbind(linkData, c(linkName, linkAddr))
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
450 invisible(dev.off())
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
451 }
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
452 }
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
453
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
454 # BCV Plot
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
455 png(bcvOutPng, width=600, height=600)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
456 plotBCV(data, main="BCV Plot")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
457 imgName <- "BCV Plot"
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
458 imgAddr <- "bcvplot.png"
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
459 imageData <- rbind(imageData, c(imgName, imgAddr))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
460 invisible(dev.off())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
461
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
462 pdf(bcvOutPdf)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
463 plotBCV(data, main="BCV Plot")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
464 linkName <- paste0("BCV Plot.pdf")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
465 linkAddr <- paste0("bcvplot.pdf")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
466 linkData <- rbind(linkData, c(linkName, linkAddr))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
467 invisible(dev.off())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
468
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
469 # Generate fit
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
470 if (wantLRT) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
471
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
472 fit <- glmFit(data, design)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
473
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
474 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
475
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
476 if (wantRobust) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
477 fit <- glmQLFit(data, design, robust=TRUE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
478 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
479 fit <- glmQLFit(data, design)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
480 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
481
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
482 # Plot QL dispersions
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
483 png(qlOutPng, width=600, height=600)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
484 plotQLDisp(fit, main="QL Plot")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
485 imgName <- "QL Plot"
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
486 imgAddr <- "qlplot.png"
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
487 imageData <- rbind(imageData, c(imgName, imgAddr))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
488 invisible(dev.off())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
489
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
490 pdf(qlOutPdf)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
491 plotQLDisp(fit, main="QL Plot")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
492 linkName <- "QL Plot.pdf"
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
493 linkAddr <- "qlplot.pdf"
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
494 linkData <- rbind(linkData, c(linkName, linkAddr))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
495 invisible(dev.off())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
496 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
497
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
498 # Save normalised counts (log2cpm)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
499 if (wantNorm) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
500 normalisedCounts <- cpm(data, normalized.lib.sizes=TRUE, log=TRUE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
501 normalisedCounts <- data.frame(data$genes, normalisedCounts)
3
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
502 write.table (normalisedCounts, file=normOut, row.names=FALSE, sep="\t", quote=FALSE)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
503 linkData <- rbind(linkData, c("edgeR_normcounts.tsv", "edgeR_normcounts.tsv"))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
504 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
505
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
506
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
507 for (i in 1:length(contrastData)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
508 if (wantLRT) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
509 res <- glmLRT(fit, contrast=contrasts[, i])
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
510 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
511 res <- glmQLFTest(fit, contrast=contrasts[, i])
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
512 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
513
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
514 status = decideTestsDGE(res, adjust.method=opt$pAdjOpt, p.value=opt$pValReq,
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
515 lfc=opt$lfcReq)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
516 sumStatus <- summary(status)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
517
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
518 # Collect counts for differential expression
2
a1634a9c2ee1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 910ffba48cb5f981aad1e00b77056bbbec7f9617
iuc
parents: 1
diff changeset
519 upCount[i] <- sumStatus["Up", ]
a1634a9c2ee1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 910ffba48cb5f981aad1e00b77056bbbec7f9617
iuc
parents: 1
diff changeset
520 downCount[i] <- sumStatus["Down", ]
a1634a9c2ee1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 910ffba48cb5f981aad1e00b77056bbbec7f9617
iuc
parents: 1
diff changeset
521 flatCount[i] <- sumStatus["NotSig", ]
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
522
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
523 # Write top expressions table
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
524 top <- topTags(res, n=Inf, sort.by="PValue")
3
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
525 write.table(top, file=topOut[i], row.names=FALSE, sep="\t", quote=FALSE)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
526
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
527 linkName <- paste0("edgeR_", contrastData[i], ".tsv")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
528 linkAddr <- paste0("edgeR_", contrastData[i], ".tsv")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
529 linkData <- rbind(linkData, c(linkName, linkAddr))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
530
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
531 # Plot MD (log ratios vs mean difference) using limma package
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
532 pdf(mdOutPdf[i])
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
533 limma::plotMD(res, status=status,
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
534 main=paste("MD Plot:", unmake.names(contrastData[i])),
3
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
535 hl.col=alpha(c("firebrick", "blue"), 0.4), values=c(1, -1),
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
536 xlab="Average Expression", ylab="logFC")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
537
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
538 abline(h=0, col="grey", lty=2)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
539
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
540 linkName <- paste0("MD Plot_", contrastData[i], ".pdf")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
541 linkAddr <- paste0("mdplot_", contrastData[i], ".pdf")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
542 linkData <- rbind(linkData, c(linkName, linkAddr))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
543 invisible(dev.off())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
544
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
545 png(mdOutPng[i], height=600, width=600)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
546 limma::plotMD(res, status=status,
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
547 main=paste("MD Plot:", unmake.names(contrastData[i])),
3
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
548 hl.col=alpha(c("firebrick", "blue"), 0.4), values=c(1, -1),
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
549 xlab="Average Expression", ylab="logFC")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
550
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
551 abline(h=0, col="grey", lty=2)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
552
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
553 imgName <- paste0("MD Plot_", contrastData[i], ".png")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
554 imgAddr <- paste0("mdplot_", contrastData[i], ".png")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
555 imageData <- rbind(imageData, c(imgName, imgAddr))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
556 invisible(dev.off())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
557 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
558 sigDiff <- data.frame(Up=upCount, Flat=flatCount, Down=downCount)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
559 row.names(sigDiff) <- contrastData
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
560
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
561 # Save relevant items as rda object
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
562 if (wantRda) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
563 if (wantNorm) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
564 save(counts, data, status, normalisedCounts, labels, factors, fit, res, top, contrasts, design,
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
565 file=rdaOut, ascii=TRUE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
566 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
567 save(counts, data, status, labels, factors, fit, res, top, contrasts, design,
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
568 file=rdaOut, ascii=TRUE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
569 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
570 linkData <- rbind(linkData, c("edgeR_analysis.RData", "edgeR_analysis.RData"))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
571 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
572
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
573 # Record session info
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
574 writeLines(capture.output(sessionInfo()), sessionOut)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
575 linkData <- rbind(linkData, c("Session Info", "session_info.txt"))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
576
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
577 # Record ending time and calculate total run time
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
578 timeEnd <- as.character(Sys.time())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
579 timeTaken <- capture.output(round(difftime(timeEnd, timeStart), digits=3))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
580 timeTaken <- gsub("Time difference of ", "", timeTaken, fixed=TRUE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
581
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
582 ################################################################################
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
583 ### HTML Generation
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
584 ################################################################################
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
585
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
586 # Clear file
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
587 cat("", file=opt$htmlPath)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
588
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
589 cata("<html>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
590
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
591 cata("<body>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
592 cata("<h3>edgeR Analysis Output:</h3>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
593 cata("Links to PDF copies of plots are in 'Plots' section below.<br />\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
594
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
595 HtmlImage(imageData$Link[1], imageData$Label[1])
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
596
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
597 for (i in 2:nrow(imageData)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
598 HtmlImage(imageData$Link[i], imageData$Label[i])
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
599 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
600
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
601 cata("<h4>Differential Expression Counts:</h4>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
602
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
603 cata("<table border=\"1\" cellpadding=\"4\">\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
604 cata("<tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
605 TableItem()
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
606 for (i in colnames(sigDiff)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
607 TableHeadItem(i)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
608 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
609 cata("</tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
610 for (i in 1:nrow(sigDiff)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
611 cata("<tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
612 TableHeadItem(unmake.names(row.names(sigDiff)[i]))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
613 for (j in 1:ncol(sigDiff)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
614 TableItem(as.character(sigDiff[i, j]))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
615 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
616 cata("</tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
617 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
618 cata("</table>")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
619
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
620 cata("<h4>Plots:</h4>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
621 for (i in 1:nrow(linkData)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
622 if (grepl(".pdf", linkData$Link[i])) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
623 HtmlLink(linkData$Link[i], linkData$Label[i])
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
624 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
625 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
626
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
627 cata("<h4>Tables:</h4>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
628 for (i in 1:nrow(linkData)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
629 if (grepl(".tsv", linkData$Link[i])) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
630 HtmlLink(linkData$Link[i], linkData$Label[i])
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
631 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
632 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
633
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
634 if (wantRda) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
635 cata("<h4>R Data Objects:</h4>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
636 for (i in 1:nrow(linkData)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
637 if (grepl(".RData", linkData$Link[i])) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
638 HtmlLink(linkData$Link[i], linkData$Label[i])
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
639 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
640 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
641 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
642
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
643 cata("<p>Alt-click links to download file.</p>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
644 cata("<p>Click floppy disc icon associated history item to download ")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
645 cata("all files.</p>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
646 cata("<p>.tsv files can be viewed in Excel or any spreadsheet program.</p>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
647
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
648 cata("<h4>Additional Information</h4>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
649 cata("<ul>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
650
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
651 if (filtCPM || filtSmpCount || filtTotCount) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
652 if (filtCPM) {
3
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
653 tempStr <- paste("Genes without more than", opt$cpmReq,
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
654 "CPM in at least", opt$sampleReq, "samples are insignificant",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
655 "and filtered out.")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
656 } else if (filtSmpCount) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
657 tempStr <- paste("Genes without more than", opt$cntReq,
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
658 "counts in at least", opt$sampleReq, "samples are insignificant",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
659 "and filtered out.")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
660 } else if (filtTotCount) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
661 tempStr <- paste("Genes without more than", opt$cntReq,
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
662 "counts, after summing counts for all samples, are insignificant",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
663 "and filtered out.")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
664 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
665
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
666 ListItem(tempStr)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
667 filterProp <- round(filteredCount/preFilterCount*100, digits=2)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
668 tempStr <- paste0(filteredCount, " of ", preFilterCount," (", filterProp,
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
669 "%) genes were filtered out for low expression.")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
670 ListItem(tempStr)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
671 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
672 ListItem(opt$normOpt, " was the method used to normalise library sizes.")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
673 if (wantLRT) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
674 ListItem("The edgeR likelihood ratio test was used.")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
675 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
676 if (wantRobust) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
677 ListItem("The edgeR quasi-likelihood test was used with robust settings (robust=TRUE with estimateDisp and glmQLFit).")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
678 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
679 ListItem("The edgeR quasi-likelihood test was used.")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
680 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
681 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
682 if (opt$pAdjOpt!="none") {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
683 if (opt$pAdjOpt=="BH" || opt$pAdjOpt=="BY") {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
684 tempStr <- paste0("MD-Plot highlighted genes are significant at FDR ",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
685 "of ", opt$pValReq," and exhibit log2-fold-change of at ",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
686 "least ", opt$lfcReq, ".")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
687 ListItem(tempStr)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
688 } else if (opt$pAdjOpt=="holm") {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
689 tempStr <- paste0("MD-Plot highlighted genes are significant at adjusted ",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
690 "p-value of ", opt$pValReq," by the Holm(1979) ",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
691 "method, and exhibit log2-fold-change of at least ",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
692 opt$lfcReq, ".")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
693 ListItem(tempStr)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
694 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
695 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
696 tempStr <- paste0("MD-Plot highlighted genes are significant at p-value ",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
697 "of ", opt$pValReq," and exhibit log2-fold-change of at ",
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
698 "least ", opt$lfcReq, ".")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
699 ListItem(tempStr)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
700 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
701 cata("</ul>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
702
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
703 cata("<h4>Summary of experimental data:</h4>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
704
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
705 cata("<p>*CHECK THAT SAMPLES ARE ASSOCIATED WITH CORRECT GROUP(S)*</p>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
706
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
707 cata("<table border=\"1\" cellpadding=\"3\">\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
708 cata("<tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
709 TableHeadItem("SampleID")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
710 TableHeadItem(names(factors)[1], " (Primary Factor)")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
711
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
712 if (ncol(factors) > 1) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
713 for (i in names(factors)[2:length(names(factors))]) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
714 TableHeadItem(i)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
715 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
716 cata("</tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
717 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
718
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
719 for (i in 1:nrow(factors)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
720 cata("<tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
721 TableHeadItem(row.names(factors)[i])
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
722 for (j in 1:ncol(factors)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
723 TableItem(as.character(unmake.names(factors[i, j])))
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
724 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
725 cata("</tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
726 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
727 cata("</table>")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
728
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
729 for (i in 1:nrow(linkData)) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
730 if (grepl("session_info", linkData$Link[i])) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
731 HtmlLink(linkData$Link[i], linkData$Label[i])
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
732 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
733 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
734
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
735 cata("<table border=\"0\">\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
736 cata("<tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
737 TableItem("Task started at:"); TableItem(timeStart)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
738 cata("</tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
739 cata("<tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
740 TableItem("Task ended at:"); TableItem(timeEnd)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
741 cata("</tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
742 cata("<tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
743 TableItem("Task run time:"); TableItem(timeTaken)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
744 cata("<tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
745 cata("</table>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
746
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
747 cata("</body>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
748 cata("</html>")