# HG changeset patch # User galaxyp # Date 1606693283 0 # Node ID c5aa9fca18c650be7e77283466dd33f310ebaeb3 # Parent 10566783d718a9757e8e21fbf80fc25a31e379f4 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit 39bd480e8813fa7a96b640150365577a69885d17-dirty" diff -r 10566783d718 -r c5aa9fca18c6 spectra_plots.xml --- a/spectra_plots.xml Tue Nov 03 23:11:11 2020 +0000 +++ b/spectra_plots.xml Sun Nov 29 23:41:23 2020 +0000 @@ -1,4 +1,4 @@ - + mass spectrometry imaging mass spectra plots @@ -66,23 +66,20 @@ ## read and extract x,y, optional annotation information spectra_tabular = read.delim("$pixel_conditional.pixel_file", header = $pixel_conditional.tabular_pixel_header, stringsAsFactors = FALSE) - #if $pixel_conditional.column_pixel_annotation: + #if str($pixel_conditional.single_or_overlaid.plot_type) == 'overlaid_plots': - spectra_input = spectra_tabular[,c($pixel_conditional.column_pixel_x, $pixel_conditional.column_pixel_y, $pixel_conditional.column_pixel_annotation)] + spectra_input = spectra_tabular[,c($pixel_conditional.column_pixel_x, $pixel_conditional.column_pixel_y, $pixel_conditional.single_or_overlaid.column_pixel_annotation)] colnames(spectra_input) = c("x", "y", "annotation") + spectra_input\$annotation = as.character(spectra_input\$annotation) - input_pixels = paste(spectra_input[,1], spectra_input[,2], sep="_") - dataset_pixels = paste(coord(msidata)\$x, coord(msidata)\$y, sep="_") - pixelsofinterest = dataset_pixels %in% input_pixels - msidata = msidata[,pixelsofinterest] + msidata_coordinates = data.frame(coord(msidata)\$x, coord(msidata)\$y) + colnames(msidata_coordinates) = c("x", "y") + merged_annotation = merge(msidata_coordinates, spectra_input, by=c("x", "y")) + merged_annotation[is.na(merged_annotation)] = "NA" - ## merge with coordinate information of msidata - msidata_coordinates = data.frame(coord(msidata)\$x, coord(msidata)\$y, c(1:ncol(msidata))) - colnames(msidata_coordinates) = c("x", "y", "pixel_index") - merged_annotation = merge(msidata_coordinates, spectra_input, by=c("x", "y"), all.x=TRUE) - merged_annotation[is.na(merged_annotation)] = "NA" - merged_annotation = merged_annotation[order(merged_annotation\$pixel_index),] - msidata\$annotation = factor(merged_annotation[,4], levels = unique(as.character(merged_annotation[,4]))) ## keep the right order + merged_annotation = merged_annotation[order(merged_annotation\$annotation),] + msidata\$annotation = factor(merged_annotation\$annotation) + ## overview plot over annotated samples number_combined = length(levels(msidata\$annotation)) @@ -100,7 +97,21 @@ legend_size = 6 } - position_df = data.frame(coord(msidata)\$x, coord(msidata)\$y, as.factor(msidata\$annotation)) + ## colours selection: + + #if str($pixel_conditional.single_or_overlaid.colour_conditional.colour_type) == "manual_colour" + #set $color_string = ','.join(['"%s"' % $color.annotation_color for $color in $pixel_conditional.single_or_overlaid.colour_conditional.colours]) + colourvector = c($color_string) + + #elif str($pixel_conditional.single_or_overlaid.colour_conditional.colour_type) == "colourpalette" + + number_levels = (length(levels(msidata\$annotation))) + + colourvector = noquote($pixel_conditional.single_or_overlaid.colour_conditional.palettes)(number_levels) + + #end if + + position_df = merged_annotation colnames(position_df) = c("x", "y", "sample_name") combine_plot = ggplot(position_df, aes(x=x, y=y, fill=sample_name))+ @@ -111,15 +122,18 @@ 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 = 6))+ - guides(fill=guide_legend(ncol=4,byrow=TRUE)) + theme(legend.key.size = unit(0.2, "line"), legend.text = element_text(size = 10))+ + guides(fill=guide_legend(ncol=4,byrow=TRUE))+ + scale_discrete_manual(aesthetics = c("colour", "fill"), values = colourvector) - coord_labels = aggregate(cbind(x,y)~sample_name, data=position_df, mean, na.rm=TRUE, na.action="na.pass") - coord_labels\$file_number = 1:length(levels(position_df\$sample_name)) + + coord_labels = aggregate(cbind(x,y)~sample_name, data=position_df, mean, na.rm=TRUE, na.action="na.pass") + coord_labels\$file_number = 1:length(unique(position_df\$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]))} + {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) @@ -130,7 +144,7 @@ #if $fullmz: ## plot single tabular mz, average per annotation - print(plot(msidata, run="infile", pixel.groups=msidata\$annotation, key=key_legend, col=hue_pal()(length(levels(msidata\$annotation))),superpose=TRUE, strip=FALSE, grid=$grid_variable), main="Average spectrum per group") + print(plot(msidata, run="infile", pixel.groups=msidata\$annotation, key=key_legend,superpose=TRUE, strip=FALSE, grid=$grid_variable, col = colourvector), main="Average spectrum per group") #end if pixeldf = data.frame(table(msidata\$annotation)) @@ -165,9 +179,10 @@ ) ## plot single tabular mz, average per annotation, manual zoom - print(plot(msidata[minmasspixel:maxmasspixel,], run="infile", strip=FALSE, + + print(plot(msidata[minmasspixel:maxmasspixel,], run="infile", strip=FALSE, col = colourvector, xlim= c($token.xlimmin,$token.xlimmax),pixel.groups=msidata\$annotation, grid = $grid_variable, - key=key_legend,col=hue_pal()(length(levels(msidata\$annotation))), superpose=TRUE, main="Average spectrum per group")) + key=key_legend, superpose=TRUE, main="Average spectrum per group")) #end for #elif str($mz_range.mz_range_options) == "tabular_mz": @@ -186,17 +201,18 @@ ## plot single tabular mz, average per annotation, tabular zoom print(plot(msidata[minmasspixel:maxmasspixel,], run="infile", strip=FALSE, main="Average spectrum per group", - xlim= c(xlimmin,xlimmax),pixel.groups=msidata\$annotation, grid = $grid_variable, - key=key_legend,col=hue_pal()(length(levels(msidata\$annotation))), superpose=TRUE)) + xlim= c(xlimmin,xlimmax),pixel.groups=msidata\$annotation, grid = $grid_variable, col = colourvector, + key=key_legend, superpose=TRUE)) + } } #end if + #elif str($pixel_conditional.single_or_overlaid.plot_type) == 'separate_plots': - #elif str($pixel_conditional.column_pixel_annotation)== "None": - spectra_tabular = spectra_tabular[,c($pixel_conditional.column_pixel_x, $pixel_conditional.column_pixel_y)] - colnames(spectra_tabular) = c("x", "y") + spectra_tabular = spectra_tabular[,c($pixel_conditional.column_pixel_x, $pixel_conditional.column_pixel_y)] + colnames(spectra_tabular) = c("x", "y") dataset_pixels = data.frame(coord(msidata)\$x, coord(msidata)\$y) colnames(dataset_pixels) = c("x", "y") @@ -261,7 +277,17 @@ } ## print single tabular mz; manual zoom - print(plot(msidata[minmasspixel:maxmasspixel,], grid = $grid_variable, coord=list(x=x_coord, y=y_coord), key=TRUE, xlim= c($token.xlimmin,$token.xlimmax), col="black")) + + tryCatch( + { + print(plot(msidata[minmasspixel:maxmasspixel,], grid = $grid_variable, coord=list(x=x_coord, y=y_coord), key=TRUE, xlim= c($token.xlimmin,$token.xlimmax), col="black")) + } + , + error=function(cond) { + ## if there are no intensities > 0 in the chosen plotting window, write a warning + text(0.5,0.5,labels = c(paste("No peaks in the spectrum with the coordinates x =", x_coord, ", y =", y_coord, sep=" "))) + } + ) #end for @@ -456,17 +482,53 @@ - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -554,19 +616,33 @@ - + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + diff -r 10566783d718 -r c5aa9fca18c6 test-data/Heatmaps_LM8_file16.pdf Binary file test-data/Heatmaps_LM8_file16.pdf has changed diff -r 10566783d718 -r c5aa9fca18c6 test-data/Heatmaps_analyze75.pdf Binary file test-data/Heatmaps_analyze75.pdf has changed diff -r 10566783d718 -r c5aa9fca18c6 test-data/Heatmaps_imzml.pdf Binary file test-data/Heatmaps_imzml.pdf has changed diff -r 10566783d718 -r c5aa9fca18c6 test-data/Heatmaps_processed.pdf Binary file test-data/Heatmaps_processed.pdf has changed diff -r 10566783d718 -r c5aa9fca18c6 test-data/Heatmaps_rdata.pdf Binary file test-data/Heatmaps_rdata.pdf has changed diff -r 10566783d718 -r c5aa9fca18c6 test-data/centroids_proc.pdf Binary file test-data/centroids_proc.pdf has changed diff -r 10566783d718 -r c5aa9fca18c6 test-data/preprocessing_results1.ibd Binary file test-data/preprocessing_results1.ibd has changed diff -r 10566783d718 -r c5aa9fca18c6 test-data/preprocessing_results1.imzml --- a/test-data/preprocessing_results1.imzml Tue Nov 03 23:11:11 2020 +0000 +++ b/test-data/preprocessing_results1.imzml Sun Nov 29 23:41:23 2020 +0000 @@ -9,8 +9,8 @@ - - + + @@ -86,15 +86,15 @@ - - + + - - - + + + @@ -115,15 +115,15 @@ - - + + - - - + + + @@ -144,15 +144,15 @@ - - + + - - - + + + @@ -173,15 +173,15 @@ - - + + - - - + + + @@ -202,15 +202,15 @@ - - + + - - - + + + @@ -231,15 +231,15 @@ - - + + - - - + + + @@ -260,15 +260,15 @@ - - + + - - - + + + @@ -289,15 +289,15 @@ - - + + - - - + + + @@ -318,15 +318,15 @@ - - + + - - - + + + diff -r 10566783d718 -r c5aa9fca18c6 test-data/preprocessing_results1.imzml.txt --- a/test-data/preprocessing_results1.imzml.txt Tue Nov 03 23:11:11 2020 +0000 +++ b/test-data/preprocessing_results1.imzml.txt Sun Nov 29 23:41:23 2020 +0000 @@ -1,4 +1,4 @@ imzML file: total 24 --rw-rw-r-- 1 meli meli 216 Oct 5 19:57 ibd --rw-rw-r-- 1 meli meli 18090 Oct 5 19:57 imzml +-rw-rw-r-- 1 meli meli 336 Nov 29 01:14 ibd +-rw-rw-r-- 1 meli meli 18092 Nov 29 01:14 imzml diff -r 10566783d718 -r c5aa9fca18c6 test-data/preprocessing_results1.pdf Binary file test-data/preprocessing_results1.pdf has changed diff -r 10566783d718 -r c5aa9fca18c6 test-data/preprocessing_results2.ibd Binary file test-data/preprocessing_results2.ibd has changed diff -r 10566783d718 -r c5aa9fca18c6 test-data/preprocessing_results2.imzml --- a/test-data/preprocessing_results2.imzml Tue Nov 03 23:11:11 2020 +0000 +++ b/test-data/preprocessing_results2.imzml Sun Nov 29 23:41:23 2020 +0000 @@ -9,8 +9,8 @@ - - + + diff -r 10566783d718 -r c5aa9fca18c6 test-data/preprocessing_results2.imzml.txt --- a/test-data/preprocessing_results2.imzml.txt Tue Nov 03 23:11:11 2020 +0000 +++ b/test-data/preprocessing_results2.imzml.txt Sun Nov 29 23:41:23 2020 +0000 @@ -1,4 +1,4 @@ imzML file: total 64 --rw-rw-r-- 1 meli meli 37404 Oct 5 19:57 ibd --rw-rw-r-- 1 meli meli 22796 Oct 5 19:57 imzml +-rw-rw-r-- 1 meli meli 37404 Nov 29 18:03 ibd +-rw-rw-r-- 1 meli meli 22796 Nov 29 18:03 imzml diff -r 10566783d718 -r c5aa9fca18c6 test-data/preprocessing_results2.pdf Binary file test-data/preprocessing_results2.pdf has changed diff -r 10566783d718 -r c5aa9fca18c6 test-data/preprocessing_results3.ibd Binary file test-data/preprocessing_results3.ibd has changed diff -r 10566783d718 -r c5aa9fca18c6 test-data/preprocessing_results3.imzml --- a/test-data/preprocessing_results3.imzml Tue Nov 03 23:11:11 2020 +0000 +++ b/test-data/preprocessing_results3.imzml Sun Nov 29 23:41:23 2020 +0000 @@ -9,9 +9,9 @@ - - - + + + @@ -86,15 +86,15 @@ - - + + - - - + + + @@ -114,16 +114,16 @@ - - - + + + - - - + + + @@ -143,16 +143,16 @@ - - - + + + - - - + + + @@ -172,16 +172,16 @@ - - - + + + - - - + + + @@ -201,16 +201,16 @@ - - - + + + - - - + + + @@ -230,16 +230,16 @@ - - - + + + - - - + + + @@ -259,16 +259,16 @@ - - - + + + - - - + + + @@ -288,16 +288,16 @@ - - - + + + - - - + + + @@ -317,16 +317,16 @@ - - - + + + - - - + + + diff -r 10566783d718 -r c5aa9fca18c6 test-data/preprocessing_results3.imzml.txt --- a/test-data/preprocessing_results3.imzml.txt Tue Nov 03 23:11:11 2020 +0000 +++ b/test-data/preprocessing_results3.imzml.txt Sun Nov 29 23:41:23 2020 +0000 @@ -1,4 +1,4 @@ imzML file: total 24 --rw-rw-r-- 1 meli meli 960 Oct 5 19:58 ibd --rw-rw-r-- 1 meli meli 18112 Oct 5 19:58 imzml +-rw-rw-r-- 1 meli meli 1456 Nov 29 18:04 ibd +-rw-rw-r-- 1 meli meli 18133 Nov 29 18:04 imzml diff -r 10566783d718 -r c5aa9fca18c6 test-data/preprocessing_results3.pdf Binary file test-data/preprocessing_results3.pdf has changed