changeset 0:b73fc4860906 draft default tip

"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/ggcyto_1d_density_plots commit b32c86c02e138aa291c869b31351c4970300fbb4"
author azomics
date Mon, 22 Jun 2020 17:53:11 -0400
parents
children
files FCS1Dplotggcyto.R FCS1Dplotggcyto.xml test-data/graph.pdf test-data/graph.png test-data/graph1.png test-data/graph2.png test-data/testfcs1.fcs
diffstat 7 files changed, 207 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FCS1Dplotggcyto.R	Mon Jun 22 17:53:11 2020 -0400
@@ -0,0 +1,88 @@
+#!/usr/bin/Rscript
+# 1D Density Plot Module for Galaxy
+# ggcyto
+######################################################################
+#                  Copyright (c) 2016 Northrop Grumman.
+#                          All rights reserved.
+######################################################################
+#
+# Version 1
+# Cristel Thomas
+#
+#
+
+library(ggcyto)
+
+generate1Dplot <- function(input, output, flag_pdf=FALSE, trans_method="None",
+                           factor="", log_w=0.5, log_t=262144, log_m=4.5) {
+  fcsfs <- read.flowSet(input, transformation=F)
+  h <- 800
+  w <- 1200
+  if ("colnames" %in% names(attributes(fcsfs)) && length(fcsfs@colnames)>12){
+    h <- 1200
+    w <- 1600
+  }
+  p <- autoplot(fcsfs[[1]])
+  if (trans_method == "arcsinh") {
+    p <- p + scale_x_flowCore_fasinh(a = 0, b = factor, c = 0) + geom_density(fill="steelblue", alpha=0.5)
+  } else if (trans_method == "logicle") {
+    p <- p + scale_x_logicle(w=log_w, t=log_t, m=log_m) + geom_density(fill="paleturquoise", alpha=0.5)
+  }
+
+  if (flag_pdf) {
+    pdf(output, useDingbats=FALSE, onefile=TRUE)
+    print({
+      p
+    })
+    dev.off()
+  } else {
+    png(output, type="cairo", height=h, width=w)
+    print({
+      p
+    })
+    dev.off()
+  }
+}
+
+checkFCS <- function(input_file, output_file, flag_pdf=FALSE, trans_met="None",
+                     factor="", w=0.5, t=262144, m=4.5) {
+  isValid <- F
+  # Check file beginning matches FCS standard
+  tryCatch({
+    isValid <- isFCSfile(input_file)
+  }, error = function(ex) {
+    print (paste("    ! Error in isFCSfile", ex))
+  })
+
+  if (isValid) {
+    generate1Dplot(input_file, output_file, flag_pdf, trans_met,
+                   factor, w, t, m)
+  } else {
+    print (paste(input_file, "does not meet FCS standard"))
+  }
+}
+
+args <- commandArgs(trailingOnly = TRUE)
+flag_pdf <- FALSE
+trans_method <- "None"
+scaling_factor <- 1 / 150
+w <- 0.5
+t <- 262144
+m <- 4.5
+
+if (args[3] == "PDF"){
+  flag_pdf <- TRUE
+}
+
+if (args[4]!="None"){
+  trans_method <- args[4]
+  if (args[4] == "arcsinh"){
+    scaling_factor <- 1 / as.numeric(args[5])
+  } else if (args[4] == "logicle"){
+    w <- args[5]
+    t <- args[6]
+    m <- args[7]
+  }
+}
+
+checkFCS(args[1], args[2], flag_pdf, trans_method, scaling_factor, w, t, m)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FCS1Dplotggcyto.xml	Mon Jun 22 17:53:11 2020 -0400
@@ -0,0 +1,119 @@
+<tool id="ggcyto_1d_density_plots" name="Generate 1D density plots" version="1.1+galaxy0">
+  <description>for FCS file</description>
+  <requirements>
+    <requirement type="package" version="1.14.0">bioconductor-ggcyto</requirement>
+    <!-- to fix https://github.com/RGLab/ggcyto/issues/64 and not able to install ggcyto 1.16.0-->
+    <requirement type="package" version="3.2.1">r-ggplot2</requirement>
+  </requirements>
+  <stdio>
+    <exit_code range="1:" />
+  </stdio>
+  <command><![CDATA[
+     Rscript $__tool_directory__/FCS1Dplotggcyto.R '${input}' '${output}' $outformat '${transform.trans_method}'
+     #if $transform.trans_method == "arcsinh"
+     $transform.scaling_factor
+     #else if $transform.trans_method == "logicle"
+     $transform.w $transform.t $transform.m
+     #end if
+  ]]>
+  </command>
+  <inputs>
+    <param format="fcs" name="input" type="data" label="FCS file"/>
+    <conditional name="transform">
+      <param name="trans_method" type="select" label="Apply transformation to plot:" help="by default, no transformation">
+        <option value="None">no transformation please.</option>
+        <option value="logicle">logicle</option>
+        <option value="arcsinh">arcsinh</option>
+      </param>
+      <when value="arcsinh">
+        <param name="scaling_factor" type="integer" min="1" max="200" value="150" label="Scaling factor b for arcsinh transform:" help="The default value is 150 for standard FCM data. The recommended value for cyTOF data is 5.">
+        </param>
+      </when>
+      <when value="logicle">
+        <param name="w" type="float" value="0.5" label="Linearization width w for logicle transform:" help="w should be positive and determines the slope of transformation at zero. The default value is 0.5.">
+        </param>
+        <param name="t" type="integer" value="262144" label="Top of the scale data value t for logicle transform:" help=" t should be greater than zero. Recommended values are 10000 for common 4 decade data or 262144 for a 18 bit data range. The default value is 262144.">
+        </param>
+        <param name="m" type="float" value="4.5" label="Full width of the transformed display m for logicle transform:" help="m is expressed in asymptotic decades and should be positive. The default value is 4.5 .">
+        </param>
+      </when>
+    </conditional>
+    <param name="outformat" type="select" label="Output Format" help="PDF will be larger files that may take some time to load.">
+      <option value="PNG">PNG</option>
+      <option value="PDF">PDF</option>
+    </param>
+  </inputs>
+  <outputs>
+    <data format="png" name="output" label="1D Density Plots for ${input.name} with ${transform.trans_method} in ${outformat}">
+      <change_format>
+        <when input="outformat" value="PDF" format="pdf" />
+      </change_format>
+    </data>
+  </outputs>
+  <tests>
+    <test>
+      <param name="input" value="testfcs1.fcs"/>
+      <param name="outformat" value="PDF"/>
+      <param name="trans_method" value="None"/>
+      <output name="output" file="graph.pdf" compare="sim_size"/>
+    </test>
+    <test>
+      <param name="input" value="testfcs1.fcs"/>
+      <param name="outformat" value="PNG"/>
+      <param name="trans_method" value="logicle"/>
+      <param name="w" value="0.4"/>
+      <param name="m" value="4.5"/>
+      <param name="t" value="10000"/>
+      <output name="output" file="graph1.png" compare="sim_size"/>
+    </test>
+    <test>
+      <param name="input" value="testfcs1.fcs"/>
+      <param name="outformat" value="PNG"/>
+      <param name="trans_method" value="arcsinh"/>
+      <param name="scaling_factor" value="150"/>
+      <output name="output" file="graph2.png" compare="sim_size"/>
+    </test>
+  </tests>
+  <help><![CDATA[
+Scatterplots of fcs sample
+-------------------
+
+This tool allows generation of density scatter plots using ggcyto.
+
+**Input files**
+
+This tool takes valid FCS files as input.
+
+**Output files**
+
+This tool generates a series of 1D density plot using ggcyto and produces a png file. A pdf file can optionally be generated.
+
+class:: warningmark
+
+PDF are larger files that may take some time to load. It might be faster to download the PDF output once generated to open it locally.
+
+-----
+
+**Transformation**
+
+This tools currently supports 2 transformation algorithms: arcsinh and logicle, implemented using flowCore. Transformation applied are color-coded: black is no transformation, blue is arcinsh, and green is logicle.
+
+-----
+
+**Example**
+
+*Output*:
+
+.. image:: ./static/images/flowtools/testoutputggcyto.png
+
+-----
+
+**ggcyto reference**
+Jiang M (2015). ggcyto: Visualize Cytometry data with ggplot. R package version 1.4.0, https://github.com/RGLab/ggcyto/issues.
+
+  ]]>
+  </help>
+  <citations>
+    <citation type="doi">10.1186/1471-2105-10-106</citation>
+  </citations>
+</tool>
Binary file test-data/graph.pdf has changed
Binary file test-data/graph.png has changed
Binary file test-data/graph1.png has changed
Binary file test-data/graph2.png has changed
Binary file test-data/testfcs1.fcs has changed