changeset 15:5bf899c13979 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/edger commit 025a0d70be99e50ae89ad78a70cc8c51571ea1a2
author iuc
date Wed, 22 Nov 2023 03:57:37 +0000
parents 070900306913
children ae2aad0a6d50
files edger.R edger.xml test-data/contrasts_file.txt
diffstat 3 files changed, 34 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/edger.R	Wed Oct 11 11:13:07 2023 +0000
+++ b/edger.R	Wed Nov 22 03:57:37 2023 +0000
@@ -85,6 +85,12 @@
   return(string)
 }
 
+# Sanitise file base names coming from factors or contrasts
+sanitise_basename <- function(string) {
+  string <- gsub("[/^]", "_", string)
+  return(string)
+}
+
 # Generate output folder and paths
 make_out <- function(filename) {
   return(paste0(out_path, "/", filename))
@@ -331,16 +337,16 @@
 mds_pdf <- character() # Initialise character vector
 mds_png <- character()
 for (i in seq_len(ncol(factors))) {
-  mds_pdf[i] <- make_out(paste0("mdsplot_", names(factors)[i], ".pdf"))
-  mds_png[i] <- make_out(paste0("mdsplot_", names(factors)[i], ".png"))
+  mds_pdf[i] <- make_out(paste0("mdsplot_", sanitise_basename(names(factors)[i]), ".pdf"))
+  mds_png[i] <- make_out(paste0("mdsplot_", sanitise_basename(names(factors)[i]), ".png"))
 }
 md_pdf <- character()
 md_png <- character()
 top_out <- character()
 for (i in seq_along(contrast_data)) {
-  md_pdf[i] <- make_out(paste0("mdplot_", contrast_data[i], ".pdf"))
-  md_png[i] <- make_out(paste0("mdplot_", contrast_data[i], ".png"))
-  top_out[i] <- make_out(paste0("edgeR_", contrast_data[i], ".tsv"))
+  md_pdf[i] <- make_out(paste0("mdplot_", sanitise_basename(contrast_data[i]), ".pdf"))
+  md_png[i] <- make_out(paste0("mdplot_", sanitise_basename(contrast_data[i]), ".png"))
+  top_out[i] <- make_out(paste0("edgeR_", sanitise_basename(contrast_data[i]), ".tsv"))
 } # Save output paths for each contrast as vectors
 norm_out <- make_out("edgeR_normcounts.tsv")
 rda_out <- make_out("edgeR_analysis.RData")
@@ -446,15 +452,15 @@
 # MDS plot
 png(mds_png, width = 600, height = 600)
 plotMDS(data, labels = labels, col = as.numeric(factors[, 1]), cex = 0.8, main = paste("MDS Plot:", names(factors)[1]))
-img_name <- paste0("MDS Plot_", names(factors)[1], ".png")
-img_addr <- paste0("mdsplot_", names(factors)[1], ".png")
+img_name <- paste0("MDS Plot_", sanitise_basename(names(factors)[1]), ".png")
+img_addr <- paste0("mdsplot_", sanitise_basename(names(factors)[1]), ".png")
 image_data[1, ] <- c(img_name, img_addr)
 invisible(dev.off())
 
 pdf(mds_pdf)
 plotMDS(data, labels = labels, col = as.numeric(factors[, 1]), cex = 0.8, main = paste("MDS Plot:", names(factors)[1]))
-link_name <- paste0("MDS Plot_", names(factors)[1], ".pdf")
-link_addr <- paste0("mdsplot_", names(factors)[1], ".pdf")
+link_name <- paste0("MDS Plot_", sanitise_basename(names(factors)[1]), ".pdf")
+link_addr <- paste0("mdsplot_", sanitise_basename(names(factors)[1]), ".pdf")
 link_data[1, ] <- c(link_name, link_addr)
 invisible(dev.off())
 
@@ -463,15 +469,15 @@
   for (i in 2:ncol(factors)) {
     png(mds_png[i], width = 600, height = 600)
     plotMDS(data, labels = labels, col = as.numeric(factors[, i]), cex = 0.8, main = paste("MDS Plot:", names(factors)[i]))
-    img_name <- paste0("MDS Plot_", names(factors)[i], ".png")
-    img_addr <- paste0("mdsplot_", names(factors)[i], ".png")
+    img_name <- paste0("MDS Plot_", sanitise_basename(names(factors)[i]), ".png")
+    img_addr <- paste0("mdsplot_", sanitise_basename(names(factors)[i]), ".png")
     image_data <- rbind(image_data, c(img_name, img_addr))
     invisible(dev.off())
 
     pdf(mds_pdf[i])
     plotMDS(data, labels = labels, col = as.numeric(factors[, i]), cex = 0.8, main = paste("MDS Plot:", names(factors)[i]))
-    link_name <- paste0("MDS Plot_", names(factors)[i], ".pdf")
-    link_addr <- paste0("mdsplot_", names(factors)[i], ".pdf")
+    link_name <- paste0("MDS Plot_", sanitise_basename(names(factors)[i]), ".pdf")
+    link_addr <- paste0("mdsplot_", sanitise_basename(names(factors)[i]), ".pdf")
     link_data <- rbind(link_data, c(link_name, link_addr))
     invisible(dev.off())
   }
@@ -549,8 +555,8 @@
   top <- topTags(res, adjust.method = opt$pAdjOpt, n = Inf, sort.by = "PValue")
   write.table(top, file = top_out[i], row.names = FALSE, sep = "\t", quote = FALSE)
 
-  link_name <- paste0("edgeR_", contrast_data[i], ".tsv")
-  link_addr <- paste0("edgeR_", contrast_data[i], ".tsv")
+  link_name <- paste0("edgeR_", sanitise_basename(contrast_data[i]), ".tsv")
+  link_addr <- paste0("edgeR_", sanitise_basename(contrast_data[i]), ".tsv")
   link_data <- rbind(link_data, c(link_name, link_addr))
 
   # Plot MD (log ratios vs mean difference) using limma package
@@ -564,8 +570,8 @@
 
   abline(h = 0, col = "grey", lty = 2)
 
-  link_name <- paste0("MD Plot_", contrast_data[i], ".pdf")
-  link_addr <- paste0("mdplot_", contrast_data[i], ".pdf")
+  link_name <- paste0("MD Plot_", sanitise_basename(contrast_data[i]), ".pdf")
+  link_addr <- paste0("mdplot_", sanitise_basename(contrast_data[i]), ".pdf")
   link_data <- rbind(link_data, c(link_name, link_addr))
   invisible(dev.off())
 
@@ -579,8 +585,8 @@
 
   abline(h = 0, col = "grey", lty = 2)
 
-  img_name <- paste0("MD Plot_", contrast_data[i], ".png")
-  img_addr <- paste0("mdplot_", contrast_data[i], ".png")
+  img_name <- paste0("MD Plot_", sanitise_basename(contrast_data[i]), ".png")
+  img_addr <- paste0("mdplot_", sanitise_basename(contrast_data[i]), ".png")
   image_data <- rbind(image_data, c(img_name, img_addr))
   invisible(dev.off())
 }
