Previous changeset 6:3d04308a99f9 (2014-04-11) Next changeset 8:548802b3492f (2014-05-02) |
Commit message:
Version 1.0.8 - Added differential representation counts table |
modified:
hairpinTool.R hairpinTool.xml |
b |
diff -r 3d04308a99f9 -r 91e411fcdecc hairpinTool.R --- a/hairpinTool.R Fri Apr 11 17:17:15 2014 +1000 +++ b/hairpinTool.R Wed Apr 23 14:05:26 2014 +1000 |
[ |
b'@@ -42,6 +42,7 @@\n # Smear Plot\n # Barcode Plots (If Genewise testing was selected)\n # Top Expression Table\n+# Feature Counts Table\n # HTML file linking to the ouputs\n #\n # Author: Shian Su - registertonysu@gmail.com - Jan 2014\n@@ -64,6 +65,14 @@\n ### Function declarations\n ################################################################################\n \n+# Function to load libaries without messages\n+silentLibrary <- function(...) {\n+ list <- c(...)\n+ for (package in list){\n+ suppressPackageStartupMessages(library(package, character.only=TRUE))\n+ }\n+}\n+\n # Function to sanitise contrast equations so there are no whitespaces\n # surrounding the arithmetic operators, leading or trailing whitespace\n sanitiseEquation <- function(equation) {\n@@ -96,16 +105,16 @@\n # Function has string input and generates both a pdf and png output strings\n imgOut <- function(filename) {\n assign(paste0(filename, "Png"), makeOut(paste0(filename,".png")), \n- envir = .GlobalEnv)\n+ envir=.GlobalEnv)\n assign(paste0(filename, "Pdf"), makeOut(paste0(filename,".pdf")),\n- envir = .GlobalEnv)\n+ envir=.GlobalEnv)\n }\n \n # Create cat function default path set, default seperator empty and appending\n # true by default (Ripped straight from the cat function with altered argument\n # defaults)\n-cata <- function(..., file = htmlPath, sep = "", fill = FALSE, labels = NULL, \n- append = TRUE) {\n+cata <- function(..., file=htmlPath, sep="", fill=FALSE, labels=NULL, \n+ append=TRUE) {\n if (is.character(file)) \n if (file == "") \n file <- stdout()\n@@ -309,6 +318,12 @@\n stringsAsFactors=FALSE)\n imageData <- data.frame(Label=character(), Link=character(),\n stringsAsFactors=FALSE)\n+ \n+# Initialise vectors for storage of up/down/neutral regulated counts\n+upCount <- numeric()\n+downCount <- numeric()\n+flatCount <- numeric()\n+\n ################################################################################\n ### Data Processing\n ################################################################################\n@@ -458,20 +473,30 @@\n top <- topTags(testData, n=Inf)\n topIDs <- top$table[(top$table$FDR < fdrThresh) &\n (abs(top$table$logFC) > lfcThresh), 1]\n+ \n write.table(top, file=topOut, row.names=FALSE, sep="\\t")\n+ \n linkName <- paste0("Top Tags Table(", pairData[2], "-", pairData[1], \n ") (.tsv)")\n linkAddr <- paste0("toptag(", pairData[2], "-", pairData[1], ").tsv")\n linkData <- rbind(linkData, c(linkName, linkAddr))\n \n+ upCount[1] <- sum(top$table$FDR < fdrThresh & top$table$logFC > lfcThresh)\n+ downCount[1] <- sum(top$table$FDR < fdrThresh & \n+ top$table$logFC < -lfcThresh)\n+ flatCount[1] <- sum(top$table$FDR > fdrThresh |\n+ abs(top$table$logFC) < lfcThresh)\n+ \n+ \n+ \n # Select hairpins with FDR < 0.05 to highlight on plot\n png(smearPng, width=600, height=600)\n plotTitle <- gsub(".", " ", \n paste0("Smear Plot: ", pairData[2], "-", pairData[1]),\n- fixed = TRUE)\n+ fixed=TRUE)\n plotSmear(testData, de.tags=topIDs, \n pch=20, cex=1.0, main=plotTitle)\n- abline(h = c(-1, 0, 1), col = c("dodgerblue", "yellow", "dodgerblue"), lty=2)\n+ abline(h=c(-1, 0, 1), col=c("dodgerblue", "yellow", "dodgerblue"), lty=2)\n imgName <- paste0("Smear Plot(", pairData[2], "-", pairData[1], ")")\n imgAddr <- paste0("smear(", pairData[2], "-", pairData[1],").png")\n imageData <- rbind(imageData, c(imgName, imgAddr))\n@@ -480,14 +505,15 @@\n pdf(smearPdf)\n plotTitle <- gsub(".", " ", \n paste0("Smear Plot: ", pairData[2], "-", pairData[1]),\n- fixed = TRUE)\n+ fixed=TRUE)\n plotSmear(testData, de.tags=topIDs, \n pch=20, cex=1.0, main=plotTitle)\n- abline(h '..b'y out Likelihood ratio test\n- testData = glmLRT(fit, contrast=contrasts)\n+ testData <- glmLRT(fit, contrast=contrasts)\n \n # Select hairpins with FDR < 0.05 to highlight on plot\n top <- topTags(testData, n=Inf)\n@@ -516,6 +543,13 @@\n linkAddr <- paste0("toptag(", contrastData[i], ").tsv")\n linkData <- rbind(linkData, c(linkName, linkAddr))\n \n+ # Collect counts for differential representation\n+ upCount[i] <- sum(top$table$FDR < fdrThresh & top$table$logFC > lfcThresh)\n+ downCount[i] <- sum(top$table$FDR < fdrThresh & \n+ top$table$logFC < -lfcThresh)\n+ flatCount[i] <- sum(top$table$FDR > fdrThresh |\n+ abs(top$table$logFC) < lfcThresh)\n+ \n # Make a plot of logFC versus logCPM\n png(smearPng[i], height=600, width=600)\n plotTitle <- paste("Smear Plot:", gsub(".", " ", contrastData[i], \n@@ -551,7 +585,7 @@\n \n if (wantRoast) {\n # Input preparaton for roast\n- nrot = 9999\n+ nrot <- 9999\n set.seed(602214129)\n roastData <- mroast(data, index=geneList, design=design,\n contrast=contrasts, nrot=nrot)\n@@ -602,6 +636,13 @@\n }\n }\n \n+sigDiff <- data.frame(Up=upCount, Flat=flatCount, Down=downCount)\n+if (workMode == "glm") {\n+ row.names(sigDiff) <- contrastData\n+} else if (workMode == "classic") {\n+ row.names(sigDiff) <- paste0(pairData[2], "-", pairData[1])\n+}\n+\n ID <- rownames(data$counts)\n outputCounts <- cbind(ID, data$counts)\n write.table(outputCounts, file=countsOut, row.names=FALSE, sep="\\t")\n@@ -652,8 +693,7 @@\n commonBCV, "<br />\\n")\n \n cata("<h4>Output:</h4>\\n")\n-cata("All images displayed have PDF copy at the bottom of the page, these can ")\n-cata("exported in a pdf viewer to high resolution image format. <br />\\n")\n+cata("PDF copies of JPEGS available in \'Plots\' section.<br />\\n")\n for (i in 1:nrow(imageData)) {\n if (grepl("barcode", imageData$Link[i])) {\n if (packageVersion("limma")<"3.19.19") {\n@@ -669,6 +709,25 @@\n }\n cata("<br />\\n")\n \n+cata("<h4>Differential Representation Counts:</h4>\\n")\n+\n+cata("<table border=\\"1\\" cellpadding=\\"4\\">\\n")\n+cata("<tr>\\n")\n+TableItem()\n+for (i in colnames(sigDiff)) {\n+ TableHeadItem(i)\n+}\n+cata("</tr>\\n")\n+for (i in 1:nrow(sigDiff)) {\n+ cata("<tr>\\n")\n+ TableHeadItem(unmake.names(row.names(sigDiff)[i]))\n+ for (j in 1:ncol(sigDiff)) {\n+ TableItem(as.character(sigDiff[i, j]))\n+ }\n+ cata("</tr>\\n")\n+}\n+cata("</table>")\n+\n cata("<h4>Plots:</h4>\\n")\n for (i in 1:nrow(linkData)) {\n if (!grepl(".tsv", linkData$Link[i])) {\n@@ -683,11 +742,10 @@\n }\n }\n \n-cata("<p>alt-click any of the links to download the file, or click the name ")\n-cata("of this task in the galaxy history panel and click on the floppy ")\n-cata("disk icon to download all files in a zip archive.</p>\\n")\n-cata("<p>.tsv files are tab seperated files that can be viewed using Excel ")\n-cata("or other spreadsheet programs</p>\\n")\n+cata("<p>Alt-click links to download file.</p>\\n")\n+cata("<p>Click floppy disc icon associated history item to download ")\n+cata("all files.</p>\\n")\n+cata("<p>.tsv files can be viewed in Excel or any spreadsheet program.</p>\\n")\n \n cata("<h4>Additional Information:</h4>\\n")\n \n@@ -698,9 +756,9 @@\n }\n \n if (cpmReq!=0 && sampleReq!=0) {\n- tempStr <- paste("Hairpins that do not have more than", cpmReq,\n- "CPM in at least", sampleReq, "samples are considered",\n- "insignificant and filtered out.")\n+ tempStr <- paste("Hairpins with less than", cpmReq,\n+ "CPM in at least", sampleReq, "samples are insignificant",\n+ "and filtered out.")\n ListItem(tempStr)\n filterProp <- round(filteredCount/preFilterCount*100, digits=2)\n tempStr <- paste0(filteredCount, " of ", preFilterCount," (", filterProp,\n@@ -714,8 +772,6 @@\n ListItem("A generalised linear model was fitted to each hairpin.")\n }\n \n-\n-\n cit <- character()\n link <-character()\n link[1] <- paste0("<a href=\\"",\n' |
b |
diff -r 3d04308a99f9 -r 91e411fcdecc hairpinTool.xml --- a/hairpinTool.xml Fri Apr 11 17:17:15 2014 +1000 +++ b/hairpinTool.xml Wed Apr 23 14:05:26 2014 +1000 |
b |
@@ -1,4 +1,4 @@ -<tool id="shRNAseq" name="shRNAseq Tool" version="1.0.7"> +<tool id="shRNAseq" name="shRNAseq Tool" version="1.0.8"> <description> Analyse hairpin differential representation using edgeR </description> @@ -242,6 +242,11 @@ reads. This tool will generate plots and tables for the analysis of differential representation. +.. class:: infomark + +A tutorial of how to use this tool is available at: +http://bioinf.wehi.edu.au/shRNAseq/galaxy.html + ----- .. class:: infomark |