Repository 'pathifier'
hg clone https://toolshed.g2.bx.psu.edu/repos/artbio/pathifier

Changeset 1:0960bd1161fa (2024-02-12)
Previous changeset 0:fec313f5c889 (2021-04-12)
Commit message:
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/pathifier commit f7363f7c391bd501fc4d1c10aaf372ec2bd82732
modified:
pathifier.R
pathifier.xml
b
diff -r fec313f5c889 -r 0960bd1161fa pathifier.R
--- a/pathifier.R Mon Apr 12 09:55:24 2021 +0000
+++ b/pathifier.R Mon Feb 12 23:57:01 2024 +0000
[
b'@@ -4,10 +4,10 @@\n ##################################################################################################\n \n \n-options(show.error.messages = F, error = function() {\n-  cat(geterrmessage(), file = stderr()); q("no", 1, F)\n-  }\n-)\n+options(show.error.messages = FALSE, error = function() {\n+    cat(geterrmessage(), file = stderr())\n+    q("no", 1, FALSE)\n+})\n # we need that to not crash galaxy with an UTF8 error on German LC settings.\n loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")\n \n@@ -18,106 +18,112 @@\n library(circlize)\n \n option_list <- list(\n-  make_option(\n-    "--exp",\n-    type = "character",\n-    help = "Expression matrix"),\n-  make_option(\n-    "--sep",\n-    type = "character",\n-    default = "\\t",\n-    help = "File separator [default : \'%default\']"\n-  ),\n-  make_option(\n-    "--genes",\n-    type = "character",\n-    help = "Gene sets Pathways : gmt format (one pathway per line : Name, description, genes (one by column), tab separated)"),\n-  make_option(\n-    "--is_normal",\n-    default = F,\n-    type = "logical",\n-    help = "Define normals cells in your data"),\n-  make_option(\n-    "--normals",\n-    type = "character",\n-    help = "A vector of sample status : 1 = Healthy, 0 = Tumor. Must be in the same order as in expression data"),\n-  make_option(\n-    "--logfile",\n-    type = "character",\n-    default = "log.txt",\n-    help = "Log file name [default : \'%default\']"\n-  ),\n-  make_option(\n-    "--max_stability",\n-    type = "logical",\n-    default = T,\n-    help = "If true, throw away components leading to low stability of sampling noise [default : \'%default\']"\n-  ),\n-  make_option(\n-    "--attempts",\n-    type = "integer",\n-    default = 10,\n-    help = "Number of runs to determine stability. [default : \'%default\']"\n-  ),\n-  make_option(\n-    "--min_std",\n-    type = "character",\n-    default = "0.4",\n-    help = "Minimum of standard deviation to filter out low variable genes.\n+    make_option(\n+        "--exp",\n+        type = "character",\n+        help = "Expression matrix"\n+    ),\n+    make_option(\n+        "--sep",\n+        type = "character",\n+        default = "\\t",\n+        help = "File separator [default : \'%default\']"\n+    ),\n+    make_option(\n+        "--genes",\n+        type = "character",\n+        help = "Gene sets Pathways : gmt format (one pathway per line : Name, description, genes (one by column), tab separated)"\n+    ),\n+    make_option(\n+        "--is_normal",\n+        default = FALSE,\n+        type = "logical",\n+        help = "Define normals cells in your data"\n+    ),\n+    make_option(\n+        "--normals",\n+        type = "character",\n+        help = "A vector of sample status : 1 = Healthy, 0 = Tumor. Must be in the same order as in expression data"\n+    ),\n+    make_option(\n+        "--logfile",\n+        type = "character",\n+        default = "log.txt",\n+        help = "Log file name [default : \'%default\']"\n+    ),\n+    make_option(\n+        "--max_stability",\n+        type = "logical",\n+        default = TRUE,\n+        help = "If true, throw away components leading to low stability of sampling noise [default : \'%default\']"\n+    ),\n+    make_option(\n+        "--attempts",\n+        type = "integer",\n+        default = 10,\n+        help = "Number of runs to determine stability. [default : \'%default\']"\n+    ),\n+    make_option(\n+        "--min_std",\n+        type = "character",\n+        default = "0.4",\n+        help = "Minimum of standard deviation to filter out low variable genes.\n     Use --min.std data, to use the minimum std of your data [default : \'%default\']"\n-  ),\n-  make_option(\n-    "--min_exp",\n-    type = "character",\n-    default = "4",\n-    help = "Minimum of gene expression to filter out low expressed genes.\n+    ),\n+    make_option(\n+        "--min_exp",\n+        type = "character",\n+        default = "4",\n+        help = "Minimum of gene expression to filter out low expressed genes.\n     Use --min.exp data, to use the minimum expression of your data [default : \'%d'..b'(exp_matrix_filtered)\n+        color_status_heatmap <- list(Status = c(normal = "blue", tumor = "red"))\n+    }\n+} else {\n+    pds <- quantify_pathways_deregulation(exp_matrix_filtered,\n+        allgenes,\n+        gs,\n+        pathwaynames,\n+        maximize_stability = args$max_stability,\n+        attempts = args$attempts,\n+        logfile = args$logfile,\n+        min_std = args$min_std,\n+        min_exp = args$min_exp\n+    )\n+    for (i in pathwaynames) {\n+        df <- data.frame(pds$curves[[i]][, 1:3],\n+            PDS = as.numeric(pds$scores[[i]]),\n+            curve_order = as.vector(pds$curves_order[[i]])\n+        )\n+        ordered <- df[df$curve_order, ]\n \n-    layout(cbind(1:2, 1:2), heights = c(7, 1))\n-    sc3 <- scatterplot3d(ordered[, 1:3],\n-                         main = paste("Principal curve of", i),\n-                         box = F, pch = 19, type = "l")\n-    sc3$points3d(ordered[, 1:3], box = F, pch = 19,\n-                 col = col_score_fun(ordered$PDS))\n+        layout(cbind(1:2, 1:2), heights = c(7, 1))\n+        sc3 <- scatterplot3d(ordered[, 1:3],\n+            main = paste("Principal curve of", i),\n+            box = FALSE, pch = 19, type = "l"\n+        )\n+        sc3$points3d(ordered[, 1:3],\n+            box = FALSE, pch = 19,\n+            col = col_score_fun(ordered$PDS)\n+        )\n \n-    # Plot color scale legend\n-    par(mar = c(5, 3, 0, 3))\n-    plot(seq(min(ordered$PDS), max(ordered$PDS), length = 100), rep(0, 100), pch = 15,\n-        axes = TRUE, yaxt = "n", xlab = "Color scale of PDS", ylab = "", bty = "n",\n-        col = col_score_fun(seq(min(ordered$PDS), max(ordered$PDS), length = 100)))\n+        # Plot color scale legend\n+        par(mar = c(5, 3, 0, 3))\n+        plot(seq(min(ordered$PDS), max(ordered$PDS), length = 100), rep(0, 100),\n+            pch = 15,\n+            axes = TRUE, yaxt = "n", xlab = "Color scale of PDS", ylab = "", bty = "n",\n+            col = col_score_fun(seq(min(ordered$PDS), max(ordered$PDS), length = 100))\n+        )\n \n \n-  ## annotation for heatmap (for the moment none for this situation)\n-  sample_status <- NA\n-  color_status_heatmap <- NA\n-  }\n+        ## annotation for heatmap (for the moment none for this situation)\n+        sample_status <- NA\n+        color_status_heatmap <- NA\n+    }\n }\n \n ## Create dataframe from Pathifier list and round score to 4 digits\n@@ -283,29 +318,31 @@\n ## plot heatmap\n if (ncol(pds_scores) > 1) {\n     pheatmap(t(pds_scores),\n-             main = "Heatmap of Pathway Deregulation Score",   # heat map title\n-             cluster_rows = args$heatmap_cluster_pathways,     # apply clustering method\n-             cluster_cols = args$heatmap_cluster_cells,        # apply clustering method\n+        main = "Heatmap of Pathway Deregulation Score", # heat map title\n+        cluster_rows = args$heatmap_cluster_pathways, # apply clustering method\n+        cluster_cols = args$heatmap_cluster_cells, # apply clustering method\n \n-             #Additional Options\n-             ## Color labeled columns\n-             annotation_col = sample_status,\n-             annotation_colors = color_status_heatmap,\n-             show_rownames = args$heatmap_show_pathway_labels,\n-             show_colnames = args$heatmap_show_cell_labels,\n-             border_color = NA,\n-             legend = TRUE)\n+        # Additional Options\n+        ## Color labeled columns\n+        annotation_col = sample_status,\n+        annotation_colors = color_status_heatmap,\n+        show_rownames = args$heatmap_show_pathway_labels,\n+        show_colnames = args$heatmap_show_cell_labels,\n+        border_color = NA,\n+        legend = TRUE\n+    )\n }\n dev.off()\n \n \n ## write table\n write.table(pds_scores,\n-            args$pds,\n-            row.names = T,\n-            col.names = T,\n-            quote = F,\n-            sep = "\\t")\n+    args$pds,\n+    row.names = TRUE,\n+    col.names = TRUE,\n+    quote = FALSE,\n+    sep = "\\t"\n+)\n \n ## write S4 pathifier object\n save(pds, file = args$rdata)\n'
b
diff -r fec313f5c889 -r 0960bd1161fa pathifier.xml
--- a/pathifier.xml Mon Apr 12 09:55:24 2021 +0000
+++ b/pathifier.xml Mon Feb 12 23:57:01 2024 +0000
[
@@ -1,23 +1,28 @@
-<tool id="pathifier" name="Pathifier" version="1.0.1">
+<tool id="pathifier" name="Pathifier" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
     <description>: Quantify deregulation of pathways in cancer</description>
+    <macros>
+        <token name="@TOOL_VERSION@">1.40.0</token>
+        <token name="@VERSION_SUFFIX@">0</token>
+        <token name="@PROFILE@">23.0</token>
+    </macros>
     <requirements>
-        <requirement type="package" version="1.6.2=r35h6115d3f_0">r-optparse</requirement>
-        <requirement type="package" version="1.22.0=r351_0">bioconductor-pathifier</requirement>
-        <requirement type="package" version="1.0.12=r351h6115d3f_0">r-pheatmap</requirement>
-        <requirement type="package" version="0.3_41=r351h6115d3f_0">r-scatterplot3d</requirement>
-        <requirement type="package" version="0.4.7=r35h6115d3f_0">r-circlize</requirement>
+        <requirement type="package" version="@TOOL_VERSION@">bioconductor-pathifier</requirement>
+        <requirement type="package" version="1.7.4">r-optparse</requirement>
+        <requirement type="package" version="1.0.12">r-pheatmap</requirement>
+        <requirement type="package" version="0.3_44">r-scatterplot3d</requirement>
+        <requirement type="package" version="0.4.15">r-circlize</requirement>
     </requirements>
     <stdio>
         <exit_code range="1:" level="fatal" description="Tool exception" />
     </stdio>
     <command detect_errors="exit_code"><![CDATA[ 
-        Rscript $__tool_directory__/pathifier.R 
+        Rscript '$__tool_directory__/pathifier.R' 
             --exp '$input'
             --sep '$input_sep'
             --genes '$genes'
 
-            #if $reference.is_normal == "Yes":
-                --is_normal 'TRUE'
+            #if str($reference.reference_selector) == 'TRUE':
+                --is_normal '$reference.reference_selector'
                 --normals '$reference.normals'
             #end if
 
@@ -35,7 +40,6 @@
             --logfile '$logfile'
             --plot '$plot'
             --rdata '$rdatafile'
-            
 ]]></command>
     <inputs>
         <param name="input" type="data" format="txt,tabular" label="expression data"/>
@@ -46,9 +50,13 @@
         <param name="genes" type="data" format="txt" label="Gene sets Pathways" 
                help="Must be in gmt format (one pathway per line : Name, description, genes (one by column), tab separated)" />
         <conditional name="reference">
-            <param name="is_normal" label="Do you have non cancer transcriptomes in your data set ?" type="boolean" truevalue="Yes" falsevalue="" checked="false" 
-                   help="If set the starting curve depends on the matrix of points with in a certain row order (first 'normal' then 'cancer' samples), otherwise the first principal component is used. See help for more informations"/>
-            <when value="Yes">
+            <param name="reference_selector" label="Do you have non cancer transcriptomes in your data set ?" type="select"
+                   help="Yes, if the starting curve depends on the matrix of points with in a certain row order
+                         (first 'normal' then 'cancer' samples), otherwise (No) the first principal component is used. See help section for more informations">
+                <option selected="True" value="TRUE">Yes</option>
+                <option value="">No</option>
+            </param>
+            <when value="TRUE">
                 <param name="normals" type="data" format="tabular" label="Sample status"
                        help="A two-column data frame, first column contains data labels, second column the levels of sample status : 1 = Healthy, 0 = Tumor (no header)" />
             </when>
@@ -74,7 +82,6 @@
             <option value="no" selected="True">No</option>
             <option value="yes">Yes</option>
         </param>
-             
     </inputs>
     <outputs>
         <data name="pds" format="tabular" label="Pathifier Deregulation Score (PDS) of ${on_string}" />
@@ -83,14 +90,14 @@
         </data>
         <data name="plot" format="pdf" label="Pathifier vizualization of ${on_string}" />
         <data name="rdatafile" format="rdata" label="Pathifier S4 object of ${on_string}" >
-            <filter>rds == 'yes'</filter>
+            <filter>rdata == 'yes'</filter>
         </data>
     </outputs>
     <tests>
-        <test>
+        <test expect_num_outputs="3">
             <param name="input" value="sheffer.tsv" ftype="tabular"/>
             <param name="genes" value="kegg_pathways.gmt" ftype="txt" />
-            <param name="is_normal" value="True" />
+            <param name="reference_selector" value="TRUE" />
             <param name="normals" value="normals.tsv" ftype="tabular" />
             <param name="log" value="yes" />
             <param name="attempts" value="100" />
@@ -98,10 +105,10 @@
             <output name="pds" file="sheffer.kegg.tsv" ftype="tabular"/>
             <output name="plot" file="plot.pdf" ftype="pdf" compare="sim_size" />
         </test>
-        <test>
+        <test expect_num_outputs="3">
             <param name="input" value="sheffer_noref.tsv" ftype="tabular"/>
             <param name="genes" value="kegg_pathways.gmt" ftype="txt" />
-            <param name="is_normal" value="" />
+            <param name="reference_selector" value="" />
             <param name="log" value="no" />
             <param name="rdata" value="yes" />
             <param name="attempts" value="50" />