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