Mercurial > repos > iuc > anndata_manipulate
comparison manipulate.xml @ 1:19592ec717ef draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/anndata/ commit 8ef5f7c6f8728608a3f05bb51e11b642b84a05f5"
author | iuc |
---|---|
date | Wed, 16 Oct 2019 06:26:45 -0400 |
parents | 0ef28c0963c8 |
children | a56baceb1900 |
comparison
equal
deleted
inserted
replaced
0:0ef28c0963c8 | 1:19592ec717ef |
---|---|
48 #set $categories = [x.strip() for x in str($manipulate.categories).split(',')] | 48 #set $categories = [x.strip() for x in str($manipulate.categories).split(',')] |
49 adata.rename_categories( | 49 adata.rename_categories( |
50 key='$manipulate.key', | 50 key='$manipulate.key', |
51 categories=$categories) | 51 categories=$categories) |
52 | 52 |
53 #else if $manipulate.function == 'transpose' | |
54 adata.transpose() | |
55 | |
56 #else if $manipulate.function == 'strings_to_categoricals' | 53 #else if $manipulate.function == 'strings_to_categoricals' |
57 adata.strings_to_categoricals() | 54 adata.strings_to_categoricals() |
55 | |
56 #else if $manipulate.function == 'transpose' | |
57 adata = adata.transpose() | |
58 | |
59 #else if $manipulate.function == 'add_annotation' | |
60 import pandas as pd | |
61 extra_annot_t = pd.read_csv('$manipulate.new_annot', sep='\t').reset_index(drop=True) | |
62 #if $manipulate.var_obs == 'var' | |
63 var_index = adata.var_names | |
64 var = pd.concat([adata.var.reset_index(drop=True), extra_annot_t], axis=1) | |
65 var.index = var_index | |
66 adata.var = var | |
67 #else if $manipulate.var_obs == 'obs' | |
68 obs_index = adata.obs.index | |
69 obs = pd.concat([adata.obs.reset_index(drop=True), extra_annot_t], axis=1) | |
70 obs.index = obs_index | |
71 adata.obs = obs | |
72 #end if | |
73 | |
74 #else if $manipulate.function == 'filter' | |
75 #if $manipulate.filter.filter == 'key' | |
76 #if $manipulate.var_obs == 'var' | |
77 filtered = adata.var['$manipulate.filter.key'] | |
78 #else if $manipulate.var_obs == 'obs' | |
79 filtered = adata.obs['$manipulate.filter.key'] | |
80 #end if | |
81 | |
82 #if $manipulate.filter.filter_key.type == 'number' | |
83 #if $manipulate.filter.filter_key.filter == 'equal' | |
84 filtered = filtered == $manipulate.filter.filter_key.value | |
85 #else if $manipulate.filter.filter_key.filter == 'equal' | |
86 filtered = filtered != $manipulate.filter.filter_key.value | |
87 #else if $manipulate.filter.filter_key.filter == 'less' | |
88 filtered = filtered < $manipulate.filter.filter_key.value | |
89 #else if $manipulate.filter.filter_key.filter == 'less_or_equal' | |
90 filtered = filtered <= $manipulate.filter.filter_key.value | |
91 #else if $manipulate.filter.filter_key.filter == 'greater' | |
92 filtered = filtered > $manipulate.filter.filter_key.value | |
93 #else if $manipulate.filter.filter_key.filter == 'greater_or_equal' | |
94 filtered = filtered >= $manipulate.filter.filter_key.value | |
95 #end if | |
96 #else if $manipulate.filter.filter_key.type == 'text' | |
97 #if $manipulate.filter.filter_key.filter == 'equal' | |
98 filtered = filtered == '$manipulate.filter.filter_key.value' | |
99 #else | |
100 filtered = filtered != '$manipulate.filter.filter_key.value' | |
101 #end if | |
102 #else if $manipulate.filter.filter_key.type == 'boolean' | |
103 filtered = filtered == $manipulate.filter.filter_key.value | |
104 #end if | |
105 | |
106 #else if $manipulate.filter.filter == 'index' | |
107 #if str($manipulate.filter.index.format) == 'file' | |
108 with open('$manipulate.filter.index.file', 'r') as filter_f: | |
109 filters = [str(x.strip()) for x in filter_f.readlines()] | |
110 filtered = filters | |
111 #else | |
112 #set $filters = [str(x.strip()) for x in $manipulate.filter.index.text.split(',')] | |
113 filtered = $filters | |
114 #end if | |
115 #end if | |
116 print(filtered) | |
117 | |
118 #if $manipulate.var_obs == 'var' | |
119 adata = adata[:,filtered] | |
120 #else if $manipulate.var_obs == 'obs' | |
121 adata = adata[filtered, :] | |
122 #end if | |
58 #end if | 123 #end if |
59 | 124 |
60 adata.write('anndata.h5ad') | 125 adata.write('anndata.h5ad') |
61 ]]></configfile> | 126 ]]></configfile> |
62 </configfiles> | 127 </configfiles> |
68 <option value="obs_names_make_unique">Makes the obs index unique by appending '1', '2', etc</option> | 133 <option value="obs_names_make_unique">Makes the obs index unique by appending '1', '2', etc</option> |
69 <option value="var_names_make_unique">Makes the var index unique by appending '1', '2', etc</option> | 134 <option value="var_names_make_unique">Makes the var index unique by appending '1', '2', etc</option> |
70 <option value="rename_categories">Rename categories of annotation</option> | 135 <option value="rename_categories">Rename categories of annotation</option> |
71 <option value="strings_to_categoricals">Transform string annotations to categoricals</option> | 136 <option value="strings_to_categoricals">Transform string annotations to categoricals</option> |
72 <option value="transpose">Transpose the data matrix, leaving observations and variables interchanged</option> | 137 <option value="transpose">Transpose the data matrix, leaving observations and variables interchanged</option> |
138 <option value="add_annotation">Add new annotation(s) for observations or variables</option> | |
139 <option value="filter">Filter observations or variables</option> | |
73 </param> | 140 </param> |
74 <when value="concatenate"> | 141 <when value="concatenate"> |
75 <param name="other_adatas" type="data" format="h5ad" multiple="true" label="Annotated data matrix to add"/> | 142 <param name="other_adatas" type="data" format="h5ad" multiple="true" label="Annotated data matrix to add"/> |
76 <param name="join" type="select" label="Join method"> | 143 <param name="join" type="select" label="Join method"> |
77 <option value="inner">Intersection of variables</option> | 144 <option value="inner">Intersection of variables</option> |
95 <param name="key" type="text" value="" label="Key for observations or variables annotation" help="Annotation key in obs or var"/> | 162 <param name="key" type="text" value="" label="Key for observations or variables annotation" help="Annotation key in obs or var"/> |
96 <param name="categories" type="text" value="" label="Comma-separated list of new categories" help="It should be the same number as the old categories"/> | 163 <param name="categories" type="text" value="" label="Comma-separated list of new categories" help="It should be the same number as the old categories"/> |
97 </when> | 164 </when> |
98 <when value="strings_to_categoricals"/> | 165 <when value="strings_to_categoricals"/> |
99 <when value="transpose"/> | 166 <when value="transpose"/> |
167 <when value="add_annotation"> | |
168 <param name="var_obs" type="select" label="What to annotate?"> | |
169 <option value="var">Variables (var)</option> | |
170 <option value="obs">Observations (obs)</option> | |
171 </param> | |
172 <param name="new_annot" type="data" format="tabular" label="Table with new annotations" | |
173 help="The new table should have the same number of rows and same order than obs or var. The key names should be in the header (1st line)"/> | |
174 </when> | |
175 <when value="filter"> | |
176 <param name="var_obs" type="select" label="What to annotate?"> | |
177 <option value="var">Variables (var)</option> | |
178 <option value="obs">Observations (obs)</option> | |
179 </param> | |
180 <conditional name="filter"> | |
181 <param name="filter" type="select" label="Type of filtering?"> | |
182 <option value="key">By key (column) values</option> | |
183 <option value="index">By index (row)</option> | |
184 </param> | |
185 <when value="key"> | |
186 <param name="key" type="text" value="n_genes" label="Key to filter"/> | |
187 <conditional name="filter_key"> | |
188 <param name="type" type="select" label="Type of value to filter"> | |
189 <option value="number">Number</option> | |
190 <option value="text">Text</option> | |
191 <option value="boolean">Boolean</option> | |
192 </param> | |
193 <when value="number"> | |
194 <param name="filter" type="select" label="Filter"> | |
195 <option value="equal">equal to</option> | |
196 <option value="not_equal">not equal to</option> | |
197 <option value="less">less than</option> | |
198 <option value="less_or_equal">less than or equal to</option> | |
199 <option value="greater">greater than</option> | |
200 <option value="greater_or_equal">greater than or equal to</option> | |
201 </param> | |
202 <param name="value" type="float" value="2500" label="Value"/> | |
203 </when> | |
204 <when value="text"> | |
205 <param name="filter" type="select" label="Filter"> | |
206 <option value="equal">equal to</option> | |
207 <option value="not_equal">not equal to</option></param> | |
208 <param name="value" type="text" value="2500" label="Value"/> | |
209 </when> | |
210 <when value="boolean"> | |
211 <param name="value" type="boolean" truevalue="True" falsevalue="False" checked="true" label="Value to keep"/> | |
212 </when> | |
213 </conditional> | |
214 </when> | |
215 <when value="index"> | |
216 <conditional name="index"> | |
217 <param name="format" type="select" label="Format for the filter by index"> | |
218 <option value="file">File</option> | |
219 <option value="text" selected="true">Text</option> | |
220 </param> | |
221 <when value="text"> | |
222 <param name="text" type="text" value="" label="List of index to keep" help="Indexes separated by a comma"/> | |
223 </when> | |
224 <when value="file"> | |
225 <param name="file" type="data" format="txt" label="File with the list of index to keep" help="One index per line"/> | |
226 </when> | |
227 </conditional> | |
228 </when> | |
229 </conditional> | |
230 </when> | |
100 </conditional> | 231 </conditional> |
101 </inputs> | 232 </inputs> |
102 <outputs> | 233 <outputs> |
103 <data name="anndata" format="h5ad" from_work_dir="anndata.h5ad" label="${tool.name} on ${on_string}"/> | 234 <data name="anndata" format="h5ad" from_work_dir="anndata.h5ad" label="${tool.name} (${manipulate.function}) on ${on_string}"/> |
104 </outputs> | 235 </outputs> |
105 <tests> | 236 <tests> |
106 <test> | 237 <test> |
238 <!-- test 1 --> | |
107 <param name="input" value="krumsiek11.h5ad"/> | 239 <param name="input" value="krumsiek11.h5ad"/> |
108 <conditional name="manipulate"> | 240 <conditional name="manipulate"> |
109 <param name="function" value="concatenate"/> | 241 <param name="function" value="concatenate"/> |
110 <param name="other_adatas" value="import.csv.h5ad"/> | 242 <param name="other_adatas" value="import.csv.h5ad"/> |
111 <param name="join" value="inner"/> | 243 <param name="join" value="inner"/> |
120 <has_text_matching expression="batch_key='batch'"/> | 252 <has_text_matching expression="batch_key='batch'"/> |
121 </assert_stdout> | 253 </assert_stdout> |
122 <output name="anndata" value="manipulate.concatenate.h5ad" ftype="h5ad" compare="sim_size"/> | 254 <output name="anndata" value="manipulate.concatenate.h5ad" ftype="h5ad" compare="sim_size"/> |
123 </test> | 255 </test> |
124 <test> | 256 <test> |
257 <!-- test 2 --> | |
125 <param name="input" value="krumsiek11.h5ad"/> | 258 <param name="input" value="krumsiek11.h5ad"/> |
126 <conditional name="manipulate"> | 259 <conditional name="manipulate"> |
127 <param name="function" value="obs_names_make_unique"/> | 260 <param name="function" value="obs_names_make_unique"/> |
128 <param name="join" value="-"/> | 261 <param name="join" value="-"/> |
129 </conditional> | 262 </conditional> |
131 <has_text_matching expression="adata.obs_names_make_unique\(join='-'\)"/> | 264 <has_text_matching expression="adata.obs_names_make_unique\(join='-'\)"/> |
132 </assert_stdout> | 265 </assert_stdout> |
133 <output name="anndata" value="manipulate.obs_names_make_unique.h5ad" ftype="h5ad" compare="sim_size"/> | 266 <output name="anndata" value="manipulate.obs_names_make_unique.h5ad" ftype="h5ad" compare="sim_size"/> |
134 </test> | 267 </test> |
135 <test> | 268 <test> |
269 <!-- test 3 --> | |
136 <param name="input" value="krumsiek11.h5ad"/> | 270 <param name="input" value="krumsiek11.h5ad"/> |
137 <conditional name="manipulate"> | 271 <conditional name="manipulate"> |
138 <param name="function" value="var_names_make_unique"/> | 272 <param name="function" value="var_names_make_unique"/> |
139 <param name="join" value="-"/> | 273 <param name="join" value="-"/> |
140 </conditional> | 274 </conditional> |
142 <has_text_matching expression="adata.var_names_make_unique\(join='-'\)"/> | 276 <has_text_matching expression="adata.var_names_make_unique\(join='-'\)"/> |
143 </assert_stdout> | 277 </assert_stdout> |
144 <output name="anndata" value="manipulate.var_names_make_unique.h5ad" ftype="h5ad" compare="sim_size"/> | 278 <output name="anndata" value="manipulate.var_names_make_unique.h5ad" ftype="h5ad" compare="sim_size"/> |
145 </test> | 279 </test> |
146 <test> | 280 <test> |
281 <!-- test 4 --> | |
147 <param name="input" value="krumsiek11.h5ad"/> | 282 <param name="input" value="krumsiek11.h5ad"/> |
148 <conditional name="manipulate"> | 283 <conditional name="manipulate"> |
149 <param name="function" value="rename_categories"/> | 284 <param name="function" value="rename_categories"/> |
150 <param name="key" value="cell_type"/> | 285 <param name="key" value="cell_type"/> |
151 <param name="categories" value="Er,Ml,Mt, Ne, pr"/> | 286 <param name="categories" value="Er,Ml,Mt, Ne, pr"/> |
156 <has_text_matching expression="categories=\['Er', 'Ml', 'Mt', 'Ne', 'pr'\]"/> | 291 <has_text_matching expression="categories=\['Er', 'Ml', 'Mt', 'Ne', 'pr'\]"/> |
157 </assert_stdout> | 292 </assert_stdout> |
158 <output name="anndata" value="manipulate.rename_categories.h5ad" ftype="h5ad" compare="sim_size"/> | 293 <output name="anndata" value="manipulate.rename_categories.h5ad" ftype="h5ad" compare="sim_size"/> |
159 </test> | 294 </test> |
160 <test> | 295 <test> |
296 <!-- test 5 --> | |
161 <param name="input" value="krumsiek11.h5ad"/> | 297 <param name="input" value="krumsiek11.h5ad"/> |
162 <conditional name="manipulate"> | 298 <conditional name="manipulate"> |
163 <param name="function" value="strings_to_categoricals"/> | 299 <param name="function" value="strings_to_categoricals"/> |
164 </conditional> | 300 </conditional> |
165 <assert_stdout> | 301 <assert_stdout> |
166 <has_text_matching expression="adata.strings_to_categoricals"/> | 302 <has_text_matching expression="adata.strings_to_categoricals"/> |
167 </assert_stdout> | 303 </assert_stdout> |
168 <output name="anndata" value="manipulate.strings_to_categoricals.h5ad" ftype="h5ad" compare="sim_size"/> | 304 <output name="anndata" value="manipulate.strings_to_categoricals.h5ad" ftype="h5ad" compare="sim_size"/> |
169 </test> | 305 </test> |
170 <test> | 306 <test> |
307 <!-- test 6 --> | |
171 <param name="input" value="krumsiek11.h5ad"/> | 308 <param name="input" value="krumsiek11.h5ad"/> |
172 <conditional name="manipulate"> | 309 <conditional name="manipulate"> |
173 <param name="function" value="transpose"/> | 310 <param name="function" value="transpose"/> |
174 </conditional> | 311 </conditional> |
175 <assert_stdout> | 312 <assert_stdout> |
176 <has_text_matching expression="adata.transpose"/> | 313 <has_text_matching expression="adata.transpose"/> |
177 </assert_stdout> | 314 </assert_stdout> |
178 <output name="anndata" value="manipulate.transpose.h5ad" ftype="h5ad" compare="sim_size"/> | 315 <output name="anndata" value="manipulate.transpose.h5ad" ftype="h5ad" compare="sim_size"/> |
316 </test> | |
317 <test> | |
318 <!-- test 7 --> | |
319 <param name="input" value="krumsiek11.h5ad"/> | |
320 <conditional name="manipulate"> | |
321 <param name="function" value="add_annotation"/> | |
322 <param name="var_obs" value="var"/> | |
323 <param name="new_annot" value="var_add_annotation.tabular"/> | |
324 </conditional> | |
325 <output name="anndata" value="manipulate.add_annotation_var.h5ad" ftype="h5ad" compare="sim_size"/> | |
326 </test> | |
327 <test> | |
328 <!-- test 8 --> | |
329 <param name="input" value="krumsiek11.h5ad"/> | |
330 <conditional name="manipulate"> | |
331 <param name="function" value="add_annotation"/> | |
332 <param name="var_obs" value="obs"/> | |
333 <param name="new_annot" value="obs_add_annotation.tabular"/> | |
334 </conditional> | |
335 <output name="anndata" value="manipulate.add_annotation_obs.h5ad" ftype="h5ad" compare="sim_size"/> | |
336 </test> | |
337 <test> | |
338 <!-- test 9 --> | |
339 <param name="input" value="krumsiek11.h5ad"/> | |
340 <conditional name="manipulate"> | |
341 <param name="function" value="filter"/> | |
342 <param name="var_obs" value="var"/> | |
343 <conditional name="filter"> | |
344 <param name="filter" value="index"/> | |
345 <conditional name="index"> | |
346 <param name="format" value="text"/> | |
347 <param name="text" value="Gata2,EKLF"/> | |
348 </conditional> | |
349 </conditional> | |
350 </conditional> | |
351 <output name="anndata" value="manipulate.filter_var_index.h5ad" ftype="h5ad" compare="sim_size"/> | |
352 </test> | |
353 <test> | |
354 <!-- test 10 --> | |
355 <param name="input" value="krumsiek11.h5ad"/> | |
356 <conditional name="manipulate"> | |
357 <param name="function" value="filter"/> | |
358 <param name="var_obs" value="obs"/> | |
359 <conditional name="filter"> | |
360 <param name="filter" value="key"/> | |
361 <param name="key" value="cell_type"/> | |
362 <conditional name="filter_key"> | |
363 <param name="type" value="text"/> | |
364 <param name="filter" value="equal"/> | |
365 <param name="value" value="progenitor"/> | |
366 </conditional> | |
367 </conditional> | |
368 </conditional> | |
369 <output name="anndata" value="manipulate.filter_obs_key.h5ad" ftype="h5ad" compare="sim_size"/> | |
179 </test> | 370 </test> |
180 </tests> | 371 </tests> |
181 <help><![CDATA[ | 372 <help><![CDATA[ |
182 **What it does** | 373 **What it does** |
183 | 374 |
208 Only affects string annotations that lead to less categories than the total number of observations. | 399 Only affects string annotations that lead to less categories than the total number of observations. |
209 | 400 |
210 - Transpose the data matrix, leaving observations and variables interchanged (`transpose method <https://anndata.readthedocs.io/en/latest/anndata.AnnData.transpose.html>`__) | 401 - Transpose the data matrix, leaving observations and variables interchanged (`transpose method <https://anndata.readthedocs.io/en/latest/anndata.AnnData.transpose.html>`__) |
211 | 402 |
212 Data matrix is transposed, observations and variables are interchanged. | 403 Data matrix is transposed, observations and variables are interchanged. |
404 | |
405 - Add annotation for variables or observations | |
406 | |
407 - Filter data variables or observations, by index or key | |
213 | 408 |
214 @HELP@ | 409 @HELP@ |
215 ]]></help> | 410 ]]></help> |
216 <expand macro="citations"/> | 411 <expand macro="citations"/> |
217 </tool> | 412 </tool> |