annotate hairpinTool.R @ 10:8923d4ea858b

- Added check for zero library size, will now filter out zero library size samples and generate report of filtered samples in html output
author shian_su <registertonysu@gmail.com>
date Tue, 12 Aug 2014 14:42:27 +1000
parents f1076bfb0ed1
children c0a76e30d61b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
1 # ARGS: 1.inputType -String specifying format of input (fastq or table)
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
2 # IF inputType is "fastQ":
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
3 # 2*.fastqPath -One or more strings specifying path to fastq files
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
4 # 2.annoPath -String specifying path to hairpin annotation table
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
5 # 3.samplePath -String specifying path to sample annotation table
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
6 # 4.barStart -Integer specifying starting position of barcode
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
7 # 5.barEnd -Integer specifying ending position of barcode
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
8 # 6.hpStart -Integer specifying startins position of hairpin
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
9 # unique region
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
10 # 7.hpEnd -Integer specifying ending position of hairpin
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
11 # unique region
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
12 # ###
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
13 # IF inputType is "counts":
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
14 # 2.countPath -String specifying path to count table
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
15 # 3.annoPath -String specifying path to hairpin annotation table
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
16 # 4.samplePath -String specifying path to sample annotation table
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
17 # ###
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
18 # 8.cpmReq -Float specifying cpm requirement
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
19 # 9.sampleReq -Integer specifying cpm requirement
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
20 # 10.fdrThresh -Float specifying the FDR requirement
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
21 # 11.lfcThresh -Float specifying the log-fold-change requirement
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
22 # 12.workMode -String specifying exact test or GLM usage
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
23 # 13.htmlPath -String specifying path to HTML file
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
24 # 14.folderPath -STring specifying path to folder for output
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
25 # IF workMode is "classic" (exact test)
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
26 # 15.pairData[2] -String specifying first group for exact test
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
27 # 16.pairData[1] -String specifying second group for exact test
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
28 # ###
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
29 # IF workMode is "glm"
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
30 # 15.contrastData -String specifying contrasts to be made
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
31 # 16.roastOpt -String specifying usage of gene-wise tests
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
32 # 17.hairpinReq -String specifying hairpin requirement for gene-
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
33 # wise test
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
34 # 18.selectOpt -String specifying type of selection for barcode
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
35 # plots
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
36 # 19.selectVals -String specifying members selected for barcode
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
37 # plots
9
f1076bfb0ed1 - Fixed tool to actually make use of barcode location options
shian_su <registertonysu@gmail.com>
parents: 8
diff changeset
38 # ###
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
39 #
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
40 # OUT: Bar Plot of Counts Per Index
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
41 # Bar Plot of Counts Per Hairpin
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
42 # MDS Plot
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
43 # Smear Plot
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
44 # Barcode Plots (If Genewise testing was selected)
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
45 # Top Expression Table
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
46 # Feature Counts Table
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
47 # HTML file linking to the ouputs
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
48 #
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
49 # Author: Shian Su - registertonysu@gmail.com - Jan 2014
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
50
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
51 # Record starting time
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
52 timeStart <- as.character(Sys.time())
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
53
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
54 # Loading and checking required packages
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
55 library(methods, quietly=TRUE, warn.conflicts=FALSE)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
56 library(statmod, quietly=TRUE, warn.conflicts=FALSE)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
57 library(splines, quietly=TRUE, warn.conflicts=FALSE)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
58 library(edgeR, quietly=TRUE, warn.conflicts=FALSE)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
59 library(limma, quietly=TRUE, warn.conflicts=FALSE)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
60
9
f1076bfb0ed1 - Fixed tool to actually make use of barcode location options
shian_su <registertonysu@gmail.com>
parents: 8
diff changeset
61 if (packageVersion("edgeR") < "3.5.27") {
8
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
62 stop("Please update 'edgeR' to version >= 3.5.23 to run this tool")
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
63 }
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
64
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
65 if (packageVersion("limma")<"3.19.19") {
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
66 message("Update 'limma' to version >= 3.19.19 to see updated barcode graphs")
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
67 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
68
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
69 ################################################################################
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
70 ### Function declarations
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
71 ################################################################################
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
72
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
73 # Function to load libaries without messages
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
74 silentLibrary <- function(...) {
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
75 list <- c(...)
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
76 for (package in list){
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
77 suppressPackageStartupMessages(library(package, character.only=TRUE))
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
78 }
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
79 }
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
80
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
81 # Function to sanitise contrast equations so there are no whitespaces
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
82 # surrounding the arithmetic operators, leading or trailing whitespace
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
83 sanitiseEquation <- function(equation) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
84 equation <- gsub(" *[+] *", "+", equation)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
85 equation <- gsub(" *[-] *", "-", equation)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
86 equation <- gsub(" *[/] *", "/", equation)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
87 equation <- gsub(" *[*] *", "*", equation)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
88 equation <- gsub("^\\s+|\\s+$", "", equation)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
89 return(equation)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
90 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
91
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
92 # Function to sanitise group information
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
93 sanitiseGroups <- function(string) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
94 string <- gsub(" *[,] *", ",", string)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
95 string <- gsub("^\\s+|\\s+$", "", string)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
96 return(string)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
97 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
98
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
99 # Function to change periods to whitespace in a string
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
100 unmake.names <- function(string) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
101 string <- gsub(".", " ", string, fixed=TRUE)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
102 return(string)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
103 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
104
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
105 # Function has string input and generates an output path string
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
106 makeOut <- function(filename) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
107 return(paste0(folderPath, "/", filename))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
108 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
109
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
110 # Function has string input and generates both a pdf and png output strings
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
111 imgOut <- function(filename) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
112 assign(paste0(filename, "Png"), makeOut(paste0(filename,".png")),
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
113 envir=.GlobalEnv)
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
114 assign(paste0(filename, "Pdf"), makeOut(paste0(filename,".pdf")),
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
115 envir=.GlobalEnv)
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
116 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
117
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
118 # Create cat function default path set, default seperator empty and appending
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
119 # true by default (Ripped straight from the cat function with altered argument
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
120 # defaults)
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
121 cata <- function(..., file=htmlPath, sep="", fill=FALSE, labels=NULL,
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
122 append=TRUE) {
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
123 if (is.character(file))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
124 if (file == "")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
125 file <- stdout()
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
126 else if (substring(file, 1L, 1L) == "|") {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
127 file <- pipe(substring(file, 2L), "w")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
128 on.exit(close(file))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
129 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
130 else {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
131 file <- file(file, ifelse(append, "a", "w"))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
132 on.exit(close(file))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
133 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
134 .Internal(cat(list(...), file, sep, fill, labels, append))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
135 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
136
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
137 # Function to write code for html head and title
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
138 HtmlHead <- function(title) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
139 cata("<head>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
140 cata("<title>", title, "</title>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
141 cata("</head>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
142 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
143
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
144 # Function to write code for html links
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
145 HtmlLink <- function(address, label=address) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
146 cata("<a href=\"", address, "\" target=\"_blank\">", label, "</a><br />\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
147 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
148
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
149 # Function to write code for html images
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
150 HtmlImage <- function(source, label=source, height=600, width=600) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
151 cata("<img src=\"", source, "\" alt=\"", label, "\" height=\"", height)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
152 cata("\" width=\"", width, "\"/>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
153 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
154
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
155 # Function to write code for html list items
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
156 ListItem <- function(...) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
157 cata("<li>", ..., "</li>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
158 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
159
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
160 TableItem <- function(...) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
161 cata("<td>", ..., "</td>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
162 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
163
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
164 TableHeadItem <- function(...) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
165 cata("<th>", ..., "</th>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
166 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
167 ################################################################################
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
168 ### Input Processing
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
169 ################################################################################
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
170
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
171 # Grabbing arguments from command line
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
172 argv <- commandArgs(TRUE)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
173
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
174 # Remove fastq file paths after collecting from argument vector
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
175 inputType <- as.character(argv[1])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
176 if (inputType=="fastq") {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
177 fastqPath <- as.character(gsub("fastq::", "", argv[grepl("fastq::", argv)],
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
178 fixed=TRUE))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
179 argv <- argv[!grepl("fastq::", argv, fixed=TRUE)]
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
180 annoPath <- as.character(argv[2])
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
181 samplePath <- as.character(argv[3])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
182 barStart <- as.numeric(argv[4])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
183 barEnd <- as.numeric(argv[5])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
184 hpStart <- as.numeric(argv[6])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
185 hpEnd <- as.numeric(argv[7])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
186 } else if (inputType=="counts") {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
187 countPath <- as.character(argv[2])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
188 annoPath <- as.character(argv[3])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
189 samplePath <- as.character(argv[4])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
190 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
191
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
192 cpmReq <- as.numeric(argv[8])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
193 sampleReq <- as.numeric(argv[9])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
194 fdrThresh <- as.numeric(argv[10])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
195 lfcThresh <- as.numeric(argv[11])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
196 workMode <- as.character(argv[12])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
197 htmlPath <- as.character(argv[13])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
198 folderPath <- as.character(argv[14])
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
199
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
200 if (workMode=="classic") {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
201 pairData <- character()
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
202 pairData[2] <- as.character(argv[15])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
203 pairData[1] <- as.character(argv[16])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
204 } else if (workMode=="glm") {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
205 contrastData <- as.character(argv[15])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
206 roastOpt <- as.character(argv[16])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
207 hairpinReq <- as.numeric(argv[17])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
208 selectOpt <- as.character(argv[18])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
209 selectVals <- as.character(argv[19])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
210 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
211
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
212 # Read in inputs
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
213
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
214 samples <- read.table(samplePath, header=TRUE, sep="\t")
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
215 anno <- read.table(annoPath, header=TRUE, sep="\t")
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
216 if (inputType=="counts") {
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
217 counts <- read.table(countPath, header=TRUE, sep="\t")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
218 }
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
219
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
220 ###################### Check inputs for correctness ############################
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
221 samples$ID <- make.names(samples$ID)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
222
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
223 if (!any(grepl("group", names(samples)))) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
224 stop("'group' column not specified in sample annotation file")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
225 } # Check if grouping variable has been specified
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
226
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
227 if (any(table(samples$ID)>1)){
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
228 tab <- table(samples$ID)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
229 offenders <- paste(names(tab[tab>1]), collapse=", ")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
230 offenders <- unmake.names(offenders)
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
231 stop("'ID' column of sample annotation must have unique values, values ",
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
232 offenders, " are repeated")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
233 } # Check that IDs in sample annotation are unique
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
234
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
235 if (inputType=="fastq") {
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
236
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
237 if (any(table(anno$ID)>1)){
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
238 tab <- table(anno$ID)
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
239 offenders <- paste(names(tab[tab>1]), collapse=", ")
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
240 stop("'ID' column of hairpin annotation must have unique values, values ",
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
241 offenders, " are repeated")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
242 } # Check that IDs in hairpin annotation are unique
4
f8af57d6f60b Fixed bug causing fastq input to break
shian_su <registertonysu@gmail.com>
parents: 2
diff changeset
243
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
244 } else if (inputType=="counts") {
4
f8af57d6f60b Fixed bug causing fastq input to break
shian_su <registertonysu@gmail.com>
parents: 2
diff changeset
245 if (any(is.na(match(samples$ID, colnames(counts))))) {
f8af57d6f60b Fixed bug causing fastq input to break
shian_su <registertonysu@gmail.com>
parents: 2
diff changeset
246 stop("not all samples have groups specified")
f8af57d6f60b Fixed bug causing fastq input to break
shian_su <registertonysu@gmail.com>
parents: 2
diff changeset
247 } # Check that a group has be specifed for each sample
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
248
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
249 if (any(table(counts$ID)>1)){
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
250 tab <- table(counts$ID)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
251 offenders <- paste(names(tab[tab>1]), collapse=", ")
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
252 stop("'ID' column of count table must have unique values, values ",
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
253 offenders, " are repeated")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
254 } # Check that IDs in count table are unique
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
255 }
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
256 if (workMode=="glm") {
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
257 if (roastOpt == "yes") {
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
258 if (is.na(match("Gene", colnames(anno)))) {
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
259 tempStr <- paste("Gene-wise tests selected but'Gene' column not",
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
260 "specified in hairpin annotation file")
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
261 stop(tempStr)
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
262 }
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
263 }
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
264 }
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
265
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
266 ################################################################################
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
267
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
268 # Process arguments
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
269 if (workMode=="glm") {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
270 if (roastOpt=="yes") {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
271 wantRoast <- TRUE
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
272 } else {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
273 wantRoast <- FALSE
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
274 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
275 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
276
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
277 # Split up contrasts seperated by comma into a vector and replace spaces with
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
278 # periods
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
279 if (exists("contrastData")) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
280 contrastData <- unlist(strsplit(contrastData, split=","))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
281 contrastData <- sanitiseEquation(contrastData)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
282 contrastData <- gsub(" ", ".", contrastData, fixed=TRUE)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
283 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
284
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
285 # Replace spaces with periods in pair data
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
286 if (exists("pairData")) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
287 pairData <- make.names(pairData)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
288 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
289
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
290 # Generate output folder and paths
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
291 dir.create(folderPath, showWarnings=FALSE)
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
292
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
293 # Generate links for outputs
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
294 imgOut("barHairpin")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
295 imgOut("barIndex")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
296 imgOut("mds")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
297 imgOut("bcv")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
298 if (workMode == "classic") {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
299 smearPng <- makeOut(paste0("smear(", pairData[2], "-", pairData[1],").png"))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
300 smearPdf <- makeOut(paste0("smear(", pairData[2], "-", pairData[1],").pdf"))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
301 topOut <- makeOut(paste0("toptag(", pairData[2], "-", pairData[1],").tsv"))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
302 } else if (workMode=="glm") {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
303 smearPng <- character()
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
304 smearPdf <- character()
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
305 topOut <- character()
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
306 roastOut <- character()
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
307 barcodePng <- character()
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
308 barcodePdf <- character()
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
309 for (i in 1:length(contrastData)) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
310 smearPng[i] <- makeOut(paste0("smear(", contrastData[i], ").png"))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
311 smearPdf[i] <- makeOut(paste0("smear(", contrastData[i], ").pdf"))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
312 topOut[i] <- makeOut(paste0("toptag(", contrastData[i], ").tsv"))
8
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
313 roastOut[i] <- makeOut(paste0("gene_level(", contrastData[i], ").tsv"))
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
314 barcodePng[i] <- makeOut(paste0("barcode(", contrastData[i], ").png"))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
315 barcodePdf[i] <- makeOut(paste0("barcode(", contrastData[i], ").pdf"))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
316 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
317 }
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
318 countsOut <- makeOut("counts.tsv")
8
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
319 sessionOut <- makeOut("session_info.txt")
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
320
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
321 # Initialise data for html links and images, table with the link label and
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
322 # link address
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
323 linkData <- data.frame(Label=character(), Link=character(),
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
324 stringsAsFactors=FALSE)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
325 imageData <- data.frame(Label=character(), Link=character(),
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
326 stringsAsFactors=FALSE)
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
327
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
328 # Initialise vectors for storage of up/down/neutral regulated counts
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
329 upCount <- numeric()
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
330 downCount <- numeric()
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
331 flatCount <- numeric()
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
332
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
333 ################################################################################
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
334 ### Data Processing
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
335 ################################################################################
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
336
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
337 # Transform gene selection from string into index values for mroast
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
338 if (workMode=="glm") {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
339 if (selectOpt=="rank") {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
340 selectVals <- gsub(" ", "", selectVals, fixed=TRUE)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
341 selectVals <- unlist(strsplit(selectVals, ","))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
342
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
343 for (i in 1:length(selectVals)) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
344 if (grepl(":", selectVals[i], fixed=TRUE)) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
345 temp <- unlist(strsplit(selectVals[i], ":"))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
346 selectVals <- selectVals[-i]
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
347 a <- as.numeric(temp[1])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
348 b <- as.numeric(temp[2])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
349 selectVals <- c(selectVals, a:b)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
350 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
351 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
352 selectVals <- as.numeric(unique(selectVals))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
353 } else {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
354 selectVals <- gsub(" ", "", selectVals, fixed=TRUE)
8
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
355 selectVals <- unlist(strsplit(selectVals, ","))
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
356 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
357 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
358
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
359 if (inputType=="fastq") {
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
360 # Use EdgeR hairpin process and capture outputs
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
361 hpReadout <- capture.output(
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
362 data <- processHairpinReads(fastqPath, samplePath, annoPath,
9
f1076bfb0ed1 - Fixed tool to actually make use of barcode location options
shian_su <registertonysu@gmail.com>
parents: 8
diff changeset
363 barcodeStart=barStart, barcodeEnd=barEnd,
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
364 hairpinStart=hpStart, hairpinEnd=hpEnd,
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
365 verbose=TRUE)
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
366 )
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
367
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
368 # Remove function output entries that show processing data or is empty
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
369 hpReadout <- hpReadout[hpReadout!=""]
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
370 hpReadout <- hpReadout[!grepl("Processing", hpReadout)]
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
371 hpReadout <- hpReadout[!grepl("in file", hpReadout)]
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
372 hpReadout <- gsub(" -- ", "", hpReadout, fixed=TRUE)
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
373
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
374 # Make the names of groups syntactically valid (replace spaces with periods)
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
375 data$samples$group <- make.names(data$samples$group)
4
f8af57d6f60b Fixed bug causing fastq input to break
shian_su <registertonysu@gmail.com>
parents: 2
diff changeset
376 } else if (inputType=="counts") {
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
377 # Process counts information, set ID column to be row names
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
378 rownames(counts) <- counts$ID
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
379 counts <- counts[ , !(colnames(counts)=="ID")]
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
380 countsRows <- nrow(counts)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
381
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
382 # Process group information
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
383 factors <- samples$group[match(samples$ID, colnames(counts))]
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
384 annoRows <- nrow(anno)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
385 anno <- anno[match(rownames(counts), anno$ID), ]
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
386 annoMatched <- sum(!is.na(anno$ID))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
387
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
388 if (any(is.na(anno$ID))) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
389 warningStr <- paste("count table contained more hairpins than",
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
390 "specified in hairpin annotation file")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
391 warning(warningStr)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
392 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
393
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
394 # Filter out rows with zero counts
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
395 sel <- rowSums(counts)!=0
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
396 counts <- counts[sel, ]
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
397 anno <- anno[sel, ]
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
398
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
399 # Create DGEList
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
400 data <- DGEList(counts=counts, lib.size=colSums(counts),
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
401 norm.factors=rep(1,ncol(counts)), genes=anno, group=factors)
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
402
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
403 # Make the names of groups syntactically valid (replace spaces with periods)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
404 data$samples$group <- make.names(data$samples$group)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
405 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
406
10
8923d4ea858b - Added check for zero library size, will now filter out zero library size
shian_su <registertonysu@gmail.com>
parents: 9
diff changeset
407 # Filter out any samples with zero counts
8923d4ea858b - Added check for zero library size, will now filter out zero library size
shian_su <registertonysu@gmail.com>
parents: 9
diff changeset
408 if (any(data$samples$lib.size == 0)) {
8923d4ea858b - Added check for zero library size, will now filter out zero library size
shian_su <registertonysu@gmail.com>
parents: 9
diff changeset
409 sampleSel <- data$samples$lib.size != 0
8923d4ea858b - Added check for zero library size, will now filter out zero library size
shian_su <registertonysu@gmail.com>
parents: 9
diff changeset
410 filteredSamples <- paste(data$samples$ID[!sampleSel], collapse=", ")
8923d4ea858b - Added check for zero library size, will now filter out zero library size
shian_su <registertonysu@gmail.com>
parents: 9
diff changeset
411 data$counts <- data$counts[, sampleSel]
8923d4ea858b - Added check for zero library size, will now filter out zero library size
shian_su <registertonysu@gmail.com>
parents: 9
diff changeset
412 data$samples <- data$samples[sampleSel, ]
8923d4ea858b - Added check for zero library size, will now filter out zero library size
shian_su <registertonysu@gmail.com>
parents: 9
diff changeset
413 }
8923d4ea858b - Added check for zero library size, will now filter out zero library size
shian_su <registertonysu@gmail.com>
parents: 9
diff changeset
414
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
415 # Filter hairpins with low counts
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
416 preFilterCount <- nrow(data)
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
417 sel <- rowSums(cpm(data$counts) > cpmReq) >= sampleReq
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
418 data <- data[sel, ]
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
419 postFilterCount <- nrow(data)
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
420 filteredCount <- preFilterCount-postFilterCount
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
421
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
422 # Estimate dispersions
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
423 data <- estimateDisp(data)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
424 commonBCV <- sqrt(data$common.dispersion)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
425
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
426 ################################################################################
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
427 ### Output Processing
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
428 ################################################################################
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
429
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
430 # Plot number of hairpins that could be matched per sample
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
431 png(barIndexPng, width=600, height=600)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
432 barplot(height<-colSums(data$counts), las=2, main="Counts per index",
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
433 cex.names=1.0, cex.axis=0.8, ylim=c(0, max(height)*1.2))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
434 imageData[1, ] <- c("Counts per Index", "barIndex.png")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
435 invisible(dev.off())
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
436
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
437 pdf(barIndexPdf)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
438 barplot(height<-colSums(data$counts), las=2, main="Counts per index",
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
439 cex.names=1.0, cex.axis=0.8, ylim=c(0, max(height)*1.2))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
440 linkData[1, ] <- c("Counts per Index Barplot (.pdf)", "barIndex.pdf")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
441 invisible(dev.off())
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
442
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
443 # Plot per hairpin totals across all samples
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
444 png(barHairpinPng, width=600, height=600)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
445 if (nrow(data$counts)<50) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
446 barplot(height<-rowSums(data$counts), las=2, main="Counts per hairpin",
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
447 cex.names=0.8, cex.axis=0.8, ylim=c(0, max(height)*1.2))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
448 } else {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
449 barplot(height<-rowSums(data$counts), las=2, main="Counts per hairpin",
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
450 cex.names=0.8, cex.axis=0.8, ylim=c(0, max(height)*1.2),
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
451 names.arg=FALSE)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
452 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
453 imageData <- rbind(imageData, c("Counts per Hairpin", "barHairpin.png"))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
454 invisible(dev.off())
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
455
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
456 pdf(barHairpinPdf)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
457 if (nrow(data$counts)<50) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
458 barplot(height<-rowSums(data$counts), las=2, main="Counts per hairpin",
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
459 cex.names=0.8, cex.axis=0.8, ylim=c(0, max(height)*1.2))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
460 } else {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
461 barplot(height<-rowSums(data$counts), las=2, main="Counts per hairpin",
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
462 cex.names=0.8, cex.axis=0.8, ylim=c(0, max(height)*1.2),
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
463 names.arg=FALSE)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
464 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
465 newEntry <- c("Counts per Hairpin Barplot (.pdf)", "barHairpin.pdf")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
466 linkData <- rbind(linkData, newEntry)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
467 invisible(dev.off())
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
468
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
469 # Make an MDS plot to visualise relationships between replicate samples
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
470 png(mdsPng, width=600, height=600)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
471 plotMDS(data, labels=data$samples$group, col=as.numeric(data$samples$group),
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
472 main="MDS Plot")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
473 imageData <- rbind(imageData, c("MDS Plot", "mds.png"))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
474 invisible(dev.off())
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
475
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
476 pdf(mdsPdf)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
477 plotMDS(data, labels=data$samples$group, col=as.numeric(data$samples$group),
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
478 main="MDS Plot")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
479 newEntry <- c("MDS Plot (.pdf)", "mds.pdf")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
480 linkData <- rbind(linkData, newEntry)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
481 invisible(dev.off())
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
482
9
f1076bfb0ed1 - Fixed tool to actually make use of barcode location options
shian_su <registertonysu@gmail.com>
parents: 8
diff changeset
483 # BCV Plot
f1076bfb0ed1 - Fixed tool to actually make use of barcode location options
shian_su <registertonysu@gmail.com>
parents: 8
diff changeset
484 png(bcvPng, width=600, height=600)
f1076bfb0ed1 - Fixed tool to actually make use of barcode location options
shian_su <registertonysu@gmail.com>
parents: 8
diff changeset
485 plotBCV(data, main="BCV Plot")
f1076bfb0ed1 - Fixed tool to actually make use of barcode location options
shian_su <registertonysu@gmail.com>
parents: 8
diff changeset
486 imageData <- rbind(imageData, c("BCV Plot", "bcv.png"))
f1076bfb0ed1 - Fixed tool to actually make use of barcode location options
shian_su <registertonysu@gmail.com>
parents: 8
diff changeset
487 invisible(dev.off())
f1076bfb0ed1 - Fixed tool to actually make use of barcode location options
shian_su <registertonysu@gmail.com>
parents: 8
diff changeset
488
f1076bfb0ed1 - Fixed tool to actually make use of barcode location options
shian_su <registertonysu@gmail.com>
parents: 8
diff changeset
489 pdf(bcvPdf)
f1076bfb0ed1 - Fixed tool to actually make use of barcode location options
shian_su <registertonysu@gmail.com>
parents: 8
diff changeset
490 plotBCV(data, main="BCV Plot")
f1076bfb0ed1 - Fixed tool to actually make use of barcode location options
shian_su <registertonysu@gmail.com>
parents: 8
diff changeset
491 newEntry <- c("BCV Plot (.pdf)", "bcv.pdf")
f1076bfb0ed1 - Fixed tool to actually make use of barcode location options
shian_su <registertonysu@gmail.com>
parents: 8
diff changeset
492 invisible(dev.off())
f1076bfb0ed1 - Fixed tool to actually make use of barcode location options
shian_su <registertonysu@gmail.com>
parents: 8
diff changeset
493
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
494 if (workMode=="classic") {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
495 # Assess differential representation using classic exact testing methodology
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
496 # in edgeR
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
497 testData <- exactTest(data, pair=pairData)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
498
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
499 top <- topTags(testData, n=Inf)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
500 topIDs <- top$table[(top$table$FDR < fdrThresh) &
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
501 (abs(top$table$logFC) > lfcThresh), 1]
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
502
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
503 write.table(top, file=topOut, row.names=FALSE, sep="\t")
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
504
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
505 linkName <- paste0("Top Tags Table(", pairData[2], "-", pairData[1],
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
506 ") (.tsv)")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
507 linkAddr <- paste0("toptag(", pairData[2], "-", pairData[1], ").tsv")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
508 linkData <- rbind(linkData, c(linkName, linkAddr))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
509
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
510 upCount[1] <- sum(top$table$FDR < fdrThresh & top$table$logFC > lfcThresh)
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
511 downCount[1] <- sum(top$table$FDR < fdrThresh &
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
512 top$table$logFC < -lfcThresh)
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
513 flatCount[1] <- sum(top$table$FDR > fdrThresh |
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
514 abs(top$table$logFC) < lfcThresh)
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
515
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
516
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
517
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
518 # Select hairpins with FDR < 0.05 to highlight on plot
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
519 png(smearPng, width=600, height=600)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
520 plotTitle <- gsub(".", " ",
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
521 paste0("Smear Plot: ", pairData[2], "-", pairData[1]),
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
522 fixed=TRUE)
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
523 plotSmear(testData, de.tags=topIDs,
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
524 pch=20, cex=1.0, main=plotTitle)
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
525 abline(h=c(-1, 0, 1), col=c("dodgerblue", "yellow", "dodgerblue"), lty=2)
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
526 imgName <- paste0("Smear Plot(", pairData[2], "-", pairData[1], ")")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
527 imgAddr <- paste0("smear(", pairData[2], "-", pairData[1],").png")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
528 imageData <- rbind(imageData, c(imgName, imgAddr))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
529 invisible(dev.off())
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
530
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
531 pdf(smearPdf)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
532 plotTitle <- gsub(".", " ",
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
533 paste0("Smear Plot: ", pairData[2], "-", pairData[1]),
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
534 fixed=TRUE)
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
535 plotSmear(testData, de.tags=topIDs,
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
536 pch=20, cex=1.0, main=plotTitle)
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
537 abline(h=c(-1, 0, 1), col=c("dodgerblue", "yellow", "dodgerblue"), lty=2)
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
538 imgName <- paste0("Smear Plot(", pairData[2], "-", pairData[1], ") (.pdf)")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
539 imgAddr <- paste0("smear(", pairData[2], "-", pairData[1], ").pdf")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
540 linkData <- rbind(linkData, c(imgName, imgAddr))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
541 invisible(dev.off())
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
542
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
543 } else if (workMode=="glm") {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
544 # Generating design information
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
545 factors <- factor(data$sample$group)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
546 design <- model.matrix(~0+factors)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
547
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
548 colnames(design) <- gsub("factors", "", colnames(design), fixed=TRUE)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
549
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
550 # Split up contrasts seperated by comma into a vector
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
551 contrastData <- unlist(strsplit(contrastData, split=","))
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
552
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
553 for (i in 1:length(contrastData)) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
554 # Generate contrasts information
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
555 contrasts <- makeContrasts(contrasts=contrastData[i], levels=design)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
556
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
557 # Fit negative bionomial GLM
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
558 fit <- glmFit(data, design)
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
559 # Carry out Likelihood ratio test
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
560 testData <- glmLRT(fit, contrast=contrasts)
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
561
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
562 # Select hairpins with FDR < 0.05 to highlight on plot
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
563 top <- topTags(testData, n=Inf)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
564 topIDs <- top$table[(top$table$FDR < fdrThresh) &
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
565 (abs(top$table$logFC) > lfcThresh), 1]
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
566 write.table(top, file=topOut[i], row.names=FALSE, sep="\t")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
567
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
568 linkName <- paste0("Top Tags Table(", contrastData[i], ") (.tsv)")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
569 linkAddr <- paste0("toptag(", contrastData[i], ").tsv")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
570 linkData <- rbind(linkData, c(linkName, linkAddr))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
571
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
572 # Collect counts for differential representation
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
573 upCount[i] <- sum(top$table$FDR < fdrThresh & top$table$logFC > lfcThresh)
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
574 downCount[i] <- sum(top$table$FDR < fdrThresh &
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
575 top$table$logFC < -lfcThresh)
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
576 flatCount[i] <- sum(top$table$FDR > fdrThresh |
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
577 abs(top$table$logFC) < lfcThresh)
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
578
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
579 # Make a plot of logFC versus logCPM
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
580 png(smearPng[i], height=600, width=600)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
581 plotTitle <- paste("Smear Plot:", gsub(".", " ", contrastData[i],
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
582 fixed=TRUE))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
583 plotSmear(testData, de.tags=topIDs, pch=20, cex=0.8, main=plotTitle)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
584 abline(h=c(-1, 0, 1), col=c("dodgerblue", "yellow", "dodgerblue"), lty=2)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
585
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
586 imgName <- paste0("Smear Plot(", contrastData[i], ")")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
587 imgAddr <- paste0("smear(", contrastData[i], ").png")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
588 imageData <- rbind(imageData, c(imgName, imgAddr))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
589 invisible(dev.off())
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
590
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
591 pdf(smearPdf[i])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
592 plotTitle <- paste("Smear Plot:", gsub(".", " ", contrastData[i],
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
593 fixed=TRUE))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
594 plotSmear(testData, de.tags=topIDs, pch=20, cex=0.8, main=plotTitle)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
595 abline(h=c(-1, 0, 1), col=c("dodgerblue", "yellow", "dodgerblue"), lty=2)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
596
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
597 linkName <- paste0("Smear Plot(", contrastData[i], ") (.pdf)")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
598 linkAddr <- paste0("smear(", contrastData[i], ").pdf")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
599 linkData <- rbind(linkData, c(linkName, linkAddr))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
600 invisible(dev.off())
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
601
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
602 genes <- as.character(data$genes$Gene)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
603 unq <- unique(genes)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
604 unq <- unq[!is.na(unq)]
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
605 geneList <- list()
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
606 for (gene in unq) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
607 if (length(which(genes==gene)) >= hairpinReq) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
608 geneList[[gene]] <- which(genes==gene)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
609 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
610 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
611
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
612 if (wantRoast) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
613 # Input preparaton for roast
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
614 nrot <- 9999
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
615 set.seed(602214129)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
616 roastData <- mroast(data, index=geneList, design=design,
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
617 contrast=contrasts, nrot=nrot)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
618 roastData <- cbind(GeneID=rownames(roastData), roastData)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
619 write.table(roastData, file=roastOut[i], row.names=FALSE, sep="\t")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
620 linkName <- paste0("Gene Level Analysis Table(", contrastData[i],
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
621 ") (.tsv)")
8
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
622 linkAddr <- paste0("gene_level(", contrastData[i], ").tsv")
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
623 linkData <- rbind(linkData, c(linkName, linkAddr))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
624 if (selectOpt=="rank") {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
625 selectedGenes <- rownames(roastData)[selectVals]
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
626 } else {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
627 selectedGenes <- selectVals
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
628 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
629
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
630 if (packageVersion("limma")<"3.19.19") {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
631 png(barcodePng[i], width=600, height=length(selectedGenes)*150)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
632 } else {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
633 png(barcodePng[i], width=600, height=length(selectedGenes)*300)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
634 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
635 par(mfrow=c(length(selectedGenes), 1))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
636 for (gene in selectedGenes) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
637 barcodeplot(testData$table$logFC, index=geneList[[gene]],
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
638 main=paste("Barcode Plot for", gene, "(logFCs)",
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
639 gsub(".", " ", contrastData[i])),
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
640 labels=c("Positive logFC", "Negative logFC"))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
641 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
642 imgName <- paste0("Barcode Plot(", contrastData[i], ")")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
643 imgAddr <- paste0("barcode(", contrastData[i], ").png")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
644 imageData <- rbind(imageData, c(imgName, imgAddr))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
645 dev.off()
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
646 if (packageVersion("limma")<"3.19.19") {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
647 pdf(barcodePdf[i], width=8, height=2)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
648 } else {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
649 pdf(barcodePdf[i], width=8, height=4)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
650 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
651 for (gene in selectedGenes) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
652 barcodeplot(testData$table$logFC, index=geneList[[gene]],
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
653 main=paste("Barcode Plot for", gene, "(logFCs)",
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
654 gsub(".", " ", contrastData[i])),
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
655 labels=c("Positive logFC", "Negative logFC"))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
656 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
657 linkName <- paste0("Barcode Plot(", contrastData[i], ") (.pdf)")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
658 linkAddr <- paste0("barcode(", contrastData[i], ").pdf")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
659 linkData <- rbind(linkData, c(linkName, linkAddr))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
660 dev.off()
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
661 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
662 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
663 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
664
8
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
665 # Generate data frame of the significant differences
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
666 sigDiff <- data.frame(Up=upCount, Flat=flatCount, Down=downCount)
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
667 if (workMode == "glm") {
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
668 row.names(sigDiff) <- contrastData
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
669 } else if (workMode == "classic") {
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
670 row.names(sigDiff) <- paste0(pairData[2], "-", pairData[1])
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
671 }
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
672
8
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
673 # Output table of summarised counts
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
674 ID <- rownames(data$counts)
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
675 outputCounts <- cbind(ID, data$counts)
8
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
676 write.table(outputCounts, file=countsOut, row.names=FALSE, sep="\t",
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
677 quote=FALSE)
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
678 linkName <- "Counts table (.tsv)"
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
679 linkAddr <- "counts.tsv"
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
680 linkData <- rbind(linkData, c(linkName, linkAddr))
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
681
8
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
682 # Record session info
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
683 writeLines(capture.output(sessionInfo()), sessionOut)
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
684 linkData <- rbind(linkData, c("Session Info", "session_info.txt"))
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
685
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
686 # Record ending time and calculate total run time
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
687 timeEnd <- as.character(Sys.time())
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
688 timeTaken <- capture.output(round(difftime(timeEnd,timeStart), digits=3))
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
689 timeTaken <- gsub("Time difference of ", "", timeTaken, fixed=TRUE)
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
690 ################################################################################
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
691 ### HTML Generation
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
692 ################################################################################
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
693 # Clear file
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
694 cat("", file=htmlPath)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
695
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
696 cata("<html>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
697 HtmlHead("EdgeR Output")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
698
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
699 cata("<body>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
700 cata("<h3>EdgeR Analysis Output:</h3>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
701 cata("<h4>Input Summary:</h4>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
702 if (inputType=="fastq") {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
703 cata("<ul>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
704 ListItem(hpReadout[1])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
705 ListItem(hpReadout[2])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
706 cata("</ul>\n")
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
707 cata(hpReadout[3], "<br />\n")
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
708 cata("<ul>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
709 ListItem(hpReadout[4])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
710 ListItem(hpReadout[7])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
711 cata("</ul>\n")
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
712 cata(hpReadout[8:11], sep="<br />\n")
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
713 cata("<br />\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
714 cata("<b>Please check that read percentages are consistent with ")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
715 cata("expectations.</b><br >\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
716 } else if (inputType=="counts") {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
717 cata("<ul>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
718 ListItem("Number of Samples: ", ncol(data$counts))
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
719 ListItem("Number of Hairpins: ", countsRows)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
720 ListItem("Number of annotations provided: ", annoRows)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
721 ListItem("Number of annotations matched to hairpin: ", annoMatched)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
722 cata("</ul>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
723 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
724
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
725 cata("The estimated common biological coefficient of variation (BCV) is: ",
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
726 commonBCV, "<br />\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
727
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
728 cata("<h4>Output:</h4>\n")
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
729 cata("PDF copies of JPEGS available in 'Plots' section.<br />\n")
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
730 for (i in 1:nrow(imageData)) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
731 if (grepl("barcode", imageData$Link[i])) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
732 if (packageVersion("limma")<"3.19.19") {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
733 HtmlImage(imageData$Link[i], imageData$Label[i],
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
734 height=length(selectedGenes)*150)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
735 } else {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
736 HtmlImage(imageData$Link[i], imageData$Label[i],
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
737 height=length(selectedGenes)*300)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
738 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
739 } else {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
740 HtmlImage(imageData$Link[i], imageData$Label[i])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
741 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
742 }
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
743 cata("<br />\n")
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
744
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
745 cata("<h4>Differential Representation Counts:</h4>\n")
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
746
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
747 cata("<table border=\"1\" cellpadding=\"4\">\n")
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
748 cata("<tr>\n")
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
749 TableItem()
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
750 for (i in colnames(sigDiff)) {
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
751 TableHeadItem(i)
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
752 }
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
753 cata("</tr>\n")
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
754 for (i in 1:nrow(sigDiff)) {
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
755 cata("<tr>\n")
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
756 TableHeadItem(unmake.names(row.names(sigDiff)[i]))
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
757 for (j in 1:ncol(sigDiff)) {
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
758 TableItem(as.character(sigDiff[i, j]))
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
759 }
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
760 cata("</tr>\n")
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
761 }
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
762 cata("</table>")
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
763
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
764 cata("<h4>Plots:</h4>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
765 for (i in 1:nrow(linkData)) {
8
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
766 if (grepl(".pdf", linkData$Link[i])) {
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
767 HtmlLink(linkData$Link[i], linkData$Label[i])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
768 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
769 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
770
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
771 cata("<h4>Tables:</h4>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
772 for (i in 1:nrow(linkData)) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
773 if (grepl(".tsv", linkData$Link[i])) {
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
774 HtmlLink(linkData$Link[i], linkData$Label[i])
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
775 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
776 }
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
777
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
778 cata("<p>Alt-click links to download file.</p>\n")
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
779 cata("<p>Click floppy disc icon associated history item to download ")
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
780 cata("all files.</p>\n")
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
781 cata("<p>.tsv files can be viewed in Excel or any spreadsheet program.</p>\n")
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
782
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
783 cata("<h4>Additional Information:</h4>\n")
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
784
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
785 if (inputType == "fastq") {
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
786 ListItem("Data was gathered from fastq raw read file(s).")
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
787 } else if (inputType == "counts") {
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
788 ListItem("Data was gathered from a table of counts.")
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
789 }
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
790
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
791 if (cpmReq!=0 && sampleReq!=0) {
8
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
792 tempStr <- paste("Hairpins without more than", cpmReq,
7
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
793 "CPM in at least", sampleReq, "samples are insignificant",
91e411fcdecc Version 1.0.8
shian_su <registertonysu@gmail.com>
parents: 6
diff changeset
794 "and filtered out.")
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
795 ListItem(tempStr)
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
796 filterProp <- round(filteredCount/preFilterCount*100, digits=2)
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
797 tempStr <- paste0(filteredCount, " of ", preFilterCount," (", filterProp,
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
798 "%) hairpins were filtered out for low count-per-million.")
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
799 ListItem(tempStr)
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
800 }
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
801
10
8923d4ea858b - Added check for zero library size, will now filter out zero library size
shian_su <registertonysu@gmail.com>
parents: 9
diff changeset
802 if (exists("filteredSamples")) {
8923d4ea858b - Added check for zero library size, will now filter out zero library size
shian_su <registertonysu@gmail.com>
parents: 9
diff changeset
803 tempStr <- paste("The following samples were filtered out for having zero",
8923d4ea858b - Added check for zero library size, will now filter out zero library size
shian_su <registertonysu@gmail.com>
parents: 9
diff changeset
804 "library size: ", filteredSamples)
8923d4ea858b - Added check for zero library size, will now filter out zero library size
shian_su <registertonysu@gmail.com>
parents: 9
diff changeset
805 ListItem(tempStr)
8923d4ea858b - Added check for zero library size, will now filter out zero library size
shian_su <registertonysu@gmail.com>
parents: 9
diff changeset
806 }
8923d4ea858b - Added check for zero library size, will now filter out zero library size
shian_su <registertonysu@gmail.com>
parents: 9
diff changeset
807
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
808 if (workMode == "classic") {
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
809 ListItem("An exact test was performed on each hairpin.")
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
810 } else if (workMode == "glm") {
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
811 ListItem("A generalised linear model was fitted to each hairpin.")
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
812 }
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
813
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
814 cit <- character()
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
815 link <-character()
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
816 link[1] <- paste0("<a href=\"",
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
817 "http://www.bioconductor.org/packages/release/bioc/",
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
818 "vignettes/limma/inst/doc/usersguide.pdf",
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
819 "\">", "limma User's Guide", "</a>.")
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
820 link[2] <- paste0("<a href=\"",
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
821 "http://www.bioconductor.org/packages/release/bioc/",
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
822 "vignettes/edgeR/inst/doc/edgeRUsersGuide.pdf",
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
823 "\">", "edgeR User's Guide", "</a>")
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
824
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
825 cit[1] <- paste("Robinson MD, McCarthy DJ and Smyth GK (2010).",
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
826 "edgeR: a Bioconductor package for differential",
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
827 "expression analysis of digital gene expression",
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
828 "data. Bioinformatics 26, 139-140")
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
829 cit[2] <- paste("Robinson MD and Smyth GK (2007). Moderated statistical tests",
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
830 "for assessing differences in tag abundance. Bioinformatics",
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
831 "23, 2881-2887")
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
832 cit[3] <- paste("Robinson MD and Smyth GK (2008). Small-sample estimation of",
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
833 "negative binomial dispersion, with applications to SAGE data.",
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
834 "Biostatistics, 9, 321-332")
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
835
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
836 cit[4] <- paste("McCarthy DJ, Chen Y and Smyth GK (2012). Differential",
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
837 "expression analysis of multifactor RNA-Seq experiments with",
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
838 "respect to biological variation. Nucleic Acids Research 40,",
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
839 "4288-4297")
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
840
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
841 cata("<h4>Citations</h4>")
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
842 cata("<ol>\n")
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
843 ListItem(cit[1])
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
844 ListItem(cit[2])
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
845 ListItem(cit[3])
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
846 ListItem(cit[4])
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
847 cata("</ol>\n")
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
848
8
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
849 cata("<p>Report problems to: su.s@wehi.edu.au</p>\n")
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
850
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
851 for (i in 1:nrow(linkData)) {
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
852 if (grepl("session_info", linkData$Link[i])) {
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
853 HtmlLink(linkData$Link[i], linkData$Label[i])
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
854 }
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
855 }
548802b3492f Version 1.0.9
shian_su <registertonysu@gmail.com>
parents: 7
diff changeset
856
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
857 cata("<table border=\"0\">\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
858 cata("<tr>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
859 TableItem("Task started at:"); TableItem(timeStart)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
860 cata("</tr>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
861 cata("<tr>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
862 TableItem("Task ended at:"); TableItem(timeEnd)
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
863 cata("</tr>\n")
6
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
864 cata("<tr>\n")
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
865 TableItem("Task run time:"); TableItem(timeTaken)
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
866 cata("<tr>\n")
3d04308a99f9 - Added differentially expressed hairpin count output
shian_su <registertonysu@gmail.com>
parents: 4
diff changeset
867 cata("</table>\n")
2
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
868
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
869 cata("</body>\n")
076ca575208f First commit
shian_su <registertonysu@gmail.com>
parents:
diff changeset
870 cata("</html>")