Repository 'limma_voom'
hg clone https://toolshed.g2.bx.psu.edu/repos/iuc/limma_voom

Changeset 20:0921444c832d (2019-05-29)
Previous changeset 19:c9c6427edfe9 (2019-05-28) Next changeset 21:58c35179ebf0 (2021-06-04)
Commit message:
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/limma_voom commit 0cc16fe170b5c8d3b9441177bf2749aa7bddca7b
modified:
limma_voom.R
limma_voom.xml
test-data/contrasts.txt
b
diff -r c9c6427edfe9 -r 0921444c832d limma_voom.R
--- 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])
   }
 }
b
diff -r c9c6427edfe9 -r 0921444c832d limma_voom.xml
--- a/limma_voom.xml Tue May 28 10:04:10 2019 -0400
+++ b/limma_voom.xml Wed May 29 10:31:41 2019 -0400
b
@@ -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>
b
diff -r c9c6427edfe9 -r 0921444c832d test-data/contrasts.txt
--- 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
b
@@ -1,3 +1,4 @@
 Contrast
 Mut-WT
-WT-Mut
\ No newline at end of file
+WT-Mut
+(Mut-WT)-(WT-Mut)