diff segmentation_tool.xml @ 2:f66c5789deac draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/msi_segmentation commit ed7d3e6f1a09c78c8f71cc1bdc1a20249767f646
author galaxyp
date Sun, 11 Mar 2018 10:39:01 -0400
parents d4158c9955ea
children 830c6df59603
line wrap: on
line diff
--- a/segmentation_tool.xml	Thu Mar 01 08:26:19 2018 -0500
+++ b/segmentation_tool.xml	Sun Mar 11 10:39:01 2018 -0400
@@ -1,4 +1,4 @@
-<tool id="mass_spectrometry_imaging_segmentations" name="MSI segmentation" version="1.7.0.1">
+<tool id="mass_spectrometry_imaging_segmentations" name="MSI segmentation" version="1.7.0.2">
     <description>tool for spatial clustering</description>
     <requirements>
         <requirement type="package" version="1.7.0">bioconductor-cardinal</requirement>
@@ -180,7 +180,7 @@
             pca = PCA(msidata, ncomp=$segm_cond.pca_ncomp, column = component_vector, superpose = FALSE, 
             method = "$segm_cond.pca_method", scale = $segm_cond.pca_scale, layout = c(ncomp, 1))
 
-            print(image(pca, main="PCA image", lattice=TRUE, strip = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9)), contrast.enhance = "$segm_cond.pca_imagecontrast", smooth.image = "$segm_cond.pca_imagesmoothing", col=colourvector, ylim=c(maximumy+2, 0)))
+            print(image(pca, main="PCA image", lattice=TRUE, strip = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9)), col=colourvector, ylim=c(maximumy+2, 0)))
             print(plot(pca, main="PCA plot", lattice=TRUE, col= colourvector, strip = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9))))
 
 
@@ -194,13 +194,19 @@
             print('kmeans')
             ##k-means
 
-            skm = spatialKMeans(msidata, r=$segm_cond.kmeans_r, k=$segm_cond.kmeans_k, method="$segm_cond.kmeans_method")
-            print(image(skm, key=TRUE, main="K-means clustering", lattice=TRUE, strip = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9)), contrast.enhance = "$segm_cond.kmeans_imagecontrast", col= colourvector, smooth.image = "$segm_cond.kmeans_imagesmoothing", ylim=c(maximumy+2, 0)))
-            print(plot(skm, main="K-means plot", lattice=TRUE, col= colourvector, strip = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9))))
+            skm = spatialKMeans(msidata, r=c($segm_cond.kmeans_r), k=c($segm_cond.kmeans_k), method="$segm_cond.kmeans_method")
+            print(image(skm, key=TRUE, main="K-means clustering", lattice=TRUE, strip = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9)), col= colourvector, ylim=c(maximumy+2, 0), layout=c(1,1)))
+
+            print(plot(skm, main="K-means plot", lattice=TRUE, col= colourvector, strip = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9)), layout=c($segm_cond.kmeans_layout)))
 
 
-            skm_clusters = (skm@resultData\$r\$cluster)
-            skm_toplabels = topLabels(skm, n=500)
+            skm_clusters = data.frame(matrix(NA, nrow = pixelcount, ncol = 0))
+            for (iteration in 1:length(skm@resultData)){
+                        skm_cluster = ((skm@resultData)[[iteration]]\$cluster)
+            skm_clusters = cbind(skm_clusters, skm_cluster) }
+            colnames(skm_clusters) = names((skm@resultData)) 
+
+            skm_toplabels = topLabels(skm, n=$segm_cond.kmeans_toplabels)
     
             write.table(skm_toplabels, file="$mzfeatures", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t")
             write.table(skm_clusters, file="$pixeloutput", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t")
@@ -210,12 +216,17 @@
             print('centroids')
             ##centroids
 
-            ssc = spatialShrunkenCentroids(msidata, r=$segm_cond.centroids_r, k=$segm_cond.centroids_k, s=$segm_cond.centroids_s, method="$segm_cond.centroids_method")
-            print(image(ssc, key=TRUE, main="Spatial shrunken centroids", lattice=TRUE, strip = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9)), contrast.enhance = "$segm_cond.centroids_imagecontrast", col= colourvector, smooth.image = "$segm_cond.centroids_imagesmoothing", ylim=c(maximumy+2, 0)))
-            print(plot(ssc, main="Spatial shrunken centroids plot", lattice=TRUE, col= colourvector, strip = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9))))
+            ssc = spatialShrunkenCentroids(msidata, r=c($segm_cond.centroids_r), k=c($segm_cond.centroids_k), s=c($segm_cond.centroids_s), method="$segm_cond.centroids_method")
+            print(image(ssc, key=TRUE, main="Spatial shrunken centroids", lattice=TRUE, strip = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9)), col= colourvector,  ylim=c(maximumy+2, 0),layout=c(1,1)))
+            print(plot(ssc, main="Spatial shrunken centroids plot", lattice=TRUE, col= colourvector, strip = strip.custom(bg="lightgrey", par.strip.text=list(col="black", cex=.9)),layout=c($segm_cond.centroids_layout)))
 
