annotate edger.R @ 4:4730985c816f draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 230fc767e2e402ee460440afab0e348f2ccab179
author iuc
date Sat, 05 Jan 2019 05:32:33 -0500
parents d79ed3ec25fe
children fb9b9f0f2f06
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)) {
4
4730985c816f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 230fc767e2e402ee460440afab0e348f2ccab179
iuc
parents: 3
diff changeset
271 factorData <- read.table(opt$factFile, header=TRUE, sep="\t", strip.white=TRUE)
4730985c816f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 230fc767e2e402ee460440afab0e348f2ccab179
iuc
parents: 3
diff changeset
272 # order samples as in counts matrix
4730985c816f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 230fc767e2e402ee460440afab0e348f2ccab179
iuc
parents: 3
diff changeset
273 factorData <- factorData[match(colnames(counts), factorData[, 1]), ]
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
274 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
275 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
276 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
277 factorData <- list()
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
278 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
279 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
280 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
281 } # 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
282
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
283 # 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
284 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
285 factorData <- factorData[, -1]
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, sanitiseGroups)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
287 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
288 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
289 # 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
290 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
291 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
292 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
293
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
294 # 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
295 if (haveAnno) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
296 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
297 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
298
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
299 #Create output directory
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
300 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
301
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
302 # 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
303 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
304 contrastData <- sanitiseEquation(contrastData)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
305 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
306
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
307 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
308 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
309 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
310 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
311 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
312 mdsOutPng <- character()
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
313 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
314 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
315 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
316 }
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
317 mdOutPdf <- character()
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
318 mdOutPng <- character()
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
319 topOut <- character()
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
320 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
321 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
322 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
323 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
324 } # 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
325 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
326 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
327 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
328
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
329 # 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
330 # Link
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
331 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
332 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
333
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
334 # 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
335 upCount <- numeric()
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
336 downCount <- numeric()
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
337 flatCount <- numeric()
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
338
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 ### Data Processing
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
341 ################################################################################
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
342
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
343 # 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
344 data <- list()
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
345 data$counts <- counts
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
346 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
347 # 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
348 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
349 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
350 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
351 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
352 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
353
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
354 # 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
355 # 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
356 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
357
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
358 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
359
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
360 if (filtTotCount) {
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
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
362 } else if (filtSmpCount) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
363 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
364 } else if (filtCPM) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
365 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
366 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
367
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
368 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
369 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
370 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
371
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
372 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
373 filteredCount <- preFilterCount-postFilterCount
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
374
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
375 # Creating naming data
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
376 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
377 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
378
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
379
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
380 # 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
381 data$samples <- sampleanno
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
382 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
383 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
384 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
385 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
386
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
387 # 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
388 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
389 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
390
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
391 formula <- "~0"
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
392 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
393 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
394 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
395
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
396 formula <- formula(formula)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
397 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
398
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
399 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
400 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
401 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
402
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
403 # 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
404 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
405
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
406 if (wantRobust) {
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, robust=TRUE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
408 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
409 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
410 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
411
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
412 # Generate contrasts information
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
413 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
414
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 ### Data Output
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
417 ################################################################################
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
418
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
419 # Plot MDS
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
420 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
421
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
422 # MDS plot
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
423 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
424 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
425 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
426 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
427 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
428 invisible(dev.off())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
429
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
430 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
431 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
432 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
433 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
434 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
435 invisible(dev.off())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
436
3
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
437 # 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
438 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
439 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
440 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
441 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
442 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
443 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
444 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
445 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
446
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
447 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
448 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
449 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
450 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
451 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
452 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
453 }
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
454 }
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
455
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
456 # BCV Plot
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
457 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
458 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
459 imgName <- "BCV Plot"
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
460 imgAddr <- "bcvplot.png"
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
461 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
462 invisible(dev.off())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
463
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
464 pdf(bcvOutPdf)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
465 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
466 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
467 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
468 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
469 invisible(dev.off())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
470
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
471 # Generate fit
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
472 if (wantLRT) {
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 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
475
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
476 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
477
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
478 if (wantRobust) {
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, robust=TRUE)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
480 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
481 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
482 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
483
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
484 # Plot QL dispersions
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
485 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
486 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
487 imgName <- "QL Plot"
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
488 imgAddr <- "qlplot.png"
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
489 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
490 invisible(dev.off())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
491
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
492 pdf(qlOutPdf)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
493 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
494 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
495 linkAddr <- "qlplot.pdf"
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
496 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
497 invisible(dev.off())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
498 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
499
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
500 # 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
501 if (wantNorm) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
502 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
503 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
504 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
505 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
506 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
507
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
508
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
509 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
510 if (wantLRT) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
511 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
512 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
513 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
514 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
515
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
516 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
517 lfc=opt$lfcReq)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
518 sumStatus <- summary(status)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
519
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
520 # 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
521 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
522 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
523 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
524
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
525 # 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
526 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
527 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
528
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
529 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
530 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
531 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
532
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
533 # 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
534 pdf(mdOutPdf[i])
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
535 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
536 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
537 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
538 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
539
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
540 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
541
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
542 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
543 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
544 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
545 invisible(dev.off())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
546
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
547 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
548 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
549 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
550 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
551 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
552
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
553 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
554
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
555 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
556 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
557 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
558 invisible(dev.off())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
559 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
560 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
561 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
562
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
563 # 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
564 if (wantRda) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
565 if (wantNorm) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
566 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
567 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
568 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
569 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
570 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
571 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
572 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
573 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
574
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
575 # Record session info
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
576 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
577 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
578
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
579 # 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
580 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
581 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
582 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
583
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 ### HTML Generation
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
586 ################################################################################
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
587
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
588 # Clear file
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
589 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
590
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
591 cata("<html>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
592
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
593 cata("<body>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
594 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
595 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
596
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
597 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
598
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
599 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
600 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
601 }
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("<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
604
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
605 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
606 cata("<tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
607 TableItem()
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
608 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
609 TableHeadItem(i)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
610 }
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 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
613 cata("<tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
614 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
615 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
616 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
617 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
618 cata("</tr>\n")
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("</table>")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
621
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
622 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
623 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
624 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
625 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
626 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
627 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
628
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
629 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
630 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
631 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
632 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
633 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
634 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
635
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
636 if (wantRda) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
637 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
638 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
639 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
640 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
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 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
644
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
645 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
646 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
647 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
648 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
649
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
650 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
651 cata("<ul>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
652
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
653 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
654 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
655 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
656 "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
657 "and filtered out.")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
658 } else if (filtSmpCount) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
659 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
660 "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
661 "and filtered out.")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
662 } else if (filtTotCount) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
663 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
664 "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
665 "and filtered out.")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
666 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
667
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
668 ListItem(tempStr)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
669 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
670 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
671 "%) 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
672 ListItem(tempStr)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
673 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
674 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
675 if (wantLRT) {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
676 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
677 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
678 if (wantRobust) {
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 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
680 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
681 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
682 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
683 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
684 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
685 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
686 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
687 "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
688 "least ", opt$lfcReq, ".")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
689 ListItem(tempStr)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
690 } 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
691 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
692 "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
693 "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
694 opt$lfcReq, ".")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
695 ListItem(tempStr)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
696 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
697 } else {
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
698 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
699 "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
700 "least ", opt$lfcReq, ".")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
701 ListItem(tempStr)
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("</ul>\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("<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
706
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
707 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
708
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
709 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
710 cata("<tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
711 TableHeadItem("SampleID")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
712 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
713
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
714 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
715 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
716 TableHeadItem(i)
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 cata("</tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
719 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
720
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
721 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
722 cata("<tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
723 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
724 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
725 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
726 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
727 cata("</tr>\n")
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 cata("</table>")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
730
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
731 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
732 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
733 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
734 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
735 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
736
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
737 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
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 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
740 cata("</tr>\n")
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 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
743 cata("</tr>\n")
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 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
746 cata("<tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
747 cata("</table>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
748
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
749 cata("</body>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
750 cata("</html>")