changeset 1:65245dc812c3 draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit d2f311f7fff24e54c565127c40414de708e31b3c
author galaxyp
date Thu, 25 Oct 2018 07:31:08 -0400
parents 93be1d20b5c3
children 129cddd02600
files combine.xml macros.xml test-data/Heatmaps_LM8_file16.pdf test-data/Heatmaps_analyze75.pdf test-data/Heatmaps_imzml.pdf test-data/Heatmaps_rdata.pdf test-data/Plot_analyze75.pdf test-data/Plot_analyze75_allpixels.pdf test-data/Plot_empty_spectra.pdf test-data/Plot_imzml.pdf test-data/Plot_rdata.pdf test-data/QC_analyze75.pdf test-data/QC_empty_spectra.pdf test-data/QC_imzml.pdf test-data/QC_rdata.pdf test-data/analyze75.svg test-data/analyze75_filtered2.pdf test-data/analyze_filteredoutside.RData test-data/centroids_rdata.pdf test-data/cluster_skm.RData test-data/imzml_filtered2.RData test-data/imzml_filtered2.pdf test-data/imzml_filtered3.RData test-data/imzml_filtered3.pdf test-data/imzml_filtered4.RData test-data/imzml_filtered4.pdf test-data/imzml_filtered5.RData test-data/imzml_filtered5.pdf test-data/kmeans_analyze.pdf test-data/pca_imzml.pdf test-data/rdata_notfiltered.RData test-data/rdata_notfiltered.pdf test-data/test1.pdf test-data/test2.pdf test-data/test2.rdata test-data/test3.pdf test-data/test4.pdf test-data/test4.rdata test-data/test5.pdf test-data/test6.pdf test-data/test6.rdata test-data/test7.pdf test-data/test7.rdata
diffstat 42 files changed, 69 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/combine.xml	Mon Oct 01 01:08:54 2018 -0400
+++ b/combine.xml	Thu Oct 25 07:31:08 2018 -0400
@@ -1,4 +1,4 @@
-<tool id="cardinal_combine" name="MSI combine" version="@VERSION@.0">
+<tool id="cardinal_combine" name="MSI combine" version="@VERSION@.1">
     <description>
         combine several mass spectrometry imaging datasets into one
     </description>
@@ -6,7 +6,7 @@
         <import>macros.xml</import>
     </macros>
     <expand macro="requirements">
-        <requirement type="package" version="3.0.0">r-ggplot2</requirement>
+        <requirement type="package" version="3.0">r-ggplot2</requirement>
     </expand>
     <command detect_errors="exit_code">
     <![CDATA[
@@ -29,7 +29,15 @@
         #end if
 
         cat '${msi_combine}' &&
-        Rscript '${msi_combine}'
+        Rscript '${msi_combine}' &&
+        #if $imzml_output:
+            mkdir $outfile_imzml.files_path &&
+            ls -l &&
+            mv ./out.imzML "${os.path.join($outfile_imzml.files_path, 'imzml')}" | true &&
+            mv ./out.ibd "${os.path.join($outfile_imzml.files_path, 'ibd')}" | true &&
+        #end if
+        echo "imzML file:" > $outfile_imzml &&
+        ls -l "$outfile_imzml.files_path" >> $outfile_imzml
 
     ]]>
     </command>
@@ -75,15 +83,15 @@
 
     #if $infile.ext == 'imzml'
         #if str($processed_cond.processed_file) == "processed":
-            msidata_$i <- readImzML('infile_${i}', mass.accuracy=$processed_cond.accuracy, units.accuracy = "$processed_cond.units")
-            centroided(msidata) = $centroids
+            msidata_$i <- readImzML('infile_${i}', mass.accuracy=$processed_cond.accuracy, units.accuracy = "$processed_cond.units", attach.only=TRUE)
+            centroided(msidata_$i) = $centroids
         #else
-            msidata_$i <- readImzML('infile_${i}')
-            centroided(msidata) = $centroids
+            msidata_$i <- readImzML('infile_${i}', attach.only=TRUE)
+            centroided(msidata_$i) = $centroids
         #end if
     #elif $infile.ext == 'analyze75'
-            msidata_$i <- readAnalyze('infile_${i}')
-            centroided(msidata) = $centroids
+            msidata_$i <- readAnalyze('infile_${i}', attach.only=TRUE)
+            centroided(msidata_$i) = $centroids
     #else
             msidata_$i = loadRData('infile_${i}.RData')
     #end if
@@ -106,6 +114,7 @@
         msidata_$i\$column5 = rep(NA, ncol(msidata_$i))
         msidata_$i\$combined_sample = rep(NA, ncol(msidata_$i))
 
+
     #if str($annotation_cond.annotation_tabular) == 'annotation'
         print("annotations")
 
