comparison quality_report.xml @ 12:ecaebe7c7b54 draft

"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit 0c667acd7cc0d0ef6c4e979ca29372b8c0d92c23"
author galaxyp
date Tue, 06 Oct 2020 08:16:29 +0000
parents f396c176f366
children 23d0394b5908
comparison
equal deleted inserted replaced
11:f396c176f366 12:ecaebe7c7b54
1 <tool id="cardinal_quality_report" name="MSI Qualitycontrol" version="@VERSION@.0"> 1 <tool id="cardinal_quality_report" name="MSI Qualitycontrol" version="@VERSION@.1">
2 <description> 2 <description>
3 mass spectrometry imaging QC 3 mass spectrometry imaging QC
4 </description> 4 </description>
5 <macros> 5 <macros>
6 <import>macros.xml</import> 6 <import>macros.xml</import>
65 #end if 65 #end if
66 66
67 ###################### calculation of data properties ################################ 67 ###################### calculation of data properties ################################
68 @DATA_PROPERTIES_INRAM@ 68 @DATA_PROPERTIES_INRAM@
69 69
70
71 ## Median intensities 70 ## Median intensities
72 medint = round(median(int_matrix), digits=2) 71 medint = round(median(int_matrix), digits=2)
73 ## Spectra multiplied with m/z (potential number of peaks) 72 ## Spectra multiplied with m/z (potential number of peaks)
74 numpeaks = as.numeric(ncol(msidata)*nrow(msidata)) 73 numpeaks = as.numeric(ncol(msidata)*nrow(msidata))
75 ## Percentage of intensities > 0 74 ## Percentage of intensities > 0
81 medTIC = round(median(TICs), digits=1) 80 medTIC = round(median(TICs), digits=1)
82 sdTIC = round(sd(TICs), digits=0) 81 sdTIC = round(sd(TICs), digits=0)
83 ## Median and sd # peaks per spectrum 82 ## Median and sd # peaks per spectrum
84 medpeaks = round(median(colSums(spectra(msidata)>0, na.rm=TRUE), na.rm=TRUE), digits=0) 83 medpeaks = round(median(colSums(spectra(msidata)>0, na.rm=TRUE), na.rm=TRUE), digits=0)
85 sdpeaks = round(sd(colSums(spectra(msidata)>0, na.rm=TRUE), na.rm=TRUE), digits=0) 84 sdpeaks = round(sd(colSums(spectra(msidata)>0, na.rm=TRUE), na.rm=TRUE), digits=0)
85 ##max window size
86 max_window = round(mz(msidata)[nrow(msidata)]-mz(msidata)[nrow(msidata)-1], digits=2)
86 ## Processing informations 87 ## Processing informations
87 centroidedinfo = centroided(msidata) 88 centroidedinfo = centroided(msidata)
88 89
89 ############## Read and filter tabular file with m/z ########################### 90 ############## Read and filter tabular file with m/z ###########################
90 91
136 properties2 = c("Median of intensities", 137 properties2 = c("Median of intensities",
137 "Intensities > 0", 138 "Intensities > 0",
138 "Number of empty spectra", 139 "Number of empty spectra",
139 "Median TIC ± sd", 140 "Median TIC ± sd",
140 "Median # peaks per spectrum ± sd", 141 "Median # peaks per spectrum ± sd",
142 "maximum m/z window size",
141 "Centroided", 143 "Centroided",
142 paste0("input m/z (#valid/#input) in \n", "$calibrant_file.display_name")) 144 paste0("input m/z (#valid/#input) in \n", "$calibrant_file.display_name"))
143 145
144 values2 = c(paste0(medint), 146 values2 = c(paste0(medint),
145 paste0(percpeaks, " %"), 147 paste0(percpeaks, " %"),
146 paste0(NumemptyTIC), 148 paste0(NumemptyTIC),
147 paste0(medTIC, " ± ", sdTIC), 149 paste0(medTIC, " ± ", sdTIC),
148 paste0(medpeaks, " ± ",sdpeaks), 150 paste0(medpeaks, " ± ",sdpeaks),
151 paste0(max_window),
149 paste0(centroidedinfo), 152 paste0(centroidedinfo),
150 paste0(number_calibrants_valid, " / ", number_calibrants_in)) 153 paste0(number_calibrants_valid, " / ", number_calibrants_in))
151 154
152 property_df2 = data.frame(properties2, values2) 155 property_df2 = data.frame(properties2, values2)
153 colnames(property_df2) = c("properties", "values") 156 colnames(property_df2) = c("properties", "values")
220 223
221 pixelnumber = 1:pixelcount 224 pixelnumber = 1:pixelcount
222 pixelxyarray=data.frame(coord(msidata)\$x, coord(msidata)\$y,pixelnumber) 225 pixelxyarray=data.frame(coord(msidata)\$x, coord(msidata)\$y,pixelnumber)
223 colnames(pixelxyarray) = c("x", "y", "pixelnumber") 226 colnames(pixelxyarray) = c("x", "y", "pixelnumber")
224 gg_title = "Pixel order" 227 gg_title = "Pixel order"
225 228
226 print(ggplot(pixelxyarray, aes(x=x, y=y, fill=pixelnumber))+ 229 print(ggplot(pixelxyarray, aes(x=x, y=y, fill=pixelnumber))+
227 geom_tile() + coord_fixed()+ 230 geom_tile() + coord_fixed()+
228 ggtitle(gg_title) + theme_bw()+ 231 ggtitle(gg_title) + theme_bw()+
229 theme(plot.title = element_text(hjust = 0.5))+ 232 theme(plot.title = element_text(hjust = 0.5))+
230 theme(text=element_text(family="ArialMT", face="bold", size=12))+ 233 theme(text=element_text(family="ArialMT", face="bold", size=12))+
753 differencevector = numeric() 756 differencevector = numeric()
754 differencevector2 = vector() 757 differencevector2 = vector()
755 758
756 if (length(inputcalibrantmasses) != 0){ 759 if (length(inputcalibrantmasses) != 0){
757 760
761
758 ### calculate plusminus values in m/z for each calibrant, this is used for all following plots 762 ### calculate plusminus values in m/z for each calibrant, this is used for all following plots
759 plusminusvalues = rep($plusminus_ppm/1000000, length(inputcalibrantmasses)) * inputcalibrantmasses 763 plusminusvalues = rep($plusminus_ppm/1000000, length(inputcalibrantmasses)) * inputcalibrantmasses
760 764
761 for (mass in 1:length(inputcalibrantmasses)){ 765 for (mass in 1:length(inputcalibrantmasses)){
762 766
765 maxmasspixel1 = features(msidata_no_NA, mz=inputcalibrantmasses[mass]+1.5) 769 maxmasspixel1 = features(msidata_no_NA, mz=inputcalibrantmasses[mass]+1.5)
766 minmasspixel2 = features(msidata_no_NA, mz=inputcalibrantmasses[mass]-0.25) 770 minmasspixel2 = features(msidata_no_NA, mz=inputcalibrantmasses[mass]-0.25)
767 maxmasspixel2 = features(msidata_no_NA, mz=inputcalibrantmasses[mass]+0.5) 771 maxmasspixel2 = features(msidata_no_NA, mz=inputcalibrantmasses[mass]+0.5)
768 minmasspixel3 = features(msidata_no_NA, mz=inputcalibrantmasses[mass]-1.5) 772 minmasspixel3 = features(msidata_no_NA, mz=inputcalibrantmasses[mass]-1.5)
769 maxmasspixel3 = features(msidata_no_NA, mz=inputcalibrantmasses[mass]+3) 773 maxmasspixel3 = features(msidata_no_NA, mz=inputcalibrantmasses[mass]+3)
774
775 ## test if some values are lower than min(mz)
776 minmasspixel1 = ifelse(length(minmasspixel1)>0, minmasspixel1, 1)
777 minmasspixel2 = ifelse(length(minmasspixel2)>0, minmasspixel2, 1)
778 minmasspixel3 = ifelse(length(minmasspixel3)>0, minmasspixel3, 1)
779
780 ## test if min and max are same (more likely for centroided data):
781 maxmasspixel1 = ifelse(minmasspixel1 != maxmasspixel1, maxmasspixel1, maxmasspixel1 + 1)
782 maxmasspixel2 = ifelse(minmasspixel2 != maxmasspixel2, maxmasspixel2, maxmasspixel1 + 1)
783 maxmasspixel3 = ifelse(minmasspixel3 != maxmasspixel3, maxmasspixel3, maxmasspixel1 + 1)
784
770 785
771 ### find m/z with the highest mean intensity in m/z range (red line in plot 16) and calculate ppm difference for plot 17 786 ### find m/z with the highest mean intensity in m/z range (red line in plot 16) and calculate ppm difference for plot 17
772 filtered_data = msidata_no_NA[mz(msidata_no_NA) >= inputcalibrantmasses[mass]-plusminusvalues[mass] & mz(msidata_no_NA) <= inputcalibrantmasses[mass]+plusminusvalues[mass],] 787 filtered_data = msidata_no_NA[mz(msidata_no_NA) >= inputcalibrantmasses[mass]-plusminusvalues[mass] & mz(msidata_no_NA) <= inputcalibrantmasses[mass]+plusminusvalues[mass],]
773 788
774 if (nrow(filtered_data) > 0 & sum(spectra(filtered_data)) > 0){ 789 if (nrow(filtered_data) > 0 & sum(spectra(filtered_data)) > 0){
835 850
836 par(mfrow = c(1,1)) 851 par(mfrow = c(1,1))
837 ### plot the ppm difference calculated above: theor. m/z value to highest m/z value: 852 ### plot the ppm difference calculated above: theor. m/z value to highest m/z value:
838 853
839 calibrant_names = as.character(inputcalibrants[,2]) 854 calibrant_names = as.character(inputcalibrants[,2])
855
840 diff_df = data.frame(differencevector, calibrant_names) 856 diff_df = data.frame(differencevector, calibrant_names)
857
841 858
842 if (sum(is.na(diff_df[,1])) == nrow(diff_df)){ 859 if (sum(is.na(diff_df[,1])) == nrow(diff_df)){
843 plot(0,type='n',axes=FALSE,ann=FALSE) 860 plot(0,type='n',axes=FALSE,ann=FALSE)
844 title(main=paste("plot 17: no peaks in the chosen region, repeat with higher ppm range")) 861 title(main=paste("plot 17: no peaks in the chosen region, repeat with higher ppm range"))
845 }else{ 862 }else{