comparison msi_combine.xml @ 0:9cbcf48bf60a draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/msi_combine commit 1e5a87e56e09f01087844f8d2c95002455b1d89d
author galaxyp
date Tue, 24 Apr 2018 13:22:48 -0400
parents
children f3f6c32ab690
comparison
equal deleted inserted replaced
-1:000000000000 0:9cbcf48bf60a
1 <tool id="mass_spectrometry_imaging_combine" name="MSI combine" version="1.7.0.0">
2 <description>
3 combine several mass spectrometry imaging datasets into one
4 </description>
5 <requirements>
6 <requirement type="package" version="1.7.0">bioconductor-cardinal</requirement>
7 </requirements>
8 <command detect_errors="exit_code">
9 <![CDATA[
10 #for $i, $infile in enumerate($infiles):
11 #if $infile.ext == 'imzml'
12 cp '${infile.extra_files_path}/imzml' infile_$i.imzML &&
13 cp '${infile.extra_files_path}/ibd' infile_$i.ibd &&
14 #elif $infile.ext == 'analyze75'
15 cp '${infile.extra_files_path}/hdr' infile_$i.hdr &&
16 cp '${infile.extra_files_path}/img' infile_$i.img &&
17 cp '${infile.extra_files_path}/t2m' infile_$i.t2m &&
18 #else
19 ln -s '$infile' infile_${i}.RData &&
20 #end if
21 #end for
22 cat '${msi_combine}' &&
23 Rscript '${msi_combine}'
24
25 ]]>
26 </command>
27 <configfiles>
28 <configfile name="msi_combine"><![CDATA[
29 library(Cardinal)
30
31 #if $coordinates_file:
32 input_list = read.delim("$coordinates_file", header = FALSE,
33 stringsAsFactors = FALSE)
34 #end if
35
36 pixel_vector = numeric()
37
38 #set $msidata = []
39 #for $i, $infile in enumerate($infiles):
40
41 #if $infile.ext == 'imzml'
42 msidata_$i <- readMSIData('infile_${i}.imzML')
43 sampleNames(msidata_$i) = "msidata"
44 #elif $infile.ext == 'analyze75'
45 msidata_$i <- readMSIData('infile_${i}.hdr')
46 sampleNames(msidata_$i) = "msidata"
47 #else
48 loadRData <- function(fileName){
49 #loads an RData file, and returns it
50 load(fileName)
51 get(ls()[ls() != "fileName"])
52 }
53 msidata_$i = loadRData('infile_${i}.RData')
54 sampleNames(msidata_$i) = "msidata"
55 #end if
56
57 #if $coordinates_file:
58 coord(msidata_$i)\$x = coord(msidata_$i)\$x + input_list[$i+1+$coordinates_header,$column_x]
59 coord(msidata_$i)\$y = coord(msidata_$i)\$y + input_list[$i+1+$coordinates_header,$column_y]
60 pixelnumber = ncol(msidata_$i)
61 pixel_vector = append(pixel_vector, rep(input_list[$i+1+$coordinates_header,$column_names],times=pixelnumber))
62 #end if
63 #silent $msidata.append('msidata_'+str($i))
64 #end for
65
66 msidata_combined = do.call(combine, list(#echo ','.join($msidata)#))
67
68 ### count NAs and replace by 0
69 spectra(msidata_combined)[is.na(spectra(msidata_combined))] <- 0
70 print(paste0("Number of NAs which were replaced ",sum(is.na(msidata_combined))))
71
72 #if $coordinates_file:
73 ### rename pixels according to dataset
74 sample_names = as.factor(pixel_vector)
75 msidata_combined@pixelData@data\$sample = sample_names
76 #end if
77
78
79 ### outputs ###
80
81 ## save as (.RData)
82 msidata = msidata_combined
83 save(msidata, file="$msidata_combined")
84
85 pdf("combining_qc.pdf", fonts = "Times", pointsize = 12)
86 image(msidata_combined, mz=1, colorkey=FALSE)
87 dev.off()
88
89 ### optional: intensity matrix ###
90
91 #if $output_matrix:
92
93 if (length(features(msidata_combined))> 0 & length(pixels(msidata_combined)) > 0)
94 {
95 spectramatrix = spectra(msidata_combined)
96 rownames(spectramatrix) = mz(msidata_combined)
97 newmatrix = rbind(pixels(msidata_combined), spectramatrix)
98 write.table(newmatrix[2:nrow(newmatrix),], file="$matrixasoutput", quote = FALSE, row.names = TRUE, col.names=NA, sep = "\t")
99 }else{
100 print("file has no features or pixels left")
101 }
102 #end if
103
104 ]]></configfile>
105 </configfiles>
106 <inputs>
107 <param name="infiles" type="data" multiple="true" format="imzml,rdata,analyze75"
108 label="MSI rawdata as imzml, analyze7.5 or Cardinal MSImageSet saved as RData"
109 help="load imzml and ibd file by uploading composite datatype imzml"/>
110 <param name="coordinates_file" type="data" optional="true" format="tabular" label="X and y values to shift data before combining"
111 help="tabular file with pixels of interest in two separate columns"/>
112 <param name="column_x" data_ref="coordinates_file" optional="true" label="Column with values for shift in x direction" type="data_column"/>
113 <param name="column_y" data_ref="coordinates_file" optional="true" label="Column with values for shift in y direction" type="data_column"/>
114 <param name="column_names" data_ref="coordinates_file" optional="true" label="Column with dataset names" type="data_column"/>
115 <param name="coordinates_header" label="Number of header lines to skip" value="0" type="integer"/>
116 <param name="output_matrix" type="boolean" display="radio" label="Intensity matrix output"/>
117 </inputs>
118 <outputs>
119 <data format="rdata" name="msidata_combined" label="Combined MSI data"/>
120 <data format="pdf" name="combining_qc" from_work_dir="combining_qc.pdf" label = "Combined image of pixels"/>
121 <data format="tabular" name="matrixasoutput" label="Combined matrix">
122 <filter>output_matrix</filter>
123 </data>
124 </outputs>
125 <tests>
126 <test expect_num_outputs="3">
127 <param name="infiles" value="msidata_1.RData,msidata_2.RData,msidata_3.RData" ftype="rdata"/>
128 <param name="coordinates_file" ftype="tabular" value="xy_coordinates.tabular"/>
129 <param name="column_x" value="1"/>
130 <param name="column_y" value="2"/>
131 <param name="column_names" value="3"/>
132 <param name="output_matrix" value="True"/>
133 <output name="matrixasoutput" file="123_combined_matrix.tabular"/>
134 <output name="msidata_combined" file="123_combined.RData" compare="sim_size" />
135 <output name="combining_qc" file="123_combined_QC.pdf" compare="sim_size" delta="20000"/>
136 </test>
137 <test expect_num_outputs="3">
138 <param name="infiles" value="msidata_1.RData,msidata_2.RData" ftype="rdata"/>
139 <param name="output_matrix" value="True"/>
140 <output name="matrixasoutput" file="12_combined_matrix.tabular"/>
141 <output name="msidata_combined" file="12_combined.RData" compare="sim_size" />
142 <output name="combining_qc" file="12_combined_QC.pdf" compare="sim_size" delta="20000"/>
143 </test>
144 </tests>
145 <help>
146 <![CDATA[
147 This tool can combine several mass-spectrometry imaging files. A prerequesite for the combination is that the m/z values are the same across all datasets. To achieve this use the filtering tool to get all datasets to the same m/z range and then use the binning function in the preprocessing tool to obtain the same bins for all dataset. The pixels on the other hand must be unique, therefore you should provide a number for the shift of x and y coordinates so that pixels of different datasets do not overlap.
148
149 Input data: 3 types of input data can be used:
150
151 - imzml file (upload imzml and ibd file via the "composite" function) `Introduction to the imzml format <http://ms-imaging.org/wp/introduction/>`_
152 - Analyze7.5 (upload hdr, img and t2m file via the "composite" function)
153 - Cardinal "MSImageSet" data (with variable name "msidata", saved as .RData)
154
155 The output of this tool is a Cardinal "MSImageSet" with the variable name "msidata" saved as .RData.
156 ]]>
157 </help>
158 <citations>
159 <citation type="doi">10.1093/bioinformatics/btv146</citation>
160 </citations>
161 </tool>