@@ -131,6 +140,7 @@
         msidata_$i\$column4 = annotation_df_8_sorted[,7]
         msidata_$i\$column5 = annotation_df_8_sorted[,8]
 
+
         ## extract columnnames from (last) annotation tabular (for QC plot names)
         annotation_colnames = colnames(input_annotation)[-c(1,2)]
 
@@ -142,8 +152,8 @@
     #if str( $combine_conditional.combine_method ) == 'xy_shifts':
 
         ## shift coordinates according to input tabular file and store file names
-        coord(msidata_$i)\$x = coord(msidata_$i)\$x + input_list[$i+1,$combine_conditional.column_x] ## shifts x coordinates according to tabular file
-        coord(msidata_$i)\$y = coord(msidata_$i)\$y + input_list[$i+1,$combine_conditional.column_y] ## shifts y coordinates according to tabular file
+        coord(msidata_$i)\$x = as.integer(coord(msidata_$i)\$x + input_list[$i+1,$combine_conditional.column_x]) ## shifts x coordinates according to tabular file
+        coord(msidata_$i)\$y = as.integer(coord(msidata_$i)\$y + input_list[$i+1,$combine_conditional.column_y]) ## shifts y coordinates according to tabular file
         pixel_vector = append(pixel_vector, rep(paste($i+1, input_list[$i+1,$combine_conditional.column_names], sep="_"),times=ncol(msidata_$i))) ## stores file name for each pixel
         msidata_$i\$combined_sample = rep(paste($i+1, input_list[$i+1,$combine_conditional.column_names], sep="_"),times=ncol(msidata_$i))
         pixelcoords_$i = cbind(coord(msidata_$i)[,1:2], rep($i+1,ncol(msidata_$i)))
@@ -167,9 +177,8 @@
         }
 
         ## Number of input files define grid which is row-wise filled with files
-
-        coord(msidata_$i)\$x = coord(msidata_$i)\$x - (min(coord(msidata_$i)\$x-1)) + x_shifts
-        coord(msidata_$i)\$y = coord(msidata_$i)\$y - (min(coord(msidata_$i)\$y-1)) + y_shifts
+        coord(msidata_$i)\$x = as.integer(coord(msidata_$i)\$x - (min(coord(msidata_$i)\$x-1)) + x_shifts)
+        coord(msidata_$i)\$y = as.integer(coord(msidata_$i)\$y - (min(coord(msidata_$i)\$y-1)) + y_shifts)
         x_shifts = max(coord(msidata_$i)\$x) + 5
         max_y = append(max_y, max(coord(msidata_$i)\$y))
         all_files = $num_infiles
@@ -209,10 +218,15 @@
     colnames(position_df)[3] = "sample_name"
 
      ## save as (.RData)
-
     msidata = msidata_combined
     save(msidata, file="$msidata_combined")
 
+    ## save msidata as imzML file
+    #if $imzml_output:
+        writeImzML(msidata, "out")
+    #end if
+
+
 ################################## xy shifts ###################################
 ################################################################################
 
@@ -242,6 +256,9 @@
     msidata = msidata_combined
     save(msidata, file="$msidata_combined")
 
+    ## save msidata as imzML file
+    writeImzML(msidata, "out")
+
     ## create x,y,sample_name dataframe for QC pdf
 
     position_df = cbind(coord(msidata), msidata\$combined_sample)
@@ -390,6 +407,8 @@
     }
 
 
+
+
     ]]></configfile>
     </configfiles>
     <inputs>
@@ -439,11 +458,15 @@
                 <param name="xy_header" type="boolean" label="Tabular files contain a header line" truevalue="TRUE" falsevalue="FALSE"/>
             </when>
         </conditional>
+        <param name="imzml_output" type="boolean" label="Output of imzML file" truevalue="TRUE" falsevalue="FALSE"/>
     </inputs>
     <outputs>
         <data format="rdata" name="msidata_combined" label="${tool.name} on ${on_string}"/>
         <data format="pdf" name="QC_overview" from_work_dir="Combined_qc.pdf" label = "${tool.name} on ${on_string}: QC"/>
         <data format="tabular" name="pixel_annotations" label="${tool.name} on ${on_string}: annotations"/>
+        <data format="imzml" name="outfile_imzml" label="${tool.name} on ${on_string} : imzML">
+            <filter>imzml_output</filter>
+       </data>
     </outputs>
     <tests>
         <test>
@@ -543,7 +566,9 @@
 
 **Output**
 
-- single imzML file containing all valid input files
+- 
+- MSI data as .RData output (can be read with the Cardinal package in R)
+- optional: MSI data as imzML file
 - pdf that shows the pixel positions and annotations of the combined files
 - Tabular file with pixel annotations (x,y,column with input file names and up to five annotation columns)
 
