# HG changeset patch # User galaxyp # Date 1519910748 18000 # Node ID fef8bd5512368fdd9d15e73ff6ee60c651791620 # Parent f6aa0cff777c9a07c1b2b793f4a46e9660457712 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/msi_qualitycontrol commit edbf2a6cb50fb04d0db56a7557a64e3bb7a0806a diff -r f6aa0cff777c -r fef8bd551236 msi_qualitycontrol.xml --- a/msi_qualitycontrol.xml Sat Feb 24 12:48:28 2018 -0500 +++ b/msi_qualitycontrol.xml Thu Mar 01 08:25:48 2018 -0500 @@ -1,4 +1,4 @@ - + mass spectrometry imaging QC @@ -34,41 +34,17 @@ library(gridExtra) library(KernSmooth) -## Read MALDI Imagind dataset +## Read MALDI Imaging dataset #if $infile.ext == 'imzml' - msidata <- readMSIData('infile.imzML') + msidata = readMSIData('infile.imzML') #elif $infile.ext == 'analyze75' - msidata <- readMSIData('infile.hdr') + msidata = readMSIData('infile.hdr') #else load('infile.RData') #end if -#if $inputpeptidefile: - ### Read tabular file with peptide masses for plots and heatmap images: - input_list = read.delim("$inputpeptidefile", header = FALSE, na.strings=c("","NA", "#NUM!", "#ZAHL!"), stringsAsFactors = FALSE) - if (ncol(input_list) == 1) - { - input_list = cbind(input_list, input_list) - } -#else - input_list = data.frame(0, 0) -#end if -colnames(input_list)[1:2] = c("mz", "name") - -#if $inputcalibrants: - ### Read tabular file with calibrant masses: - calibrant_list = read.delim("$inputcalibrants", header = FALSE, na.strings=c("","NA", "#NUM!", "#ZAHL!"), stringsAsFactors = FALSE) - if (ncol(calibrant_list) == 1) - { - calibrant_list = cbind(calibrant_list, calibrant_list) - } -#else - calibrant_list = data.frame(0,0) -#end if - -colnames(calibrant_list)[1:2] = c("mz", "name") ###################################### file properties in numbers ###################### @@ -131,11 +107,47 @@ peakpickinginfo=processinginfo@peakPicking } -### calculate how many input peptide masses are valid: -inputpeptides = input_list[input_list[,1]>minmz & input_list[,1]minmz & input_list[,1]minmz & calibrant_list[,1]minmz & calibrant_list[,1]0)) countdf= cbind(coord(msidata), countvector) - mycolours = c("black","grey", "darkblue", "blue", "green" , "red", "yellow", "magenta", "olivedrap1", "lightseagreen") + mycolours = c("black","grey", "darkblue", "blue", "green" , "red", "yellow", "magenta", "olivedrab1", "lightseagreen") print(ggplot(countdf, aes(x=x, y=y, fill=countvector)) + geom_tile() + coord_fixed() @@ -276,7 +283,7 @@ + theme(text=element_text(family="ArialMT", face="bold", size=12)) + scale_fill_manual(values = mycolours[1:length(countvector)], na.value = "black", name = "# calibrants")) - }else{print("2) The inputcalibrant masses were outside the mass range")} + }else{print("2) The inputcalibrant masses were not provided or outside the mass range")} ############# new 2b) image of foldchanges (log2 intensity ratios) between two masses in the same spectrum @@ -306,25 +313,24 @@ mzdown2 = features(msidata, mz = mass2-2) mzup2 = features(msidata, mz = mass2+3) - ### plot the part which was chosen, with chosen value in blue, distance in blue, maxmass in red, xlim fixed to 5 Da window + ### find mass in the given range with the highest intensity (will be plotted in red) if (mzrowdown1 == mzrowup1) { - maxmassrow1 = spectra(msidata)[mzrowup1,] - maxmass1 = mz(msidata)[mzrowup1][which.max(maxmassrow1)] - }else{ + maxmass1 = mz(msidata)[ mzrowdown1] + }else{ ### for all masses in the massrange calculate mean intensity over all pixels and take mass which has highest mean maxmassrow1 = rowMeans(spectra(msidata)[mzrowdown1:mzrowup1,]) - maxmass1 = mz(msidata)[mzrowdown1:mzrowup1][which.max(maxmassrow1)] + maxmass1 = mz(msidata)[mzrowdown1:mzrowup1][which.max(maxmassrow1)] } if (mzrowdown2 == mzrowup2) { - maxmassrow2 = spectra(msidata)[mzrowup2,] - maxmass2 = mz(msidata)[mzrowup2][which.max(maxmassrow2)] + maxmass2 = mz(msidata)[mzrowup2] }else{ maxmassrow2 = rowMeans(spectra(msidata)[mzrowdown2:mzrowup2,]) maxmass2 = mz(msidata)[mzrowdown2:mzrowup2][which.max(maxmassrow2)] } + ### plot the part which was chosen, with chosen value in blue, distance in blue, maxmass in red, xlim fixed to 5 Da window par(mfrow=c(2,1), oma=c(0,0,2,0)) plot(msidata[mzdown1:mzup1,], pixel = 1:pixelcount, main=paste0("average spectrum ", mass1, " Da")) abline(v=c(mass1-distance, mass1, mass1+distance), col="blue",lty=c(3,5,3)) @@ -339,7 +345,6 @@ mass1vector = spectra(msidata)[features(msidata, mz = maxmass1),] mass2vector = spectra(msidata)[features(msidata, mz = maxmass2),] - foldchange = log2(mass1vector/mass2vector) ratiomatrix = cbind(foldchange, coord(msidata)) @@ -360,9 +365,9 @@ if (length(inputmasses) != 0) { for (mass in 1:length(inputmasses)) { - image(msidata, mz=inputmasses[mass], plusminus=$plusminusinDalton, - main= paste0("3", LETTERS[mass], ") ", inputnames[mass], " (", round(inputmasses[mass], digits = 2)," ± ", $plusminusinDalton, " Da)"), - contrast.enhance = "histogram", ylim=c(maxy+1, 0)) + image(msidata, mz=inputmasses[mass], plusminus=$plusminus_dalton, + main= paste0("3", LETTERS[mass], ") ", inputnames[mass], " (", round(inputmasses[mass], digits = 2)," ± ", $plusminus_dalton, " Da)"), + contrast.enhance = "histogram", ylim=c(maximumy+2, 0)) } } else {print("3) The inputpeptide masses were outside the mass range")} @@ -381,7 +386,7 @@ ## 5) TIC image TICcoordarray=cbind(coord(msidata), TICs) - colo <- colorRampPalette( + colo = colorRampPalette( c("blue", "cyan", "green", "yellow","red")) print(ggplot(TICcoordarray, aes(x=x, y=y, fill=TICs), colour=colo) + geom_tile() + coord_fixed() @@ -414,10 +419,10 @@ secondhighestmz_pixel = which(round(highestmz_matrix\$highestmzinDa, digits=0) == secondhighestmz)[1] ## 7) pca image for two components - pca <- PCA(msidata, ncomp=2) + pca = PCA(msidata, ncomp=2) par(mfrow = c(2,1)) plot(pca, col=c("black", "darkgrey"), main="7) PCA for two components") - image(pca, col=c("black", "white"),ylim=c(maxy+1, 0)) + image(pca, col=c("black", "white"),ylim=c(maximumy+2, 0)) ############################# III) properties over acquisition (spectra index)########## @@ -436,7 +441,7 @@ title(ylab="Frequency = # spectra", line=4) abline(v=median(peaksperpixel), col="blue") - ## 9a) TIC per spectrum - density scatterplot + ## 9a) TIC per spectrum - density scatterplot zero=0 par(mfrow = c(2,1), mar=c(5,6,4,2)) plot_colorByDensity(pixels(msidata), TICs, ylab = "", xlab = "", main="9a) TIC per pixel") @@ -533,7 +538,7 @@ plot(msidata, pixel = secondhighestmz_pixel, main= paste0("Spectrum at ", rownames(coord(msidata)[secondhighestmz_pixel,]))) ## 15) Zoomed in mass spectra for calibrants - plusminusvalue = $plusminusinDalton + plusminusvalue = $plusminus_dalton x = 1 if (length(inputcalibrantmasses) != 0) { @@ -545,7 +550,7 @@ par(mfrow = c(2, 2), oma=c(0,0,2,0)) plot(msidata[minmasspixel:maxmasspixel,], pixel = 1:length(pixelnumber), main= "average spectrum") abline(v=c(calibrant-plusminusvalue, calibrant,calibrant+plusminusvalue), col="blue", lty=c(3,5,3)) - plot(msidata[minmasspixel:maxmasspixel,], pixel =round(pixelnumber/2, digits=0), main="pixel in middle of acquisition") + plot(msidata[minmasspixel:maxmasspixel,], pixel =round(length(pixelnumber)/2, digits=0), main="pixel in middle of acquisition") abline(v=c(calibrant-plusminusvalue, calibrant,calibrant+plusminusvalue), col="blue", lty=c(3,5,3)) plot(msidata[minmasspixel:maxmasspixel,], pixel = highestmz_pixel,main= paste0("Spectrum at ", rownames(coord(msidata)[highestmz_pixel,]))) abline(v=c(calibrant-plusminusvalue, calibrant,calibrant+plusminusvalue), col="blue", lty=c(3,5,3)) @@ -569,12 +574,12 @@ - - - + @@ -592,14 +597,15 @@ - - - + + + + @@ -610,34 +616,34 @@ - - - + + + - - - + + + - - - + + + diff -r f6aa0cff777c -r fef8bd551236 test-data/LM8_file16.rdata diff -r f6aa0cff777c -r fef8bd551236 test-data/LM8_file16output.pdf Binary file test-data/LM8_file16output.pdf has changed diff -r f6aa0cff777c -r fef8bd551236 test-data/Testfile_qualitycontrol_analyze75.pdf Binary file test-data/Testfile_qualitycontrol_analyze75.pdf has changed diff -r f6aa0cff777c -r fef8bd551236 test-data/Testfile_qualitycontrol_imzml.pdf Binary file test-data/Testfile_qualitycontrol_imzml.pdf has changed diff -r f6aa0cff777c -r fef8bd551236 test-data/Testfile_qualitycontrol_rdata.pdf Binary file test-data/Testfile_qualitycontrol_rdata.pdf has changed