# HG changeset patch # User galaxyp # Date 1529446006 14400 # Node ID dcf79af72c8f6bba182d213125063a241e5b2358 # Parent 693a8efdfdeb1b29b1bd5f2b0e4dcaf832f73272 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msi_spectra_plots commit 37da74ed68228b16efbdbde776e7c38cc06eb5d5 diff -r 693a8efdfdeb -r dcf79af72c8f msi_spectra_plots.xml --- a/msi_spectra_plots.xml Mon Jun 11 17:33:12 2018 -0400 +++ b/msi_spectra_plots.xml Tue Jun 19 18:06:46 2018 -0400 @@ -1,10 +1,12 @@ - + mass spectrometry imaging mass spectra plots bioconductor-cardinal r-gridextra + r-ggplot2 + r-scales 20 && number_combined<40){ + legend_size = 9 + }else if (number_combined>40 && number_combined<60){ + legend_size = 8 + }else if (number_combined>60 && number_combined<100){ + legend_size = 7 + }else{ + legend_size = 6 + } + + position_df = cbind(coord(msidata)[,1:2], msidata\$combined_sample) + colnames(position_df)[3] = "sample_name" + + combine_plot = ggplot(position_df, aes(x=x, y=y, fill=sample_name))+ + geom_tile() + + coord_fixed()+ + ggtitle("Spatial orientation of combined data")+ + theme_bw()+ + theme(plot.title = element_text(hjust = 0.5))+ + theme(text=element_text(family="ArialMT", face="bold", size=12))+ + theme(legend.position="bottom",legend.direction="vertical")+ + theme(legend.key.size = unit(0.2, "line"), legend.text = element_text(size = legend_size))+ + guides(fill=guide_legend(ncol=5,byrow=TRUE)) + coord_labels = aggregate(cbind(x,y)~sample_name, data=position_df, mean) + coord_labels\$file_number = gsub( "_.*$", "", coord_labels\$sample_name) + for(file_count in 1:nrow(coord_labels)) + {combine_plot = combine_plot + annotate("text",x=coord_labels[file_count,"x"], + y=coord_labels[file_count,"y"],label=toString(coord_labels[file_count,4]))} + + print(combine_plot) + + ## print legend only for less than 10 samples + if (length(levels(msidata\$combined_sample)) < 10){ + key_legend = TRUE + }else{key_legend = FALSE} + + plot(msidata, pixel=1:ncol(msidata), pixel.groups=msidata\$combined_sample, key=key_legend, col=hue_pal()(length(levels(msidata\$combined_sample))),superpose=TRUE) + }else{ + plot(msidata, pixel=1:ncol(msidata), key=TRUE)} ##################### II) Sample: plot zoom-in mass spectrum ########## #if $pixel_conditional.zoomed_sample: #for $token in $pixel_conditional.zoomed_sample: + print("zoomed sample pixels") minmasspixel = features(msidata, mz=$token.xlimmin) maxmasspixel = features(msidata, mz=$token.xlimmax) - plot(msidata[minmasspixel:maxmasspixel,], pixel=1:ncol(msidata), - xlim= c($token.xlimmin,$token.xlimmax),pixel.groups=msidata\$combined_sample, - key=TRUE,col=c("blue", "orange", "green", "red", "yellow", "grey"), superpose=TRUE) + ## coloured plot with mean over all spectra for combined_sample, otherwise only 1 black plot + if (!is.null(levels(msidata\$combined_sample))){ + print("combined samples") + plot(msidata[minmasspixel:maxmasspixel,], pixel=1:ncol(msidata), + xlim= c($token.xlimmin,$token.xlimmax),pixel.groups=msidata\$combined_sample, + key=key_legend,col=hue_pal()(length(levels(msidata\$combined_sample))), superpose=TRUE) + }else{ + plot(msidata[minmasspixel:maxmasspixel,], pixel=1:ncol(msidata), key=TRUE, xlim= c($token.xlimmin,$token.xlimmax))} #end for #end if - - pixeldf = data.frame(table(msidata\$combined_sample)) + if (!is.null(levels(msidata\$combined_sample))){ + pixeldf = data.frame(table(msidata\$combined_sample)) + }else{ + pixeldf = data.frame("$filename", ncol(msidata))} colnames(pixeldf) = c("sample name", "number of pixels") #end if + ### overview table of pixels or samples: plot(0,type='n',axes=FALSE,ann=FALSE) title(main="Overview of chosen pixel:") - grid.table(pixeldf, rows= NULL) + + ### for more than 20 combined samples print only 20 samples per page: + if (is.null(levels(msidata\$combined_sample))){ + grid.table(pixeldf, rows= NULL) + }else if (length(levels(msidata\$combined_sample)) <= 20){ + grid.table(pixeldf, rows= NULL) + }else{ + grid.table(pixeldf[1:20,], rows= NULL) + mincount = 21 + maxcount = 40 + for (count20 in 1:(ceiling(nrow(pixeldf)/20)-1)){ + plot(0,type='n',axes=FALSE,ann=FALSE) + if (maxcount <= nrow(pixeldf)){ + grid.table(pixeldf[mincount:maxcount,], rows= NULL) + mincount = mincount+20 + maxcount = maxcount+20 + }else{### stop last page with last sample otherwise NA in table + grid.table(pixeldf[mincount:nrow(pixeldf),], rows= NULL)} + } + } dev.off() @@ -249,6 +327,11 @@ + + + + + @@ -353,10 +436,25 @@ - + + + + + + + + + + + + + + + + @@ -364,23 +462,19 @@ - + - - - - - - - - - - - - + + + + + + + + @@ -403,9 +497,8 @@ - Enter the x and y coordinates of your pixel of interest - To have a visual control for the selected pixel, a heatmap of a m/z of interest will be drawn. Two intersecting lines will show the pixel location. This procedure requires an m/z of interest together with a m/z range and for the lines the colour and type. - Additionally zoom into mass spectra plots is possible by providing the minimum and maximum m/z value to define the limits of the plot -- "All pixels of a sample": Returns a full average mass spectrum plot with different colours for each subfile +- "All pixels of a sample": Returns a full average mass spectrum plot with different colours for the sample/each combined sample - - This option only works on files that have previosly been combined in the combine tool - Additionally zoom into mass spectra plots is possible by providing the minimum and maximum m/z value to define the limits of the plot Output: diff -r 693a8efdfdeb -r dcf79af72c8f test-data/Plot_analyze75.pdf Binary file test-data/Plot_analyze75.pdf has changed diff -r 693a8efdfdeb -r dcf79af72c8f test-data/Plot_analyze75_allpixels.pdf Binary file test-data/Plot_analyze75_allpixels.pdf has changed diff -r 693a8efdfdeb -r dcf79af72c8f test-data/Plot_empty_spectra.pdf Binary file test-data/Plot_empty_spectra.pdf has changed diff -r 693a8efdfdeb -r dcf79af72c8f test-data/Plot_imzml.pdf Binary file test-data/Plot_imzml.pdf has changed diff -r 693a8efdfdeb -r dcf79af72c8f test-data/Plot_rdata.pdf Binary file test-data/Plot_rdata.pdf has changed