Mercurial > repos > galaxyp > cardinal_spectra_plots
comparison spectra_plots.xml @ 2:3642ed221eb2 draft
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit f127be2141cf22e269c85282d226eb16fe14a9c1
author | galaxyp |
---|---|
date | Fri, 15 Feb 2019 10:23:28 -0500 |
parents | 1d9931768896 |
children | 58c4aef16eb0 |
comparison
equal
deleted
inserted
replaced
1:1d9931768896 | 2:3642ed221eb2 |
---|---|
1 <tool id="cardinal_spectra_plots" name="MSI plot spectra" version="@VERSION@.1"> | 1 <tool id="cardinal_spectra_plots" name="MSI plot spectra" version="@VERSION@.2"> |
2 <description> | 2 <description> |
3 mass spectrometry imaging mass spectra plots | 3 mass spectrometry imaging mass spectra plots |
4 </description> | 4 </description> |
5 <macros> | 5 <macros> |
6 <import>macros.xml</import> | 6 <import>macros.xml</import> |
25 library(Cardinal) | 25 library(Cardinal) |
26 library(gridExtra) | 26 library(gridExtra) |
27 library(ggplot2) | 27 library(ggplot2) |
28 library(scales) | 28 library(scales) |
29 | 29 |
30 | |
30 @READING_MSIDATA@ | 31 @READING_MSIDATA@ |
31 | 32 |
32 @DATA_PROPERTIES@ | 33 @DATA_PROPERTIES@ |
33 | 34 |
34 | 35 |
50 | 51 |
51 grid.table(property_df, rows= NULL) | 52 grid.table(property_df, rows= NULL) |
52 | 53 |
53 ## set NA to 0 otherwise plot function will not work | 54 ## set NA to 0 otherwise plot function will not work |
54 | 55 |
55 ##spectra(msidata)[is.na(spectra(msidata)[])] = 0 ## in case of NA values they will be set to zero | 56 #if str($processed_cond.processed_file) == "processed": |
56 | 57 ##processed file needs to be converted into matrix to be able to replace NAs |
57 spectra_df = spectra(msidata)[] | 58 iData(msidata) <- iData(msidata)[] |
58 spectra_df[is.na(spectra_df)] = 0 | 59 spectra(msidata)[][is.na(spectra(msidata)[])] = 0 |
59 print(paste0("Number of NA which were converted into 0:",sum(is.na(spectra_df)))) | 60 #else |
60 spectra(msidata) = spectra_df | 61 spectra(msidata)[is.na(spectra(msidata))] = 0 |
61 | 62 #end if |
62 | 63 |
63 if (npeaks > 0){ | 64 ## run only if mz and pixels are > 0 |
65 | |
66 if (ncol(msidata)>0 & nrow(msidata) >0){ | |
64 | 67 |
65 pixeldf = data.frame(matrix(ncol = 2, nrow=0)) | 68 pixeldf = data.frame(matrix(ncol = 2, nrow=0)) |
66 | 69 |
67 ############################# single pixel ################################ | 70 ############################# single pixel ################################ |
68 ########################################################################### | 71 ########################################################################### |
71 print("single_pixel") | 74 print("single_pixel") |
72 | 75 |
73 #for $chosenpixel in $pixel_conditional.repeatpixel: | 76 #for $chosenpixel in $pixel_conditional.repeatpixel: |
74 | 77 |
75 pixelname = paste0("x = ", $chosenpixel.inputx,", ", "y = ", $chosenpixel.inputy) | 78 pixelname = paste0("x = ", $chosenpixel.inputx,", ", "y = ", $chosenpixel.inputy) |
76 pixelisvalid = as.character(pixelname %in% names(pixels(msidata))) | 79 |
80 | |
81 | |
82 input_pixels = paste($chosenpixel.inputx, $chosenpixel.inputy, sep="_") | |
83 dataset_pixels = paste(coord(msidata)\$x, coord(msidata)\$y, sep="_") | |
84 | |
85 pixelisvalid = as.character(input_pixels %in% dataset_pixels) | |
86 | |
87 | |
88 | |
77 pixeldf = rbind(pixeldf, cbind(pixelname, pixelisvalid)) | 89 pixeldf = rbind(pixeldf, cbind(pixelname, pixelisvalid)) |
78 | 90 |
79 ############################# II) control image #################### | 91 ############################# II) control image #################### |
80 | 92 |
81 if (pixelisvalid == "TRUE"){ | 93 if (pixelisvalid == "TRUE"){ |
82 print(pixelisvalid) | |
83 | 94 |
84 image(msidata, mz=$chosenpixel.inputmz, ylim = c(maximumy+(0.2*maximumy),minimumy-1), | 95 image(msidata, mz=$chosenpixel.inputmz, ylim = c(maximumy+(0.2*maximumy),minimumy-1), |
85 colorkey=FALSE, plusminus = $chosenpixel.plusminusinDalton, | 96 colorkey=FALSE, plusminus = $chosenpixel.plusminusinDalton, |
86 main= paste0("x= ",$chosenpixel.inputx, ", y= ", $chosenpixel.inputy)) | 97 main= paste0("x= ",$chosenpixel.inputx, ", y= ", $chosenpixel.inputy)) |
87 | 98 |
186 ## print legend only for less than 10 samples | 197 ## print legend only for less than 10 samples |
187 if (length(levels(msidata\$annotation)) < 10){ | 198 if (length(levels(msidata\$annotation)) < 10){ |
188 key_legend = TRUE | 199 key_legend = TRUE |
189 }else{key_legend = FALSE} | 200 }else{key_legend = FALSE} |
190 | 201 |
191 spectra(msidata)[is.na(spectra(msidata)[])] = 0 ## in case of NA values they will be set to zero | |
192 plot(msidata, pixel=1:ncol(msidata), pixel.groups=msidata\$annotation, key=key_legend, col=hue_pal()(length(levels(msidata\$annotation))),superpose=TRUE) | 202 plot(msidata, pixel=1:ncol(msidata), pixel.groups=msidata\$annotation, key=key_legend, col=hue_pal()(length(levels(msidata\$annotation))),superpose=TRUE) |
193 }else{ | 203 }else{ |
194 spectra(msidata)[is.na(spectra(msidata)[])] = 0 ## in case of NA values they will be set to zero | |
195 plot(msidata, pixel=1:ncol(msidata), key=TRUE)} | 204 plot(msidata, pixel=1:ncol(msidata), key=TRUE)} |
196 | 205 |
197 ##################### II) Sample: plot zoom-in mass spectrum ########## | 206 ##################### II) Sample: plot zoom-in mass spectrum ########## |
198 | 207 |
199 #if $pixel_conditional.zoomed_sample: | 208 #if $pixel_conditional.zoomed_sample: |
200 iData(msidata) <- iData(msidata)[] ## getting back data on disk | |
201 #for $token in $pixel_conditional.zoomed_sample: | 209 #for $token in $pixel_conditional.zoomed_sample: |
202 print("zoomed sample pixels") | 210 print("zoomed sample pixels") |
203 | 211 |
204 minmasspixel = features(msidata, mz=$token.xlimmin) | 212 minmasspixel = features(msidata, mz=$token.xlimmin) |
205 maxmasspixel = features(msidata, mz=$token.xlimmax) | 213 maxmasspixel = features(msidata, mz=$token.xlimmax) |
315 </repeat> | 323 </repeat> |
316 </when> | 324 </when> |
317 </conditional> | 325 </conditional> |
318 </inputs> | 326 </inputs> |
319 <outputs> | 327 <outputs> |
320 <data format="pdf" name="plots" from_work_dir="mzplots.pdf" label="${tool.name} on ${on_string}"/> | 328 <data format="pdf" name="plots" from_work_dir="mzplots.pdf" label="${tool.name} on ${on_string}:results"/> |
321 </outputs> | 329 </outputs> |
322 <tests> | 330 <tests> |
323 <test> | 331 <test> |
324 <expand macro="infile_imzml"/> | 332 <expand macro="infile_imzml"/> |
325 <conditional name="pixel_conditional"> | 333 <conditional name="pixel_conditional"> |