--- a/edger.xml	Wed Oct 11 11:13:07 2023 +0000
+++ b/edger.xml	Wed Nov 22 03:57:37 2023 +0000
@@ -4,7 +4,7 @@
     </description>
     <macros>
         <token name="@TOOL_VERSION@">3.36.0</token>
-        <token name="@VERSION_SUFFIX@">3</token>
+        <token name="@VERSION_SUFFIX@">4</token>
     </macros>
     <edam_topics>
         <edam_topic>topic_3308</edam_topic>
@@ -694,7 +694,7 @@
             <param name="cinfo" value="contrasts_file.txt"/>
             <param name="formula" value="~ 0 + Genotype + Batch"/>
             <param name="normalisationOption" value="TMM"/>
-            <output_collection name="outTables" count="2">
+            <output_collection name="outTables" count="3">
                 <element name="edgeR_Mut-WT" ftype="tabular">
                     <assert_contents>
                         <has_text_matching expression="GeneID.*logFC.*logCPM.*F.*PValue.*FDR"/>
@@ -706,6 +706,11 @@
                         <has_text_matching expression="GeneID.*logFC.*logCPM.*F.*PValue.*FDR"/>
                     </assert_contents>
                 </element>
+                <element name="edgeR_(2*Mut_3*WT)-WT" ftype="tabular">
+                    <assert_contents>
+                        <has_text_matching expression="GeneID.*logFC.*logCPM.*F.*PValue.*FDR"/>
+                    </assert_contents>
+                </element>
             </output_collection>
         </test>
     </tests>
--- a/test-data/contrasts_file.txt	Wed Oct 11 11:13:07 2023 +0000
+++ b/test-data/contrasts_file.txt	Wed Nov 22 03:57:37 2023 +0000
@@ -1,3 +1,4 @@
 Contrasts
 Mut-WT
-WT-Mut
\ No newline at end of file
+WT-Mut
+(2*Mut/3*WT)-WT
\ No newline at end of file