changeset 20:0921444c832d draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/limma_voom commit 0cc16fe170b5c8d3b9441177bf2749aa7bddca7b
author iuc
date Wed, 29 May 2019 10:31:41 -0400
parents c9c6427edfe9
children 58c35179ebf0
files limma_voom.R limma_voom.xml test-data/contrasts.txt
diffstat 3 files changed, 39 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/limma_voom.R	Tue May 28 10:04:10 2019 -0400
+++ b/limma_voom.R	Wed May 29 10:31:41 2019 -0400
@@ -79,6 +79,14 @@
     return(string)
 }
 
+# Function to make contrast contain valid R names
+sanitiseContrast <- function(string) {
+    string <- strsplit(string, split="-")
+    string <- lapply(string, make.names)
+    string <- lapply(string, paste, collapse="-")
+    return(string)
+}
+
 # Function to change periods to whitespace in a string
 unmake.names <- function(string) {
     string <- gsub(".", " ", string, fixed=TRUE)
@@ -353,16 +361,29 @@
     # Split up contrasts seperated by comma into a vector then sanitise
     contrastData <- unlist(strsplit(opt$contrastInput, split=","))
 }
-
-# in case input groups start with numbers this will make the names valid R names, required for makeContrasts
 contrastData <- sanitiseEquation(contrastData)
 contrastData <- gsub(" ", ".", contrastData, fixed=TRUE)
+
+# in case input groups start with numbers make the names valid R names, required for makeContrasts
 cons <- NULL
+cons_d <- NULL
 for (i in contrastData) {
-    i <- strsplit(i, split="-")
-    i <- lapply(i, make.names)
-    i <- lapply(i, paste, collapse="-")
-    cons <- append(cons, unlist(i))
+
+    # if the contrast is a difference of differences e.g. (A-B)-(X-Y)
+    if (grepl("\\)-\\(", i)) {
+        i <- unlist(strsplit(i, split="\\)-\\("))
+        i <- gsub("\\(|\\)","", i)
+        for (j in i) {
+           j <- sanitiseContrast(j)
+           j <- paste0("(", j, ")")
+           cons_d  <- append(cons_d, unlist(j))
+        }
+        cons_d <- paste(cons_d, collapse = '-')
+        cons <- append(cons, unlist(cons_d))
+    } else {
+        i <- sanitiseContrast(i)
+        cons <- append(cons, unlist(i))
+    }
 }
 
 plots <- character()
@@ -852,6 +873,7 @@
 sumStatus <- summary(status)
 
 for (i in 1:length(cons)) {
+    con_name <- cons[i]
     con <- cons[i]
     con <- gsub("\\(|\\)", "", con)
     # Collect counts for differential expression
@@ -957,7 +979,7 @@
     imgName <- paste0("MDVolPlot_", con)
     imgAddr <- paste0("mdvolplot_", con, ".png")
     imageData <- rbind(imageData, c(imgName, imgAddr))
-    title(paste0("Contrast: ", unmake.names(con)), outer=TRUE, cex.main=1.5)
+    title(paste0("Contrast: ", con_name), outer=TRUE, cex.main=1.5)
     invisible(dev.off())
 
     if ("h" %in% plots) {
@@ -1076,7 +1098,7 @@
 cata("<h4>Plots:</h4>\n")
 #PDFs
 for (i in 1:nrow(linkData)) {
-    if (grepl("density|cpm|boxplot|mds|mdplots|voom|saplot", linkData$Link[i])) {
+    if (grepl(".pdf", linkData$Link[i]) & grepl("density|cpm|boxplot|mds|mdplots|voom|saplot", linkData$Link[i])) {
         HtmlLink(linkData$Link[i], linkData$Label[i])
   }
 }
--- a/limma_voom.xml	Tue May 28 10:04:10 2019 -0400
+++ b/limma_voom.xml	Wed May 29 10:31:41 2019 -0400
@@ -721,7 +721,7 @@
             <param name="cinfo" value="contrasts.txt" />
             <param name="normalisationOption" value="TMM" />
             <param name="topgenes" value="6" />
-            <output_collection name="outTables" count="2">
+            <output_collection name="outTables" count="3">
                 <element name="limma-voom_Mut-WT" ftype="tabular" >
                     <assert_contents>
                         <has_text_matching expression="GeneID.*logFC.*AveExpr.*t.*P.Value.*adj.P.Val.*B" />
@@ -734,6 +734,12 @@
                         <has_text_matching expression="11304.*-0.4573" />
                     </assert_contents>
                 </element>
+                <element name="limma-voom_Mut-WT-WT-Mut" ftype="tabular" >
+                     <assert_contents>
+                        <has_text_matching expression="GeneID.*logFC.*AveExpr.*t.*P.Value.*adj.P.Val.*B" />
+                        <has_text_matching expression="11304.*0.9146" />
+                    </assert_contents>
+                </element>
             </output_collection>
         </test>
     </tests>
--- a/test-data/contrasts.txt	Tue May 28 10:04:10 2019 -0400
+++ b/test-data/contrasts.txt	Wed May 29 10:31:41 2019 -0400
@@ -1,3 +1,4 @@
 Contrast
 Mut-WT
-WT-Mut
\ No newline at end of file
+WT-Mut
+(Mut-WT)-(WT-Mut)