changeset 2:1023fa7bd75f draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/mqppep commit 423304b26e63d23cd8e5fb4c2fb729c5beea1254
author galaxyp
date Mon, 12 Dec 2022 22:00:29 +0000
parents 2276e88d5a1f
children 6f51e262d84d
files macros.xml mqppep_anova_script.Rmd overview_flowchart.dia overview_flowchart.pdf
diffstat 4 files changed, 65 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/macros.xml	Fri Oct 28 18:25:25 2022 +0000
+++ b/macros.xml	Mon Dec 12 22:00:29 2022 +0000
@@ -1,5 +1,5 @@
 <macros>
-    <token name="@TOOL_VERSION@">0.1.15</token>
+    <token name="@TOOL_VERSION@">0.1.16</token>
     <token name="@VERSION_SUFFIX@">0</token>
     <xml name="requirements">
         <requirements>
@@ -41,7 +41,7 @@
         </requirements>
         <!-- I specified the versions above because it takes a VERY long time
              to search for package versions when they are not omitted; also,
-             locking version numbers might lead to more-reproducible behavior.
+             locking version numbers might lead to more-reproducible behavior.  
         -->
     </xml>
 </macros>
--- a/mqppep_anova_script.Rmd	Fri Oct 28 18:25:25 2022 +0000
+++ b/mqppep_anova_script.Rmd	Mon Dec 12 22:00:29 2022 +0000
@@ -6,7 +6,7 @@
 - "Art Eschenlauer^[ORCiD 0000-0002-2882-0508, University of Minnesota: Minneapolis, Minnesota, US]"
 date:
 - "May 28, 2018"
-- "; revised June 23, 2022"
+- "; revised December 7, 2022"
 lot: true
 output:
   pdf_document:
@@ -97,13 +97,14 @@
   kinaseUprtDescLutBz2: "./kinase_uniprot_description_lut.tabular.bz2"
   # should debugging trace messages be printed?
   showEnrichedSubstrates: FALSE
-
   # should debugging nb/nbe messages be printed?
   printNBMsgs:          FALSE
+  # showld row-scaling be applied to heatmaps: "none" or "row"
+  defaultHeatMapRowScaling: "none"
   # should debugging trace messages be printed?
   printTraceMsgs:       FALSE
   # when debugging files are needed, set debugFileBasePath to the path
-  #   to the directory where they should be writtn
+  #   to the directory where they should be written
   debugFileBasePath:    !r if (TRUE) NULL else "test-data"
 ---
 
@@ -556,6 +557,16 @@
   }
 )
 
+g_default_heatmap_row_scaling <-
+  params$defaultHeatMapRowScaling
+if (
+  !is.character(g_default_heatmap_row_scaling) ||
+  !(g_default_heatmap_row_scaling %in% c("row", "none"))
+  ) {
+  cat("invalid defaultHeatMapRowScaling (must be 'row' or 'none')")
+  knitr::knit_exit()
+}
+
 # intensityHeatmapRows: 50
 # TODO Validate >> 0 < 75
 g_intensity_hm_rows     <- params$intensityHeatmapRows
@@ -2287,7 +2298,16 @@
   my_limit <- g_intensity_hm_rows
 
   my_row_cex_scale <- master_cex * 150 / nrow_x
+  #ACE row cex shrink hack begin
+  my_row_cex_scale <- master_cex * 150 / max(nrow_x, ncol_x)
+  #ACE row cex shrink hack end
+
   my_col_cex_scale <- 3.0
+  #ACE col cex shrink hack begin
+  if (ncol_x > 40)
+    my_col_cex_scale <- 3.0 * 40 / ncol_x
+  #ACE col cex shrink hack end
+
   my_asterisk_scale <- 0.4 * my_row_cex_scale
   my_row_warp <- 1
   my_note_warp <- 2
@@ -2606,6 +2626,8 @@
     margins = NULL,                 # optional margins (bottom, right)
     cellnote = NULL,                # optional matrix of character; dim = dim(m)
     adj = 0.5,                      # adjust text: 0 left, 0.5 middle, 1 right
+    row_scaling =                   # should row-scaling be applied if possible?
+      g_default_heatmap_row_scaling,
     ...                             # passthru to hm2plus or heatmap.2
   ) {
     use_heatmap_1 <- FALSE
@@ -2780,11 +2802,11 @@
             }
 
             # invoke hm_call inner function
