Mercurial > repos > galaxyp > mass_spectrometry_imaging_segmentations
comparison segmentation_tool.xml @ 6:80b6b96a175c draft
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msi_segmentation commit 37da74ed68228b16efbdbde776e7c38cc06eb5d5
author | galaxyp |
---|---|
date | Tue, 19 Jun 2018 18:08:36 -0400 |
parents | cee9cf693709 |
children | adfef12c7e31 |
comparison
equal
deleted
inserted
replaced
5:cee9cf693709 | 6:80b6b96a175c |
---|---|
1 <tool id="mass_spectrometry_imaging_segmentations" name="MSI segmentation" version="1.10.0.1"> | 1 <tool id="mass_spectrometry_imaging_segmentations" name="MSI segmentation" version="1.10.0.2"> |
2 <description>mass spectrometry imaging spatial clustering</description> | 2 <description>mass spectrometry imaging spatial clustering</description> |
3 <requirements> | 3 <requirements> |
4 <requirement type="package" version="1.10.0">bioconductor-cardinal</requirement> | 4 <requirement type="package" version="1.10.0">bioconductor-cardinal</requirement> |
5 <requirement type="package" version="2.2.1">r-gridextra</requirement> | 5 <requirement type="package" version="2.2.1">r-gridextra</requirement> |
6 <requirement type="package" version="0.20-35">r-lattice</requirement> | 6 <requirement type="package" version="0.20-35">r-lattice</requirement> |
35 library(lattice) | 35 library(lattice) |
36 | 36 |
37 ## Read MALDI Imaging dataset | 37 ## Read MALDI Imaging dataset |
38 | 38 |
39 #if $infile.ext == 'imzml' | 39 #if $infile.ext == 'imzml' |
40 msidata = readImzML('infile') | 40 msidata <- readImzML('infile', mass.accuracy=$accuracy, units.accuracy = "$units") |
41 #elif $infile.ext == 'analyze75' | 41 #elif $infile.ext == 'analyze75' |
42 msidata = readAnalyze('infile') | 42 msidata = readAnalyze('infile') |
43 #else | 43 #else |
44 load('infile.RData') | 44 load('infile.RData') |
45 #end if | 45 #end if |
46 | 46 |
47 ## create full matrix to make processed imzML files compatible with segmentation | |
48 iData(msidata) <- iData(msidata)[] | |
47 ###################################### file properties in numbers ############## | 49 ###################################### file properties in numbers ############## |
48 | 50 |
49 ## Number of features (m/z) | 51 ## Number of features (m/z) |
50 maxfeatures = length(features(msidata)) | 52 maxfeatures = length(features(msidata)) |
51 ## Range m/z | 53 ## Range m/z |
103 } else { | 105 } else { |
104 peakpickinginfo=processinginfo@peakPicking | 106 peakpickinginfo=processinginfo@peakPicking |
105 } | 107 } |
106 | 108 |
107 properties = c("Number of m/z features", | 109 properties = c("Number of m/z features", |
108 "Range of m/z values [Da]", | 110 "Range of m/z values", |
109 "Number of pixels", | 111 "Number of pixels", |
110 "Range of x coordinates", | 112 "Range of x coordinates", |
111 "Range of y coordinates", | 113 "Range of y coordinates", |
112 "Range of intensities", | 114 "Range of intensities", |
113 "Median of intensities", | 115 "Median of intensities", |
155 grid.table(property_df, rows= NULL) | 157 grid.table(property_df, rows= NULL) |
156 | 158 |
157 if (npeaks > 0) | 159 if (npeaks > 0) |
158 { | 160 { |
159 | 161 |
160 | |
161 ######################## II) segmentation tools ############################# | 162 ######################## II) segmentation tools ############################# |
162 ############################################################################# | 163 ############################################################################# |
163 #set $color_string = ','.join(['"%s"' % $color.feature_color for $color in $colours]) | 164 #set $color_string = ','.join(['"%s"' % $color.feature_color for $color in $colours]) |
164 colourvector = c($color_string) | 165 colourvector = c($color_string) |
165 | 166 |
184 ##pca | 185 ##pca |
185 | 186 |
186 component_vector = character() | 187 component_vector = character() |
187 for (numberofcomponents in 1:$segm_cond.pca_ncomp) | 188 for (numberofcomponents in 1:$segm_cond.pca_ncomp) |
188 {component_vector[numberofcomponents]= paste0("PC", numberofcomponents)} | 189 {component_vector[numberofcomponents]= paste0("PC", numberofcomponents)} |
189 pca = PCA(msidata, ncomp=$segm_cond.pca_ncomp, column = component_vector, superpose = FALSE, | 190 pca_result = PCA(msidata, ncomp=$segm_cond.pca_ncomp, column = component_vector, superpose = FALSE, |
190 method = "$segm_cond.pca_method", scale = $segm_cond.pca_scale, layout = c(ncomp, 1)) | 191 method = "$segm_cond.pca_method", scale = $segm_cond.pca_scale, layout = c(ncomp, 1)) |
191 | 192 |
192 print(image(pca, main="PCA image", lattice=lattice_input, strip = strip_input, col=colourvector)) | 193 ### images in pdf file |
193 print(plot(pca, main="PCA plot", lattice=lattice_input, col= colourvector, strip = strip_input)) | 194 print(image(pca_result, main="PCA image", lattice=lattice_input, strip = strip_input, col=colourvector)) |
194 | 195 for (PCs in 1:$segm_cond.pca_ncomp){ |
195 pcaloadings = (pca@resultData\$ncomp\$loadings) ### loading for each m/z value | 196 print(image(pca_result, column = c(paste0("PC",PCs)), superpose = FALSE, col.regions = risk.colors(100)))} |
196 pcascores = (pca@resultData\$ncomp\$scores) ### scores for each pixel | 197 ### plots in pdf file |
198 print(plot(pca_result, main="PCA plot", lattice=lattice_input, col= colourvector, strip = strip_input)) | |
199 for (PCs in 1:$segm_cond.pca_ncomp){ | |
200 print(plot(pca_result, column = c(paste0("PC",PCs)), superpose = FALSE))} | |
201 | |
202 | |
203 ### values in tabular files | |
204 pcaloadings = (pca_result@resultData\$ncomp\$loadings) ### loading for each m/z value | |
205 pcascores = (pca_result@resultData\$ncomp\$scores) ### scores for each pixel | |
197 | 206 |
198 write.table(pcaloadings, file="$mzfeatures", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t") | 207 write.table(pcaloadings, file="$mzfeatures", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t") |
199 write.table(pcascores, file="$pixeloutput", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t") | 208 write.table(pcascores, file="$pixeloutput", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t") |
200 | 209 |
201 ## optional output as .RData | 210 ## optional output as .RData |
202 #if $output_rdata: | 211 #if $output_rdata: |
203 | |
204 ## save as (.RData) | 212 ## save as (.RData) |
205 save(pca, file="$segmentation_rdata") | 213 save(pca, file="$segmentation_rdata") |
206 | 214 |
207 #end if | 215 #end if |
208 | 216 |
239 ##centroids | 247 ##centroids |
240 | 248 |
241 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") | 249 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") |
242 print(image(ssc, key=TRUE, main="Spatial shrunken centroids", lattice=lattice_input, strip = strip_input, col= colourvector,layout=c(1,1))) | 250 print(image(ssc, key=TRUE, main="Spatial shrunken centroids", lattice=lattice_input, strip = strip_input, col= colourvector,layout=c(1,1))) |
243 print(plot(ssc, main="Spatial shrunken centroids plot", lattice=lattice_input, col= colourvector, strip = strip_input,layout=c($segm_cond.centroids_layout))) | 251 print(plot(ssc, main="Spatial shrunken centroids plot", lattice=lattice_input, col= colourvector, strip = strip_input,layout=c($segm_cond.centroids_layout))) |
252 print(plot(ssc, mode = "tstatistics",key = TRUE, lattice=lattice_input, layout = c($segm_cond.centroids_layout), main="t-statistics", col=colourvector)) | |
253 print(plot(summary(ssc), main = "Number of segments",lattice=lattice_input)) | |
244 | 254 |
245 ssc_classes = data.frame(matrix(NA, nrow = pixelcount, ncol = 0)) | 255 ssc_classes = data.frame(matrix(NA, nrow = pixelcount, ncol = 0)) |
246 for (iteration in 1:length(ssc@resultData)){ | 256 for (iteration in 1:length(ssc@resultData)){ |
247 ssc_class = ((ssc@resultData)[[iteration]]\$classes) | 257 ssc_class = ((ssc@resultData)[[iteration]]\$classes) |
248 ssc_classes = cbind(ssc_classes, ssc_class) } | 258 ssc_classes = cbind(ssc_classes, ssc_class) } |
249 colnames(ssc_classes) = names((ssc@resultData)) | 259 colnames(ssc_classes) = names((ssc@resultData)) |
250 | 260 |
251 ssc_toplabels = topLabels(ssc, n=$segm_cond.centroids_toplabels) | 261 ssc_toplabels = topLabels(ssc, n=$segm_cond.centroids_toplabels) |
252 | 262 |
253 write.table(ssc_toplabels, file="$mzfeatures", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t") | 263 write.table(ssc_toplabels, file="$mzfeatures", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t") |
254 write.table(ssc_classes, file="$pixeloutput", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t") | 264 write.table(ssc_classes, file="$pixeloutput", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t") |
271 } | 281 } |
272 | 282 |
273 ]]></configfile> | 283 ]]></configfile> |
274 </configfiles> | 284 </configfiles> |
275 <inputs> | 285 <inputs> |
276 <param name="infile" type="data" format="imzml, rdata, analyze75" | 286 <param name="infile" type="data" format="imzml,rdata,analyze75" |
277 label="Inputfile as imzML, Analyze7.5 or Cardinal MSImageSet saved as RData" | 287 label="Inputfile as imzML, Analyze7.5 or Cardinal MSImageSet saved as RData" |
278 help="Upload composite datatype imzml (ibd+imzML) or analyze75 (hdr+img+t2m) or regular upload .RData (Cardinal MSImageSet)"/> | 288 help="Upload composite datatype imzml (ibd+imzML) or analyze75 (hdr+img+t2m) or regular upload .RData (Cardinal MSImageSet)"/> |
289 <param name="accuracy" type="float" value="50" label="Only for processed imzML files: enter mass accuracy to which the m/z values will be binned" help="This should be set to the native accuracy of the mass spectrometer, if known"/> | |
290 <param name="units" display="radio" type="select" label="Only for processed imzML files: unit of the mass accuracy" help="either m/z or ppm"> | |
291 <option value="mz" >mz</option> | |
292 <option value="ppm" selected="True" >ppm</option> | |
293 </param> | |
279 <conditional name="segm_cond"> | 294 <conditional name="segm_cond"> |
280 <param name="segmentationtool" type="select" label="Select the tool for spatial clustering"> | 295 <param name="segmentationtool" type="select" label="Select the tool for spatial clustering"> |
281 <option value="pca" selected="True">pca</option> | 296 <option value="pca" selected="True">pca</option> |
282 <option value="kmeans">k-means</option> | 297 <option value="kmeans">k-means</option> |
283 <option value="centroids">spatial shrunken centroids</option> | 298 <option value="centroids">spatial shrunken centroids</option> |
320 label="The initial number of clusters (k)" help="Multiple values are allowed (e.g. 1,2,3 or 2:5)"/> | 335 label="The initial number of clusters (k)" help="Multiple values are allowed (e.g. 1,2,3 or 2:5)"/> |
321 <param name="centroids_s" type="text" value="2" | 336 <param name="centroids_s" type="text" value="2" |
322 label="The sparsity thresholding parameter by which to shrink the t-statistics (s)" | 337 label="The sparsity thresholding parameter by which to shrink the t-statistics (s)" |
323 help="As s increases, fewer m/z features (m/z values) will be used in the spatial segmentation, and only the informative m/z features will be retained. Multiple values are allowed (e.g. 1,2,3 or 2:5)"/> | 338 help="As s increases, fewer m/z features (m/z values) will be used in the spatial segmentation, and only the informative m/z features will be retained. Multiple values are allowed (e.g. 1,2,3 or 2:5)"/> |
324 <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"> | 339 <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"> |
325 <option value="gaussian" selected="True">gaussian</option> | 340 <option value="gaussian">gaussian</option> |
326 <option value="adaptive">adaptive</option> | 341 <option value="adaptive" selected="True">adaptive</option> |
327 </param> | 342 </param> |
328 <param name="centroids_toplabels" type="integer" value="500" | 343 <param name="centroids_toplabels" type="integer" value="500" |
329 label="Number of toplabels (m/z) which should be written in tabular output"/> | 344 label="Number of toplabels (m/z) which should be written in tabular output"/> |
330 <param name="centroids_layout" type="text" value="1,1" | 345 <param name="centroids_layout" type="text" value="1,1" |
331 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"/> | 346 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"/> |
404 </test> | 419 </test> |
405 <test> | 420 <test> |
406 <param name="infile" value="preprocessed.RData" ftype="rdata"/> | 421 <param name="infile" value="preprocessed.RData" ftype="rdata"/> |
407 <param name="segmentationtool" value="centroids"/> | 422 <param name="segmentationtool" value="centroids"/> |
408 <param name="centroids_r" value="1,2"/> | 423 <param name="centroids_r" value="1,2"/> |
409 <param name="centroids_k" value="5"/> | 424 <param name="centroids_k" value="3"/> |
410 <param name="centroids_toplabels" value="50"/> | 425 <param name="centroids_toplabels" value="50"/> |
411 <repeat name="colours"> | 426 <repeat name="colours"> |
412 <param name="feature_color" value="#0000FF"/> | 427 <param name="feature_color" value="#0000FF"/> |
413 </repeat> | 428 </repeat> |
414 <repeat name="colours"> | 429 <repeat name="colours"> |
442 - Cardinal "MSImageSet" data (with variable name "msidata", saved as .RData) | 457 - Cardinal "MSImageSet" data (with variable name "msidata", saved as .RData) |
443 | 458 |
444 Options: | 459 Options: |
445 | 460 |
446 - PCA: principal component analysis | 461 - PCA: principal component analysis |
447 - k-means: patially-aware k-means clustering | 462 - k-means: spatially-aware k-means clustering |
448 - spatial shrunken centroids: Allows the number of segments to decrease according to the data. This allows automatic selection of the number of clusters | 463 - spatial shrunken centroids: Allows the number of segments to decrease according to the data. This allows automatic selection of the number of clusters |
449 | 464 |
450 Output: | 465 Output: |
451 | 466 |
452 - Pdf with the heatmaps and plots for the segmentation | 467 - Pdf with the heatmaps and plots for the segmentation |