Mercurial > repos > galaxyp > cardinal_combine
comparison combine.xml @ 5:b41107d8fe89 draft
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit 1df4591de435d232862f20669aea529ceb23b12a"
author | galaxyp |
---|---|
date | Fri, 13 Dec 2019 13:54:23 -0500 |
parents | 48c07268f341 |
children | bb1ac6b47a6c |
comparison
equal
deleted
inserted
replaced
4:48c07268f341 | 5:b41107d8fe89 |
---|---|
1 <tool id="cardinal_combine" name="MSI combine" version="@VERSION@.3"> | 1 <tool id="cardinal_combine" name="MSI combine" version="2.2.6.0"> |
2 <description> | 2 <description> |
3 combine several mass spectrometry imaging datasets into one | 3 combine several mass spectrometry imaging datasets into one |
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 <requirements> |
9 <requirement type="package" version="3.0">r-ggplot2</requirement> | 9 <requirement type="package" version="2.2.6">bioconductor-cardinal</requirement> |
10 </expand> | 10 <requirement type="package" version="3.6.1">r-base</requirement> |
11 <requirement type="package" version="3.2.1">r-ggplot2</requirement> | |
12 <requirement type="package" version="0.12">r-maldiquantforeign</requirement> | |
13 <requirement type="package" version="1.19.3">r-maldiquant</requirement> | |
14 </requirements> | |
11 <command detect_errors="exit_code"> | 15 <command detect_errors="exit_code"> |
12 <![CDATA[ | 16 <![CDATA[ |
13 #for $i, $infile in enumerate($infiles): | 17 #for $i, $infile in enumerate($infiles): |
14 #if $infile.ext == 'imzml' | 18 #if $infile.ext == 'imzml' |
15 ln -s '${infile.extra_files_path}/imzml' infile_${i}.imzML && | 19 ln -s '${infile.extra_files_path}/imzml' infile_${i}.imzML && |
28 #end for | 32 #end for |
29 #end if | 33 #end if |
30 | 34 |
31 cat '${msi_combine}' && | 35 cat '${msi_combine}' && |
32 Rscript '${msi_combine}' && | 36 Rscript '${msi_combine}' && |
33 #if str($imzml_output) == "imzml_format": | 37 mkdir $outfile_imzml.files_path && |
34 mkdir $outfile_imzml.files_path && | 38 mv ./out.imzML "${os.path.join($outfile_imzml.files_path, 'imzml')}" | true && |
35 mv ./out.imzML "${os.path.join($outfile_imzml.files_path, 'imzml')}" | true && | 39 mv ./out.ibd "${os.path.join($outfile_imzml.files_path, 'ibd')}" | true && |
36 mv ./out.ibd "${os.path.join($outfile_imzml.files_path, 'ibd')}" | true && | |
37 #end if | |
38 echo "imzML file:" > $outfile_imzml && | 40 echo "imzML file:" > $outfile_imzml && |
39 ls -l "$outfile_imzml.files_path" >> $outfile_imzml | 41 ls -l "$outfile_imzml.files_path" >> $outfile_imzml |
40 | 42 |
41 ]]> | 43 ]]> |
42 </command> | 44 </command> |
43 <configfiles> | 45 <configfiles> |
44 <configfile name="msi_combine"><![CDATA[ | 46 <configfile name="msi_combine"><![CDATA[ |
45 | |
46 #import re | 47 #import re |
47 | 48 |
48 ################ load libraries and some preparations ################# | 49 ################ 1) load libraries and do preparations ################# |
49 | 50 |
50 library(Cardinal) | 51 library(Cardinal) |
51 library(ggplot2) | 52 library(ggplot2) |
53 library(MALDIquantForeign) | |
54 library(MALDIquant) | |
52 | 55 |
53 ## read tabular file for xy_shift option | 56 ## read tabular file for xy_shift option |
54 #if str( $combine_conditional.combine_method ) == 'xy_shifts': | 57 #if str( $combine_conditional.combine_method ) == 'xy_shifts': |
55 input_list = read.delim("$combine_conditional.coordinates_file", header = $combine_conditional.xy_header, | 58 input_list = read.delim("$combine_conditional.coordinates_file", header = $combine_conditional.xy_header, |
56 stringsAsFactors = FALSE) | 59 stringsAsFactors = FALSE) |
61 load(fileName) | 64 load(fileName) |
62 get(ls()[ls() != "fileName"]) | 65 get(ls()[ls() != "fileName"]) |
63 } | 66 } |
64 | 67 |
65 ## preparations for reading files one by one with for loop | 68 ## preparations for reading files one by one with for loop |
66 pixel_vector = numeric() | 69 sample_names = numeric() |
67 x_shifts = 0 | 70 x_shifts = 0 |
68 y_shifts = 0 | 71 y_shifts = 0 |
69 max_y = numeric() | 72 max_y = numeric() |
70 valid_dataset = logical() | 73 valid_dataset = logical() |
74 coordinates_combined = data.frame(matrix(,ncol=2, nrow=0)) | |
75 msidata_combined = list() | |
71 #set $msidata = [] | 76 #set $msidata = [] |
72 #set $pixelcoords = [] | 77 #set $pixelcoords = [] |
73 #set $num_infiles = len($infiles) | 78 #set $num_infiles = len($infiles) |
74 all_files = $num_infiles | 79 all_files = $num_infiles |
75 | 80 |
76 | 81 ###################### 2) reading MSI files #################################### |
77 ############## reading files and changing pixel coordinates ################### | |
78 | 82 |
79 #for $i, $infile in enumerate($infiles): | 83 #for $i, $infile in enumerate($infiles): |
80 | 84 |
81 ## read and manipulate MSI data | 85 ## read and manipulate MSI data |
82 | 86 |
83 #if $infile.ext == 'imzml' | 87 #if $infile.ext == 'imzml' |
84 #if str($processed_cond.processed_file) == "processed": | 88 #if str($processed_cond.processed_file) == "processed": |
85 msidata_$i <- readImzML('infile_${i}', mass.accuracy=$processed_cond.accuracy, units.accuracy = "$processed_cond.units", attach.only=TRUE) | 89 msidata_$i <- readImzML('infile_${i}', mass.accuracy=$processed_cond.accuracy, units.accuracy = "$processed_cond.units", attach.only=TRUE, as = c("MSImageSet")) |
86 centroided(msidata_$i) = $centroids | 90 centroided(msidata_$i) = $centroids |
87 #else | 91 #else |
88 msidata_$i <- readImzML('infile_${i}', attach.only=TRUE) | 92 msidata_$i <- readImzML('infile_${i}', attach.only=TRUE, as = c("MSImageSet")) |
89 centroided(msidata_$i) = $centroids | 93 centroided(msidata_$i) = $centroids |
90 #end if | 94 #end if |
91 #elif $infile.ext == 'analyze75' | 95 #elif $infile.ext == 'analyze75' |
92 msidata_$i <- readAnalyze('infile_${i}', attach.only=TRUE) | 96 msidata_$i <- readAnalyze('infile_${i}', attach.only=TRUE, as = c("MSImageSet")) |
93 centroided(msidata_$i) = $centroids | 97 centroided(msidata_$i) = $centroids |
94 #else | 98 #else |
95 msidata_$i = loadRData('infile_${i}.RData') | 99 msidata_$i = loadRData('infile_${i}.RData') |
100 ## keep compatibility with old .RData files: | |
101 msidata_$i\$column1 = NULL | |
102 msidata_$i\$column2 = NULL | |
103 msidata_$i\$column3 = NULL | |
104 msidata_$i\$column4 = NULL | |
105 msidata_$i\$column5 = NULL | |
106 msidata_$i\$combined_sample = NULL | |
107 | |
96 #end if | 108 #end if |
97 | 109 |
98 ## remove duplicated coordinates, otherwise combine will fail | 110 ## remove duplicated coordinates, otherwise combine will fail |
99 print(paste0(sum(duplicated(coord(msidata_$i))), " duplicated coordinates were removed from input file")) | 111 print(paste0(sum(duplicated(coord(msidata_$i))), " duplicated coordinates were removed from input file")) |
100 msidata_${i} <- msidata_${i}[,!duplicated(coord(msidata_${i}))] | 112 msidata_${i} <- msidata_${i}[,!duplicated(coord(msidata_${i}))] |
101 | 113 |
102 ## same name for MSI data files necessary to combine data in one single coordinate system | 114 ## same name for MSI data files necessary to combine data into one single coordinate system |
103 sampleNames(msidata_$i) = "msidata" | 115 sampleNames(msidata_$i) = "msidata" |
104 | 116 |
105 | 117 ############ 3) Read and process annotation tabular files ###################### |
106 ## read and process annotation tabular or automatically use name of infile as annotation | |
107 | |
108 ## set all pixel annotations to NA, necessary in case files were combined before with different annotations | |
109 msidata_$i\$column1 = rep(NA, ncol(msidata_$i)) | |
110 msidata_$i\$column2 = rep(NA, ncol(msidata_$i)) | |
111 msidata_$i\$column3 = rep(NA, ncol(msidata_$i)) | |
112 msidata_$i\$column4 = rep(NA, ncol(msidata_$i)) | |
113 msidata_$i\$column5 = rep(NA, ncol(msidata_$i)) | |
114 msidata_$i\$combined_sample = rep(NA, ncol(msidata_$i)) | |
115 | |
116 | 118 |
117 #if str($annotation_cond.annotation_tabular) == 'annotation' | 119 #if str($annotation_cond.annotation_tabular) == 'annotation' |
118 print("annotations") | 120 print("annotations") |
119 | 121 |
120 ## read annotation tabular, set first two columns as x and y, merge with coordinates dataframe and order according to pixelorder in msidata | 122 ## read annotation tabular, set first two columns as x and y, merge with coordinates dataframe and order according to pixelorder in msidata |
121 input_annotation = read.delim("annotation_file_${i}.tabular", header = $annotation_cond.tabular_header, stringsAsFactors = FALSE) | 123 input_annotation = read.delim("annotation_file_${i}.tabular", header = $annotation_cond.tabular_header, stringsAsFactors = FALSE) |
122 | |
123 colnames(input_annotation)[1:2] = c("x", "y") | 124 colnames(input_annotation)[1:2] = c("x", "y") |
125 | |
124 msidata_coordinates = cbind(coord(msidata_$i)[,1:2], 1:ncol(msidata_$i)) | 126 msidata_coordinates = cbind(coord(msidata_$i)[,1:2], 1:ncol(msidata_$i)) |
125 colnames(msidata_coordinates)[3] = "pixel_index" | 127 colnames(msidata_coordinates)[3] = "pixel_index" |
126 | 128 |
127 ## only first 5 annotation columns are kept | |
128 if (ncol(input_annotation) > 7){ | |
129 input_annotation = input_annotation[,1:7]} | |
130 | |
131 annotation_df = merge(msidata_coordinates, input_annotation, by=c("x", "y"), all.x=TRUE) | 129 annotation_df = merge(msidata_coordinates, input_annotation, by=c("x", "y"), all.x=TRUE) |
132 annotation_df_8 = cbind(annotation_df, data.frame(matrix(NA,ncol=8-ncol(annotation_df), nrow=ncol(msidata_$i)))) | 130 annotation_df_sorted = annotation_df[order(annotation_df\$pixel_index),]## orders pixel according to msidata |
133 annotation_df_8_sorted = annotation_df_8[order(annotation_df_8\$pixel_index),]## orders pixel according to msidata | 131 annotation_df_sorted\$pixel_index = NULL |
134 | |
135 ## each annotation column is assigned to the pixel in the pData slot of the MSIdata | |
136 msidata_$i\$column1 = annotation_df_8_sorted[,4] | |
137 msidata_$i\$column2 = annotation_df_8_sorted[,5] | |
138 msidata_$i\$column3 = annotation_df_8_sorted[,6] | |
139 msidata_$i\$column4 = annotation_df_8_sorted[,7] | |
140 msidata_$i\$column5 = annotation_df_8_sorted[,8] | |
141 | |
142 | 132 |
143 ## extract columnnames from (last) annotation tabular (for QC plot names) | 133 ## extract columnnames from (last) annotation tabular (for QC plot names) |
144 annotation_colnames = colnames(input_annotation)[-c(1,2)] | 134 annotation_colnames = colnames(input_annotation) |
145 | 135 |
146 #end if | 136 #end if |
147 | 137 |
148 | 138 ############### 4) shift coordinates with xy shifts ############################ |
149 ################### preparation xy shifts ########################## | |
150 | 139 |
151 #if str( $combine_conditional.combine_method ) == 'xy_shifts': | 140 #if str( $combine_conditional.combine_method ) == 'xy_shifts': |
141 | |
142 ## optional: set all files to 1/1 and then add shift | |
143 #if $combine_conditional.xy_origin: | |
144 coord(msidata_$i)\$x = as.integer(coord(msidata_$i)\$x - min(coord(msidata_$i)\$x-1)) | |
145 coord(msidata_$i)\$y = as.integer(coord(msidata_$i)\$y - min(coord(msidata_$i)\$y-1)) | |
146 #end if | |
152 | 147 |
153 ## shift coordinates according to input tabular file and store file names | 148 ## shift coordinates according to input tabular file and store file names |
154 coord(msidata_$i)\$x = as.integer(coord(msidata_$i)\$x + input_list[$i+1,$combine_conditional.column_x]) ## shifts x coordinates according to tabular file | 149 coord(msidata_$i)\$x = as.integer(coord(msidata_$i)\$x + input_list[$i+1,$combine_conditional.column_x]) ## shifts x coordinates according to tabular file |
155 coord(msidata_$i)\$y = as.integer(coord(msidata_$i)\$y + input_list[$i+1,$combine_conditional.column_y]) ## shifts y coordinates according to tabular file | 150 coord(msidata_$i)\$y = as.integer(coord(msidata_$i)\$y + input_list[$i+1,$combine_conditional.column_y]) ## shifts y coordinates according to tabular file |
156 pixel_vector = append(pixel_vector, rep(paste($i+1, input_list[$i+1,$combine_conditional.column_names], sep="_"),times=ncol(msidata_$i))) ## stores file name for each pixel | 151 sample_name = rep(paste(input_list[$i+1,$combine_conditional.column_names]),times=ncol(msidata_$i)) ## stores file name for each pixel |
157 msidata_$i\$combined_sample = rep(paste($i+1, input_list[$i+1,$combine_conditional.column_names], sep="_"),times=ncol(msidata_$i)) | 152 sample_names = append(sample_names, sample_name) |
158 ## store number of file | 153 |
154 ## store number of file to use later when removing duplicate coordinates | |
159 pixelcoords_$i = cbind(coord(msidata_$i)[,1:2], rep($i+1,ncol(msidata_$i))) | 155 pixelcoords_$i = cbind(coord(msidata_$i)[,1:2], rep($i+1,ncol(msidata_$i))) |
160 #silent $pixelcoords.append('pixelcoords_'+str($i)) | 156 #silent $pixelcoords.append('pixelcoords_'+str($i)) |
161 colnames(pixelcoords_$i)[3] = "file_number" | 157 colnames(pixelcoords_$i)[3] = "file_number" |
162 | 158 |
163 ################### preparation automatic combination ########################## | 159 ##################### 5) shift coordinates automatically ####################### |
164 | 160 |
165 #elif str( $combine_conditional.combine_method ) == 'automatic_combine': | 161 #elif str( $combine_conditional.combine_method ) == 'automatic_combine': |
166 | 162 |
167 ## use name of Galaxy inputfile as combined sample annotation | 163 ## use name of Galaxy inputfile as sample annotation |
168 names_vector = character() | 164 sample_name = character() |
169 #set escaped_element_identifier = re.sub('[^\w\-\s\[/]]', '_', str($infile.element_identifier)) | 165 #set escaped_element_identifier = re.sub('[^\w\-\s\[/]]', '_', str($infile.element_identifier)) |
170 | 166 |
171 if (ncol(msidata_$i)>0 & nrow(msidata_$i) >0) | 167 if (ncol(msidata_$i)>0 & nrow(msidata_$i) >0) |
172 { | 168 { |
173 if (is.null(levels(msidata_$i\$combined_sample))) | 169 sample_name = append(sample_name, rep(paste("$escaped_element_identifier"),ncol(msidata_$i))) |
174 { | |
175 names_vector = append(names_vector, rep(paste($i+1, "$escaped_element_identifier", sep="_"),ncol(msidata_$i))) | |
176 msidata_$i\$combined_sample = as.factor(names_vector) | |
177 } | |
178 } | 170 } |
179 | 171 |
180 ## Number of input files define grid which is row-wise filled with files | 172 ## Number of input files define grid which is row-wise filled with files |
181 coord(msidata_$i)\$x = as.integer(coord(msidata_$i)\$x - (min(coord(msidata_$i)\$x-1)) + x_shifts) | 173 coord(msidata_$i)\$x = as.integer(coord(msidata_$i)\$x - (min(coord(msidata_$i)\$x-1)) + x_shifts) |
182 coord(msidata_$i)\$y = as.integer(coord(msidata_$i)\$y - (min(coord(msidata_$i)\$y-1)) + y_shifts) | 174 coord(msidata_$i)\$y = as.integer(coord(msidata_$i)\$y - (min(coord(msidata_$i)\$y-1)) + y_shifts) |
183 x_shifts = max(coord(msidata_$i)\$x) + 5 | 175 |
176 x_shifts = max(coord(msidata_$i)\$x) + $combine_conditional.shift_value | |
184 max_y = append(max_y, max(coord(msidata_$i)\$y)) | 177 max_y = append(max_y, max(coord(msidata_$i)\$y)) |
185 all_files = $num_infiles | 178 all_files = $num_infiles |
186 new_row = ($i+1)/ceiling(sqrt(all_files)) | 179 new_row = ($i+1)/ceiling(sqrt(all_files)) |
187 new_row%%1==0 | 180 new_row%%1==0 |
188 if (new_row%%1==0) | 181 if (new_row%%1==0) |
189 {x_shifts = 0 ### when row is filled: x values start again at zero | 182 {x_shifts = 0 ### when row is filled: x values start again at zero |
190 y_shifts = max(max_y) + 5 ### when row is filled: y value increases to start a new row | 183 y_shifts = max(max_y) + $combine_conditional.shift_value ### when row is filled: y value increases to start a new row |
191 max_y = numeric()} | 184 max_y = numeric()} |
192 | 185 |
193 #end if | 186 #end if |
194 | 187 |
188 ############################# 6) combination of files ########################## | |
189 | |
190 ## combine shifted coordinates with sample name and annotations from input file | |
191 | |
192 #if str($annotation_cond.annotation_tabular) == 'annotation' | |
193 cardinal_coordinates_$i = data.frame(as.matrix(Cardinal::coord(msidata_$i)[,1:2]), sample_name, annotation_df_sorted[,-c(1,2)]) | |
194 #else | |
195 cardinal_coordinates_$i = data.frame(as.matrix(Cardinal::coord(msidata_$i)[,1:2]), sample_name) | |
196 #end if | |
197 | |
195 ## store files to combine them later and for each file check if it is valid | 198 ## store files to combine them later and for each file check if it is valid |
196 | 199 #silent $msidata.append('msidata_'+str($i)) |
197 #silent $msidata.append('msidata_'+str($i)) | 200 valid_dataset = append(valid_dataset, ncol(msidata_$i)>0 & nrow(msidata_$i)>0) |
198 valid_dataset = append(valid_dataset, ncol(msidata_$i)>0 & nrow(msidata_$i)>0) ## file with no intensities is considered valid | 201 |
202 | |
203 ######################### 6a) combination different mz axis #################### | |
204 | |
205 ## combination for files with different mz axis via MALDIquant during for loop | |
206 | |
207 #if $processed_true: | |
208 print("mz axis differ") | |
209 | |
210 cardinal_mzs_$i = Cardinal::mz(msidata_$i) | |
211 | |
212 for(number_spectra in 1:ncol(msidata_${i})){ | |
213 | |
214 if (centroided(msidata_$i) == FALSE){ | |
215 ## create mass spectrum object | |
216 maldi_data_${i} = list() | |
217 for(number_spectra in 1:ncol(msidata_$i)){ | |
218 maldi_data_${i}[[number_spectra]] = MALDIquant::createMassSpectrum(mass = cardinal_mzs_$i, intensity = Cardinal::iData(msidata_$i)[,number_spectra])} | |
219 }else{ | |
220 maldi_data_${i} = list() | |
221 for (spectra in 1:ncol(msidata_$i)) | |
222 { | |
223 single_peaks_${i} = createMassPeaks(cardinal_mzs_$i, Cardinal::spectra(msidata_$i)[,spectra], snr=as.numeric(rep("NA", nrow(msidata_$i)))) | |
224 maldi_data_${i}[[spectra]] = single_peaks_${i} | |
225 } | |
226 } | |
227 } | |
228 | |
229 msidata_combined = append(msidata_combined, maldi_data_$i) | |
230 | |
231 #end if | |
232 | |
233 coordinates_combined = rbind(coordinates_combined, cardinal_coordinates_$i) | |
199 | 234 |
200 #end for | 235 #end for |
201 | 236 |
202 | 237 |
203 ###################### automatic combination ################################### | 238 ######################### 6a) combination same mz axis ################### |
204 ################################################################################ | |
205 | 239 |
206 #if str( $combine_conditional.combine_method ) == 'automatic_combine': | 240 #if str( $combine_conditional.combine_method ) == 'automatic_combine': |
207 print("automatic_combine") | 241 print("automatic combine") |
208 | 242 |
209 ## combine only valid datasets | 243 #if not $processed_true: |
210 | 244 ## combine only valid datasets |
211 valid_data = list(#echo ','.join($msidata)#)[valid_dataset] | 245 |
212 msidata_combined = do.call(combine, valid_data) | 246 valid_data = list(#echo ','.join($msidata)#)[valid_dataset] |
213 print("Valid datasets in order of input bottom to top:") | 247 msidata = do.call(combine, valid_data) |
214 print(valid_dataset) | 248 print("Valid datasets in order of input bottom to top:") |
215 | 249 print(valid_dataset) |
216 ## create dataframe with x,y,sample_name and show all pixels in PDF as QC | |
217 position_df = cbind(coord(msidata_combined)[,1:2], msidata_combined\$combined_sample) | |
218 colnames(position_df)[3] = "sample_name" | |
219 | |
220 msidata = msidata_combined | |
221 | |
222 ## save msidata as imzML file | |
223 #if str($imzml_output) == "imzml_format": | |
224 writeImzML(msidata, "out") | 250 writeImzML(msidata, "out") |
225 #elif str($imzml_output) == "rdata_format": | 251 |
226 ## save as (.RData) | 252 #else |
227 iData(msidata) = iData(msidata)[] | 253 |
228 save(msidata, file="$outfile_rdata") | 254 ## save msidata as imzML file MALDIquant |
229 #end if | 255 MALDIquantForeign::exportImzMl(msidata_combined, file="out.imzML", processed=TRUE, coordinates=as.matrix(coordinates_combined[,1:2])) |
230 | 256 |
231 | 257 #end if |
232 ################################## xy shifts ################################### | 258 |
259 ########################### xy shift combination ############################### | |
233 ################################################################################ | 260 ################################################################################ |
234 | 261 |
235 #elif str( $combine_conditional.combine_method ) == 'xy_shifts': | 262 #elif str( $combine_conditional.combine_method ) == 'xy_shifts': |
236 print("xy_shifts") | 263 print("xy_shifts") |
237 | 264 |
238 ## in case user made mistake with xy shifts: find duplicated coordinates | 265 #if not $processed_true: |
239 all_coordinates = do.call(rbind, list(#echo ','.join($pixelcoords)#)) | 266 |
240 duplicated_coordinates= duplicated(all_coordinates[,1:2])| duplicated(all_coordinates[,1:2], fromLast=TRUE) | 267 duplicated_coordinates= duplicated(coordinates_combined[,1:2])| duplicated(coordinates_combined[,1:2], fromLast=TRUE) |
241 print(paste0("Number of removed duplicated coordinates after combination: ", sum(duplicated_coordinates)/2)) | 268 print(paste0("Number of removed duplicated coordinates after combination: ", sum(duplicated_coordinates))) |
242 unique_coordinates = all_coordinates[!duplicated_coordinates,] | 269 coordinates_combined = coordinates_combined[!duplicated_coordinates,] |
243 | 270 |
244 ## remove duplicated coordinates | 271 ## remove duplicated coordinates |
245 datasetlist = list() | 272 datasetlist = list() |
246 count = 1 | 273 count = 1 |
247 for (usable_dataset in list(#echo ','.join($msidata)#)){ | 274 for (usable_dataset in list(#echo ','.join($msidata)#)){ |
248 pixelsofinterest = pixels(usable_dataset)[names(pixels(usable_dataset)) %in% rownames(unique_coordinates)] | 275 pixelsofinterest = pixels(usable_dataset)[names(pixels(usable_dataset)) %in% rownames(coordinates_combined)] |
249 filtered_dataset = usable_dataset[,pixelsofinterest] | 276 filtered_dataset = usable_dataset[,pixelsofinterest] |
250 if (ncol(filtered_dataset) > 0 ){ | 277 if (ncol(filtered_dataset) > 0 ){ |
251 datasetlist[[count]] = filtered_dataset} | 278 datasetlist[[count]] = filtered_dataset} |
252 count = count +1} | 279 count = count +1} |
253 | 280 |
254 msidata_combined = do.call(combine, datasetlist) | 281 msidata = do.call(combine, datasetlist) |
255 | |
256 msidata = msidata_combined | |
257 | |
258 ## save msidata as imzML file | |
259 #if str($imzml_output) == "imzml_format": | |
260 writeImzML(msidata, "out") | 282 writeImzML(msidata, "out") |
261 #elif str($imzml_output) == "rdata_format": | 283 |
262 ## save as (.RData) | 284 #else |
263 iData(msidata) = iData(msidata)[] | 285 |
264 save(msidata, file="$outfile_rdata") | 286 ## in case user made mistake with xy shifts: find duplicated coordinates |
265 #end if | 287 duplicated_coordinates= duplicated(coordinates_combined[,1:2])| duplicated(coordinates_combined[,1:2], fromLast=TRUE) |
266 | 288 print(paste0("Number of removed duplicated coordinates after combination: ", sum(duplicated_coordinates))) |
267 ## create x,y,sample_name dataframe for QC pdf | 289 unique_coordinates = data.frame(coordinates_combined)[!duplicated_coordinates,] |
268 | 290 |
269 position_df = cbind(coord(msidata)[,1:2], msidata\$combined_sample) | 291 filtered_dataset = msidata_combined [!duplicated_coordinates] |
270 colnames(position_df)[3] = "sample_name" | 292 coordinates_matrix = as.matrix(unique_coordinates[,1:2]) |
293 | |
294 ## save msidata as imzML file MALDIquant | |
295 MALDIquantForeign::exportImzMl(filtered_dataset, file="out.imzML", processed=TRUE, coordinates=coordinates_matrix) | |
296 | |
297 ## create x,y,sample_name dataframe for QC pdf | |
298 ## position_df = unique_coordinates ### ! anders | |
299 ## colnames(position_df)[3] = "sample_name" | |
300 ##coordinates_combined = coordinates_combined[pixelsofinterest,] ###! anders | |
301 coordinates_combined = unique_coordinates | |
302 ##TODO: hier aufräumen kann alles weg?! | |
303 | |
304 #end if | |
271 | 305 |
272 #end if | 306 #end if |
273 | 307 |
274 | 308 ################################## outputs ##################################### |
275 ################################## outputs #################################### | |
276 ################################################################################ | 309 ################################################################################ |
277 | 310 |
278 ########### QC with pixels and their annotations ################################ | 311 ########### QC with pixels and their annotations ################################ |
279 | 312 |
280 pdf("Combined_qc.pdf", width=15, height=15) | 313 pdf("Combined_qc.pdf", width=15, height=15) |
281 | 314 |
282 ## combined plot | 315 ## combined plot |
283 combine_plot = ggplot(position_df, aes(x=x, y=y, fill=sample_name))+ | 316 combine_plot = ggplot(coordinates_combined[,1:3], aes(x=x, y=y, fill=sample_name))+ |
284 geom_tile() + | 317 geom_tile() + |
285 coord_fixed()+ | 318 coord_fixed()+ |
286 ggtitle("Spatial orientation of combined data")+ | 319 ggtitle("Spatial orientation of combined data")+ |
287 theme_bw()+ | 320 theme_bw()+ |
288 theme(text=element_text(family="ArialMT", face="bold", size=15))+ | 321 theme(text=element_text(family="ArialMT", face="bold", size=15))+ |
289 theme(legend.position="bottom",legend.direction="vertical")+ | 322 theme(legend.position="bottom",legend.direction="vertical")+ |
290 guides(fill=guide_legend(ncol=4,byrow=TRUE)) | 323 guides(fill=guide_legend(ncol=4,byrow=TRUE)) |
291 coord_labels = aggregate(cbind(x,y)~sample_name, data=position_df, mean) | 324 coord_labels = aggregate(cbind(x,y)~sample_name, data=coordinates_combined[,1:3], mean) |
292 coord_labels\$file_number = gsub( "_.*$", "", coord_labels\$sample_name) | 325 coord_labels\$file_number = gsub( "_.*$", "", coord_labels\$sample_name) |
293 for(file_count in 1:nrow(coord_labels)) | 326 |
294 {combine_plot = combine_plot + annotate("text",x=coord_labels[file_count,"x"], | |
295 y=coord_labels[file_count,"y"],label=toString(coord_labels[file_count,4]))} | |
296 print(combine_plot) | 327 print(combine_plot) |
297 | 328 |
298 #if str($annotation_cond.annotation_tabular) == 'annotation' | 329 #if str($annotation_cond.annotation_tabular) == 'annotation' |
299 ## annotation plots | 330 ## annotation plots |
300 | 331 for (inputcolumns in 4:ncol(coordinates_combined)){ |
301 ## plot 1 | 332 ## plot 1 |
302 column1_df = cbind(coord(msidata)[,1:2], msidata\$column1) | 333 column1_df = coordinates_combined[,c(1,2,inputcolumns)] |
303 colnames(column1_df)[3] = "column1" | 334 colnames(column1_df)[3] = "column1" |
304 | 335 |
305 if (sum(is.na(column1_df[3])) < nrow(column1_df)){ | 336 if (sum(is.na(column1_df[3])) < nrow(column1_df)){ |
306 column1_plot = ggplot(column1_df, aes(x=x, y=y, fill=column1))+ | 337 column1_plot = ggplot(column1_df, aes(x=x, y=y, fill=column1))+ |
307 geom_tile() + | 338 geom_tile() + |
308 coord_fixed()+ | 339 coord_fixed()+ |
309 ggtitle(paste0(annotation_colnames[1]))+ | 340 ggtitle(paste0(annotation_colnames[inputcolumns-1]))+ |
310 theme_bw()+ | 341 theme_bw()+ |
311 theme(text=element_text(family="ArialMT", face="bold", size=15))+ | 342 theme(text=element_text(family="ArialMT", face="bold", size=15))+ |
312 theme(legend.position="bottom",legend.direction="vertical")+ | 343 theme(legend.position="bottom",legend.direction="vertical")+ |
313 guides(fill=guide_legend(ncol=4,byrow=TRUE, title=annotation_colnames[1])) | 344 guides(fill=guide_legend(ncol=4,byrow=TRUE, title=annotation_colnames[1])) |
314 print(column1_plot)} | 345 print(column1_plot)} |
315 ##rename columnname for output tabular file | 346 ##rename columnname for output tabular file |
316 colnames(column1_df)[3] = annotation_colnames[1] | 347 colnames(column1_df)[3] = annotation_colnames[inputcolumns-1] |
317 | 348 |
318 ## plot 2 | 349 } |
319 column2_df = cbind(coord(msidata)[,1:2], msidata\$column2) | |
320 colnames(column2_df)[3] = "column2" | |
321 | |
322 if (sum(is.na(column2_df[3])) < nrow(column2_df)){ | |
323 column2_plot = ggplot(column2_df, aes(x=x, y=y, fill=column2))+ | |
324 geom_tile() + | |
325 coord_fixed()+ | |
326 ggtitle(paste0(annotation_colnames[2]))+ | |
327 theme_bw()+ | |
328 theme(text=element_text(family="ArialMT", face="bold", size=15))+ | |
329 theme(legend.position="bottom",legend.direction="vertical")+ | |
330 guides(fill=guide_legend(ncol=4,byrow=TRUE, title=annotation_colnames[2])) | |
331 print(column2_plot)} | |
332 | |
333 ##rename columnname for output tabular file | |
334 colnames(column2_df)[3] = annotation_colnames[2] | |
335 | |
336 ## plot 3 | |
337 column3_df = cbind(coord(msidata)[,1:2], msidata\$column3) | |
338 colnames(column3_df)[3] = "column3" | |
339 if (sum(is.na(column3_df[3])) < nrow(column3_df)){ | |
340 column3_plot = ggplot(column3_df, aes(x=x, y=y, fill=column3))+ | |
341 geom_tile() + | |
342 coord_fixed()+ | |
343 ggtitle(paste0(annotation_colnames[3]))+ | |
344 theme_bw()+ | |
345 theme(text=element_text(family="ArialMT", face="bold", size=15))+ | |
346 theme(legend.position="bottom",legend.direction="vertical")+ | |
347 guides(fill=guide_legend(ncol=4,byrow=TRUE, title=annotation_colnames[3])) | |
348 print(column3_plot)} | |
349 ##rename columnname for output tabular file | |
350 colnames(column3_df)[3] = annotation_colnames[3] | |
351 | |
352 ## plot 4 | |
353 column4_df = cbind(coord(msidata)[,1:2], msidata\$column4) | |
354 colnames(column4_df)[3] = "column4" | |
355 | |
356 if (sum(is.na(column4_df[3])) < nrow(column4_df)){ | |
357 column4_plot = ggplot(column4_df, aes(x=x, y=y, fill=column4))+ | |
358 geom_tile() + | |
359 coord_fixed()+ | |
360 ggtitle(paste0(annotation_colnames[4]))+ | |
361 theme_bw()+ | |
362 theme(text=element_text(family="ArialMT", face="bold", size=15))+ | |
363 theme(legend.position="bottom",legend.direction="vertical")+ | |
364 guides(fill=guide_legend(ncol=4,byrow=TRUE, title=annotation_colnames[4])) | |
365 print(column4_plot)} | |
366 ##rename columnname for output tabular file | |
367 colnames(column4_df)[3] = annotation_colnames[4] | |
368 | |
369 ## plot5 | |
370 | |
371 column5_df = cbind(coord(msidata)[,1:2], msidata\$column5) | |
372 colnames(column5_df)[3] = "column5" | |
373 if (sum(is.na(column5_df[3])) < nrow(column5_df)){ | |
374 column5_plot = ggplot(column5_df, aes(x=x, y=y, fill=column5))+ | |
375 geom_tile() + | |
376 coord_fixed()+ | |
377 ggtitle(paste0(annotation_colnames[5]))+ | |
378 theme_bw()+ | |
379 theme(text=element_text(family="ArialMT", face="bold", size=15))+ | |
380 theme(legend.position="bottom",legend.direction="vertical")+ | |
381 guides(fill=guide_legend(ncol=4,byrow=TRUE, title=annotation_colnames[5])) | |
382 print(column5_plot)} | |
383 ##rename columnname for output tabular file | |
384 colnames(column5_df)[3] = annotation_colnames[5] | |
385 | 350 |
386 #end if | 351 #end if |
387 dev.off() | 352 dev.off() |
388 | 353 |
389 ##################### annotation tabular output ################################ | 354 ##################### annotation tabular output ################################ |
390 | 355 |
391 if (length(features(msidata))> 0 & length(pixels(msidata)) > 0){ | 356 write.table(coordinates_combined, file="$pixel_annotations", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") |
392 position_df\$sample_name = gsub("^[^_]*_","",position_df\$sample_name) | |
393 | |
394 #if str($annotation_cond.annotation_tabular) == 'no_annotation': | |
395 | |
396 write.table(position_df, file="$pixel_annotations", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") | |
397 | |
398 #else | |
399 annotation_df_list = list(position_df, column1_df, column2_df, column3_df, column4_df, column5_df) | |
400 combined_annotations = Reduce(function(...) merge(..., by=c("x", "y"), all=TRUE), annotation_df_list) | |
401 write.table(combined_annotations, file="$pixel_annotations", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") | |
402 #end if | |
403 | |
404 }else{ | |
405 print("No annotation tabular output because file has no features or pixels left") | |
406 } | |
407 | |
408 | |
409 | |
410 | 357 |
411 ]]></configfile> | 358 ]]></configfile> |
412 </configfiles> | 359 </configfiles> |
413 <inputs> | 360 <inputs> |
414 <param name="infiles" type="data" multiple="true" format="imzml,rdata,analyze75" | 361 <param name="infiles" type="data" multiple="true" format="imzml,rdata,analyze75" |
436 </param> | 383 </param> |
437 <when value="no_annotation"/> | 384 <when value="no_annotation"/> |
438 <when value="annotation"> | 385 <when value="annotation"> |
439 <param name="annotation_files" type="data" multiple="true" format="tabular" | 386 <param name="annotation_files" type="data" multiple="true" format="tabular" |
440 label="Pixel annotations tabular files" | 387 label="Pixel annotations tabular files" |
441 help="Same number and order of files as input files. First column x values, second column y values. Up to 5 columns with pixel annotations"/> | 388 help="Same number and order of files as input files. First column x values, second column y values, further columns with annotations"/> |
442 <param name="tabular_header" type="boolean" label="Tabular files contain a header line" truevalue="TRUE" falsevalue="FALSE"/> | 389 <param name="tabular_header" type="boolean" label="Tabular files contain a header line" truevalue="TRUE" falsevalue="FALSE"/> |
443 </when> | 390 </when> |
444 </conditional> | 391 </conditional> |
445 <conditional name="combine_conditional"> | 392 <conditional name="combine_conditional"> |
446 <param name="combine_method" type="select" label="Way of combining multiple files"> | 393 <param name="combine_method" type="select" label="Way of combining multiple files"> |
447 <option value="automatic_combine" selected="True" >automatic combination</option> | 394 <option value="automatic_combine" selected="True" >automatic combination</option> |
448 <option value="xy_shifts">shift xy coordinates with a tabular file</option> | 395 <option value="xy_shifts">shift xy coordinates with a tabular file</option> |
449 </param> | 396 </param> |
450 <when value="automatic_combine"/> | 397 <when value="automatic_combine"> |
398 <param name="shift_value" type="integer" value="5" label="Number of empty pixels that should separate different datasets in x and y dimension"/> | |
399 </when> | |
451 <when value="xy_shifts"> | 400 <when value="xy_shifts"> |
452 <param name="coordinates_file" type="data" format="tabular" label="Datasetnames, x and y values to shift pixel coordinates before combining" | 401 <param name="coordinates_file" type="data" format="tabular" label="Datasetnames, x and y values to shift pixel coordinates before combining" |
453 help="Tabular file with three columns: 1 for the filename, 1 for the x-coordinate shift and 1 for the y-coordinate shift. Pixels with the same coordinates after shifting will be deleted."/> | 402 help="Tabular file with three columns: 1 for the filename, 1 for the x-coordinate shift and 1 for the y-coordinate shift. Pixels with the same coordinates after shifting will be deleted."/> |
454 <param name="column_x" data_ref="coordinates_file" label="Column with values for shift in x direction" type="data_column"/> | 403 <param name="column_x" data_ref="coordinates_file" label="Column with values for shift in x direction" type="data_column"/> |
455 <param name="column_y" data_ref="coordinates_file" label="Column with values for shift in y direction" type="data_column"/> | 404 <param name="column_y" data_ref="coordinates_file" label="Column with values for shift in y direction" type="data_column"/> |
456 <param name="column_names" data_ref="coordinates_file" label="Column with dataset names" type="data_column"/> | 405 <param name="column_names" data_ref="coordinates_file" label="Column with dataset names" type="data_column"/> |
457 <param name="xy_header" type="boolean" label="Tabular files contain a header line" truevalue="TRUE" falsevalue="FALSE"/> | 406 <param name="xy_header" type="boolean" label="Tabular files contain a header line" truevalue="TRUE" falsevalue="FALSE"/> |
407 <param name="xy_origin" type="boolean" label="Set all file coordinates to 1/1 as origin" truevalue="TRUE" falsevalue="FALSE" help="Yes: all file coordinates are shifted in order to have at least one pixel with x = 1 and one with y = 1; then coordinates shifts are added. No: the coordinate shifts are added to the current coordinates of the file"/> | |
458 </when> | 408 </when> |
459 </conditional> | 409 </conditional> |
460 <param name="imzml_output" type="select" display = "radio" optional = "False" | 410 <param name="processed_true" type="boolean" label="Do the files have different m/z axis?" help="If all m/z values of all files are exactly the same choose 'No'. If not sure choose 'Yes'." truevalue="TRUE" falsevalue="FALSE"/> |
461 label="Output format" help= "Choose the output format"> | |
462 <option value="imzml_format">imzML</option> | |
463 <option value="rdata_format" selected="True" >RData</option> | |
464 </param> | |
465 </inputs> | 411 </inputs> |
466 <outputs> | 412 <outputs> |
467 <data format="imzml" name="outfile_imzml" label="${tool.name} on ${on_string}: imzML"> | 413 <data format="imzml" name="outfile_imzml" label="${tool.name} on ${on_string}: imzML"/> |
468 <filter>imzml_output=='imzml_format'</filter> | |
469 </data> | |
470 <data format="rdata" name="outfile_rdata" label="${tool.name} on ${on_string}: RData"> | |
471 <filter>imzml_output == 'rdata_format'</filter> | |
472 </data> | |
473 <data format="pdf" name="QC_overview" from_work_dir="Combined_qc.pdf" label = "${tool.name} on ${on_string}: QC"/> | 414 <data format="pdf" name="QC_overview" from_work_dir="Combined_qc.pdf" label = "${tool.name} on ${on_string}: QC"/> |
474 <data format="tabular" name="pixel_annotations" label="${tool.name} on ${on_string}: annotations"/> | 415 <data format="tabular" name="pixel_annotations" label="${tool.name} on ${on_string}: annotations"/> |
475 </outputs> | 416 </outputs> |
476 <tests> | 417 <tests> |
477 <test> | 418 <test> |
484 <param name="combine_method" value="xy_shifts"/> | 425 <param name="combine_method" value="xy_shifts"/> |
485 <param name="coordinates_file" ftype="tabular" value="xy_coordinates.tabular"/> | 426 <param name="coordinates_file" ftype="tabular" value="xy_coordinates.tabular"/> |
486 <param name="column_x" value="1"/> | 427 <param name="column_x" value="1"/> |
487 <param name="column_y" value="2"/> | 428 <param name="column_y" value="2"/> |
488 <param name="column_names" value="3"/> | 429 <param name="column_names" value="3"/> |
489 <param name="imzml_output" value="rdata_format"/> | 430 <param name="processed_true" value="FALSE"/> |
490 <output name="pixel_annotations" file="123_annotation_output.tabular"/> | 431 <output name="pixel_annotations" file="123_annotation_output.tabular"/> |
491 <output name="outfile_rdata" file="123_combined.RData" compare="sim_size" /> | |
492 <output name="QC_overview" file="123_combined_QC.pdf" compare="sim_size"/> | 432 <output name="QC_overview" file="123_combined_QC.pdf" compare="sim_size"/> |
433 <output name="outfile_imzml" ftype="imzml" file="123_combined.imzml.txt" compare="sim_size"> | |
434 <extra_files type="file" file="123_combined.imzml" name="imzml" lines_diff="4"/> | |
435 <extra_files type="file" file="123_combined.ibd" name="ibd" compare="sim_size"/> | |
436 </output> | |
437 </test> | |
438 <test> | |
439 <param name="infiles" value="123_combined_picked.rdata,123_combined_picked2.rdata" ftype="rdata"/> | |
440 <param name="centroids" value="TRUE"/> | |
441 <param name="combine_method" value="xy_shifts"/> | |
442 <param name="coordinates_file" ftype="tabular" value="xy_coordinates2.tabular"/> | |
443 <param name="column_x" value="1"/> | |
444 <param name="column_y" value="2"/> | |
445 <param name="column_names" value="3"/> | |
446 <param name="processed_true" value="TRUE"/> | |
447 <output name="pixel_annotations" file="picked.tabular"/> | |
448 <output name="QC_overview" file="picked_QC.pdf" compare="sim_size"/> | |
449 <output name="outfile_imzml" ftype="imzml" file="picked.imzml.txt" compare="sim_size"> | |
450 <extra_files type="file" file="picked.imzml" name="imzml" lines_diff="6"/> | |
451 <extra_files type="file" file="picked.ibd" name="ibd" compare="sim_size"/> | |
452 </output> | |
493 </test> | 453 </test> |
494 <test> | 454 <test> |
495 <param name="infiles" value="msidata_1.RData,msidata_2.RData,msidata_3.RData" ftype="rdata"/> | 455 <param name="infiles" value="msidata_1.RData,msidata_2.RData,msidata_3.RData" ftype="rdata"/> |
496 <conditional name="annotation_cond"> | 456 <conditional name="annotation_cond"> |
497 <param name="annotation_tabular" value="no_annotation"/> | 457 <param name="annotation_tabular" value="no_annotation"/> |
498 </conditional> | 458 </conditional> |
499 <param name="combine_method" value="automatic_combine"/> | 459 <param name="combine_method" value="automatic_combine"/> |
500 <param name="imzml_output" value="imzml_format"/> | 460 <param name="processed_true" value="FALSE"/> |
501 <output name="QC_overview" file="123_combined_auto.pdf" compare="sim_size"/> | 461 <output name="QC_overview" file="123_combined_auto.pdf" compare="sim_size"/> |
502 <output name="pixel_annotations" file="123_combined_auto.tabular"/> | 462 <output name="pixel_annotations" file="123_combined_auto.tabular"/> |
503 <output name="outfile_imzml" ftype="imzml" file="123_combined_auto.imzml.txt" compare="sim_size"> | 463 <output name="outfile_imzml" ftype="imzml" file="123_combined_auto.imzml.txt" compare="sim_size"> |
504 <extra_files type="file" file="123_combined_auto.imzml" name="imzml" lines_diff="4"/> | 464 <extra_files type="file" file="123_combined_auto.imzml" name="imzml" lines_diff="4"/> |
505 <extra_files type="file" file="123_combined_auto.ibd" name="ibd" compare="sim_size"/> | 465 <extra_files type="file" file="123_combined_auto.ibd" name="ibd" compare="sim_size"/> |
511 <param name="annotation_tabular" value="annotation"/> | 471 <param name="annotation_tabular" value="annotation"/> |
512 <param name="annotation_files" value="annotations_file1.tabular,annotations_file2.tabular" ftype="tabular"/> | 472 <param name="annotation_files" value="annotations_file1.tabular,annotations_file2.tabular" ftype="tabular"/> |
513 <param name="tabular_header" value="TRUE"/> | 473 <param name="tabular_header" value="TRUE"/> |
514 </conditional> | 474 </conditional> |
515 <param name="combine_method" value="automatic_combine"/> | 475 <param name="combine_method" value="automatic_combine"/> |
516 <param name="imzml_output" value="rdata_format"/> | 476 <param name="processed_true" value="FALSE"/> |
517 <output name="pixel_annotations" file="12_annotation_output.tabular"/> | 477 <output name="pixel_annotations" file="12_annotation_output.tabular"/> |
518 <output name="outfile_rdata" file="12_combined.RData" compare="sim_size" /> | |
519 <output name="QC_overview" file="12_combined_QC.pdf" compare="sim_size"/> | 478 <output name="QC_overview" file="12_combined_QC.pdf" compare="sim_size"/> |
479 <output name="outfile_imzml" ftype="imzml" file="12_combined.imzml.txt" compare="sim_size"> | |
480 <extra_files type="file" file="12_combined.imzml" name="imzml" lines_diff="4"/> | |
481 <extra_files type="file" file="12_combined.ibd" name="ibd" compare="sim_size"/> | |
482 </output> | |
520 </test> | 483 </test> |
521 <test> | 484 <test> |
522 <param name="infiles" value="msidata_1.RData,123_combined.RData" ftype="rdata"/> | 485 <param name="infiles" value="msidata_1.RData,123_combined.RData" ftype="rdata"/> |
523 <conditional name="annotation_cond"> | 486 <conditional name="annotation_cond"> |
524 <param name="annotation_tabular" value="annotation"/> | 487 <param name="annotation_tabular" value="annotation"/> |
525 <param name="annotation_files" value="annotations_file1.tabular,123_annotation.tabular" ftype="tabular"/> | 488 <param name="annotation_files" value="annotations_file1.tabular,123_annotation.tabular" ftype="tabular"/> |
526 <param name="tabular_header" value="TRUE"/> | 489 <param name="tabular_header" value="TRUE"/> |
527 </conditional> | 490 </conditional> |
528 <param name="combine_method" value="automatic_combine"/> | 491 <param name="combine_method" value="automatic_combine"/> |
529 <param name="imzml_output" value="imzml_format"/> | 492 <param name="processed_true" value="FALSE"/> |
530 <output name="pixel_annotations" file="112_annotation_output.tabular"/> | 493 <output name="pixel_annotations" file="112_annotation_output.tabular"/> |
531 <output name="QC_overview" file="112_auto_combined_QC.pdf" compare="sim_size"/> | 494 <output name="QC_overview" file="112_auto_combined_QC.pdf" compare="sim_size"/> |
532 <output name="outfile_imzml" ftype="imzml" file="112_auto_combined.imzml.txt" compare="sim_size"> | 495 <output name="outfile_imzml" ftype="imzml" file="112_auto_combined.imzml.txt" compare="sim_size"> |
533 <extra_files type="file" file="112_auto_combined.imzml" name="imzml" lines_diff="4"/> | 496 <extra_files type="file" file="112_auto_combined.imzml" name="imzml" lines_diff="4"/> |
534 <extra_files type="file" file="112_auto_combined.ibd" name="ibd" compare="sim_size"/> | 497 <extra_files type="file" file="112_auto_combined.ibd" name="ibd" compare="sim_size"/> |
538 <param name="infiles" value="msidata_2.RData,123_combined.RData" ftype="rdata"/> | 501 <param name="infiles" value="msidata_2.RData,123_combined.RData" ftype="rdata"/> |
539 <conditional name="annotation_cond"> | 502 <conditional name="annotation_cond"> |
540 <param name="annotation_tabular" value="no_annotation"/> | 503 <param name="annotation_tabular" value="no_annotation"/> |
541 </conditional> | 504 </conditional> |
542 <param name="combine_method" value="automatic_combine"/> | 505 <param name="combine_method" value="automatic_combine"/> |
543 <param name="imzml_output" value="rdata_format"/> | 506 <param name="processed_true" value="FALSE"/> |
544 <output name="pixel_annotations" file="2123_annotation_output.tabular"/> | 507 <output name="pixel_annotations" file="2123_annotation_output.tabular"/> |
545 <output name="outfile_rdata" file="2123_auto_combined.RData" compare="sim_size" /> | |
546 <output name="QC_overview" file="2123_auto_combined_QC.pdf" compare="sim_size"/> | 508 <output name="QC_overview" file="2123_auto_combined_QC.pdf" compare="sim_size"/> |
509 <output name="outfile_imzml" ftype="imzml" file="2123_auto_combined.imzml.txt" compare="sim_size"> | |
510 <extra_files type="file" file="2123_auto_combined.imzml" name="imzml" lines_diff="4"/> | |
511 <extra_files type="file" file="2123_auto_combined.ibd" name="ibd" compare="sim_size"/> | |
512 </output> | |
547 </test> | 513 </test> |
548 </tests> | 514 </tests> |
549 <help> | 515 <help> |
550 <![CDATA[ | 516 <![CDATA[ |
551 | 517 |
552 @CARDINAL_DESCRIPTION@ | 518 @CARDINAL_DESCRIPTION@ |
553 | 519 |
554 ----- | 520 ----- |
555 | 521 |
556 This tool uses the Cardinal combine function to combine several mass spectrometry imaging data. | 522 This tool combines several mass spectrometry imaging data files. |
557 | 523 |
558 @MSIDATA_INPUT_DESCRIPTION@ | 524 @MSIDATA_INPUT_DESCRIPTION@ |
559 - MSI data files must have the same m/z values (to obtain same m/z values for different files: filtering tool same m/z range and preprocessing tool same binning width) | |
560 - Coordinates stored as decimals rather than integers will be rounded to obtain a regular pixel grid. This might lead to duplicated coordinates which will be automatically removed before the tools analysis starts. | 525 - Coordinates stored as decimals rather than integers will be rounded to obtain a regular pixel grid. This might lead to duplicated coordinates which will be automatically removed before the tools analysis starts. |
561 @SPECTRA_TABULAR_INPUT_DESCRIPTION@ | 526 @SPECTRA_TABULAR_INPUT_DESCRIPTION@ |
562 | 527 |
563 - For xy shifts with tabular file: Tabular file with x and y coordinates shift and file name | 528 - For xy shifts with tabular file: Tabular file with x and y coordinates shift and file name |
564 | 529 |
565 - Each input file is shifted in x and y direction according to this tabular file. In the example the files have about the same pixel dimensions which is smaller than 510x260. | 530 - Each input file is renamed and shifted in x and y direction according to this tabular file. In the example the files have about the same pixel dimensions which is smaller than 510x260. |
566 - The file can have any column names as header (in this case set "Tabular file contains a header line" to yes) or no header at all | 531 - The file can have any column names as header (in this case set "Tabular file contains a header line" to "Yes") or no header at all (set "Tabular file contains a header line" to "No"). |
567 | 532 |
568 :: | 533 :: |
569 | 534 |
570 x_shift y_shift file name | 535 x_shift y_shift file name |
571 0 0 file1 | 536 0 0 file1 |
578 | 543 |
579 | 544 |
580 | 545 |
581 **Options** | 546 **Options** |
582 | 547 |
583 - "automatic combination": files are automatically arranged in a grid (duplicated pixels are allowed), subfiles are named according to the input file name | 548 - "automatic combination": files are automatically arranged in a grid, subfiles are named according to the input file name |
584 - "xy shifts": each file can be moved in x and y direction according to the users need (define one tabular file in the order in which the files are loaded in the history (bottom to top) and define for each file the x and y coordinates shifts in separate columns and the file name in a third column as shown above). The xy shift option combines all datasets and removes all duplicated pixels (same x and y coordinates). | 549 - "xy shifts": each file can be moved in x and y direction according to the users need (define one tabular file in the order in which the files are loaded in the history (bottom to top) and define for each file the x and y coordinates shifts in separate columns and the file name in a third column as shown above). The xy shift option combines all datasets and removes all duplicated pixels (same x and y coordinates). |
550 - "Set all file coordinates to 1/1 as origin" can be choosen to override current pixel coordinates of the input file and set their minimal x and minimal y values to 1. Then the shifts from the xy shift tabular files are used to move the pixels of each dataset. | |
551 - In case the input files have not exactly the same m/z values set "Do the files have different m/z axis?" to "Yes". Then functionalities of the "MALDIquant" package are used to combine the datasets. | |
552 | |
585 | 553 |
586 **Tips** | 554 **Tips** |
587 | 555 |
588 - The combine tools puts all samples into a common x-y-grid, therefore pixel coordinates will change. In case the pixels are already annotated, the annotations should be provided as tabular files and the tool will return an annotation file with the new pixel coordinates. This annotation file can then be used together with the combined MSI data for tools in which the annotation is required (e.g. 'MSI classification') or useful (e.g. 'MSI spectra plots'). | 556 - The combine tool puts all samples into a common x-y-grid, therefore pixel coordinates will change. In case the pixels are already annotated, the annotations should be provided as tabular files and the tool will return an annotation file with the new pixel coordinates. This annotation file can then be used together with the combined MSI data for tools in which the annotation is required (e.g. 'MSI classification') or useful (e.g. 'MSI spectra plots'). |
589 - In case more annotations are required: The annotation input file should have an identifier column, for example the patient_ID. A second tabular file that contains more annotations and also one column with the identifier column (e.g. 'patient_ID') can be merged to the annotation output file of this tool with the tool 'join two files' and then set the 'Column to use' parameters for both files to the identifier column. | |
590 | |
591 | 557 |
592 | 558 |
593 **Output** | 559 **Output** |
594 | 560 |
595 - MSI data as imzML file or .RData (can be read with the Cardinal package in R) | 561 - MSI data as imzML file (in continous format when m/z axis were the same; in processed format when m/z axis were different) |
596 - pdf that shows the pixel positions and annotations of the combined files | 562 - Pdf with pixel positions and annotations of the combined files |
597 - Tabular file with pixel annotations (x,y,column with input file names and up to five annotation columns) | 563 - Tabular file with pixel annotations (x,y,column with input file names and annotation columns) |
598 | 564 |
599 | 565 |
600 ]]> | 566 ]]> |
601 </help> | 567 </help> |
602 <expand macro="citations"/> | 568 <citations> |
569 <citation type="doi">10.1093/bioinformatics/btv146</citation> | |
570 <citation type="doi">10.1007/978-3-319-45809-0_6</citation> | |
571 </citations> | |
603 </tool> | 572 </tool> |