diff classification.xml @ 3:60cf221846e5 draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit 2c4a1a862900b4efbc30824cbcb798f835b168b2
author galaxyp
date Thu, 28 Feb 2019 09:16:39 -0500
parents bf0eb536e4e5
children a7204db5e3a4
line wrap: on
line diff
--- a/classification.xml	Fri Feb 15 10:07:59 2019 -0500
+++ b/classification.xml	Thu Feb 28 09:16:39 2019 -0500
@@ -33,6 +33,10 @@
 ## to make sure that processed files work as well: 
 iData(msidata) = iData(msidata)[]
 
+## remove duplicated coordinates
+print(paste0(sum(duplicated(coord(msidata))), " duplicated coordinates were removed"))
+msidata <- msidata[,!duplicated(coord(msidata))]
+
 @DATA_PROPERTIES_INRAM@
 
 
@@ -231,10 +235,13 @@
 
                 ### m/z and pixel information output
                 pls_classes = data.frame(msidata.pls\$classes[[1]])
-                pixel_names = gsub(", y = ", "_", names(pixels(msidata)))
-                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]
+                ## pixel names and coordinates
+                ## to remove potential sample names and z dimension, split at comma and take only x and y 
+                x_coords = unlist(lapply(strsplit(names(pixels(msidata)), ","), `[[`, 1))
+                y_coords = unlist(lapply(strsplit(names(pixels(msidata)), ","), `[[`, 2))
+                x_coordinates = gsub("x = ","",x_coords)
+                y_coordinates = gsub(" y = ","",y_coords)
+                pixel_names = paste0("xy_", x_coordinates, "_", y_coordinates)
 
                 ## remove msidata to clean up RAM space
                 rm(msidata)
@@ -373,12 +380,15 @@
                 maximumy = max(coord(msidata)[,2])
                 print(image(msidata, mz = topLabels(msidata.opls)[1,1], normalize.image = "linear", contrast.enhance = "histogram",smooth.image="gaussian", ylim= c(maximumy+0.2*maximumy,minimumy-0.2*minimumy), main="best m/z heatmap"))
 
-                ## m/z and pixel information output
                 opls_classes = data.frame(msidata.opls\$classes[[1]])
-                pixel_names = gsub(", y = ", "_", names(pixels(msidata)))
-                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]
+                ## pixel names and coordinates
+                ## to remove potential sample names and z dimension, split at comma and take only x and y
+                x_coords = unlist(lapply(strsplit(names(pixels(msidata)), ","), `[[`, 1))
+                y_coords = unlist(lapply(strsplit(names(pixels(msidata)), ","), `[[`, 2))
+                x_coordinates = gsub("x = ","",x_coords)
+                y_coordinates = gsub(" y = ","",y_coords)
+                pixel_names = paste0("xy_", x_coordinates, "_", y_coordinates)
+
                 opls_classes2 = data.frame(pixel_names, x_coordinates, y_coordinates, opls_classes)
                 colnames(opls_classes2) = c("pixel names", "x", "y","predicted condition")
 
@@ -520,10 +530,15 @@
 
                 ## m/z and pixel information output
                 ssc_classes = data.frame(msidata.ssc\$classes[[1]])
-                pixel_names = gsub(", y = ", "_", names(pixels(msidata)))
-                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]
+
+                ## pixel names and coordinates
+                ## to remove potential sample names and z dimension, split at comma and take only x and y 
+                x_coords = unlist(lapply(strsplit(names(pixels(msidata)), ","), `[[`, 1))
+                y_coords = unlist(lapply(strsplit(names(pixels(msidata)), ","), `[[`, 2))
+                x_coordinates = gsub("x = ","",x_coords)
+                y_coordinates = gsub(" y = ","",y_coords)
+                pixel_names = paste0("xy_", x_coordinates, "_", y_coordinates)
+
 
                 ## remove msidata to clean up RAM space
                 rm(msidata)