Mercurial > repos > galaxyp > cardinal_colocalization
comparison colocalization.xml @ 0:d3ca64dafdef draft
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cardinal commit badc51fcd74ba0c14cd1ae64d5f524291fa11441"
author | galaxyp |
---|---|
date | Tue, 22 Feb 2022 20:52:51 +0000 |
parents | |
children | 8ad8061e18c4 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d3ca64dafdef |
---|---|
1 <tool id="cardinal_colocalization" name="MSI colocalization" version="@VERSION@.0"> | |
2 <description>mass spectrometry imaging colocalization</description> | |
3 <macros> | |
4 <import>macros.xml</import> | |
5 </macros> | |
6 <expand macro="requirements"> | |
7 <requirement type="package" version="2.3">r-gridextra</requirement> | |
8 </expand> | |
9 <command detect_errors="exit_code"> | |
10 <![CDATA[ | |
11 | |
12 @INPUT_LINKING@ | |
13 cat '${MSI_colocalization}' && | |
14 Rscript '${MSI_colocalization}' | |
15 | |
16 ]]> | |
17 </command> | |
18 <configfiles> | |
19 <configfile name="MSI_colocalization"><![CDATA[ | |
20 | |
21 ################################# load libraries and read file ################# | |
22 | |
23 library(Cardinal) | |
24 library(gridExtra) | |
25 | |
26 @READING_MSIDATA_FULLY_COMPATIBLE@ | |
27 | |
28 #if str($reference_type.reference) == "roi_ref": | |
29 ## read and extract x,y,annotation information | |
30 input_tabular <- read.delim("$reference_type.annotation_file", header = $reference_type.tabular_header, stringsAsFactors = FALSE) | |
31 annotation_input <- input_tabular[,c($reference_type.column_x, $reference_type.column_y, $reference_type.column_names)] | |
32 annotation_name <- colnames(annotation_input)[3] ##extract header for annotations to later export tabular with same name | |
33 colnames(annotation_input) <- c("x", "y", "annotation") ## rename annotations header to default name "annotation" | |
34 | |
35 ## merge with coordinate information of msidata | |
36 msidata_coordinates <- data.frame(coord(msidata)\$x, coord(msidata)\$y, c(1:ncol(msidata))) | |
37 colnames(msidata_coordinates) <- c("x", "y", "pixel_index") | |
38 merged_annotation <- merge(msidata_coordinates, annotation_input, by=c("x", "y"), all.x=TRUE) | |
39 merged_annotation[is.na(merged_annotation)] <- "NA" | |
40 merged_annotation <- merged_annotation[order(merged_annotation\$pixel_index),] | |
41 msidata\$annotation <- as.character(merged_annotation[,4]) | |
42 reference_group <- msidata\$annotation == "$reference_type.ref_name" | |
43 #end if | |
44 | |
45 ## remove duplicated coordinates | |
46 msidata <- msidata[,!duplicated(coord(msidata))] | |
47 | |
48 | |
49 @DATA_PROPERTIES_INRAM@ | |
50 | |
51 | |
52 ######################################## PDF ################################### | |
53 ################################################################################ | |
54 ################################################################################ | |
55 | |
56 | |
57 pdf("colocalization.pdf", fonts = "Times", pointsize = 12) | |
58 plot(0,type='n',axes=FALSE,ann=FALSE) | |
59 | |
60 title(main=paste0("Colocalization for file: \n\n", "$infile.display_name")) | |
61 | |
62 grid.table(property_df, rows= NULL) | |
63 | |
64 | |
65 if (npeaks > 0 && sum(is.na(spectra(msidata)))==0) | |
66 { | |
67 | |
68 ## colocalization analysis | |
69 col_results <- colocalized(msidata, | |
70 #if str($reference_type.reference) == "mz_ref": | |
71 mz = $reference_type.mz_value, | |
72 #else | |
73 ref = reference_group, | |
74 #end if | |
75 n = $n_tophits, | |
76 sort.by = "$sort_by", | |
77 threshold = median) | |
78 | |
79 ## Summary results table | |
80 col_results_df <- as.data.frame(col_results) | |
81 | |
82 write.table(col_results_df, file="$coloc_results", quote = FALSE, row.names = FALSE, col.names=TRUE, sep = "\t") | |
83 | |
84 ## visualize top 10 m/z features | |
85 | |
86 if (nrow(col_results_df) <= 10) | |
87 { | |
88 for (mass in col_results_df\$mz){ | |
89 par(oma=c(0,0,0,1))## margin for image legend | |
90 print(image(msidata, mz=mass, plusminus=0.25, | |
91 main= paste0(round(mass, digits = 2)), | |
92 contrast.enhance = "histogram", strip=FALSE, ylim= c(maximumy,minimumy))) | |
93 } | |
94 }else{ | |
95 for (mass in col_results_df\$mz[1:10]){ | |
96 par(oma=c(0,0,0,1))## margin for image legend | |
97 print(image(msidata, mz=mass, plusminus=0.25, | |
98 main= paste0(round(mass, digits = 2)), | |
99 contrast.enhance = "histogram", strip=FALSE, ylim= c(maximumy,minimumy))) | |
100 } | |
101 } | |
102 | |
103 | |
104 dev.off() | |
105 | |
106 }else{ | |
107 print("Inputfile has no intensities > 0") | |
108 } | |
109 | |
110 ]]></configfile> | |
111 </configfiles> | |
112 <inputs> | |
113 <expand macro="reading_msidata"/> | |
114 <conditional name="reference_type"> | |
115 <param name="reference" type="select" label="Reference type" help="Region of interest (selected spectra) or m/z feature."> | |
116 <option value="mz_ref" selected="True">m/z feature</option> | |
117 <option value="roi_ref">Region of interest (spectra)</option> | |
118 </param> | |
119 <when value="mz_ref"> | |
120 <param name="mz_value" type="float" value="1000" label="m/z feature" help="The m/z closest to this m/z value will be used as a reference."/> | |
121 </when> | |
122 <when value="roi_ref"> | |
123 <expand macro="reading_pixel_annotations"/> | |
124 <param name="ref_name" type="text" value="reference" label="Reference name" help="Name has to match exactly on of the annotation names in the annotation file"/> | |
125 </when> | |
126 </conditional> | |
127 <param name="n_tophits" type="integer" value="10" label="Top hits" help="The number of top-ranked colocalized features to return in the tabular file." /> | |
128 <param name="sort_by" type="select" display="radio" | |
129 label="sort.by" help="The colocalization measure used to rank colocalized features. Possible options | |
130 include Pearson’s correlation and Manders’ colocalization coefficients."> | |
131 <option value="correlation" selected="True">Pearson's correlation</option> | |
132 <option value="M1">Manders' colocalization coefficient 1</option> | |
133 <option value="M2">Manders' colocalization coefficient 2</option> | |
134 </param> | |
135 </inputs> | |
136 <outputs> | |
137 <data format="pdf" name="coloc_pdf" from_work_dir="colocalization.pdf" label = "${tool.name} on ${on_string}: results"/> | |
138 <data format="tabular" name="coloc_results" label="${tool.name} on ${on_string}: summary"/> | |
139 </outputs> | |
140 <tests> | |
141 <test> | |
142 <param name="infile" value="" ftype="imzml"> | |
143 <composite_data value="spatial_DGMM_input.imzML"/> | |
144 <composite_data value="spatial_DGMM_input.ibd"/> | |
145 </param> | |
146 <conditional name="reference_type"> | |
147 <param name="reference" value="mz_ref"/> | |
148 <param name="mz_value" value="1000"/> | |
149 </conditional> | |
150 <output name="coloc_pdf" file="coloc1.pdf" compare="sim_size" delta="2000"/> | |
151 <output name="coloc_results" file="coloc_table1.tabular"/> | |
152 </test> | |
153 <test> | |
154 <param name="infile" value="" ftype="imzml"> | |
155 <composite_data value="spatial_DGMM_input.imzML"/> | |
156 <composite_data value="spatial_DGMM_input.ibd"/> | |
157 </param> | |
158 <conditional name="reference_type"> | |
159 <param name="reference" value="roi_ref"/> | |
160 <param name="annotation_file" value="DGMM_annotations.tabular"/> | |
161 <param name="column_x" value="1"/> | |
162 <param name="column_y" value="2"/> | |
163 <param name="column_names" value="3"/> | |
164 <param name="tabular_header" value="True"/> | |
165 <param name="ref_name" value="circle"/> | |
166 </conditional> | |
167 <param name="n_tophits" value="5"/> | |
168 <param name="sort_by" value="M2"/> | |
169 <output name="coloc_pdf" file="coloc2.pdf" compare="sim_size" delta="2000"/> | |
170 <output name="coloc_results" file="coloc_table2.tabular"/> | |
171 </test> | |
172 <test> | |
173 <param name="infile" value="123_combined.RData" ftype="rdata"/> | |
174 <conditional name="reference_type"> | |
175 <param name="reference" value="mz_ref"/> | |
176 <param name="mz_value" value="102.0"/> | |
177 </conditional> | |
178 <param name="n_tophits" value="50"/> | |
179 <param name="sort_by" value="correlation"/> | |
180 <output name="coloc_pdf" file="coloc3.pdf" compare="sim_size" delta="2000"/> | |
181 <output name="coloc_results" file="coloc_table3.tabular"/> | |
182 </test> | |
183 </tests> | |
184 <help> | |
185 <![CDATA[ | |
186 | |
187 @CARDINAL_DESCRIPTION@ | |
188 | |
189 ----- | |
190 | |
191 This tool finds colocalized features in an imaging dataset. Use it to find m/z features that are colocalized with another m/z feature or regions of interests. | |
192 | |
193 @MSIDATA_INPUT_DESCRIPTION@ | |
194 | |
195 - NA intensities are not allowed | |
196 - duplicated coordinates will be removed | |
197 - it is highly recommended to use a dataset that is reduced for the number of m/z features e.g. pre-processed and optionally filtered for m/z of interest in order to keep computational times reasonable. | |
198 | |
199 | |
200 **Options** | |
201 | |
202 - The reference can be either a single m/z feature or a region of interest provided via the annotation file. | |
203 | |
204 - For single m/z features the closest m/z to the m/z value that is used as reference is used | |
205 - For regions of interest as a reference the name of the region that should be used as a reference has to be written exactly in the way in which it appears in the annotation file input. | |
206 @SPECTRA_TABULAR_INPUT_DESCRIPTION@ | |
207 | |
208 - By default, pearson correlation is used to rank the colocalized features. Manders’ colocalization coefficients (M1 and M2) are also provided. | |
209 | |
210 **Output** | |
211 | |
212 - Pdf with file info and the ion images of the top 10 m/z features (to plot the ion images for more m/z features use the MSI mz images tool) | |
213 - Tabular file with the top m/z features and their correlation values (pearson, Manders 1 and Manders 2) with the reference | |
214 | |
215 | |
216 ]]> | |
217 </help> | |
218 <citations> | |
219 <citation type="doi">10.1093/bioinformatics/btv146</citation> | |
220 </citations> | |
221 | |
222 </tool> |