annotate edger.R @ 15:5bf899c13979 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
author iuc
date Wed, 22 Nov 2023 03:57:37 +0000
parents 070900306913
children ae2aad0a6d50
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
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
10 # factInput", "i", 2, "character" -String containing factors if manually input
14
070900306913 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
iuc
parents: 13
diff changeset
11 # formula", "F", 2, "character". -String containing a formula to override default use of factInput
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
12 # 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
13 # 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
14 # 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
15 # 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
16 # sampleReq", "s", 2, "integer" -Integer specifying cpm requirement
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
17 # normCounts", "x", 0, "logical" -String specifying if normalised counts should be output
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
18 # rdaOpt", "r", 0, "logical" -String specifying if RData should be output
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
19 # lfcReq", "l", 1, "double" -Float specifying the log-fold-change requirement
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
20 # pValReq", "p", 1, "double" -Float specifying the p-value requirement
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
21 # pAdjOpt", "d", 1, "character" -String specifying the p-value adjustment method
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
22 # normOpt", "n", 1, "character" -String specifying type of normalisation used
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
23 # robOpt", "b", 0, "logical" -String specifying if robust options should be used
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
24 # lrtOpt", "t", 0, "logical" -String specifying whether to perform LRT test instead
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
25 #
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
26 # OUT:
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
27 # MDS Plot
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
28 # BCV Plot
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
29 # QL Plot
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
30 # MD Plot
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
31 # Expression Table
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
32 # 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
33 # Optional:
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
34 # Normalised counts Table
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
35 # RData file
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
36 #
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
37 # 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
38 # 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
39
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
40 # Record starting time
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
41 time_start <- as.character(Sys.time())
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
42
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
43 # setup R error handling to go to stderr
12
a8305cf0c951 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 4955aeed800ea8e45057b7e8578dc878a07f9cfc
iuc
parents: 9
diff changeset
44 options(show.error.messages = FALSE, error = function() {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
45 cat(geterrmessage(), file = stderr())
12
a8305cf0c951 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 4955aeed800ea8e45057b7e8578dc878a07f9cfc
iuc
parents: 9
diff changeset
46 q("no", 1, FALSE)
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
47 })
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
48
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
49 # 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
50 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
51
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
52 # Load all required libraries
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
53 library(methods, quietly = TRUE, warn.conflicts = FALSE)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
54 library(statmod, quietly = TRUE, warn.conflicts = FALSE)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
55 library(splines, quietly = TRUE, warn.conflicts = FALSE)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
56 library(edgeR, quietly = TRUE, warn.conflicts = FALSE)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
57 library(limma, quietly = TRUE, warn.conflicts = FALSE)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
58 library(scales, quietly = TRUE, warn.conflicts = FALSE)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
59 library(getopt, quietly = TRUE, warn.conflicts = FALSE)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
60
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
61 ################################################################################
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
62 ### Function Delcaration
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
63 ################################################################################
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
64 # 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
65 # surrounding the arithmetic operators, leading or trailing whitespace
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
66 sanitise_equation <- function(equation) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
67 equation <- gsub(" *[+] *", "+", equation)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
68 equation <- gsub(" *[-] *", "-", equation)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
69 equation <- gsub(" *[/] *", "/", equation)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
70 equation <- gsub(" *[*] *", "*", equation)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
71 equation <- gsub("^\\s+|\\s+$", "", equation)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
72 return(equation)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
73 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
74
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
75 # Function to sanitise group information
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
76 sanitise_groups <- function(string) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
77 string <- gsub(" *[,] *", ",", string)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
78 string <- gsub("^\\s+|\\s+$", "", string)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
79 return(string)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
80 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
81
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
82 # Function to change periods to whitespace in a string
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
83 unmake_names <- function(string) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
84 string <- gsub(".", " ", string, fixed = TRUE)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
85 return(string)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
86 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
87
15
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
88 # Sanitise file base names coming from factors or contrasts
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
89 sanitise_basename <- function(string) {
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
90 string <- gsub("[/^]", "_", string)
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
91 return(string)
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
92 }
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
93
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
94 # Generate output folder and paths
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
95 make_out <- function(filename) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
96 return(paste0(out_path, "/", filename))
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
97 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
98
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
99 # Generating design information
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
100 paste_listname <- function(string) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
101 return(paste0("factors$", string))
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
102 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
103
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
104 # 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
105 # 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
106 # defaults)
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
107 cata <- function(..., file = opt$htmlPath, sep = "", fill = FALSE, labels = NULL,
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
108 append = TRUE) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
109 if (is.character(file)) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
110 if (file == "") {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
111 file <- stdout()
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
112 } else if (substring(file, 1L, 1L) == "|") {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
113 file <- pipe(substring(file, 2L), "w")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
114 on.exit(close(file))
12
a8305cf0c951 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 4955aeed800ea8e45057b7e8578dc878a07f9cfc
iuc
parents: 9
diff changeset
115 } else {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
116 file <- file(file, ifelse(append, "a", "w"))
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
117 on.exit(close(file))
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
118 }
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
119 }
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
120 .Internal(cat(list(...), file, sep, fill, labels, append))
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
121 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
122
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
123 # Function to write code for html head and title
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
124 html_head <- function(title) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
125 cata("<head>\n")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
126 cata("<title>", title, "</title>\n")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
127 cata("</head>\n")
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
128 }
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 # Function to write code for html links
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
131 html_link <- function(address, label = address) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
132 cata("<a href=\"", address, "\" target=\"_blank\">", label, "</a><br />\n")
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
133 }
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 # Function to write code for html images
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
136 html_image <- function(source, label = source, height = 600, width = 600) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
137 cata("<img src=\"", source, "\" alt=\"", label, "\" height=\"", height)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
138 cata("\" width=\"", width, "\"/>\n")
0
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
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
141 # Function to write code for html list items
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
142 list_item <- function(...) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
143 cata("<li>", ..., "</li>\n")
0
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
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
146 table_item <- function(...) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
147 cata("<td>", ..., "</td>\n")
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
148 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
149
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
150 table_head_item <- function(...) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
151 cata("<th>", ..., "</th>\n")
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
152 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
153
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
154 ################################################################################
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
155 ### Input Processing
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
156 ################################################################################
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
157
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
158 # Collect arguments from command line
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
159 args <- commandArgs(trailingOnly = TRUE)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
160
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
161 # 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
162 # 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
163 spec <- matrix(c(
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
164 "htmlPath", "R", 1, "character",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
165 "outPath", "o", 1, "character",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
166 "filesPath", "j", 2, "character",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
167 "matrixPath", "m", 2, "character",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
168 "factFile", "f", 2, "character",
14
070900306913 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
iuc
parents: 13
diff changeset
169 "formula", "F", 2, "character",
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
170 "factInput", "i", 2, "character",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
171 "annoPath", "a", 2, "character",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
172 "contrastData", "C", 1, "character",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
173 "cpmReq", "c", 1, "double",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
174 "totReq", "y", 0, "logical",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
175 "cntReq", "z", 1, "integer",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
176 "sampleReq", "s", 1, "integer",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
177 "normCounts", "x", 0, "logical",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
178 "rdaOpt", "r", 0, "logical",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
179 "lfcReq", "l", 1, "double",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
180 "pValReq", "p", 1, "double",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
181 "pAdjOpt", "d", 1, "character",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
182 "normOpt", "n", 1, "character",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
183 "robOpt", "b", 0, "logical",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
184 "lrtOpt", "t", 0, "logical"
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
185 ),
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
186 byrow = TRUE, ncol = 4
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
187 )
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
188 opt <- getopt(spec)
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
189
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
190
12
a8305cf0c951 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 4955aeed800ea8e45057b7e8578dc878a07f9cfc
iuc
parents: 9
diff changeset
191 if (is.null(opt$matrixPath) && is.null(opt$filesPath)) {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
192 cat("A counts matrix (or a set of counts files) is required.\n")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
193 q(status = 1)
0
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
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
196 if (is.null(opt$cpmReq)) {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
197 filt_cpm <- FALSE
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
198 } else {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
199 filt_cpm <- TRUE
0
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
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
202 if (is.null(opt$cntReq) || is.null(opt$sampleReq)) {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
203 filt_smpcount <- FALSE
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
204 } else {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
205 filt_smpcount <- TRUE
0
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
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
208 if (is.null(opt$totReq)) {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
209 filt_totcount <- FALSE
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
210 } else {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
211 filt_totcount <- TRUE
0
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
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
214 if (is.null(opt$lrtOpt)) {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
215 want_lrt <- FALSE
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
216 } else {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
217 want_lrt <- TRUE
0
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
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
220 if (is.null(opt$rdaOpt)) {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
221 want_rda <- FALSE
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
222 } else {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
223 want_rda <- TRUE
0
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
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
226 if (is.null(opt$annoPath)) {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
227 have_anno <- FALSE
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
228 } else {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
229 have_anno <- TRUE
0
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$normCounts)) {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
233 want_norm <- FALSE
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
234 } else {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
235 want_norm <- TRUE
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
236 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
237
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
238 if (is.null(opt$robOpt)) {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
239 want_robust <- FALSE
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
240 } else {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
241 want_robust <- TRUE
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
242 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
243
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
244
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
245 if (!is.null(opt$filesPath)) {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
246 # Process the separate count files (adapted from DESeq2 wrapper)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
247 library("rjson")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
248 parser <- newJSONParser()
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
249 parser$addData(opt$filesPath)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
250 factor_list <- parser$getObject()
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
251 factors <- sapply(factor_list, function(x) x[[1]])
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
252 filenames_in <- unname(unlist(factor_list[[1]][[2]]))
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
253 sampletable <- data.frame(
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
254 sample = basename(filenames_in),
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
255 filename = filenames_in,
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
256 row.names = filenames_in,
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
257 stringsAsFactors = FALSE
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
258 )
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
259 for (factor in factor_list) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
260 factorname <- factor[[1]]
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
261 sampletable[[factorname]] <- character(nrow(sampletable))
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
262 lvls <- sapply(factor[[2]], function(x) names(x))
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
263 for (i in seq_along(factor[[2]])) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
264 files <- factor[[2]][[i]][[1]]
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
265 sampletable[files, factorname] <- lvls[i]
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
266 }
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
267 sampletable[[factorname]] <- factor(sampletable[[factorname]], levels = lvls)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
268 }
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
269 rownames(sampletable) <- sampletable$sample
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
270 rem <- c("sample", "filename")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
271 factors <- sampletable[, !(names(sampletable) %in% rem), drop = FALSE]
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
272
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
273 # read in count files and create single table
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
274 countfiles <- lapply(sampletable$filename, function(x) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
275 read.delim(x, row.names = 1)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
276 })
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
277 counts <- do.call("cbind", countfiles)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
278 } else {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
279 # Process the single count matrix
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
280 counts <- read.table(opt$matrixPath, header = TRUE, sep = "\t", strip.white = TRUE, stringsAsFactors = FALSE)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
281 row.names(counts) <- counts[, 1]
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
282 counts <- counts[, -1]
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
283 countsrows <- nrow(counts)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
284
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
285 # Process factors
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
286 if (is.null(opt$factInput)) {
9
6e53e565fc6a "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 8c4b8f8711df0a4d6fa98fa8a6f91b977395d62c"
iuc
parents: 8
diff changeset
287 factordata <- read.table(opt$factFile, header = TRUE, sep = "\t", strip.white = TRUE, stringsAsFactors = TRUE)
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
288 # check samples names match
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
289 if (!any(factordata[, 1] %in% colnames(counts))) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
290 stop("Sample IDs in factors file and count matrix don't match")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
291 }
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
292 # order samples as in counts matrix
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
293 factordata <- factordata[match(colnames(counts), factordata[, 1]), ]
13
0cb907a2a810 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 95a36f5b0bd139f161d131b4c2c9c36940e749c6
iuc
parents: 12
diff changeset
294 factors <- data.frame(sapply(factordata[, -1, drop = FALSE], make.names))
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
295 } else {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
296 factors <- unlist(strsplit(opt$factInput, "|", fixed = TRUE))
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
297 factordata <- list()
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
298 for (fact in factors) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
299 newfact <- unlist(strsplit(fact, split = "::"))
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
300 factordata <- rbind(factordata, newfact)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
301 } # Factors have the form: FACT_NAME::LEVEL,LEVEL,LEVEL,LEVEL,... The first factor is the Primary Factor.
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
302
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
303 # Set the row names to be the name of the factor and delete first row
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
304 row.names(factordata) <- factordata[, 1]
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
305 factordata <- factordata[, -1]
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
306 factordata <- sapply(factordata, sanitise_groups)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
307 factordata <- sapply(factordata, strsplit, split = ",")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
308 factordata <- sapply(factordata, make.names)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
309 # Transform factor data into data frame of R factor objects
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
310 factors <- data.frame(factordata)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
311 }
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
312 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
313
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
314 # if annotation file provided
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
315 if (have_anno) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
316 geneanno <- read.table(opt$annoPath, header = TRUE, sep = "\t", quote = "", strip.white = TRUE, stringsAsFactors = FALSE)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
317 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
318
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
319 # Create output directory
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
320 out_path <- opt$outPath
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
321 dir.create(out_path, showWarnings = FALSE)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
322
14
070900306913 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
iuc
parents: 13
diff changeset
323 # Check if contrastData is a file or not
070900306913 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
iuc
parents: 13
diff changeset
324 if (file.exists(opt$contrastData)) {
070900306913 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
iuc
parents: 13
diff changeset
325 contrast_data <- unlist(read.table(opt$contrastData, sep = "\t", header = TRUE)[[1]])
070900306913 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
iuc
parents: 13
diff changeset
326 } else {
070900306913 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
iuc
parents: 13
diff changeset
327 # Split up contrasts separated by comma into a vector then sanitise
070900306913 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
iuc
parents: 13
diff changeset
328 contrast_data <- unlist(strsplit(opt$contrastData, split = ","))
070900306913 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
iuc
parents: 13
diff changeset
329 }
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
330 contrast_data <- sanitise_equation(contrast_data)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
331 contrast_data <- gsub(" ", ".", contrast_data, fixed = TRUE)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
332
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
333 bcv_pdf <- make_out("bcvplot.pdf")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
334 bcv_png <- make_out("bcvplot.png")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
335 ql_pdf <- make_out("qlplot.pdf")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
336 ql_png <- make_out("qlplot.png")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
337 mds_pdf <- character() # Initialise character vector
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
338 mds_png <- character()
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
339 for (i in seq_len(ncol(factors))) {
15
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
340 mds_pdf[i] <- make_out(paste0("mdsplot_", sanitise_basename(names(factors)[i]), ".pdf"))
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
341 mds_png[i] <- make_out(paste0("mdsplot_", sanitise_basename(names(factors)[i]), ".png"))
3
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
342 }
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
343 md_pdf <- character()
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
344 md_png <- character()
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
345 top_out <- character()
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
346 for (i in seq_along(contrast_data)) {
15
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
347 md_pdf[i] <- make_out(paste0("mdplot_", sanitise_basename(contrast_data[i]), ".pdf"))
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
348 md_png[i] <- make_out(paste0("mdplot_", sanitise_basename(contrast_data[i]), ".png"))
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
349 top_out[i] <- make_out(paste0("edgeR_", sanitise_basename(contrast_data[i]), ".tsv"))
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
350 } # Save output paths for each contrast as vectors
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
351 norm_out <- make_out("edgeR_normcounts.tsv")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
352 rda_out <- make_out("edgeR_analysis.RData")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
353 session_out <- make_out("session_info.txt")
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
354
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
355 # Initialise data for html links and images, data frame with columns Label and
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
356 # Link
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
357 link_data <- data.frame(Label = character(), Link = character(), stringsAsFactors = FALSE)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
358 image_data <- data.frame(Label = character(), Link = character(), stringsAsFactors = FALSE)
0
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 # Initialise vectors for storage of up/down/neutral regulated counts
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
361 up_count <- numeric()
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
362 down_count <- numeric()
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
363 flat_count <- numeric()
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
364
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
365 ################################################################################
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
366 ### Data Processing
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
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
369 # 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
370 data <- list()
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
371 data$counts <- counts
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
372 if (have_anno) {
3
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
373 # order annotation by genes in counts (assumes gene ids are in 1st column of geneanno)
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
374 annoord <- geneanno[match(row.names(counts), geneanno[, 1]), ]
3
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
375 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
376 } else {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
377 data$genes <- data.frame(GeneID = row.names(counts))
0
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 # 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
381 # samples. Default is no filtering
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
382 prefilter_count <- nrow(data$counts)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
383
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
384 if (filt_cpm || filt_smpcount || filt_totcount) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
385 if (filt_totcount) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
386 keep <- rowSums(data$counts) >= opt$cntReq
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
387 } else if (filt_smpcount) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
388 keep <- rowSums(data$counts >= opt$cntReq) >= opt$sampleReq
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
389 } else if (filt_cpm) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
390 keep <- rowSums(cpm(data$counts) >= opt$cpmReq) >= opt$sampleReq
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
391 }
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
392
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
393 data$counts <- data$counts[keep, ]
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
394 data$genes <- data$genes[keep, , drop = FALSE]
0
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
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
397 postfilter_count <- nrow(data$counts)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
398 filtered_count <- prefilter_count - postfilter_count
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
399
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
400 # 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
401 row.names(factors) <- names(data$counts)
12
a8305cf0c951 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 4955aeed800ea8e45057b7e8578dc878a07f9cfc
iuc
parents: 9
diff changeset
402 factor_list <- names(factors)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
403
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
404 # Generating the DGEList object "data"
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
405 samplenames <- colnames(data$counts)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
406 genes <- data$genes
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
407 data <- DGEList(data$counts)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
408 colnames(data) <- samplenames
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
409 data$samples <- factors
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
410 data$genes <- genes
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
411
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
412
14
070900306913 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
iuc
parents: 13
diff changeset
413 if (!is.null(opt$formula)) {
070900306913 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
iuc
parents: 13
diff changeset
414 formula <- opt$formula
070900306913 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
iuc
parents: 13
diff changeset
415 # sanitisation can be getting rid of the "~"
070900306913 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
iuc
parents: 13
diff changeset
416 if (!startsWith(formula, "~")) {
070900306913 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
iuc
parents: 13
diff changeset
417 formula <- paste0("~", formula)
070900306913 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
iuc
parents: 13
diff changeset
418 }
070900306913 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
iuc
parents: 13
diff changeset
419 } else {
070900306913 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
iuc
parents: 13
diff changeset
420 formula <- "~0"
070900306913 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
iuc
parents: 13
diff changeset
421 for (i in seq_along(factor_list)) {
070900306913 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
iuc
parents: 13
diff changeset
422 formula <- paste(formula, factor_list[i], sep = "+")
070900306913 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 0c79416d9612d0ebdcb7c3c0543d510e11bb0774
iuc
parents: 13
diff changeset
423 }
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
424 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
425
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
426 formula <- formula(formula)
12
a8305cf0c951 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 4955aeed800ea8e45057b7e8578dc878a07f9cfc
iuc
parents: 9
diff changeset
427 design <- model.matrix(formula, factors)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
428
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
429 for (i in seq_along(factor_list)) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
430 colnames(design) <- gsub(factor_list[i], "", colnames(design), fixed = TRUE)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
431 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
432
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
433 # Calculating normalising factor, estimating dispersion
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
434 data <- calcNormFactors(data, method = opt$normOpt)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
435
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
436 if (want_robust) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
437 data <- estimateDisp(data, design = design, robust = TRUE)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
438 } else {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
439 data <- estimateDisp(data, design = design)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
440 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
441
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
442 # Generate contrasts information
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
443 contrasts <- makeContrasts(contrasts = contrast_data, levels = design)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
444
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
445 ################################################################################
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
446 ### Data Output
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
447 ################################################################################
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
448
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
449 # Plot MDS
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
450 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
451
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
452 # MDS plot
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
453 png(mds_png, width = 600, height = 600)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
454 plotMDS(data, labels = labels, col = as.numeric(factors[, 1]), cex = 0.8, main = paste("MDS Plot:", names(factors)[1]))
15
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
455 img_name <- paste0("MDS Plot_", sanitise_basename(names(factors)[1]), ".png")
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
456 img_addr <- paste0("mdsplot_", sanitise_basename(names(factors)[1]), ".png")
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
457 image_data[1, ] <- c(img_name, img_addr)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
458 invisible(dev.off())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
459
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
460 pdf(mds_pdf)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
461 plotMDS(data, labels = labels, col = as.numeric(factors[, 1]), cex = 0.8, main = paste("MDS Plot:", names(factors)[1]))
15
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
462 link_name <- paste0("MDS Plot_", sanitise_basename(names(factors)[1]), ".pdf")
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
463 link_addr <- paste0("mdsplot_", sanitise_basename(names(factors)[1]), ".pdf")
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
464 link_data[1, ] <- c(link_name, link_addr)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
465 invisible(dev.off())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
466
3
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
467 # 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
468 if (ncol(factors) > 1) {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
469 for (i in 2:ncol(factors)) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
470 png(mds_png[i], width = 600, height = 600)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
471 plotMDS(data, labels = labels, col = as.numeric(factors[, i]), cex = 0.8, main = paste("MDS Plot:", names(factors)[i]))
15
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
472 img_name <- paste0("MDS Plot_", sanitise_basename(names(factors)[i]), ".png")
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
473 img_addr <- paste0("mdsplot_", sanitise_basename(names(factors)[i]), ".png")
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
474 image_data <- rbind(image_data, c(img_name, img_addr))
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
475 invisible(dev.off())
3
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
476
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
477 pdf(mds_pdf[i])
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
478 plotMDS(data, labels = labels, col = as.numeric(factors[, i]), cex = 0.8, main = paste("MDS Plot:", names(factors)[i]))
15
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
479 link_name <- paste0("MDS Plot_", sanitise_basename(names(factors)[i]), ".pdf")
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
480 link_addr <- paste0("mdsplot_", sanitise_basename(names(factors)[i]), ".pdf")
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
481 link_data <- rbind(link_data, c(link_name, link_addr))
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
482 invisible(dev.off())
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
483 }
3
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
484 }
d79ed3ec25fe planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit e646be741e315df9332b5206cec1e47c11370ff1
iuc
parents: 2
diff changeset
485
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
486 # BCV Plot
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
487 png(bcv_png, width = 600, height = 600)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
488 plotBCV(data, main = "BCV Plot")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
489 img_name <- "BCV Plot"
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
490 img_addr <- "bcvplot.png"
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
491 image_data <- rbind(image_data, c(img_name, img_addr))
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
492 invisible(dev.off())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
493
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
494 pdf(bcv_pdf)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
495 plotBCV(data, main = "BCV Plot")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
496 link_name <- paste0("BCV Plot.pdf")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
497 link_addr <- paste0("bcvplot.pdf")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
498 link_data <- rbind(link_data, c(link_name, link_addr))
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
499 invisible(dev.off())
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
500
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
501 # Generate fit
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
502 if (want_lrt) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
503 fit <- glmFit(data, design)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
504 } else {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
505 if (want_robust) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
506 fit <- glmQLFit(data, design, robust = TRUE)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
507 } else {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
508 fit <- glmQLFit(data, design)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
509 }
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
510
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
511 # Plot QL dispersions
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
512 png(ql_png, width = 600, height = 600)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
513 plotQLDisp(fit, main = "QL Plot")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
514 img_name <- "QL Plot"
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
515 img_addr <- "qlplot.png"
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
516 image_data <- rbind(image_data, c(img_name, img_addr))
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
517 invisible(dev.off())
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
518
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
519 pdf(ql_pdf)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
520 plotQLDisp(fit, main = "QL Plot")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
521 link_name <- "QL Plot.pdf"
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
522 link_addr <- "qlplot.pdf"
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
523 link_data <- rbind(link_data, c(link_name, link_addr))
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
524 invisible(dev.off())
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
525 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
526
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
527 # Save normalised counts (log2cpm)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
528 if (want_norm) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
529 normalised_counts <- cpm(data, normalized.lib.sizes = TRUE, log = TRUE)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
530 normalised_counts <- data.frame(data$genes, normalised_counts)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
531 write.table(normalised_counts, file = norm_out, row.names = FALSE, sep = "\t", quote = FALSE)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
532 link_data <- rbind(link_data, c("edgeR_normcounts.tsv", "edgeR_normcounts.tsv"))
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
533 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
534
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
535
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
536 for (i in seq_along(contrast_data)) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
537 if (want_lrt) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
538 res <- glmLRT(fit, contrast = contrasts[, i])
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
539 } else {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
540 res <- glmQLFTest(fit, contrast = contrasts[, i])
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
541 }
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
542
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
543 status <- decideTestsDGE(res,
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
544 adjust.method = opt$pAdjOpt, p.value = opt$pValReq,
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
545 lfc = opt$lfcReq
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
546 )
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
547 sum_status <- summary(status)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
548
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
549 # Collect counts for differential expression
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
550 up_count[i] <- sum_status["Up", ]
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
551 down_count[i] <- sum_status["Down", ]
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
552 flat_count[i] <- sum_status["NotSig", ]
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
553
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
554 # Write top expressions table
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
555 top <- topTags(res, adjust.method = opt$pAdjOpt, n = Inf, sort.by = "PValue")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
556 write.table(top, file = top_out[i], row.names = FALSE, sep = "\t", quote = FALSE)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
557
15
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
558 link_name <- paste0("edgeR_", sanitise_basename(contrast_data[i]), ".tsv")
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
559 link_addr <- paste0("edgeR_", sanitise_basename(contrast_data[i]), ".tsv")
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
560 link_data <- rbind(link_data, c(link_name, link_addr))
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
561
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
562 # Plot MD (log ratios vs mean difference) using limma package
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
563 pdf(md_pdf[i])
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
564 limma::plotMD(res,
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
565 status = status,
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
566 main = paste("MD Plot:", unmake_names(contrast_data[i])),
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
567 hl.col = alpha(c("firebrick", "blue"), 0.4), values = c(1, -1),
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
568 xlab = "Average Expression", ylab = "logFC"
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
569 )
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
570
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
571 abline(h = 0, col = "grey", lty = 2)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
572
15
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
573 link_name <- paste0("MD Plot_", sanitise_basename(contrast_data[i]), ".pdf")
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
574 link_addr <- paste0("mdplot_", sanitise_basename(contrast_data[i]), ".pdf")
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
575 link_data <- rbind(link_data, c(link_name, link_addr))
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
576 invisible(dev.off())
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
577
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
578 png(md_png[i], height = 600, width = 600)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
579 limma::plotMD(res,
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
580 status = status,
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
581 main = paste("MD Plot:", unmake_names(contrast_data[i])),
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
582 hl.col = alpha(c("firebrick", "blue"), 0.4), values = c(1, -1),
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
583 xlab = "Average Expression", ylab = "logFC"
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
584 )
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
585
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
586 abline(h = 0, col = "grey", lty = 2)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
587
15
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
588 img_name <- paste0("MD Plot_", sanitise_basename(contrast_data[i]), ".png")
5bf899c13979 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
iuc
parents: 14
diff changeset
589 img_addr <- paste0("mdplot_", sanitise_basename(contrast_data[i]), ".png")
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
590 image_data <- rbind(image_data, c(img_name, img_addr))
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
591 invisible(dev.off())
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
592 }
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
593 sig_diff <- data.frame(Up = up_count, Flat = flat_count, Down = down_count)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
594 row.names(sig_diff) <- contrast_data
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
595
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
596 # Save relevant items as rda object
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
597 if (want_rda) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
598 if (want_norm) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
599 save(counts, data, status, normalised_counts, labels, factors, fit, res, top, contrasts, design,
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
600 file = rda_out, ascii = TRUE
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
601 )
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
602 } else {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
603 save(counts, data, status, labels, factors, fit, res, top, contrasts, design,
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
604 file = rda_out, ascii = TRUE
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
605 )
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
606 }
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
607 link_data <- rbind(link_data, c("edgeR_analysis.RData", "edgeR_analysis.RData"))
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
608 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
609
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
610 # Record session info
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
611 writeLines(capture.output(sessionInfo()), session_out)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
612 link_data <- rbind(link_data, c("Session Info", "session_info.txt"))
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
613
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
614 # Record ending time and calculate total run time
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
615 time_end <- as.character(Sys.time())
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
616 time_taken <- capture.output(round(difftime(time_end, time_start), digits = 3))
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
617 time_taken <- gsub("Time difference of ", "", time_taken, fixed = TRUE)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
618
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 ### HTML Generation
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
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
623 # Clear file
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
624 cat("", file = opt$htmlPath)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
625
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
626 cata("<html>\n")
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 cata("<body>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
629 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
630 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
631
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
632 html_image(image_data$Link[1], image_data$Label[1])
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
633
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
634 for (i in 2:nrow(image_data)) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
635 html_image(image_data$Link[i], image_data$Label[i])
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
636 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
637
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
638 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
639
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
640 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
641 cata("<tr>\n")
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
642 table_item()
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
643 for (i in colnames(sig_diff)) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
644 table_head_item(i)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
645 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
646 cata("</tr>\n")
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
647 for (i in seq_len(nrow(sig_diff))) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
648 cata("<tr>\n")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
649 table_head_item(unmake_names(row.names(sig_diff)[i]))
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
650 for (j in seq_len(ncol(sig_diff))) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
651 table_item(as.character(sig_diff[i, j]))
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
652 }
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
653 cata("</tr>\n")
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
654 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
655 cata("</table>")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
656
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
657 cata("<h4>Plots:</h4>\n")
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
658 for (i in seq_len(nrow(link_data))) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
659 if (grepl(".pdf", link_data$Link[i])) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
660 html_link(link_data$Link[i], link_data$Label[i])
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
661 }
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
662 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
663
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
664 cata("<h4>Tables:</h4>\n")
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
665 for (i in seq_len(nrow(link_data))) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
666 if (grepl(".tsv", link_data$Link[i])) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
667 html_link(link_data$Link[i], link_data$Label[i])
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
668 }
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
669 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
670
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
671 if (want_rda) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
672 cata("<h4>R Data Objects:</h4>\n")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
673 for (i in seq_len(nrow(link_data))) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
674 if (grepl(".RData", link_data$Link[i])) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
675 html_link(link_data$Link[i], link_data$Label[i])
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
676 }
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
677 }
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
678 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
679
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
680 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
681 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
682 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
683 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
684
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
685 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
686 cata("<ul>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
687
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
688 if (filt_cpm || filt_smpcount || filt_totcount) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
689 if (filt_cpm) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
690 temp_str <- paste(
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
691 "Genes without more than", opt$cpmReq,
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
692 "CPM in at least", opt$sampleReq, "samples are insignificant",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
693 "and filtered out."
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
694 )
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
695 } else if (filt_smpcount) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
696 temp_str <- paste(
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
697 "Genes without more than", opt$cntReq,
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
698 "counts in at least", opt$sampleReq, "samples are insignificant",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
699 "and filtered out."
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
700 )
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
701 } else if (filt_totcount) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
702 temp_str <- paste(
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
703 "Genes without more than", opt$cntReq,
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
704 "counts, after summing counts for all samples, are insignificant",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
705 "and filtered out."
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
706 )
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
707 }
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
708
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
709 list_item(temp_str)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
710 filter_prop <- round(filtered_count / prefilter_count * 100, digits = 2)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
711 temp_str <- paste0(
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
712 filtered_count, " of ", prefilter_count, " (", filter_prop,
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
713 "%) genes were filtered out for low expression."
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
714 )
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
715 list_item(temp_str)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
716 }
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
717 list_item(opt$normOpt, " was the method used to normalise library sizes.")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
718 if (want_lrt) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
719 list_item("The edgeR likelihood ratio test was used.")
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
720 } else {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
721 if (want_robust) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
722 list_item("The edgeR quasi-likelihood test was used with robust settings (robust=TRUE with estimateDisp and glmQLFit).")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
723 } else {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
724 list_item("The edgeR quasi-likelihood test was used.")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
725 }
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
726 }
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
727 if (opt$pAdjOpt != "none") {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
728 if (opt$pAdjOpt == "BH" || opt$pAdjOpt == "BY") {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
729 temp_str <- paste0(
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
730 "MD-Plot highlighted genes are significant at FDR ",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
731 "of ", opt$pValReq, " and exhibit log2-fold-change of at ",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
732 "least ", opt$lfcReq, "."
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
733 )
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
734 list_item(temp_str)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
735 } else if (opt$pAdjOpt == "holm") {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
736 temp_str <- paste0(
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
737 "MD-Plot highlighted genes are significant at adjusted ",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
738 "p-value of ", opt$pValReq, " by the Holm(1979) ",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
739 "method, and exhibit log2-fold-change of at least ",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
740 opt$lfcReq, "."
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
741 )
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
742 list_item(temp_str)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
743 }
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
744 } else {
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
745 temp_str <- paste0(
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
746 "MD-Plot highlighted genes are significant at p-value ",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
747 "of ", opt$pValReq, " and exhibit log2-fold-change of at ",
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
748 "least ", opt$lfcReq, "."
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
749 )
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
750 list_item(temp_str)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
751 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
752 cata("</ul>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
753
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
754 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
755
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
756 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
757
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
758 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
759 cata("<tr>\n")
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
760 table_head_item("SampleID")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
761 table_head_item(names(factors)[1], " (Primary Factor)")
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
762
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
763 if (ncol(factors) > 1) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
764 for (i in names(factors)[2:length(names(factors))]) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
765 table_head_item(i)
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
766 }
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
767 cata("</tr>\n")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
768 }
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
769
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
770 for (i in seq_len(nrow((factors)))) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
771 cata("<tr>\n")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
772 table_head_item(row.names(factors)[i])
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
773 for (j in seq_len(ncol(factors))) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
774 table_item(as.character(unmake_names(factors[i, j])))
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
775 }
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
776 cata("</tr>\n")
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
777 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
778 cata("</table>")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
779
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
780 for (i in seq_len(nrow(link_data))) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
781 if (grepl("session_info", link_data$Link[i])) {
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
782 html_link(link_data$Link[i], link_data$Label[i])
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
783 }
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
784 }
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
785
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
786 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
787 cata("<tr>\n")
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
788 table_item("Task started at:")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
789 table_item(time_start)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
790 cata("</tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
791 cata("<tr>\n")
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
792 table_item("Task ended at:")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
793 table_item(time_end)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
794 cata("</tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
795 cata("<tr>\n")
8
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
796 table_item("Task run time:")
3d89af8a44f0 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 215a0f27f3de87506895ac655f801c40e8c7edbc"
iuc
parents: 6
diff changeset
797 table_item(time_taken)
0
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
798 cata("<tr>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
799 cata("</table>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
800
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
801 cata("</body>\n")
9bdff28ae1b1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit eac022c9c6e51e661c1513306b9fefdad673487d
iuc
parents:
diff changeset
802 cata("</html>")