Mercurial > repos > galaxyp > mass_spectrometry_imaging_segmentations
comparison segmentation_tool.xml @ 7:adfef12c7e31 draft
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msi_segmentation commit 8087490eb4dcaf4ead0f03eae4126780d21e5503
author | galaxyp |
---|---|
date | Fri, 06 Jul 2018 14:14:27 -0400 |
parents | 80b6b96a175c |
children | 4a62874c21a3 |
comparison
equal
deleted
inserted
replaced
6:80b6b96a175c | 7:adfef12c7e31 |
---|---|
1 <tool id="mass_spectrometry_imaging_segmentations" name="MSI segmentation" version="1.10.0.2"> | 1 <tool id="mass_spectrometry_imaging_segmentations" name="MSI segmentation" version="1.10.0.3"> |
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', mass.accuracy=$accuracy, units.accuracy = "$units") | 40 #if str($processed_cond.processed_file) == "processed": |
41 msidata <- readImzML('infile', mass.accuracy=$processed_cond.accuracy, units.accuracy = "$processed_cond.units") | |
42 #else | |
43 msidata <- readImzML('infile') | |
44 #end if | |
41 #elif $infile.ext == 'analyze75' | 45 #elif $infile.ext == 'analyze75' |
42 msidata = readAnalyze('infile') | 46 msidata = readAnalyze('infile') |
43 #else | 47 #else |
44 load('infile.RData') | 48 load('infile.RData') |
45 #end if | 49 #end if |
50 | |
46 | 51 |
47 ## create full matrix to make processed imzML files compatible with segmentation | 52 ## create full matrix to make processed imzML files compatible with segmentation |
48 iData(msidata) <- iData(msidata)[] | 53 iData(msidata) <- iData(msidata)[] |
49 ###################################### file properties in numbers ############## | 54 ###################################### file properties in numbers ############## |
50 | 55 |
60 maximumx = max(coord(msidata)[,1]) | 65 maximumx = max(coord(msidata)[,1]) |
61 ## Range y coordinates | 66 ## Range y coordinates |
62 minimumy = min(coord(msidata)[,2]) | 67 minimumy = min(coord(msidata)[,2]) |
63 maximumy = max(coord(msidata)[,2]) | 68 maximumy = max(coord(msidata)[,2]) |
64 ## Range of intensities | 69 ## Range of intensities |
65 minint = round(min(spectra(msidata)[]), digits=2) | 70 minint = round(min(spectra(msidata)[],na.rm=TRUE), digits=2) |
66 maxint = round(max(spectra(msidata)[]), digits=2) | 71 maxint = round(max(spectra(msidata)[],na.rm=TRUE), digits=2) |
67 medint = round(median(spectra(msidata)[]), digits=2) | 72 medint = round(median(spectra(msidata)[]), digits=2) |
68 ## Number of intensities > 0 | 73 ## Number of intensities > 0 |
69 npeaks= sum(spectra(msidata)[]>0) | 74 npeaks= sum(spectra(msidata)[]>0, na.rm=TRUE) |
70 ## Spectra multiplied with m/z (potential number of peaks) | 75 ## Spectra multiplied with m/z (potential number of peaks) |
71 numpeaks = ncol(spectra(msidata)[])*nrow(spectra(msidata)[]) | 76 numpeaks = ncol(spectra(msidata)[])*nrow(spectra(msidata)[]) |
72 ## Percentage of intensities > 0 | 77 ## Percentage of intensities > 0 |
73 percpeaks = round(npeaks/numpeaks*100, digits=2) | 78 percpeaks = round(npeaks/numpeaks*100, digits=2) |
74 ## Number of empty TICs | 79 ## Number of empty TICs |
75 TICs = colSums(spectra(msidata)[]) | 80 TICs = colSums(spectra(msidata)[], na.rm=TRUE) |
76 NumemptyTIC = sum(TICs == 0) | 81 NumemptyTIC = sum(TICs == 0) |
82 | |
83 | |
77 | 84 |
78 ## Processing informations | 85 ## Processing informations |
79 processinginfo = processingData(msidata) | 86 processinginfo = processingData(msidata) |
80 centroidedinfo = processinginfo@centroided # TRUE or FALSE | 87 centroidedinfo = processinginfo@centroided # TRUE or FALSE |
81 | 88 |
191 method = "$segm_cond.pca_method", scale = $segm_cond.pca_scale, layout = c(ncomp, 1)) | 198 method = "$segm_cond.pca_method", scale = $segm_cond.pca_scale, layout = c(ncomp, 1)) |
192 | 199 |
193 ### images in pdf file | 200 ### images in pdf file |
194 print(image(pca_result, main="PCA image", lattice=lattice_input, strip = strip_input, col=colourvector)) | 201 print(image(pca_result, main="PCA image", lattice=lattice_input, strip = strip_input, col=colourvector)) |
195 for (PCs in 1:$segm_cond.pca_ncomp){ | 202 for (PCs in 1:$segm_cond.pca_ncomp){ |
196 print(image(pca_result, column = c(paste0("PC",PCs)), superpose = FALSE, col.regions = risk.colors(100)))} | 203 print(image(pca_result, column = c(paste0("PC",PCs)), lattice=lattice_input, superpose = FALSE, col.regions = risk.colors(100)))} |
197 ### plots in pdf file | 204 ### plots in pdf file |
198 print(plot(pca_result, main="PCA plot", lattice=lattice_input, col= colourvector, strip = strip_input)) | 205 print(plot(pca_result, main="PCA plot", lattice=lattice_input, col= colourvector, strip = strip_input)) |
199 for (PCs in 1:$segm_cond.pca_ncomp){ | 206 for (PCs in 1:$segm_cond.pca_ncomp){ |
200 print(plot(pca_result, column = c(paste0("PC",PCs)), superpose = FALSE))} | 207 print(plot(pca_result, column = c(paste0("PC",PCs)),superpose = FALSE))} |
201 | 208 |
202 | |
203 ### values in tabular files | 209 ### values in tabular files |
204 pcaloadings = (pca_result@resultData\$ncomp\$loadings) ### loading for each m/z value | 210 pcaloadings = (pca_result@resultData\$ncomp\$loadings) ### loading for each m/z value |
205 pcascores = (pca_result@resultData\$ncomp\$scores) ### scores for each pixel | 211 pcascores = (pca_result@resultData\$ncomp\$scores) ### scores for each pixel |
206 | 212 |
207 write.table(pcaloadings, file="$mzfeatures", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t") | 213 write.table(pcaloadings, file="$mzfeatures", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t") |
248 | 254 |
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") | 255 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") |
250 print(image(ssc, key=TRUE, main="Spatial shrunken centroids", lattice=lattice_input, strip = strip_input, col= colourvector,layout=c(1,1))) | 256 print(image(ssc, key=TRUE, main="Spatial shrunken centroids", lattice=lattice_input, strip = strip_input, col= colourvector,layout=c(1,1))) |
251 print(plot(ssc, main="Spatial shrunken centroids plot", lattice=lattice_input, col= colourvector, strip = strip_input,layout=c($segm_cond.centroids_layout))) | 257 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)) | 258 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)) | 259 plot(summary(ssc), main = "Number of segments") |
254 | 260 |
255 ssc_classes = data.frame(matrix(NA, nrow = pixelcount, ncol = 0)) | 261 ssc_classes = data.frame(matrix(NA, nrow = pixelcount, ncol = 0)) |
256 for (iteration in 1:length(ssc@resultData)){ | 262 for (iteration in 1:length(ssc@resultData)){ |
257 ssc_class = ((ssc@resultData)[[iteration]]\$classes) | 263 ssc_class = ((ssc@resultData)[[iteration]]\$classes) |
258 ssc_classes = cbind(ssc_classes, ssc_class) } | 264 ssc_classes = cbind(ssc_classes, ssc_class) } |
284 </configfiles> | 290 </configfiles> |
285 <inputs> | 291 <inputs> |
286 <param name="infile" type="data" format="imzml,rdata,analyze75" | 292 <param name="infile" type="data" format="imzml,rdata,analyze75" |
287 label="Inputfile as imzML, Analyze7.5 or Cardinal MSImageSet saved as RData" | 293 label="Inputfile as imzML, Analyze7.5 or Cardinal MSImageSet saved as RData" |
288 help="Upload composite datatype imzml (ibd+imzML) or analyze75 (hdr+img+t2m) or regular upload .RData (Cardinal MSImageSet)"/> | 294 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"/> | 295 <conditional name="processed_cond"> |
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"> | 296 <param name="processed_file" type="select" label="Is the input file a processed imzML file "> |
291 <option value="mz" >mz</option> | 297 <option value="no_processed" selected="True">not a processed imzML</option> |
292 <option value="ppm" selected="True" >ppm</option> | 298 <option value="processed">processed imzML</option> |
293 </param> | 299 </param> |
300 <when value="no_processed"/> | |
301 <when value="processed"> | |
302 <param name="accuracy" type="float" value="50" label="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"/> | |
303 <param name="units" display="radio" type="select" label="Unit of the mass accuracy" help="either m/z or ppm"> | |
304 <option value="mz" >mz</option> | |
305 <option value="ppm" selected="True" >ppm</option> | |
306 </param> | |
307 </when> | |
308 </conditional> | |
294 <conditional name="segm_cond"> | 309 <conditional name="segm_cond"> |
295 <param name="segmentationtool" type="select" label="Select the tool for spatial clustering"> | 310 <param name="segmentationtool" type="select" label="Select the tool for spatial clustering"> |
296 <option value="pca" selected="True">pca</option> | 311 <option value="pca" selected="True">pca</option> |
297 <option value="kmeans">k-means</option> | 312 <option value="kmeans">k-means</option> |
298 <option value="centroids">spatial shrunken centroids</option> | 313 <option value="centroids">spatial shrunken centroids</option> |