-            ssc_classes = (ssc@resultData\$r\$classes)
-            ssc_toplabels =  topLabels(ssc, n=500)
+            ssc_classes = data.frame(matrix(NA, nrow = pixelcount, ncol = 0))
+            for (iteration in 1:length(ssc@resultData)){
+            ssc_class = ((ssc@resultData)[[iteration]]\$classes)
+            ssc_classes = cbind(ssc_classes, ssc_class) }
+            colnames(ssc_classes) = names((ssc@resultData)) 
+
+            ssc_toplabels =  topLabels(ssc, n=$segm_cond.centroids_toplabels)
 
             write.table(ssc_toplabels, file="$mzfeatures", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t")
             write.table(ssc_classes, file="$pixeloutput", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t")
@@ -255,62 +266,40 @@
                         <option value="TRUE">yes</option>
                         <option value="FALSE" selected="True">no</option>
                 </param>
-                <param name="pca_imagecontrast" type="select" label="Select a contrast enhancement function." help="The 'histogram' equalization method flatterns the distribution of intensities. The hotspot 'suppression' method uses thresholding to reduce the intensities of hotspots">
-                    <option value="none" selected="True">none</option>
-                    <option value="suppression">suppression</option>
-                    <option value="histogram">histogram</option>
-                </param>
-                <param name="pca_imagesmoothing" type="select" label="Select an image smoothing function." help="The 'gaussian' smoothing method smooths images with a simple gaussian kernel. The 'adaptive' method uses bilateral filtering to preserve edges.">
-                    <option value="none" selected="True">none</option>
-                    <option value="gaussian">gaussian</option>
-                    <option value="adaptive">adaptive</option>
-                </param>
                 </when> 
 
                 <when value="kmeans">
                     <param name="kmeans_r" type="text" value="2"
-                           label="The spatial neighborhood radius of nearby pixels to consider (r)."/>
+                           label="The spatial neighborhood radius of nearby pixels to consider (r)." help="Multiple values are allowed (e.g. 1,2,3 or 2:5)"/>
                     <param name="kmeans_k" type="text" value="3"
-                           label="The number of clusters (k)."/>
+                           label="The number of clusters (k)." help="Multiple values are allowed (e.g. 1,2,3 or 2:5)"/>
                     <param name="kmeans_method" type="select" display="radio"
                            label="The method to use to calculate the spatial smoothing kernels for the embedding. The 'gaussian' method refers to spatially-aware (SA) clustering, and 'adaptive' refers to spatially-aware structurally-adaptive (SASA) clustering.">
                         <option value="gaussian">gaussian</option>
                         <option value="adaptive" selected="True">adaptive</option>
                 </param>
-                <param name="kmeans_imagecontrast" type="select" label="Select a contrast enhancement function." help="The 'histogram' equalization method flatterns the distribution of intensities. The hotspot 'suppression' method uses thresholding to reduce the intensities of hotspots">
-                    <option value="none" selected="True">none</option>
-                    <option value="suppression">suppression</option>
-                    <option value="histogram">histogram</option>
-                </param>
-                <param name="kmeans_imagesmoothing" type="select" label="Select an image smoothing function." help="The 'gaussian' smoothing method smooths images with a simple gaussian kernel. The 'adaptive' method uses bilateral filtering to preserve edges.">
-                    <option value="none" selected="True">none</option>
-                    <option value="gaussian">gaussian</option>
-                    <option value="adaptive">adaptive</option>
-                </param>
-                </when>
+                <param name="kmeans_toplabels" type="integer" value="500"
+                       label="Number of toplabels (masses) which should be written in tabular output"/>
+                <param name="kmeans_layout" type="text" value="1,1"
+                       label="Number of rows and columns to plot pictures in pdf output" help="e.g. 1,1 means 1 plot per page; 2,3 means 2 rows with 3 plots each = 6 plots per page"/>
+                 </when>
 
                 <when value="centroids">
                     <param name="centroids_r" type="text" value="2"
-                           label="The spatial neighborhood radius of nearby pixels to consider (r)."/>
+                           label="The spatial neighborhood radius of nearby pixels to consider (r)." help="Multiple values are allowed (e.g. 1,2,3 or 2:5)"/>
                     <param name="centroids_k" type="text" value="5"
-                           label="The initial number of clusters (k)."/>
-                    <param name="centroids_s" type="integer" value="2"
+                           label="The initial number of clusters (k)." help="Multiple values are allowed (e.g. 1,2,3 or 2:5)"/>
+                    <param name="centroids_s" type="text" value="2"
                            label="The sparsity thresholding parameter by which to shrink the t-statistics (s)."
-                           help="As s increases, fewer mass features (m/z values) will be used in the spatial segmentation, and only the informative mass features will be retained."/>
+                           help="As s increases, fewer mass features (m/z values) will be used in the spatial segmentation, and only the informative mass features will be retained. Multiple values are allowed (e.g. 1,2,3 or 2:5)."/>
                     <param name="centroids_method" type="select" display="radio" label = "The method to use to calculate the spatial smoothing kernels for the embedding. The 'gaussian' method refers to spatially-aware (SA) weights, and 'adaptive' refers to spatially-aware structurally-adaptive (SASA) weights.">
                         <option value="gaussian" selected="True">gaussian</option>
                         <option value="adaptive">adaptive</option>
                 </param>
-                <param name="centroids_imagecontrast" type="select" label="Select a contrast enhancement function." help="The 'histogram' equalization method flatterns the distribution of intensities. The hotspot 'suppression' method uses thresholding to reduce the intensities of hotspots">
-                    <option value="none" selected="True">none</option>
-                    <option value="suppression">suppression</option>
-                    <option value="histogram">histogram</option>
-                </param>
-                <param name="centroids_imagesmoothing" type="select" label="Select an image smoothing function." help="The 'gaussian' smoothing method smooths images with a simple gaussian kernel. The 'adaptive' method uses bilateral filtering to preserve edges.">
-                    <option value="none" selected="True">none</option>
-                    <option value="gaussian">gaussian</option>
-                    <option value="adaptive">adaptive</option>
-                </param>
+                <param name="centroids_toplabels" type="integer" value="500"
+                       label="Number of toplabels (masses) which should be written in tabular output"/>
+                <param name="centroids_layout" type="text" value="1,1"
+                       label="Number of rows and columns to plot pictures in pdf output" help="e.g. 1,1 means 1 plot per page; 2,3 means 2 rows with 3 plots each = 6 plots per page"/>
                 </when>
             </conditional>
             <repeat name="colours" title="Colours for the plots" min="1" max="50">
@@ -352,6 +341,8 @@
                 <composite_data value="Analyze75.t2m" />
             </param>
             <param name="segmentationtool" value="kmeans"/>
+            <param name="kmeans_r" value="1:3"/>
+            <param name="kmeans_k" value="2,3"/>
             <repeat name="colours">
                 <param name="feature_color" value="#ff00ff"/>
             </repeat>
@@ -368,6 +359,9 @@
         <test>
             <param name="infile" value="preprocessing_results1.RData" ftype="rdata"/>
             <param name="segmentationtool" value="centroids"/>
+            <param name="centroids_r" ftype="text" value="1,2"/>
+            <param name="centroids_k" ftype="text" value="5"/>
+            <param name="centroids_toplabels" ftype="integer" value="100"/>
             <repeat name="colours">
                 <param name="feature_color" value="#0000FF"/>
             </repeat>