comparison 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
comparison
equal deleted inserted replaced
0:e56a955cd1c0 1:98d48f081ad9
1 <tool id="cardinal_segmentations" name="MSI segmentation" version="@VERSION@.0"> 1 <tool id="cardinal_segmentations" name="MSI segmentation" version="@VERSION@.1">
2 <description>mass spectrometry imaging spatial clustering</description> 2 <description>mass spectrometry imaging spatial clustering</description>
3 <macros> 3 <macros>
4 <import>macros.xml</import> 4 <import>macros.xml</import>
5 </macros> 5 </macros>
6 <expand macro="requirements"> 6 <expand macro="requirements">
7 <requirement type="package" version="2.2.1">r-gridextra</requirement> 7 <requirement type="package" version="2.3">r-gridextra</requirement>
8 <requirement type="package" version="0.20-35">r-lattice</requirement> 8 <requirement type="package" version="0.20_35">r-lattice</requirement>
9 </expand> 9 </expand>
10 <command detect_errors="exit_code"> 10 <command detect_errors="exit_code">
11 <![CDATA[ 11 <![CDATA[
12 12
13 @INPUT_LINKING@ 13 @INPUT_LINKING@
76 set.seed($setseed) 76 set.seed($setseed)
77 77
78 #if str( $segm_cond.segmentationtool ) == 'pca': 78 #if str( $segm_cond.segmentationtool ) == 'pca':
79 print('pca') 79 print('pca')
80 ##pca 80 ##pca
81 81
82 component_vector = character() 82 component_vector = character()
83 for (numberofcomponents in 1:$segm_cond.pca_ncomp) 83 for (numberofcomponents in 1:$segm_cond.pca_ncomp)
84 {component_vector[numberofcomponents]= paste0("PC", numberofcomponents)} 84 {component_vector[numberofcomponents]= paste0("PC", numberofcomponents)}
85 pca_result = PCA(msidata, ncomp=$segm_cond.pca_ncomp, column = component_vector, superpose = FALSE, 85 pca_result = PCA(msidata, ncomp=$segm_cond.pca_ncomp, column = component_vector, superpose = FALSE,
86 method = "$segm_cond.pca_method", scale = $segm_cond.pca_scale, layout = c(ncomp, 1)) 86 method = "$segm_cond.pca_method", scale = $segm_cond.pca_scale, layout = c(ncomp, 1))
99 pcaloadings2 = cbind(matrix(unlist(strsplit(rownames(pcaloadings), " = ")), ncol=2, byrow=TRUE)[,2], pcaloadings) 99 pcaloadings2 = cbind(matrix(unlist(strsplit(rownames(pcaloadings), " = ")), ncol=2, byrow=TRUE)[,2], pcaloadings)
100 colnames(pcaloadings2) = c("mz", colnames(pcaloadings)) 100 colnames(pcaloadings2) = c("mz", colnames(pcaloadings))
101 pcascores = (pca_result@resultData\$ncomp\$scores) ### scores for each pixel 101 pcascores = (pca_result@resultData\$ncomp\$scores) ### scores for each pixel
102 102
103 ## pixel names and coordinates 103 ## pixel names and coordinates
104 pixel_names = gsub(", y = ", "_", rownames(pcascores)) 104 ## to remove potential sample names and z dimension, split at comma and take only x and y
105 pixel_names = gsub(" = ", "y_", pixel_names) 105 x_coords = unlist(lapply(strsplit(rownames(pcascores), ","), `[[`, 1))
106 x_coordinates = matrix(unlist(strsplit(pixel_names, "_")), ncol=3, byrow=TRUE)[,2] 106 y_coords = unlist(lapply(strsplit(rownames(pcascores), ","), `[[`, 2))
107 y_coordinates = matrix(unlist(strsplit(pixel_names, "_")), ncol=3, byrow=TRUE)[,3] 107 x_coordinates = gsub("x = ","",x_coords)
108 y_coordinates = gsub(" y = ","",y_coords)
109
110 pixel_names = paste0("xy_", x_coordinates, "_", y_coordinates)
108 pcascores2 = data.frame(pixel_names, x_coordinates, y_coordinates, pcascores) 111 pcascores2 = data.frame(pixel_names, x_coordinates, y_coordinates, pcascores)
109 colnames(pcascores2) = c("pixel names", "x", "y", colnames(pcascores)) 112 colnames(pcascores2) = c("pixel names", "x", "y", colnames(pcascores))
110 write.table(pcaloadings2, file="$mzfeatures", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") 113 write.table(pcaloadings2, file="$mzfeatures", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t")
111 write.table(pcascores2, file="$pixeloutput", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") 114 write.table(pcascores2, file="$pixeloutput", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t")
112 115
130 for (iteration in 1:length(skm@resultData)){ 133 for (iteration in 1:length(skm@resultData)){
131 skm_cluster = ((skm@resultData)[[iteration]]\$cluster) 134 skm_cluster = ((skm@resultData)[[iteration]]\$cluster)
132 skm_clusters = cbind(skm_clusters, skm_cluster) } 135 skm_clusters = cbind(skm_clusters, skm_cluster) }
133 136
134 ## pixel names and coordinates 137 ## pixel names and coordinates
135 pixel_names = gsub(", y = ", "_", rownames(skm_clusters)) 138 ## to remove potential sample names and z dimension, split at comma and take only x and y
136 pixel_names = gsub(" = ", "y_", pixel_names) 139 x_coords = unlist(lapply(strsplit(rownames(skm_clusters), ","), `[[`, 1))
137 x_coordinates = matrix(unlist(strsplit(pixel_names, "_")), ncol=3, byrow=TRUE)[,2] 140 y_coords = unlist(lapply(strsplit(rownames(skm_clusters), ","), `[[`, 2))
138 y_coordinates = matrix(unlist(strsplit(pixel_names, "_")), ncol=3, byrow=TRUE)[,3] 141 x_coordinates = gsub("x = ","",x_coords)
142 y_coordinates = gsub(" y = ","",y_coords)
143 pixel_names = paste0("xy_", x_coordinates, "_", y_coordinates)
139 skm_clusters2 = data.frame(pixel_names, x_coordinates, y_coordinates, skm_clusters) 144 skm_clusters2 = data.frame(pixel_names, x_coordinates, y_coordinates, skm_clusters)
140 colnames(skm_clusters2) = c("pixel names", "x", "y",names(skm@resultData)) 145 colnames(skm_clusters2) = c("pixel names", "x", "y",names(skm@resultData))
141 146
142 skm_toplabels = topLabels(skm, n=$segm_cond.kmeans_toplabels) 147 skm_toplabels = topLabels(skm, n=$segm_cond.kmeans_toplabels)
143 148
166 for (iteration in 1:length(ssc@resultData)){ 171 for (iteration in 1:length(ssc@resultData)){
167 ssc_class = ((ssc@resultData)[[iteration]]\$classes) 172 ssc_class = ((ssc@resultData)[[iteration]]\$classes)
168 ssc_classes = cbind(ssc_classes, ssc_class) } 173 ssc_classes = cbind(ssc_classes, ssc_class) }
169 174
170 ## pixel names and coordinates 175 ## pixel names and coordinates
171 pixel_names = gsub(", y = ", "_", rownames(ssc_classes)) 176 ## to remove potential sample names and z dimension, split at comma and take only x and y
172 pixel_names = gsub(" = ", "y_", pixel_names) 177 x_coords = unlist(lapply(strsplit(rownames(ssc_classes), ","), `[[`, 1))
173 x_coordinates = matrix(unlist(strsplit(pixel_names, "_")), ncol=3, byrow=TRUE)[,2] 178 y_coords = unlist(lapply(strsplit(rownames(ssc_classes), ","), `[[`, 2))
174 y_coordinates = matrix(unlist(strsplit(pixel_names, "_")), ncol=3, byrow=TRUE)[,3] 179 x_coordinates = gsub("x = ","",x_coords)
180 y_coordinates = gsub(" y = ","",y_coords)
181 pixel_names = paste0("xy_", x_coordinates, "_", y_coordinates)
175 ssc_classes2 = data.frame(pixel_names, x_coordinates, y_coordinates, ssc_classes) 182 ssc_classes2 = data.frame(pixel_names, x_coordinates, y_coordinates, ssc_classes)
176 colnames(ssc_classes2) = c("pixel names", "x", "y", names(ssc@resultData)) 183 colnames(ssc_classes2) = c("pixel names", "x", "y", names(ssc@resultData))
177 184
178 ssc_toplabels = topLabels(ssc, n=$segm_cond.centroids_toplabels) 185 ssc_toplabels = topLabels(ssc, n=$segm_cond.centroids_toplabels)
179 186