-            if (sum(rowSums(!is.na(m_hm)) < 2))
+            if (row_scaling != "row" || sum(rowSums(!is.na(m_hm)) < 2))
               hm_call(
                 m_hm,
                 "none",
-                "log(intensities), unscaled, unimputed, and unnormalized"
+                "log(intensities), unimputed, and unnormalized"
                 )
             else
               hm_call(
@@ -2802,10 +2824,7 @@
                     hm_call(
                       m_hm,
                       "none",
-                      paste(
-                        "log(intensities), unscaled,",
-                        "zero-imputed, unnormalized"
-                        )
+                      "log(intensities), zero-imputed, unnormalized"
                       )
                   else
                     cat("\nThere are too few peptides to produce a heatmap.\n")
@@ -3715,12 +3734,8 @@
 imp_smry_rejected_after  <- sum(!good_rows)
 imp_smry_missing_values_after   <- sum(is.na(quant_data_imp[good_rows, ]))
 
-# From ?`%in%`, %in% is currently defined as function(x, table) match(x, table, nomatch = 0) > 0
-
-sink(stderr())
-print("`%in%`:")
-print(`%in%`)
-sink()
+# From ?`%in%`:
+#   %in% is currently defined as function(x, table) match(x, table, nomatch = 0) > 0
 
 stock_in <-
   names(good_rows) %in%
@@ -5094,33 +5109,38 @@
         one_way_f = one_way_two_categories, # anova_func arg3
         simplify = TRUE # TRUE is the default for simplify
         )
-    contrast_data_adj_p_values <- p.adjust(
-        p = p_value_data_contrast_ps,
-        method = "fdr",
-        n = length(p_value_data_contrast_ps) # this is the default, length(p)
-      )
-    # - compute the fold-change
-    contrast_p_df <-
-      data.frame(
-        contrast = contrast,
-        phosphopep = contrast_cast$phosphopep,
-        p_value_raw = p_value_data_contrast_ps,
-        p_value_adj = contrast_data_adj_p_values
+
+    if (!is.null(p_value_data_contrast_ps)) {
+      contrast_data_adj_p_values <-
+        p.adjust(
+          p = p_value_data_contrast_ps,
+          method = "fdr",
+          n = length(p_value_data_contrast_ps) # this is the default, length(p)
+          )
+
+      # - compute the fold-change
+      contrast_p_df <-
+        data.frame(
+          contrast = contrast,
+          phosphopep = contrast_cast$phosphopep,
+          p_value_raw = p_value_data_contrast_ps,
+          p_value_adj = contrast_data_adj_p_values
+        )
+      db_write_table_overwrite <- (contrast < 2)
+      db_write_table_append <- !db_write_table_overwrite
+      RSQLite::dbWriteTable(
+        conn = db,
+        name = "contrast_ppep_p_val",
+        value = contrast_p_df,
+        append = db_write_table_append
+        )
+      # Create UK for insert
+      ddl_exec(db, "
+        CREATE UNIQUE INDEX IF NOT EXISTS contrast_ppep_p_val__uk__idx
+          ON contrast_ppep_p_val(phosphopep, contrast);
+        "
       )
-    db_write_table_overwrite <- (contrast < 2)
-    db_write_table_append <- !db_write_table_overwrite
-    RSQLite::dbWriteTable(
-      conn = db,
-      name = "contrast_ppep_p_val",
-      value = contrast_p_df,
-      append = db_write_table_append
-      )
-    # Create UK for insert
-    ddl_exec(db, "
-      CREATE UNIQUE INDEX IF NOT EXISTS contrast_ppep_p_val__uk__idx
-        ON contrast_ppep_p_val(phosphopep, contrast);
-      "
-    )
+    }
   }
   # Perhaps this could be done more elegantly using unique keys
   #   or creating the tables before saving data to them, but this
@@ -6095,7 +6115,8 @@
           suppress_row_dendrogram = FALSE,
           master_cex              = 0.35,
           sepcolor                = "black",
-          colsep                  = sample_colsep
+          colsep                  = sample_colsep,
+          row_scaling             = "none"
         )
         if (number_of_peptides_found > 1) {
 
Binary file overview_flowchart.dia has changed
Binary file overview_flowchart.pdf has changed