diff segmentation.xml @ 1:98d48f081ad9 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:25:52 -0400
parents e56a955cd1c0
children 034885df9b09
line wrap: on
line diff
--- a/segmentation.xml	Mon Oct 01 01:05:00 2018 -0400
+++ b/segmentation.xml	Thu Oct 25 07:25:52 2018 -0400
@@ -1,11 +1,11 @@
-<tool id="cardinal_segmentations" name="MSI segmentation" version="@VERSION@.0">
+<tool id="cardinal_segmentations" name="MSI segmentation" version="@VERSION@.1">
     <description>mass spectrometry imaging spatial clustering</description>
     <macros>
         <import>macros.xml</import>
     </macros>
     <expand macro="requirements">
-        <requirement type="package" version="2.2.1">r-gridextra</requirement>
-        <requirement type="package" version="0.20-35">r-lattice</requirement>
+        <requirement type="package" version="2.3">r-gridextra</requirement>
+        <requirement type="package" version="0.20_35">r-lattice</requirement>
     </expand>
     <command detect_errors="exit_code">
     <![CDATA[
@@ -78,7 +78,7 @@
         #if str( $segm_cond.segmentationtool ) == 'pca':
             print('pca')
             ##pca
-            
+
             component_vector = character()
             for (numberofcomponents in 1:$segm_cond.pca_ncomp)
             {component_vector[numberofcomponents]= paste0("PC", numberofcomponents)}
@@ -101,10 +101,13 @@
             pcascores = (pca_result@resultData\$ncomp\$scores) ### scores for each pixel
 
             ## pixel names and coordinates
-            pixel_names = gsub(", y = ", "_", rownames(pcascores))
-            pixel_names = gsub(" = ", "y_", pixel_names)
-            x_coordinates = matrix(unlist(strsplit(pixel_names, "_")), ncol=3, byrow=TRUE)[,2]
-            y_coordinates = matrix(unlist(strsplit(pixel_names, "_")), ncol=3, byrow=TRUE)[,3]
+            ## to remove potential sample names and z dimension, split at comma and take only x and y 
+            x_coords = unlist(lapply(strsplit(rownames(pcascores), ","), `[[`, 1))
+            y_coords = unlist(lapply(strsplit(rownames(pcascores), ","), `[[`, 2))
+            x_coordinates = gsub("x = ","",x_coords)
+            y_coordinates = gsub(" y = ","",y_coords)
+
+            pixel_names = paste0("xy_", x_coordinates, "_", y_coordinates)
             pcascores2 = data.frame(pixel_names, x_coordinates, y_coordinates, pcascores)
             colnames(pcascores2) = c("pixel names", "x", "y", colnames(pcascores))
             write.table(pcaloadings2, file="$mzfeatures", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t")
@@ -132,10 +135,12 @@
             skm_clusters = cbind(skm_clusters, skm_cluster) }
 
             ## pixel names and coordinates
-            pixel_names = gsub(", y = ", "_", rownames(skm_clusters))
-            pixel_names = gsub(" = ", "y_", pixel_names)
-            x_coordinates = matrix(unlist(strsplit(pixel_names, "_")), ncol=3, byrow=TRUE)[,2]
-            y_coordinates = matrix(unlist(strsplit(pixel_names, "_")), ncol=3, byrow=TRUE)[,3]
+            ## to remove potential sample names and z dimension, split at comma and take only x and y 
+            x_coords = unlist(lapply(strsplit(rownames(skm_clusters), ","), `[[`, 1))
+            y_coords = unlist(lapply(strsplit(rownames(skm_clusters), ","), `[[`, 2))
+            x_coordinates = gsub("x = ","",x_coords)
+            y_coordinates = gsub(" y = ","",y_coords)
+            pixel_names = paste0("xy_", x_coordinates, "_", y_coordinates)
             skm_clusters2 = data.frame(pixel_names, x_coordinates, y_coordinates, skm_clusters)
             colnames(skm_clusters2) = c("pixel names", "x", "y",names(skm@resultData))
 
@@ -168,10 +173,12 @@
             ssc_classes = cbind(ssc_classes, ssc_class) }
 
             ## pixel names and coordinates
-            pixel_names = gsub(", y = ", "_", rownames(ssc_classes))
-            pixel_names = gsub(" = ", "y_", pixel_names)
-            x_coordinates = matrix(unlist(strsplit(pixel_names, "_")), ncol=3, byrow=TRUE)[,2]
-            y_coordinates = matrix(unlist(strsplit(pixel_names, "_")), ncol=3, byrow=TRUE)[,3]
+            ## to remove potential sample names and z dimension, split at comma and take only x and y 
+            x_coords = unlist(lapply(strsplit(rownames(ssc_classes), ","), `[[`, 1))
+            y_coords = unlist(lapply(strsplit(rownames(ssc_classes), ","), `[[`, 2))
+            x_coordinates = gsub("x = ","",x_coords)
+            y_coordinates = gsub(" y = ","",y_coords)
+            pixel_names = paste0("xy_", x_coordinates, "_", y_coordinates)
             ssc_classes2 = data.frame(pixel_names, x_coordinates, y_coordinates, ssc_classes)
             colnames(ssc_classes2) = c("pixel names", "x", "y", names(ssc@resultData))