--- a/macros.xml	Mon Oct 01 01:08:54 2018 -0400
+++ b/macros.xml	Thu Oct 25 07:31:08 2018 -0400
@@ -4,10 +4,17 @@
     <xml name="requirements">
         <requirements>
             <requirement type="package" version="@VERSION@">bioconductor-cardinal</requirement>
+            <requirement type="package" version="3.5.1">r-base</requirement>
             <yield/>
         </requirements>
     </xml>
 
+    <xml name="print_version">
+        <version_command><![CDATA[
+echo $(R --version | grep version | grep -v GNU)", Cardinal version" $(R --vanilla --slave -e "library(Cardinal); cat(sessionInfo()\$otherPkgs\$Cardinal\$Version)" 2> /dev/null | grep -v -i "WARNING: ")
+        ]]></version_command>
+    </xml>
+
     <token name="@INPUT_LINKING@"><![CDATA[
         #if $infile.ext == 'imzml'
             ln -s '${infile.extra_files_path}/imzml' infile.imzML &&
@@ -33,14 +40,14 @@
 
         #if $infile.ext == 'imzml'
             #if str($processed_cond.processed_file) == "processed":
-                msidata <- readImzML('infile', mass.accuracy=$processed_cond.accuracy, units.accuracy = "$processed_cond.units")
+                msidata <- readImzML('infile', mass.accuracy=$processed_cond.accuracy, units.accuracy = "$processed_cond.units", attach.only=TRUE)
                 centroided(msidata) = $centroids
             #else
-                msidata <- readImzML('infile')
+                msidata <- readImzML('infile', attach.only=TRUE)
                 centroided(msidata) = $centroids
             #end if
         #elif $infile.ext == 'analyze75'
-            msidata = readAnalyze('infile')
+            msidata = readAnalyze('infile', attach.only=TRUE)
             centroided(msidata) = $centroids
         #else
             msidata = loadRData('infile.RData')
@@ -177,7 +184,8 @@
         <param name="filename" type="text" value="" label="Title" help="Will appear in the pdf output, if nothing given it will take the dataset name">
             <sanitizer invalid_char="">
                 <valid initial="string.ascii_letters,string.digits">
-                    <add value="_" />
+                    <add value="_"/>
+                    <add value=" "/>
                 </valid>
             </sanitizer>
         </param>
@@ -198,12 +206,12 @@
         <param name="feature_header" type="boolean" label="Tabular file contains a header line" truevalue="TRUE" falsevalue="FALSE"/>
     </xml>
 
-    <xml name="reading_2_column_mz_tabular">
-        <param name="calibrant_file" type="data" optional="true" format="tabular"
+    <xml name="reading_2_column_mz_tabular" token_optional="false">
+        <param name="calibrant_file" type="data" optional="@OPTIONAL@" format="tabular"
             label="m/z of interest (e.g. internal Calibrants)" help="one column with m/z values, optional second column with names (m/z values can also be selected as name)"/>
-        <param name="mz_column" data_ref="calibrant_file" label="Column with m/z values" type="data_column"/>
-        <param name="name_column" data_ref="calibrant_file" label="Column with name of m/z values" type="data_column"/>
-        <param name="calibrant_header" type="boolean" label="Tabular file contains a header line" truevalue="TRUE" falsevalue="FALSE"/>
+        <param name="mz_column" data_ref="calibrant_file" optional="@OPTIONAL@" label="Column with m/z values" type="data_column"/>
+        <param name="name_column" data_ref="calibrant_file" optional="@OPTIONAL@" label="Column with name of m/z values" type="data_column"/>
+        <param name="calibrant_header" type="boolean" optional="@OPTIONAL@" label="Tabular file contains a header line" truevalue="TRUE" falsevalue="FALSE"/>
     </xml>
 
     <xml name="reading_pixel_annotations">
Binary file test-data/Heatmaps_LM8_file16.pdf has changed
Binary file test-data/Heatmaps_analyze75.pdf has changed
Binary file test-data/Heatmaps_imzml.pdf has changed
Binary file test-data/Heatmaps_rdata.pdf has changed
Binary file test-data/Plot_analyze75.pdf has changed
Binary file test-data/Plot_analyze75_allpixels.pdf has changed
Binary file test-data/Plot_empty_spectra.pdf has changed
Binary file test-data/Plot_imzml.pdf has changed
Binary file test-data/Plot_rdata.pdf has changed
Binary file test-data/QC_analyze75.pdf has changed
Binary file test-data/QC_empty_spectra.pdf has changed
Binary file test-data/QC_imzml.pdf has changed
Binary file test-data/QC_rdata.pdf has changed
--- a/test-data/analyze75.svg	Mon Oct 01 01:08:54 2018 -0400
+++ b/test-data/analyze75.svg	Thu Oct 25 07:31:08 2018 -0400
@@ -1,15 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="216pt" height="216pt" viewBox="0 0 216 216" version="1.1">
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="504pt" height="504pt" viewBox="0 0 504 504" version="1.1">
 <g id="surface1">
-<rect x="0" y="0" width="216" height="216" style="fill:rgb(100%,100%,100%);fill-opacity:1;stroke:none;"/>
-<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,100%,80%);fill-opacity:1;" d="M 0 0 L 72 0 L 72 72 L 0 72 Z M 0 0 "/>
-<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,100%,32.156863%);fill-opacity:1;" d="M 0 72 L 72 72 L 72 144 L 0 144 Z M 0 72 "/>
-<path style=" stroke:none;fill-rule:nonzero;fill:rgb(100%,3.921569%,0%);fill-opacity:1;" d="M 0 144 L 72 144 L 72 216 L 0 216 Z M 0 144 "/>
-<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 72 0 L 144 0 L 144 72 L 72 72 Z M 72 0 "/>
-<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0.392157%,33.333333%);fill-opacity:1;" d="M 72 72 L 144 72 L 144 144 L 72 144 Z M 72 72 "/>
-<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,1.568627%,93.72549%);fill-opacity:1;" d="M 72 144 L 144 144 L 144 216 L 72 216 Z M 72 144 "/>
-<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0.784314%,54.509804%);fill-opacity:1;" d="M 144 0 L 216 0 L 216 72 L 144 72 Z M 144 0 "/>
-<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,1.568627%,81.568627%);fill-opacity:1;" d="M 144 72 L 216 72 L 216 144 L 144 144 Z M 144 72 "/>
-<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,1.960784%,100%);fill-opacity:1;" d="M 144 144 L 216 144 L 216 216 L 144 216 Z M 144 144 "/>
+<rect x="0" y="0" width="504" height="504" style="fill:rgb(100%,100%,100%);fill-opacity:1;stroke:none;"/>
+<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,100%,80%);fill-opacity:1;" d="M 0 504 L 168 504 L 168 336 L 0 336 Z M 0 504 "/>
+<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,100%,32.156863%);fill-opacity:1;" d="M 0 336 L 168 336 L 168 168 L 0 168 Z M 0 336 "/>
+<path style=" stroke:none;fill-rule:nonzero;fill:rgb(100%,3.921569%,0%);fill-opacity:1;" d="M 0 168 L 168 168 L 168 0 L 0 0 Z M 0 168 "/>
+<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 168 504 L 336 504 L 336 336 L 168 336 Z M 168 504 "/>
+<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0.392157%,33.333333%);fill-opacity:1;" d="M 168 336 L 336 336 L 336 168 L 168 168 Z M 168 336 "/>
+<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,1.568627%,93.72549%);fill-opacity:1;" d="M 168 168 L 336 168 L 336 0 L 168 0 Z M 168 168 "/>
+<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0.784314%,54.509804%);fill-opacity:1;" d="M 336 504 L 504 504 L 504 336 L 336 336 Z M 336 504 "/>
+<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,1.568627%,81.568627%);fill-opacity:1;" d="M 336 336 L 504 336 L 504 168 L 336 168 Z M 336 336 "/>
+<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,1.960784%,100%);fill-opacity:1;" d="M 336 168 L 504 168 L 504 0 L 336 0 Z M 336 168 "/>
 </g>
 </svg>
