Mercurial > repos > galaxyp > cardinal_quality_report
comparison quality_report.xml @ 18:d426a9107a6c draft default tip
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit 91e77c139cb3b7c6d67727dc39140dd79355fa0c
author | galaxyp |
---|---|
date | Thu, 04 Jul 2024 13:35:30 +0000 |
parents | 23d0394b5908 |
children |
comparison
equal
deleted
inserted
replaced
17:a7fb9b395ddf | 18:d426a9107a6c |
---|---|
1 <tool id="cardinal_quality_report" name="MSI Qualitycontrol" version="@VERSION@.0"> | 1 <tool id="cardinal_quality_report" name="MSI Qualitycontrol" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="22.05"> |
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> |
7 </macros> | 7 </macros> |
8 <expand macro="requirements"> | 8 <expand macro="requirements"/> |
9 <requirement type="package" version="2.3">r-gridextra</requirement> | |
10 <requirement type="package" version="3.3.5">r-ggplot2</requirement> | |
11 <requirement type="package" version="1.1_2">r-rcolorbrewer</requirement> | |
12 <requirement type="package" version="2.23_20">r-kernsmooth</requirement> | |
13 <requirement type="package" version="1.1.1">r-scales</requirement> | |
14 <requirement type="package" version="1.0.12">r-pheatmap</requirement> | |
15 </expand> | |
16 <command detect_errors="exit_code"> | 9 <command detect_errors="exit_code"> |
17 <![CDATA[ | 10 <![CDATA[ |
18 @INPUT_LINKING@ | 11 @INPUT_LINKING@ |
19 cat '${cardinal_qualitycontrol_script}' && | 12 cat '${cardinal_qualitycontrol_script}' && |
20 Rscript '${cardinal_qualitycontrol_script}' | 13 Rscript '${cardinal_qualitycontrol_script}' |
39 if (class(msidata) == "MSImageSet"){ | 32 if (class(msidata) == "MSImageSet"){ |
40 msidata = as(msidata, "MSImagingExperiment") | 33 msidata = as(msidata, "MSImagingExperiment") |
41 run(msidata) = "infile" | 34 run(msidata) = "infile" |
42 } | 35 } |
43 | 36 |
37 | |
44 ## remove duplicated coordinates | 38 ## remove duplicated coordinates |
45 msidata <- msidata[,!duplicated(coord(msidata))] | 39 msidata <- msidata[,!duplicated(coord(msidata))] |
40 | |
46 | 41 |
47 ## optional annotation from tabular file to obtain pixel groups (otherwise all pixels are considered to be one sample) | 42 ## optional annotation from tabular file to obtain pixel groups (otherwise all pixels are considered to be one sample) |
48 | 43 |
49 #if str($tabular_annotation.load_annotation) == 'yes_annotation': | 44 #if str($tabular_annotation.load_annotation) == 'yes_annotation': |
50 | 45 |
78 NumemptyTIC = sum(TICs == 0) | 73 NumemptyTIC = sum(TICs == 0) |
79 ## Median und sd TIC | 74 ## Median und sd TIC |
80 medTIC = round(median(TICs), digits=1) | 75 medTIC = round(median(TICs), digits=1) |
81 sdTIC = round(sd(TICs), digits=0) | 76 sdTIC = round(sd(TICs), digits=0) |
82 ## Median and sd # peaks per spectrum | 77 ## Median and sd # peaks per spectrum |
83 medpeaks = round(median(colSums(spectra(msidata)>0, na.rm=TRUE), na.rm=TRUE), digits=0) | 78 medpeaks = round(median(colSums(as.matrix(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) | 79 sdpeaks = round(sd(colSums(as.matrix(spectra(msidata))>0, na.rm=TRUE), na.rm=TRUE), digits=0) |
85 ##max window size | 80 ## max window size |
86 max_window = round(mz(msidata)[nrow(msidata)]-mz(msidata)[nrow(msidata)-1], digits=2) | 81 max_window = round(mz(msidata)[nrow(msidata)]-mz(msidata)[nrow(msidata)-1], digits=2) |
87 ## Processing informations | 82 ## Processing informations |
88 centroidedinfo = centroided(msidata) | 83 centroidedinfo = centroided(msidata) |
89 | 84 |
85 | |
90 ############## Read and filter tabular file with m/z ########################### | 86 ############## Read and filter tabular file with m/z ########################### |
91 | 87 |
92 ### reading m/z input (calibrant) file: | 88 ### reading m/z input (calibrant) file: |
93 | 89 |
94 #if $calibrant_file: | 90 #if $calibrant_file: |
95 | 91 |
96 calibrant_list = read.delim("$calibrant_file", header = $calibrant_header, na.strings=c(" ","","NA"), stringsAsFactors = FALSE) | 92 calibrant_list = read.delim("$calibrant_file", header = $calibrant_header, na.strings=c(" ","","NA"), stringsAsFactors = FALSE) |
97 calibrant_list = calibrant_list[,c($mz_column, $name_column)] | 93 calibrant_list = calibrant_list[,c($mz_column, $name_column)] |
94 calibrant_list = calibrant_list[order(calibrant_list[,1]),] | |
98 | 95 |
99 ### calculate how many input calibrant m/z are valid: | 96 ### calculate how many input calibrant m/z are valid: |
100 | 97 |
101 inputcalibrants = calibrant_list[calibrant_list[,1]>minmz & calibrant_list[,1]<maxmz,] | 98 inputcalibrants = calibrant_list[calibrant_list[,1]>minmz & calibrant_list[,1]<maxmz,] |
102 number_calibrants_in = length(calibrant_list[,1]) | 99 number_calibrants_in = length(calibrant_list[,1]) |
242 | 239 |
243 ## matrix with calibrants in columns and in rows if there is peak intensity in range or not | 240 ## matrix with calibrants in columns and in rows if there is peak intensity in range or not |
244 pixelmatrix = matrix(ncol=ncol(msidata), nrow = 0) | 241 pixelmatrix = matrix(ncol=ncol(msidata), nrow = 0) |
245 | 242 |
246 ## plot only possible when there is at least one valid calibrant | 243 ## plot only possible when there is at least one valid calibrant |
244 | |
247 if (length(inputcalibrantmasses) != 0){ | 245 if (length(inputcalibrantmasses) != 0){ |
248 | 246 |
249 ## calculate plusminus values in m/z for each calibrant | 247 ## calculate plusminus values in m/z for each calibrant |
250 plusminusvalues = rep($plusminus_ppm/1000000, length(inputcalibrantmasses))*inputcalibrantmasses | 248 plusminusvalues = rep($plusminus_ppm/1000000, length(inputcalibrantmasses))*inputcalibrantmasses |
251 | 249 |
252 ## filter for m/z window of each calibrant and calculate if sum of peak intensities > 0 | 250 ## filter for m/z window of each calibrant and calculate if sum of peak intensities > 0 |
253 | 251 |
254 for (mass in 1:length(inputcalibrantmasses)){ | 252 for (mass in 1:length(inputcalibrantmasses)){ |
255 | 253 |
256 filtered_data = msidata[mz(msidata) >= inputcalibrantmasses[mass]-plusminusvalues[mass] & mz(msidata) <= inputcalibrantmasses[mass]+plusminusvalues[mass],] | 254 filtered_data = msidata[mz(msidata) >= inputcalibrantmasses[mass]-plusminusvalues[mass] & mz(msidata) <= inputcalibrantmasses[mass]+plusminusvalues[mass],] |
257 | 255 |
258 if (nrow(filtered_data) > 0 & sum(spectra(filtered_data),na.rm=TRUE) > 0){ | 256 if (nrow(filtered_data) > 0 & sum(as.matrix(spectra(filtered_data)),na.rm=TRUE) > 0){ |
259 | 257 |
260 ## intensity of all m/z > 0 | 258 ## intensity of all m/z > 0 |
261 intensity_sum = colSums(spectra(filtered_data), na.rm=TRUE) > 0 | 259 intensity_sum = colSums(as.matrix(spectra(filtered_data)[1,]), na.rm=TRUE) > 0 |
262 | 260 |
263 ###}else if(nrow(filtered_data) == 1 & sum(spectra(filtered_data), na.rm=TRUE) > 0){ | 261 ###}else if(nrow(filtered_data) == 1 & sum(as.matrix(spectra(filtered_data)), na.rm=TRUE) > 0){ |
264 | 262 |
265 ## intensity of only m/z > 0 | 263 ## intensity of only m/z > 0 |
266 intensity_sum = colSums(spectra(filtered_data), na.rm=TRUE) > 0 | 264 intensity_sum = colSums(as.matrix(spectra(filtered_data)[1,]), na.rm=TRUE) > 0 |
267 | 265 |
268 }else{ | 266 }else{ |
269 | 267 intensity_sum = rep(FALSE, ncol(filtered_data))} |
270 intensity_sum = rep(FALSE, ncol(filtered_data))} | 268 |
271 | 269 ## for each pixel add sum of intensities > 0 in the given m/z range |
272 ## for each pixel add sum of intensities > 0 in the given m/z range | 270 pixelmatrix = rbind(pixelmatrix, intensity_sum) |
273 pixelmatrix = rbind(pixelmatrix, intensity_sum) | |
274 } | 271 } |
272 | |
275 | 273 |
276 ## for each pixel count TRUE (each calibrant m/z range with intensity > 0 is TRUE) | 274 ## for each pixel count TRUE (each calibrant m/z range with intensity > 0 is TRUE) |
277 countvector= as.factor(colSums(pixelmatrix, na.rm=TRUE)) | 275 countvector= as.factor(colSums(pixelmatrix, na.rm=TRUE)) |
278 countdf= data.frame(coord(msidata)\$x, coord(msidata)\$y, countvector) ## add pixel coordinates to counts | 276 countdf= data.frame(coord(msidata)\$x, coord(msidata)\$y, countvector) ## add pixel coordinates to counts |
279 colnames(countdf) = c("x", "y", "countvector") | 277 colnames(countdf) = c("x", "y", "countvector") |
290 | 288 |
291 ## remove countdf to clean up RAM space | 289 ## remove countdf to clean up RAM space |
292 rm(countdf) | 290 rm(countdf) |
293 gc() | 291 gc() |
294 | 292 |
295 }else{print("2) The inputcalibrant m/z were not provided or outside the m/z range")} | 293 }else{plot.new() |
294 text(0.5, 0.5, "The input calibrant m/z were not provided \n or outside the m/z range.", cex = 1.5) | |
295 print("2) The input calibrant m/z were not provided or outside the m/z range")} | |
296 | 296 |
297 ########################## 3) fold change image ########################### | 297 ########################## 3) fold change image ########################### |
298 | 298 |
299 #if $calibrantratio: | 299 #if $calibrantratio: |
300 #for $foldchanges in $calibrantratio: | 300 #for $foldchanges in $calibrantratio: |
377 ## if there are not enough intensities in the mz range skip creating an image | 377 ## if there are not enough intensities in the mz range skip creating an image |
378 print(paste0("Not enough intensities > 0 for m/z ", inputcalibrants[,1][mass])) | 378 print(paste0("Not enough intensities > 0 for m/z ", inputcalibrants[,1][mass])) |
379 } | 379 } |
380 ) | 380 ) |
381 } | 381 } |
382 } else {print("4) The input peptide and calibrant m/z were not provided or outside the m/z range")} | 382 } else {plot.new() |
383 text(0.5, 0.5, "The input peptide and calibrant m/z were not \n provided or outside the m/z range.", cex = 1.5) | |
384 print("4) The input peptide and calibrant m/z were not provided or outside the m/z range")} | |
383 | 385 |
384 #end if | 386 #end if |
385 | 387 |
386 #################### 5) Number of peaks per pixel - image ################## | 388 #################### 5) Number of peaks per pixel - image ################## |
387 | 389 |
388 ## here every intensity value > 0 counts as peak | 390 ## here every intensity value > 0 counts as peak |
389 peaksperpixel = colSums(spectra(msidata)> 0, na.rm=TRUE) | 391 peaksperpixel = colSums(int_matrix> 0, na.rm=TRUE) |
390 peakscoordarray=data.frame(coord(msidata)\$x, coord(msidata)\$y, peaksperpixel) | 392 peakscoordarray=data.frame(coord(msidata)\$x, coord(msidata)\$y, peaksperpixel) |
391 colnames(peakscoordarray) = c("x", "y", "peaksperpixel") | 393 colnames(peakscoordarray) = c("x", "y", "peaksperpixel") |
392 | 394 |
393 print(ggplot(peakscoordarray, aes(x=x, y=y, fill=peaksperpixel))+ | 395 print(ggplot(peakscoordarray, aes(x=x, y=y, fill=peaksperpixel))+ |
394 geom_tile() + coord_fixed() + | 396 geom_tile() + coord_fixed() + |
493 gc() | 495 gc() |
494 | 496 |
495 #end if | 497 #end if |
496 | 498 |
497 ########################## 8) optional pca image for two components ################# | 499 ########################## 8) optional pca image for two components ################# |
498 | 500 ### PCA removed until next Update |
499 #if $do_pca: | 501 ####if $do_pca: |
500 | 502 |
501 set.seed(1) | 503 set.seed(1) |
502 pca = PCA(msidata, ncomp=2) | 504 ##pca = PCA(msidata, ncomp=2) |
503 | 505 |
504 ## plot overview image and plot and PC1 and 2 images | 506 ## plot overview image and plot and PC1 and 2 images |
505 print(plot(pca, col=c("black", "darkgrey"), main="PCA for two components", layout=c(2,1), strip=FALSE)) | 507 ##print(plot(pca, col=c("black", "darkgrey"), main="PCA for two components", layout=c(2,1), strip=FALSE)) |
506 print(image(pca, run="infile", col=c("black", "white"), strip=FALSE, ylim= c(maximumy+0.2*maximumy,minimumy-1), layout=FALSE)) | 508 ##print(image(pca, run="infile", col=c("black", "white"), strip=FALSE, ylim= c(maximumy+0.2*maximumy,minimumy-1), layout=FALSE)) |
507 | 509 |
508 par(oma=c(0,0,0,1))## margin for image legend | 510 ##par(oma=c(0,0,0,1))## margin for image legend |
509 print(image(pca, column = "PC1" , strip=FALSE, superpose = FALSE, main="PC1", col.regions = risk.colors(100), layout=c(2,1), ylim= c(maximumy+0.2*maximumy,minimumy-1))) | 511 ##print(image(pca, column = "PC1" , strip=FALSE, superpose = FALSE, main="PC1", col.regions = risk.colors(100), layout=c(2,1), ylim= c(maximumy+0.2*maximumy,minimumy-1))) |
510 print(image(pca, column = "PC2" , strip=FALSE, superpose = FALSE, main="PC2", col.regions = risk.colors(100), layout=FALSE, ylim= c(maximumy+0.2*maximumy,minimumy-1))) | 512 ##print(image(pca, column = "PC2" , strip=FALSE, superpose = FALSE, main="PC2", col.regions = risk.colors(100), layout=FALSE, ylim= c(maximumy+0.2*maximumy,minimumy-1))) |
511 ## remove pca to clean up space | 513 ## remove pca to clean up space |
512 rm(pca) | 514 ##rm(pca) |
513 gc() | 515 ##gc() |
514 | 516 |
515 #end if | 517 ####end if |
516 | 518 |
517 ################## III) properties over spectra index ###################### | 519 ################## III) properties over spectra index ###################### |
518 ############################################################################ | 520 ############################################################################ |
519 print("properties over pixels") | 521 print("properties over pixels") |
520 par(mfrow = c(2,1), mar=c(5,6,4,2)) | 522 par(mfrow = c(2,1), mar=c(5,6,4,2)) |
610 | 612 |
611 ########################## 12) Number of peaks per m/z ##################### | 613 ########################## 12) Number of peaks per m/z ##################### |
612 | 614 |
613 #if $report_depth: | 615 #if $report_depth: |
614 | 616 |
615 peakspermz = rowSums(spectra(msidata) > 0, na.rm=TRUE) | 617 peakspermz = rowSums(int_matrix > 0, na.rm=TRUE) |
616 | 618 |
617 par(mfrow = c(2,1), mar=c(5,6,4,4.5)) | 619 par(mfrow = c(2,1), mar=c(5,6,4,4.5)) |
618 ## 12a) scatterplot | 620 ## 12a) scatterplot |
619 plot_colorByDensity(mz(msidata),peakspermz, main= "Number of peaks per m/z", ylab ="") | 621 plot_colorByDensity(mz(msidata),peakspermz, main= "Number of peaks per m/z", ylab ="") |
620 title(xlab="m/z", line=2.5) | 622 title(xlab="m/z", line=2.5) |
663 ## 14b) histogram: | 665 ## 14b) histogram: |
664 hist(int_matrix, main="", xlab = "", ylab="", las=1) | 666 hist(int_matrix, main="", xlab = "", ylab="", las=1) |
665 title(main="Intensity histogram", line=2) | 667 title(main="Intensity histogram", line=2) |
666 title(xlab="intensities") | 668 title(xlab="intensities") |
667 title(ylab="Frequency", line=4) | 669 title(ylab="Frequency", line=4) |
668 abline(v=median(int_matrix)[(as.matrix(spectra(msidata))>0)], col="blue") | 670 abline(v=median(int_matrix)[(int_matrix>0)], col="blue") |
669 | 671 |
670 #end if | 672 #end if |
671 | 673 |
672 ## 14c) histogram to show contribution of annotation groups | 674 ## 14c) histogram to show contribution of annotation groups |
673 | 675 |
674 if (!is.null(unique(msidata\$annotation))){ | 676 if (!is.null(unique(msidata\$annotation))){ |
675 | 677 |
676 df_13 = data.frame(matrix(,ncol=2, nrow=0)) | 678 df_13 = data.frame(matrix(,ncol=2, nrow=0)) |
677 for (subsample in unique(msidata\$annotation)){ | 679 for (subsample in unique(msidata\$annotation)){ |
678 log2_int_subsample = spectra(msidata)[,msidata\$annotation==subsample] | 680 log2_int_subsample = int_matrix[,msidata\$annotation==subsample] |
679 df_subsample = data.frame(as.numeric(log2_int_subsample)) | 681 df_subsample = data.frame(as.numeric(log2_int_subsample)) |
680 df_subsample\$annotation = subsample | 682 df_subsample\$annotation = subsample |
681 df_13 = rbind(df_13, df_subsample)} | 683 df_13 = rbind(df_13, df_subsample)} |
682 df_13\$annotation = as.factor(df_13\$annotation) | 684 df_13\$annotation = as.factor(df_13\$annotation) |
683 colnames(df_13) = c("int", "annotation") | 685 colnames(df_13) = c("int", "annotation") |
696 ## 14d) boxplots to visualize in a different way the intensity distributions | 698 ## 14d) boxplots to visualize in a different way the intensity distributions |
697 par(mfrow = c(1,1), cex.axis=1.3, cex.lab=1.3, mar=c(10,4.1,5.1,2.1)) | 699 par(mfrow = c(1,1), cex.axis=1.3, cex.lab=1.3, mar=c(10,4.1,5.1,2.1)) |
698 | 700 |
699 mean_matrix = matrix(,ncol=0, nrow = nrow(msidata)) | 701 mean_matrix = matrix(,ncol=0, nrow = nrow(msidata)) |
700 for (subsample in unique(msidata\$annotation)){ | 702 for (subsample in unique(msidata\$annotation)){ |
701 mean_mz_sample = rowMeans(spectra(msidata)[,msidata\$annotation==subsample],na.rm=TRUE) | 703 mean_mz_sample = rowMeans(int_matrix[,msidata\$annotation==subsample],na.rm=TRUE) |
702 mean_matrix = cbind(mean_matrix, mean_mz_sample)} | 704 mean_matrix = cbind(mean_matrix, mean_mz_sample)} |
703 | 705 |
704 boxplot(log10(as.data.frame(mean_matrix)), ylab = "Log10 mean intensity per m/z", main="Log10 mean m/z intensities per annotation group", xaxt = "n") | 706 boxplot(log10(as.data.frame(mean_matrix)), ylab = "Log10 mean intensity per m/z", main="Log10 mean m/z intensities per annotation group", xaxt = "n") |
705 (axis(1, at = c(1:number_combined), cex.axis=0.9, labels=unique(msidata\$annotation), las=2)) | 707 (axis(1, at = c(1:number_combined), cex.axis=0.9, labels=unique(msidata\$annotation), las=2)) |
706 | 708 |
707 ## 14e) Heatmap of mean intensities of annotation groups | 709 ## 14e) Heatmap of mean intensities of annotation groups |
708 | 710 |
709 colnames(mean_matrix) = unique(msidata\$annotation) | 711 colnames(mean_matrix) = unique(msidata\$annotation) |
712 print(mean_matrix) | |
713 | |
710 mean_matrix[is.na(mean_matrix)] = 0 | 714 mean_matrix[is.na(mean_matrix)] = 0 |
711 heatmap.parameters <- list(mean_matrix, | 715 heatmap.parameters <- list(mean_matrix, |
712 show_rownames = T, show_colnames = T, | 716 show_rownames = T, show_colnames = T, |
713 main = "Heatmap of mean intensities per annotation group") | 717 main = "Heatmap of mean intensities per annotation group") |
714 par(oma=c(5,0,0,0)) | 718 par(oma=c(5,0,0,0)) |
805 | 809 |
806 | 810 |
807 ### find m/z with the highest mean intensity in m/z range (red line in plot 16) and calculate ppm difference for plot 17 | 811 ### find m/z with the highest mean intensity in m/z range (red line in plot 16) and calculate ppm difference for plot 17 |
808 filtered_data = msidata_no_NA[mz(msidata_no_NA) >= inputcalibrantmasses[mass]-plusminusvalues[mass] & mz(msidata_no_NA) <= inputcalibrantmasses[mass]+plusminusvalues[mass],] | 812 filtered_data = msidata_no_NA[mz(msidata_no_NA) >= inputcalibrantmasses[mass]-plusminusvalues[mass] & mz(msidata_no_NA) <= inputcalibrantmasses[mass]+plusminusvalues[mass],] |
809 | 813 |
810 if (nrow(filtered_data) > 0 & sum(spectra(filtered_data)) > 0){ | 814 if (nrow(filtered_data) > 0 & sum(as.matrix(spectra(filtered_data))) > 0){ |
811 maxmassrow = featureApply(filtered_data, mean) ## for each m/z average intensity is calculated | 815 maxmassrow = featureApply(filtered_data, mean) ## for each m/z average intensity is calculated |
812 maxvalue = mz(filtered_data)[which.max(maxmassrow)] ### m/z with highest average intensity in m/z range | 816 maxvalue = mz(filtered_data)[which.max(maxmassrow)] ### m/z with highest average intensity in m/z range |
813 mzdifference = maxvalue - inputcalibrantmasses[mass] ### difference: theoretical value - closest m/z value | 817 mzdifference = maxvalue - inputcalibrantmasses[mass] ### difference: theoretical value - closest m/z value |
814 ppmdifference = mzdifference/inputcalibrantmasses[mass]*1000000 ### calculate ppm for accuracy measurement | 818 ppmdifference = mzdifference/inputcalibrantmasses[mass]*1000000 ### calculate ppm for accuracy measurement |
815 }else{ | 819 }else{ |
832 abline(v=c(inputcalibrantmasses[mass] -plusminusvalues[count], inputcalibrantmasses[mass] ,inputcalibrantmasses[mass] +plusminusvalues[count]), col="blue", lty=c(3,5,3)) | 836 abline(v=c(inputcalibrantmasses[mass] -plusminusvalues[count], inputcalibrantmasses[mass] ,inputcalibrantmasses[mass] +plusminusvalues[count]), col="blue", lty=c(3,5,3)) |
833 abline(v=c(maxvalue), col="red", lty=2) | 837 abline(v=c(maxvalue), col="red", lty=2) |
834 abline(v=c(mzvalue), col="green2", lty=4) | 838 abline(v=c(mzvalue), col="green2", lty=4) |
835 ## average plot including points per data point | 839 ## average plot including points per data point |
836 print(plot(msidata_no_NA[minmasspixel1:maxmasspixel1,], run="infile", layout=FALSE, strip=FALSE, main="Average spectrum with data points", col="black")) | 840 print(plot(msidata_no_NA[minmasspixel1:maxmasspixel1,], run="infile", layout=FALSE, strip=FALSE, main="Average spectrum with data points", col="black")) |
837 points(mz(msidata_no_NA[minmasspixel1:maxmasspixel1,]), rowMeans(spectra(msidata_no_NA)[minmasspixel1:maxmasspixel1,,drop=FALSE]), col="blue", pch=20) | 841 points(mz(msidata_no_NA[minmasspixel1:maxmasspixel1,]), rowMeans(as.matrix(spectra(msidata_no_NA))[minmasspixel1:maxmasspixel1,,drop=FALSE]), col="blue", pch=20) |
838 ## plot of third average plot | 842 ## plot of third average plot |
839 print(plot(msidata_no_NA[minmasspixel2:maxmasspixel2,], run="infile", layout=FALSE, strip=FALSE, main= "Average spectrum", col="black")) | 843 print(plot(msidata_no_NA[minmasspixel2:maxmasspixel2,], run="infile", layout=FALSE, strip=FALSE, main= "Average spectrum", col="black")) |
840 abline(v=c(inputcalibrantmasses[mass] -plusminusvalues[count], inputcalibrantmasses[mass] ,inputcalibrantmasses[mass] +plusminusvalues[count]), col="blue", lty=c(3,5,3)) | 844 abline(v=c(inputcalibrantmasses[mass] -plusminusvalues[count], inputcalibrantmasses[mass] ,inputcalibrantmasses[mass] +plusminusvalues[count]), col="blue", lty=c(3,5,3)) |
841 abline(v=c(maxvalue), col="red", lty=2) | 845 abline(v=c(maxvalue), col="red", lty=2) |
842 abline(v=c(mzvalue), col="green2", lty=4) | 846 abline(v=c(mzvalue), col="green2", lty=4) |
910 print(diff_plot2) | 914 print(diff_plot2) |
911 | 915 |
912 #end if | 916 #end if |
913 | 917 |
914 #################### 19) ppm difference over pixels ##################### | 918 #################### 19) ppm difference over pixels ##################### |
919 print("ppm difference over pixels") | |
915 | 920 |
916 par(mfrow = c(1,1)) | 921 par(mfrow = c(1,1)) |
917 count = 1 | 922 count = 1 |
918 ppm_df = as.data.frame(matrix(,ncol=0, nrow = ncol(msidata))) | 923 ppm_df = as.data.frame(matrix(,ncol=0, nrow = ncol(msidata))) |
924 | |
919 for (calibrant in inputcalibrantmasses){ | 925 for (calibrant in inputcalibrantmasses){ |
920 ### find m/z with the highest mean intensity in m/z range, if no m/z in the range, ppm differences for this calibrant will be NA | 926 ### find m/z with the highest mean intensity in m/z range, if no m/z in the range, ppm differences for this calibrant will be NA |
921 filtered_data = msidata[mz(msidata) >= calibrant-plusminusvalues[count] & mz(msidata) <= calibrant+plusminusvalues[count],] | 927 filtered_data = msidata[mz(msidata) >= calibrant-plusminusvalues[count] & mz(msidata) <= calibrant+plusminusvalues[count],] |
922 | 928 |
923 if (nrow(filtered_data) > 0){ | 929 if (nrow(filtered_data) > 0){ |
976 theme(text=element_text(family="ArialMT", face="bold", size=12))+ | 982 theme(text=element_text(family="ArialMT", face="bold", size=12))+ |
977 scale_fill_gradient2(low = "navy", mid = "grey", high = "red", midpoint = 0 ,space = "Lab", na.value = "black", name = "ppm\nerror"))} | 983 scale_fill_gradient2(low = "navy", mid = "grey", high = "red", midpoint = 0 ,space = "Lab", na.value = "black", name = "ppm\nerror"))} |
978 | 984 |
979 #end if | 985 #end if |
980 | 986 |
981 }else{print("plot 16+17+18+19) The inputcalibrant m/z were not provided or outside the m/z range")} | 987 }else{ |
988 plot.new() | |
989 text(0.5, 0.5, "plot 16+17+18+19) The input calibrant m/z were not provided \n or outside the m/z range", cex = 1.5) | |
990 print("plot 16+17+18+19) The input calibrant m/z were not provided or outside the m/z range")} | |
982 }else{ | 991 }else{ |
983 print("inputfile has no intensities > 0") | 992 plot.new() |
993 text(0.5, 0.5, "The input file has no intensities > 0", cex = 1.5) | |
994 print("input file has no intensities > 0") | |
984 } | 995 } |
985 dev.off() | 996 dev.off() |
986 | 997 |
987 | 998 |
988 ]]></configfile> | 999 ]]></configfile> |
1000 <when value="no_annotation"/> | 1011 <when value="no_annotation"/> |
1001 </conditional> | 1012 </conditional> |
1002 <expand macro="pdf_filename"/> | 1013 <expand macro="pdf_filename"/> |
1003 <expand macro="reading_2_column_mz_tabular" optional="true"/> | 1014 <expand macro="reading_2_column_mz_tabular" optional="true"/> |
1004 <param name="plusminus_ppm" value="200" type="float" label="ppm range" help="Will be added in both directions to input calibrant m/z"/> | 1015 <param name="plusminus_ppm" value="200" type="float" label="ppm range" help="Will be added in both directions to input calibrant m/z"/> |
1005 <param name="do_pca" type="boolean" label="PCA with 2 components"/> | 1016 <!--param name="do_pca" type="boolean" label="PCA with 2 components"/--> |
1006 <param name="report_depth" type="boolean" label="Generate full QC report" truevalue="TRUE" falsevalue="FALSE" checked="True" help="No: does not generate all plots but only the most informatives"/> | 1017 <param name="report_depth" type="boolean" label="Generate full QC report" truevalue="TRUE" falsevalue="FALSE" checked="True" help="No: does not generate all plots but only the most informatives"/> |
1007 <repeat name="calibrantratio" title="Plot fold change of two m/z" min="0" max="10"> | 1018 <repeat name="calibrantratio" title="Plot fold change of two m/z" min="0" max="10"> |
1008 <param name="mass1" value="1111" type="float" label="M/z 1" help="First m/z"/> | 1019 <param name="mass1" value="1111" type="float" label="M/z 1" help="First m/z"/> |
1009 <param name="mass2" value="2222" type="float" label="M/z 2" help="Second m/z"/> | 1020 <param name="mass2" value="2222" type="float" label="M/z 2" help="Second m/z"/> |
1010 <param name="distance" value="200" type="float" label="ppm range" help="Will be added in both directions to input calibrant m/z and intensities will be averaged in this range."/> | 1021 <param name="distance" value="200" type="float" label="ppm range" help="Will be added in both directions to input calibrant m/z and intensities will be averaged in this range."/> |
1038 <param name="calibrant_file" value="inputcalibrantfile1.tabular" ftype="tabular"/> | 1049 <param name="calibrant_file" value="inputcalibrantfile1.tabular" ftype="tabular"/> |
1039 <param name="mz_column" value="1"/> | 1050 <param name="mz_column" value="1"/> |
1040 <param name="name_column" value="1"/> | 1051 <param name="name_column" value="1"/> |
1041 <param name="plusminus_ppm" value="100"/> | 1052 <param name="plusminus_ppm" value="100"/> |
1042 <param name="filename" value="Testfile_imzml"/> | 1053 <param name="filename" value="Testfile_imzml"/> |
1043 <param name="do_pca" value="True"/> | 1054 <!--param name="do_pca" value="True"/--> |
1044 <repeat name="calibrantratio"> | 1055 <repeat name="calibrantratio"> |
1045 <param name="mass1" value="328.9"/> | 1056 <param name="mass1" value="328.9"/> |
1046 <param name="mass2" value="398.8"/> | 1057 <param name="mass2" value="398.8"/> |
1047 <param name="distance" value="500"/> | 1058 <param name="distance" value="500"/> |
1048 <param name="filenameratioplot" value = "Ratio of mz 328.9 and mz 398.8"/> | 1059 <param name="filenameratioplot" value = "Ratio of mz 328.9 and mz 398.8"/> |
1053 <expand macro="infile_analyze75"/> | 1064 <expand macro="infile_analyze75"/> |
1054 <conditional name="tabular_annotation"> | 1065 <conditional name="tabular_annotation"> |
1055 <param name="load_annotation" value="no_annotation"/> | 1066 <param name="load_annotation" value="no_annotation"/> |
1056 </conditional> | 1067 </conditional> |
1057 <param name="filename" value="Testfile_analyze75"/> | 1068 <param name="filename" value="Testfile_analyze75"/> |
1058 <param name="do_pca" value="True"/> | 1069 <!--param name="do_pca" value="True"/--> |
1059 <output name="QC_report" file="QC_analyze75.pdf" compare="sim_size"/> | 1070 <output name="QC_report" file="QC_analyze75.pdf" compare="sim_size"/> |
1060 </test> | 1071 </test> |
1061 <test> | 1072 <test> |
1062 <param name="infile" value="3_files_combined.RData" ftype="rdata"/> | 1073 <param name="infile" value="3_files_combined.RData" ftype="rdata"/> |
1063 <conditional name="tabular_annotation"> | 1074 <conditional name="tabular_annotation"> |
1071 <param name="calibrant_file" value="inputcalibrantfile1.tabular" ftype="tabular"/> | 1082 <param name="calibrant_file" value="inputcalibrantfile1.tabular" ftype="tabular"/> |
1072 <param name="mz_column" value="1"/> | 1083 <param name="mz_column" value="1"/> |
1073 <param name="name_column" value="1"/> | 1084 <param name="name_column" value="1"/> |
1074 <param name="plusminus_ppm" value="100"/> | 1085 <param name="plusminus_ppm" value="100"/> |
1075 <param name="filename" value="Testfile_rdata"/> | 1086 <param name="filename" value="Testfile_rdata"/> |
1076 <param name="do_pca" value="True"/> | 1087 <!--param name="do_pca" value="True"/--> |
1077 <output name="QC_report" file="QC_rdata.pdf" compare="sim_size"/> | 1088 <output name="QC_report" ftype="pdf"> |
1089 <assert_contents> | |
1090 <has_size value="1276311" delta="100"/> | |
1091 </assert_contents> | |
1092 </output> | |
1078 </test> | 1093 </test> |
1079 <test> | 1094 <test> |
1080 <param name="infile" value="empty_spectra.rdata" ftype="rdata"/> | 1095 <param name="infile" value="empty_spectra.rdata" ftype="rdata"/> |
1081 <conditional name="tabular_annotation"> | 1096 <conditional name="tabular_annotation"> |
1082 <param name="load_annotation" value="no_annotation"/> | 1097 <param name="load_annotation" value="no_annotation"/> |
1083 </conditional> | 1098 </conditional> |
1084 <param name="calibrant_file" value="inputcalibrantfile2.txt"/> | 1099 <param name="calibrant_file" value="inputcalibrantfile2.txt"/> |
1085 <param name="mz_column" value="1"/> | 1100 <param name="mz_column" value="1"/> |
1086 <param name="name_column" value="2"/> | 1101 <param name="name_column" value="2"/> |
1087 <param name="filename" value="Testfile_rdata"/> | 1102 <param name="filename" value="Testfile_rdata"/> |
1088 <param name="do_pca" value="False"/> | 1103 <!--param name="do_pca" value="False"/--> |
1089 <output name="QC_report" file="QC_empty_spectra.pdf" compare="sim_size"/> | 1104 <output name="QC_report" file="QC_empty_spectra.pdf" compare="sim_size"/> |
1090 </test> | 1105 </test> |
1091 <test> | 1106 <test> |
1092 <param name="infile" value="" ftype="imzml"> | 1107 <param name="infile" value="" ftype="imzml"> |
1093 <composite_data value="Example_Processed.imzML"/> | 1108 <composite_data value="Example_Processed.imzML"/> |