# HG changeset patch # User galaxyp # Date 1606693508 0 # Node ID 6b36be80febb83700e8aea9560ec7edf43df7515 # Parent e0669b1854b16905b222ad81f4cd243ed27909e8 "planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit 39bd480e8813fa7a96b640150365577a69885d17-dirty" diff -r e0669b1854b1 -r 6b36be80febb preprocessing.xml --- a/preprocessing.xml Thu Oct 22 20:38:29 2020 +0000 +++ b/preprocessing.xml Sun Nov 29 23:45:08 2020 +0000 @@ -1,4 +1,4 @@ - + mass spectrometry imaging preprocessing @@ -47,7 +47,6 @@ ## remove duplicated coordinates, otherwise peak picking and log2 transformation will fail -msidata <- msidata[,!duplicated(coord(msidata)[,1:2])] ## set variable to False #set $used_peak_picking = False @@ -135,24 +134,29 @@ print('gaussian smoothing') msidata = smoothSignal(msidata, method="$method.methods_conditional.methods_for_smoothing.smoothing_method", window=$method.methods_conditional.window_smoothing, sd = $method.methods_conditional.methods_for_smoothing.sd_gaussian) + msidata <- process(msidata, BPPARAM=MulticoreParam(workers=number_cpu)) #elif str( $method.methods_conditional.methods_for_smoothing.smoothing_method) == 'sgolay': print('sgolay smoothing') msidata = smoothSignal(msidata, method="$method.methods_conditional.methods_for_smoothing.smoothing_method", window=$method.methods_conditional.window_smoothing, order = $method.methods_conditional.methods_for_smoothing.order_of_filters) + msidata <- process(msidata, BPPARAM=MulticoreParam(workers=number_cpu)) ## if selected replace negative intensities with zero #if $method.methods_conditional.methods_for_smoothing.replace_negatives: - spectra(msidata)[spectra(msidata)<0] = 0 + ## bring spectra matrix to disk + spectra_df = as.matrix(spectra(msidata)) + spectra_df[spectra_df<0] = 0 + spectra(msidata) = spectra_df #end if #elif str($method.methods_conditional.methods_for_smoothing.smoothing_method) == 'ma': print('moving average smoothing') msidata = smoothSignal(msidata, method="$method.methods_conditional.methods_for_smoothing.smoothing_method", window=$method.methods_conditional.window_smoothing, coef = $method.methods_conditional.methods_for_smoothing.coefficients_ma_filter) + msidata <- process(msidata, BPPARAM=MulticoreParam(workers=number_cpu)) #end if - msidata <- process(msidata, BPPARAM=MulticoreParam(workers=number_cpu)) ############################### QC ########################### @@ -170,7 +174,7 @@ ############################### Mz alignment ########################### #elif str( $method.methods_conditional.preprocessing_method ) == 'mz_alignment': - print('M/z alignment') + print('m/z alignment') ## M/z alignment #if str( $method.methods_conditional.mzalign_ref_type.align_reference_datatype) == 'align_table': @@ -183,7 +187,7 @@ #elif str( $method.methods_conditional.mzalign_ref_type.align_reference_datatype) == 'align_noref': - msidata = mzAlign(msidata,tolerance = $method.methods_conditional.alignment_tol, units = "$method.methods_conditional.alignment_units", , quantile = $method.methods_conditional.quantile, span = $method.methods_conditional.span) + msidata = mzAlign(msidata,tolerance = $method.methods_conditional.alignment_tol, units = "$method.methods_conditional.alignment_units", quantile = $method.methods_conditional.quantile, span = $method.methods_conditional.span) #end if @@ -332,23 +336,23 @@ #elif str( $method.methods_conditional.preprocessing_method) == 'Mass_binning': print('mass binning') - #if str( $method.methods_conditional.mz_range.features_filtering) == 'change_mz_range': - - #if str($processed_cond.processed_file) == "processed": + #if str($method.methods_conditional.mz_range.features_filtering) == 'change_mz_range': msidata = mse_bin = mzBin(msidata,resolution=$method.methods_conditional.bin_width, from=$method.methods_conditional.mz_range.min_mz, to=$method.methods_conditional.mz_range.max_mz, units="$method.methods_conditional.bin_units", fun="$method.methods_conditional.bin_fun") - - #else - ## continuous file cannot be binned from m/z to m/z, therefore first cut m/z range and then do mzbin: - msidata = msidata[mz(msidata) >= $method.methods_conditional.mz_range.min_mz & mz(msidata) <= $method.methods_conditional.mz_range.max_mz,] - msidata = mse_bin = mzBin(msidata,resolution=$method.methods_conditional.bin_width, units="$method.methods_conditional.bin_units", fun="$method.methods_conditional.bin_fun") - #end if - #elif str( $method.methods_conditional.mz_range.features_filtering) == 'none': + #elif str($method.methods_conditional.mz_range.features_filtering) == 'none': msidata = mse_bin = mzBin(msidata,resolution=$method.methods_conditional.bin_width, units="$method.methods_conditional.bin_units", fun=$method.methods_conditional.bin_fun) + #elif str($method.methods_conditional.mz_range.features_filtering) == 'bin_to_reference': + + bin_reference_mz = read.delim("$method.methods_conditional.mz_range.mz_tabular", header = $method.methods_conditional.mz_range.feature_header, stringsAsFactors = FALSE) + bin_reference_mz = bin_reference_mz[,$method.methods_conditional.mz_range.feature_column] + + msidata = mse_bin = mzBin(msidata,resolution=$method.methods_conditional.bin_width, units="$method.methods_conditional.bin_units", fun=$method.methods_conditional.bin_fun, + ref=bin_reference_mz) + #end if msidata <- process(msidata, BPPARAM=MulticoreParam(workers=number_cpu)) @@ -385,7 +389,7 @@ print('log2 transformation') ## replace 0 with NA to prevent Inf - spectra_df = spectra(msidata) ## convert into R matrix + spectra_df = as.matrix(spectra(msidata)) ## convert into R matrix spectra_df[spectra_df ==0] = NA print(paste0("Number of 0 which were converted into NA:",sum(is.na(spectra_df)))) spectra(msidata) = spectra_df @@ -422,25 +426,14 @@ ################################################################################ ## save msidata as imzML file, will only work if there is at least 1 m/z left - - #if str($imzml_output) == "cont_format": - #set $continuous_format = True - #end if if (nrow(msidata) > 0){ ## make sure that coordinates are integers coord(msidata)\$y = as.integer(coord(msidata)\$y) coord(msidata)\$x = as.integer(coord(msidata)\$x) - #if $used_peak_picking: - #if $continuous_format: - msidata = as(msidata, "MSContinuousImagingExperiment") - #end if - #elif $used_peak_alignment - #if $continuous_format: - msidata = as(msidata, "MSContinuousImagingExperiment") - #end if - #end if - writeImzML(msidata, "out") + ## only continuous files can currently be exported + msidata = as(msidata, "MSContinuousImagingExperiment") + writeImzML(msidata, "out") } plot(0,type='n',axes=FALSE,ann=FALSE) @@ -620,15 +613,19 @@ - + + + + + @@ -645,7 +642,6 @@ - @@ -666,10 +662,8 @@ - - + - @@ -702,7 +696,6 @@ - @@ -727,7 +720,6 @@ - @@ -753,13 +745,11 @@ - - @@ -850,7 +840,7 @@ **Output** -- MSI data as continuous or processed imzML file +- MSI data as continuous imzML file - pdf with key values and four random mass spectra after each processing step ]]> diff -r e0669b1854b1 -r 6b36be80febb test-data/Heatmaps_LM8_file16.pdf Binary file test-data/Heatmaps_LM8_file16.pdf has changed diff -r e0669b1854b1 -r 6b36be80febb test-data/Heatmaps_analyze75.pdf Binary file test-data/Heatmaps_analyze75.pdf has changed diff -r e0669b1854b1 -r 6b36be80febb test-data/Heatmaps_imzml.pdf Binary file test-data/Heatmaps_imzml.pdf has changed diff -r e0669b1854b1 -r 6b36be80febb test-data/Heatmaps_processed.pdf Binary file test-data/Heatmaps_processed.pdf has changed diff -r e0669b1854b1 -r 6b36be80febb test-data/Heatmaps_rdata.pdf Binary file test-data/Heatmaps_rdata.pdf has changed diff -r e0669b1854b1 -r 6b36be80febb test-data/centroids_proc.pdf Binary file test-data/centroids_proc.pdf has changed diff -r e0669b1854b1 -r 6b36be80febb test-data/preprocessing_results1.ibd Binary file test-data/preprocessing_results1.ibd has changed diff -r e0669b1854b1 -r 6b36be80febb test-data/preprocessing_results1.imzml --- a/test-data/preprocessing_results1.imzml Thu Oct 22 20:38:29 2020 +0000 +++ b/test-data/preprocessing_results1.imzml Sun Nov 29 23:45:08 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 e0669b1854b1 -r 6b36be80febb test-data/preprocessing_results1.imzml.txt --- a/test-data/preprocessing_results1.imzml.txt Thu Oct 22 20:38:29 2020 +0000 +++ b/test-data/preprocessing_results1.imzml.txt Sun Nov 29 23:45:08 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 e0669b1854b1 -r 6b36be80febb test-data/preprocessing_results1.pdf Binary file test-data/preprocessing_results1.pdf has changed diff -r e0669b1854b1 -r 6b36be80febb test-data/preprocessing_results2.ibd Binary file test-data/preprocessing_results2.ibd has changed diff -r e0669b1854b1 -r 6b36be80febb test-data/preprocessing_results2.imzml --- a/test-data/preprocessing_results2.imzml Thu Oct 22 20:38:29 2020 +0000 +++ b/test-data/preprocessing_results2.imzml Sun Nov 29 23:45:08 2020 +0000 @@ -9,8 +9,8 @@ - - + + diff -r e0669b1854b1 -r 6b36be80febb test-data/preprocessing_results2.imzml.txt --- a/test-data/preprocessing_results2.imzml.txt Thu Oct 22 20:38:29 2020 +0000 +++ b/test-data/preprocessing_results2.imzml.txt Sun Nov 29 23:45:08 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 e0669b1854b1 -r 6b36be80febb test-data/preprocessing_results2.pdf Binary file test-data/preprocessing_results2.pdf has changed diff -r e0669b1854b1 -r 6b36be80febb test-data/preprocessing_results3.ibd Binary file test-data/preprocessing_results3.ibd has changed diff -r e0669b1854b1 -r 6b36be80febb test-data/preprocessing_results3.imzml --- a/test-data/preprocessing_results3.imzml Thu Oct 22 20:38:29 2020 +0000 +++ b/test-data/preprocessing_results3.imzml Sun Nov 29 23:45:08 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 e0669b1854b1 -r 6b36be80febb test-data/preprocessing_results3.imzml.txt --- a/test-data/preprocessing_results3.imzml.txt Thu Oct 22 20:38:29 2020 +0000 +++ b/test-data/preprocessing_results3.imzml.txt Sun Nov 29 23:45:08 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 e0669b1854b1 -r 6b36be80febb test-data/preprocessing_results3.pdf Binary file test-data/preprocessing_results3.pdf has changed