Binary file test-data/analyze75_filtered2.pdf has changed
Binary file test-data/analyze_filteredoutside.RData has changed
Binary file test-data/centroids_rdata.pdf has changed
Binary file test-data/cluster_skm.RData has changed
Binary file test-data/imzml_filtered2.pdf has changed
Binary file test-data/imzml_filtered3.RData has changed
Binary file test-data/imzml_filtered3.pdf has changed
Binary file test-data/imzml_filtered4.RData has changed
Binary file test-data/imzml_filtered4.pdf has changed
Binary file test-data/imzml_filtered5.RData has changed
Binary file test-data/imzml_filtered5.pdf has changed
Binary file test-data/kmeans_analyze.pdf has changed
Binary file test-data/pca_imzml.pdf has changed
Binary file test-data/rdata_notfiltered.RData has changed
Binary file test-data/rdata_notfiltered.pdf has changed
Binary file test-data/test1.pdf has changed
Binary file test-data/test2.pdf has changed
Binary file test-data/test2.rdata has changed
Binary file test-data/test3.pdf has changed
Binary file test-data/test4.pdf has changed
Binary file test-data/test4.rdata has changed
Binary file test-data/test5.pdf has changed
Binary file test-data/test6.pdf has changed
Binary file test-data/test6.rdata has changed
Binary file test-data/test7.pdf has changed
Binary file test-data/test7.rdata has changed