comparison manipulate.xml @ 13:7e8c677a7b71 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/anndata/ commit 67b3808b56df343798263ff0c905df8cb789edfa
author iuc
date Sat, 14 Sep 2024 19:58:00 +0000
parents ed4996a16f7f
children c4209ea387d4
comparison
equal deleted inserted replaced
12:ed4996a16f7f 13:7e8c677a7b71
1 <tool id="anndata_manipulate" name="Manipulate AnnData" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@"> 1 <tool id="anndata_manipulate" name="Manipulate AnnData" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
2 <description>object</description> 2 <description>object</description>
3 <macros> 3 <macros>
4 <import>macros.xml</import> 4 <import>macros.xml</import>
5 <xml name="param_join"> 5 <xml name="param_join">
6 <param name="join" type="select" label="The connecting string between name and integer"> 6 <param name="join" type="select" label="The connecting string between name and integer">
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 == 'remove_keys'
54 #if $manipulate.obs_keys
55 #set $keys = [x.strip() for x in str($manipulate.obs_keys).split(',')]
56 adata.obs = adata.obs.drop(columns=$keys)
57 #end if
58
59 #if $manipulate.var_keys
60 #set $keys = [x.strip() for x in str($manipulate.var_keys).split(',')]
61 adata.var = adata.vars.drop(columns=$keys)
62 #end if
63
64 #else if $manipulate.function == 'flag_genes'
65 ## adapted from anndata operations
66 #for $flag in $manipulate.gene_flags
67 k_cat = adata.var_names.str.startswith('${flag.startswith}')
68 if k_cat.sum() > 0:
69 adata.var['${flag.col_name}'] = k_cat
70 else:
71 print(f'No genes starting with {'${flag.startswith}'} found.')
72 #end for
73
53 #else if $manipulate.function == 'strings_to_categoricals' 74 #else if $manipulate.function == 'strings_to_categoricals'
54 adata.strings_to_categoricals() 75 adata.strings_to_categoricals()
55 76
56 #else if $manipulate.function == 'transpose' 77 #else if $manipulate.function == 'transpose'
57 adata = adata.transpose() 78 adata = adata.transpose()
68 obs_index = adata.obs.index 89 obs_index = adata.obs.index
69 obs = pd.concat([adata.obs.reset_index(drop=True), extra_annot_t], axis=1) 90 obs = pd.concat([adata.obs.reset_index(drop=True), extra_annot_t], axis=1)
70 obs.index = obs_index 91 obs.index = obs_index
71 adata.obs = obs 92 adata.obs = obs
72 #end if 93 #end if
94
95 #else if $manipulate.function == 'split_on_obs'
96 import os
97 res_dir = "output_split"
98 os.makedirs(res_dir, exist_ok=True)
99 for s,field_value in enumerate(adata.obs["${manipulate.key}"].unique()):
100 ad_s = adata[adata.obs.${manipulate.key} == field_value]
101 ad_s.write(f"{res_dir}/${manipulate.key}_{s}.h5ad", compression='gzip')
73 102
74 #else if $manipulate.function == 'filter' 103 #else if $manipulate.function == 'filter'
75 #if $manipulate.filter.filter == 'key' 104 #if $manipulate.filter.filter == 'key'
76 #if $manipulate.var_obs == 'var' 105 #if $manipulate.var_obs == 'var'
77 filtered = adata.var['$manipulate.filter.key'] 106 filtered = adata.var['$manipulate.filter.key']
124 #else if $manipulate.function == 'save_raw' 153 #else if $manipulate.function == 'save_raw'
125 adata.raw = adata 154 adata.raw = adata
126 155
127 #end if 156 #end if
128 157
129 adata.write('anndata.h5ad') 158 #if $manipulate.function != 'split_on_obs'
159 adata.write('anndata.h5ad', compression='gzip')
160 print(adata)
161 #end if
162
130 ]]></configfile> 163 ]]></configfile>
131 </configfiles> 164 </configfiles>
132 <inputs> 165 <inputs>
133 <param name="input" type="data" format="h5ad" label="Annotated data matrix"/> 166 <param name="input" type="data" format="h5ad" label="Annotated data matrix"/>
134 <conditional name="manipulate"> 167 <conditional name="manipulate">
135 <param name="function" type="select" label="Function to manipulate the object"> 168 <param name="function" type="select" label="Function to manipulate the object">
136 <option value="concatenate">Concatenate along the observations axis</option> 169 <option value="concatenate">Concatenate along the observations axis</option>
137 <option value="obs_names_make_unique">Makes the obs index unique by appending '1', '2', etc</option> 170 <option value="obs_names_make_unique">Makes the obs index unique by appending '1', '2', etc</option>
138 <option value="var_names_make_unique">Makes the var index unique by appending '1', '2', etc</option> 171 <option value="var_names_make_unique">Makes the var index unique by appending '1', '2', etc</option>
139 <option value="rename_categories">Rename categories of annotation</option> 172 <option value="rename_categories">Rename categories of annotation</option>
173 <option value="remove_keys">Remove keys from obs or var annotations</option>
174 <option value="flag_genes">Flag genes start with a pattern</option><!--adapted from EBI anndata operations tool -->
140 <option value="strings_to_categoricals">Transform string annotations to categoricals</option> 175 <option value="strings_to_categoricals">Transform string annotations to categoricals</option>
141 <option value="transpose">Transpose the data matrix, leaving observations and variables interchanged</option> 176 <option value="transpose">Transpose the data matrix, leaving observations and variables interchanged</option>
142 <option value="add_annotation">Add new annotation(s) for observations or variables</option> 177 <option value="add_annotation">Add new annotation(s) for observations or variables</option>
178 <option value="split_on_obs">Split the AnnData object into multiple AnnData objects based on the values of a given obs key</option><!--adapted from EBI anndata operations tool-->
143 <option value="filter">Filter observations or variables</option> 179 <option value="filter">Filter observations or variables</option>
144 <option value="save_raw">Freeze the current state into the 'raw' attribute</option> 180 <option value="save_raw">Freeze the current state into the 'raw' attribute</option>
145 </param> 181 </param>
146 <when value="concatenate"> 182 <when value="concatenate">
147 <param name="other_adatas" type="data" format="h5ad" multiple="true" label="Annotated data matrix to add"/> 183 <param name="other_adatas" type="data" format="h5ad" multiple="true" label="Annotated data matrix to add"/>
165 </when> 201 </when>
166 <when value="rename_categories"> 202 <when value="rename_categories">
167 <param name="key" type="text" value="" label="Key for observations or variables annotation" help="Annotation key in obs or var"/> 203 <param name="key" type="text" value="" label="Key for observations or variables annotation" help="Annotation key in obs or var"/>
168 <param name="categories" type="text" value="" label="Comma-separated list of new categories" help="It should be the same number as the old categories"/> 204 <param name="categories" type="text" value="" label="Comma-separated list of new categories" help="It should be the same number as the old categories"/>
169 </when> 205 </when>
206 <when value="remove_keys">
207 <param name="obs_keys" type="text" value="" optional="true" label="Keys/fields to remove from observations (obs)">
208 <expand macro="sanitize_query"/>
209 </param>
210 <param name="var_keys" type="text" value="" optional="true" label="Keys/fields to remove from variables (var)">
211 <expand macro="sanitize_query"/>
212 </param>
213 </when>
214 <when value="flag_genes">
215 <repeat name="gene_flags" title="Flag genes that start with these names">
216 <param name="startswith" type="text" label="Text that you expect the genes to be flagged to start with" help="For example, 'MT-' for mito genes">
217 <sanitizer invalid_char="">
218 <valid initial="string.ascii_letters,string.digits,string.punctuation">
219 <remove value="&apos;" />
220 </valid>
221 </sanitizer>
222 </param>
223 <param name="col_name" type="text" label="Name of the column in var.names where this boolean flag is stored" help="For example, name this column as 'mito' for mitochondrial genes."/>
224 </repeat>
225 </when>
170 <when value="strings_to_categoricals" ></when> 226 <when value="strings_to_categoricals" ></when>
171 <when value="transpose" ></when> 227 <when value="transpose" ></when>
172 <when value="add_annotation"> 228 <when value="add_annotation">
173 <param name="var_obs" type="select" label="What to annotate?"> 229 <param name="var_obs" type="select" label="What to annotate?">
174 <option value="var">Variables (var)</option> 230 <option value="var">Variables (var)</option>
175 <option value="obs">Observations (obs)</option> 231 <option value="obs">Observations (obs)</option>
176 </param> 232 </param>
177 <param name="new_annot" type="data" format="tabular" label="Table with new annotations" 233 <param name="new_annot" type="data" format="tabular" label="Table with new annotations"
178 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)"/> 234 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)"/>
235 </when>
236 <when value="split_on_obs">
237 <param name="key" type="text" label="The obs key to split on" help="For example, if you want to split on cluster annotation, you can use the key 'louvain'. The output will be a collection of anndata objects">
238 <sanitizer invalid_char="">
239 <valid initial="string.ascii_letters,string.digits,string.punctuation">
240 <remove value="&apos;" />
241 </valid>
242 </sanitizer>
243 </param>
179 </when> 244 </when>
180 <when value="filter"> 245 <when value="filter">
181 <param name="var_obs" type="select" label="What to filter?"> 246 <param name="var_obs" type="select" label="What to filter?">
182 <option value="var">Variables (var)</option> 247 <option value="var">Variables (var)</option>
183 <option value="obs">Observations (obs)</option> 248 <option value="obs">Observations (obs)</option>
235 </when> 300 </when>
236 <when value="save_raw"></when> 301 <when value="save_raw"></when>
237 </conditional> 302 </conditional>
238 </inputs> 303 </inputs>
239 <outputs> 304 <outputs>
240 <data name="anndata" format="h5ad" from_work_dir="anndata.h5ad" label="${tool.name} (${manipulate.function}) on ${on_string}"/> 305 <data name="anndata" format="h5ad" from_work_dir="anndata.h5ad" label="${tool.name} (${manipulate.function}) on ${on_string}">
306 <filter>manipulate['function'] != 'split_on_obs'</filter>
307 </data>
308 <collection name="output_h5ad_split" type="list" label="${tool.name} (${manipulate.function}) on ${on_string} Collection">
309 <discover_datasets pattern="(?P&lt;designation&gt;.+)\.h5" directory="output_split" format="h5ad" visible="true"/>
310 <filter>manipulate['function'] == 'split_on_obs'</filter>
311 </collection>
241 </outputs> 312 </outputs>
242 <tests> 313 <tests>
243 <test> 314 <test expect_num_outputs="1">
244 <!-- test 1 --> 315 <!-- test 1 -->
245 <param name="input" value="import.csv.h5ad"/> 316 <param name="input" value="import.csv.h5ad"/>
246 <conditional name="manipulate"> 317 <conditional name="manipulate">
247 <param name="function" value="concatenate"/> 318 <param name="function" value="concatenate"/>
248 <param name="other_adatas" value="import.csv.h5ad"/> 319 <param name="other_adatas" value="import.csv.h5ad"/>
254 <has_text_matching expression="adata_0"/> 325 <has_text_matching expression="adata_0"/>
255 <has_text_matching expression="adata.concatenate"/> 326 <has_text_matching expression="adata.concatenate"/>
256 <has_text_matching expression="join='inner'"/> 327 <has_text_matching expression="join='inner'"/>
257 <has_text_matching expression="index_unique='-'"/> 328 <has_text_matching expression="index_unique='-'"/>
258 <has_text_matching expression="batch_key='batch'"/> 329 <has_text_matching expression="batch_key='batch'"/>
259 </assert_stdout> 330 <has_text_matching expression="6 × 2"/>
260 <output name="anndata" value="manipulate.concatenate.h5ad" ftype="h5ad" compare="sim_size"/> 331 </assert_stdout>
261 </test> 332 <output name="anndata" ftype="h5ad">
262 <test> 333 <assert_contents>
334 <has_h5_keys keys="obs/batch"/>
335 </assert_contents>
336 </output>
337 </test>
338 <test expect_num_outputs="1">
263 <!-- test 2 --> 339 <!-- test 2 -->
264 <param name="input" value="krumsiek11.h5ad"/> 340 <param name="input" value="krumsiek11.h5ad"/>
265 <conditional name="manipulate"> 341 <conditional name="manipulate">
266 <param name="function" value="obs_names_make_unique"/> 342 <param name="function" value="obs_names_make_unique"/>
267 <param name="join" value="-"/> 343 <param name="join" value="-"/>
268 </conditional> 344 </conditional>
269 <assert_stdout> 345 <assert_stdout>
270 <has_text_matching expression="adata.obs_names_make_unique\(join='-'\)"/> 346 <has_text_matching expression="adata.obs_names_make_unique\(join='-'\)"/>
271 </assert_stdout> 347 <has_text_matching expression="500 × 11"/>
272 <output name="anndata" value="manipulate.obs_names_make_unique.h5ad" ftype="h5ad" compare="sim_size"/> 348 </assert_stdout>
273 </test> 349 <output name="anndata" ftype="h5ad">
274 <test> 350 <assert_contents>
351 <has_h5_keys keys="obs/cell_type"/>
352 <has_h5_keys keys="uns/highlights"/>
353 <has_h5_keys keys="uns/iroot"/>
354 </assert_contents>
355 </output>
356 </test>
357 <test expect_num_outputs="1">
275 <!-- test 3 --> 358 <!-- test 3 -->
276 <param name="input" value="krumsiek11.h5ad"/> 359 <param name="input" value="krumsiek11.h5ad"/>
277 <conditional name="manipulate"> 360 <conditional name="manipulate">
278 <param name="function" value="var_names_make_unique"/> 361 <param name="function" value="var_names_make_unique"/>
279 <param name="join" value="-"/> 362 <param name="join" value="-"/>
280 </conditional> 363 </conditional>
281 <assert_stdout> 364 <assert_stdout>
282 <has_text_matching expression="adata.var_names_make_unique\(join='-'\)"/> 365 <has_text_matching expression="adata.var_names_make_unique\(join='-'\)"/>
283 </assert_stdout> 366 <has_text_matching expression="500 × 11"/>
284 <output name="anndata" value="manipulate.var_names_make_unique.h5ad" ftype="h5ad" compare="sim_size"/> 367 </assert_stdout>
285 </test> 368 <output name="anndata" ftype="h5ad">
286 <test> 369 <assert_contents>
370 <has_h5_keys keys="obs/cell_type"/>
371 <has_h5_keys keys="uns/highlights"/>
372 <has_h5_keys keys="uns/iroot"/>
373 </assert_contents>
374 </output>
375 </test>
376 <test expect_num_outputs="1">
287 <!-- test 4 --> 377 <!-- test 4 -->
288 <param name="input" value="krumsiek11.h5ad"/> 378 <param name="input" value="krumsiek11.h5ad"/>
289 <conditional name="manipulate"> 379 <conditional name="manipulate">
290 <param name="function" value="rename_categories"/> 380 <param name="function" value="rename_categories"/>
291 <param name="key" value="cell_type"/> 381 <param name="key" value="cell_type"/>
292 <param name="categories" value="Ery, Mk, Mo, progenitor"/> 382 <param name="categories" value="ery, mk, mo, progenitor"/>
293 </conditional> 383 </conditional>
294 <assert_stdout> 384 <assert_stdout>
295 <has_text_matching expression="adata.rename_categories"/> 385 <has_text_matching expression="adata.rename_categories"/>
296 <has_text_matching expression="key='cell_type'"/> 386 <has_text_matching expression="key='cell_type'"/>
297 <has_text_matching expression="categories=\['Ery', 'Mk', 'Mo', 'progenitor'\]"/> 387 <has_text_matching expression="categories=\['ery', 'mk', 'mo', 'progenitor'\]"/>
298 </assert_stdout> 388 <has_text_matching expression="500 × 11"/>
299 <output name="anndata" value="manipulate.rename_categories.h5ad" ftype="h5ad" compare="sim_size"/> 389 </assert_stdout>
300 </test> 390 <output name="anndata" ftype="h5ad">
301 <test> 391 <assert_contents>
392 <has_h5_keys keys="obs/cell_type"/>
393 <has_h5_keys keys="uns/highlights"/>
394 <has_h5_keys keys="uns/iroot"/>
395 </assert_contents>
396 </output>
397 </test>
398 <test expect_num_outputs="1">
302 <!-- test 5 --> 399 <!-- test 5 -->
303 <param name="input" value="krumsiek11.h5ad"/> 400 <param name="input" value="krumsiek11.h5ad"/>
304 <conditional name="manipulate"> 401 <conditional name="manipulate">
305 <param name="function" value="strings_to_categoricals"/> 402 <param name="function" value="strings_to_categoricals"/>
306 </conditional> 403 </conditional>
307 <assert_stdout> 404 <assert_stdout>
308 <has_text_matching expression="adata.strings_to_categoricals"/> 405 <has_text_matching expression="adata.strings_to_categoricals"/>
309 </assert_stdout> 406 <has_text_matching expression="500 × 11"/>
310 <output name="anndata" value="manipulate.strings_to_categoricals.h5ad" ftype="h5ad" compare="sim_size"/> 407 </assert_stdout>
311 </test> 408 <output name="anndata" ftype="h5ad">
312 <test> 409 <assert_contents>
410 <has_h5_keys keys="obs/cell_type"/>
411 <has_h5_keys keys="uns/highlights"/>
412 <has_h5_keys keys="uns/iroot"/>
413 </assert_contents>
414 </output>
415 </test>
416 <test expect_num_outputs="1">
313 <!-- test 6 --> 417 <!-- test 6 -->
314 <param name="input" value="krumsiek11.h5ad"/> 418 <param name="input" value="krumsiek11.h5ad"/>
315 <conditional name="manipulate"> 419 <conditional name="manipulate">
316 <param name="function" value="transpose"/> 420 <param name="function" value="transpose"/>
317 </conditional> 421 </conditional>
318 <assert_stdout> 422 <assert_stdout>
319 <has_text_matching expression="adata.transpose"/> 423 <has_text_matching expression="adata.transpose"/>
320 </assert_stdout> 424 <has_text_matching expression="11 × 500"/>
321 <output name="anndata" value="manipulate.transpose.h5ad" ftype="h5ad" compare="sim_size"/> 425 </assert_stdout>
322 </test> 426 <output name="anndata" ftype="h5ad">
323 <test> 427 <assert_contents>
428 <has_h5_keys keys="var/cell_type"/>
429 <has_h5_keys keys="uns/highlights"/>
430 <has_h5_keys keys="uns/iroot"/>
431 </assert_contents>
432 </output>
433 </test>
434 <test expect_num_outputs="1">
324 <!-- test 7 --> 435 <!-- test 7 -->
325 <param name="input" value="krumsiek11.h5ad"/> 436 <param name="input" value="krumsiek11.h5ad"/>
326 <conditional name="manipulate"> 437 <conditional name="manipulate">
327 <param name="function" value="add_annotation"/> 438 <param name="function" value="add_annotation"/>
328 <param name="var_obs" value="var"/> 439 <param name="var_obs" value="var"/>
329 <param name="new_annot" value="var_add_annotation.tabular"/> 440 <param name="new_annot" value="var_add_annotation.tabular"/>
330 </conditional> 441 </conditional>
331 <output name="anndata" value="manipulate.add_annotation_var.h5ad" ftype="h5ad" compare="sim_size"/> 442 <assert_stdout>
332 </test> 443 <has_text_matching expression="500 × 11"/>
333 <test> 444 </assert_stdout>
445 <output name="anndata" ftype="h5ad">
446 <assert_contents>
447 <has_h5_keys keys="obs/cell_type"/>
448 <has_h5_keys keys="var/annot1"/>
449 <has_h5_keys keys="var/annot2"/>
450 <has_h5_keys keys="uns/highlights"/>
451 <has_h5_keys keys="uns/iroot"/>
452 </assert_contents>
453 </output>
454 </test>
455 <test expect_num_outputs="1">
334 <!-- test 8 --> 456 <!-- test 8 -->
335 <param name="input" value="krumsiek11.h5ad"/> 457 <param name="input" value="krumsiek11.h5ad"/>
336 <conditional name="manipulate"> 458 <conditional name="manipulate">
337 <param name="function" value="add_annotation"/> 459 <param name="function" value="add_annotation"/>
338 <param name="var_obs" value="obs"/> 460 <param name="var_obs" value="obs"/>
339 <param name="new_annot" value="obs_add_annotation.tabular"/> 461 <param name="new_annot" value="obs_add_annotation.tabular"/>
340 </conditional> 462 </conditional>
341 <output name="anndata" value="manipulate.add_annotation_obs.h5ad" ftype="h5ad" compare="sim_size"/> 463 <assert_stdout>
342 </test> 464 <has_text_matching expression="500 × 11"/>
343 <test> 465 </assert_stdout>
466 <output name="anndata" ftype="h5ad">
467 <assert_contents>
468 <has_h5_keys keys="obs/cell_type"/>
469 <has_h5_keys keys="obs/annot1"/>
470 <has_h5_keys keys="obs/annot2"/>
471 <has_h5_keys keys="uns/highlights"/>
472 <has_h5_keys keys="uns/iroot"/>
473 </assert_contents>
474 </output>
475 </test>
476 <test expect_num_outputs="1">
344 <!-- test 9 --> 477 <!-- test 9 -->
345 <param name="input" value="krumsiek11.h5ad"/> 478 <param name="input" value="krumsiek11.h5ad"/>
346 <conditional name="manipulate"> 479 <conditional name="manipulate">
347 <param name="function" value="filter"/> 480 <param name="function" value="filter"/>
348 <param name="var_obs" value="var"/> 481 <param name="var_obs" value="var"/>
352 <param name="format" value="text"/> 485 <param name="format" value="text"/>
353 <param name="text" value="Gata2,EKLF"/> 486 <param name="text" value="Gata2,EKLF"/>
354 </conditional> 487 </conditional>
355 </conditional> 488 </conditional>
356 </conditional> 489 </conditional>
357 <output name="anndata" value="manipulate.filter_var_index.h5ad" ftype="h5ad" compare="sim_size"/> 490 <assert_stdout>
358 </test> 491 <has_text_matching expression="500 × 2"/>
359 <test> 492 </assert_stdout>
493 <output name="anndata" ftype="h5ad">
494 <assert_contents>
495 <has_h5_keys keys="obs/cell_type"/>
496 <has_h5_keys keys="uns/highlights"/>
497 <has_h5_keys keys="uns/iroot"/>
498 </assert_contents>
499 </output>
500 </test>
501 <test expect_num_outputs="1">
360 <!-- test 10 --> 502 <!-- test 10 -->
361 <param name="input" value="krumsiek11.h5ad"/> 503 <param name="input" value="krumsiek11.h5ad"/>
362 <conditional name="manipulate"> 504 <conditional name="manipulate">
363 <param name="function" value="filter"/> 505 <param name="function" value="filter"/>
364 <param name="var_obs" value="obs"/> 506 <param name="var_obs" value="obs"/>
370 <param name="filter" value="equal"/> 512 <param name="filter" value="equal"/>
371 <param name="value" value="progenitor"/> 513 <param name="value" value="progenitor"/>
372 </conditional> 514 </conditional>
373 </conditional> 515 </conditional>
374 </conditional> 516 </conditional>
375 <output name="anndata" value="manipulate.filter_obs_key.h5ad" ftype="h5ad" compare="sim_size"/> 517 <assert_stdout>
376 </test> 518 <has_text_matching expression="260 × 11"/>
377 <test> 519 </assert_stdout>
520 <output name="anndata" ftype="h5ad">
521 <assert_contents>
522 <has_h5_keys keys="obs/cell_type"/>
523 <has_h5_keys keys="uns/highlights"/>
524 <has_h5_keys keys="uns/iroot"/>
525 </assert_contents>
526 </output>
527 </test>
528 <test expect_num_outputs="1">
378 <!-- test 11 --> 529 <!-- test 11 -->
379 <param name="input" value="krumsiek11.h5ad"/> 530 <param name="input" value="krumsiek11.h5ad"/>
380 <conditional name="manipulate"> 531 <conditional name="manipulate">
381 <param name="function" value="save_raw"/> 532 <param name="function" value="save_raw"/>
382 </conditional> 533 </conditional>
383 <output name="anndata" value="manipulate.save_raw.h5ad" ftype="h5ad" compare="sim_size" delta="20000" /> 534 <assert_stdout>
535 <has_text_matching expression="500 × 11"/>
536 </assert_stdout>
537 <output name="anndata" ftype="h5ad">
538 <assert_contents>
539 <has_h5_keys keys="obs/cell_type"/>
540 <has_h5_keys keys="uns/highlights"/>
541 <has_h5_keys keys="uns/iroot"/>
542 </assert_contents>
543 </output>
544 </test>
545 <test expect_num_outputs="1">
546 <!-- test 12 remove_keys -->
547 <param name="input" value="krumsiek11.h5ad"/>
548 <conditional name="manipulate">
549 <param name="function" value="remove_keys"/>
550 <param name="obs_keys" value="cell_type"/>
551 </conditional>
552 <assert_stdout>
553 <has_text_matching expression="500 × 11"/>
554 </assert_stdout>
555 <output name="anndata" ftype="h5ad">
556 <assert_contents>
557 <has_h5_keys keys="uns/highlights"/>
558 <has_h5_keys keys="uns/iroot"/>
559 </assert_contents>
560 </output>
561 </test>
562 <test expect_num_outputs="1">
563 <!-- test 13 flag_genes -->
564 <param name="input" value="krumsiek11.h5ad"/>
565 <conditional name="manipulate">
566 <param name="function" value="flag_genes"/>
567 <repeat name="gene_flags">
568 <param name="startswith" value="Gata"/>
569 <param name="col_name" value="Gata_TF"/>
570 </repeat>
571 <repeat name="gene_flags">
572 <param name="startswith" value="Gf"/>
573 <param name="col_name" value="GF"/>
574 </repeat>
575 </conditional>
576 <assert_stdout>
577 <has_text_matching expression="500 × 11"/>
578 </assert_stdout>
579 <output name="anndata" ftype="h5ad">
580 <assert_contents>
581 <has_h5_keys keys="var/Gata_TF"/>
582 <has_h5_keys keys="var/GF"/>
583 </assert_contents>
584 </output>
585 </test>
586 <test expect_num_outputs="1">
587 <!-- test 14 split_on_obs -->
588 <param name="input" value="krumsiek11.h5ad"/>
589 <conditional name="manipulate">
590 <param name="function" value="split_on_obs"/>
591 <param name="key" value="cell_type"/>
592 </conditional>
593 <output_collection name="output_h5ad_split" type="list">
594 <element name="cell_type_0">
595 <assert_contents>
596 <has_h5_keys keys="obs/cell_type"/>
597 <has_h5_keys keys="uns/highlights"/>
598 <has_h5_keys keys="uns/iroot"/>
599 </assert_contents>
600 </element>
601 <element name="cell_type_1">
602 <assert_contents>
603 <has_h5_keys keys="obs/cell_type"/>
604 <has_h5_keys keys="uns/highlights"/>
605 <has_h5_keys keys="uns/iroot"/>
606 </assert_contents>
607 </element>
608 <element name="cell_type_2">
609 <assert_contents>
610 <has_h5_keys keys="obs/cell_type"/>
611 <has_h5_keys keys="uns/highlights"/>
612 <has_h5_keys keys="uns/iroot"/>
613 </assert_contents>
614 </element>
615 <element name="cell_type_3">
616 <assert_contents>
617 <has_h5_keys keys="obs/cell_type"/>
618 <has_h5_keys keys="uns/highlights"/>
619 <has_h5_keys keys="uns/iroot"/>
620 </assert_contents>
621 </element>
622 </output_collection>
384 </test> 623 </test>
385 </tests> 624 </tests>
386 <help><![CDATA[ 625 <help><![CDATA[
387 **What it does** 626 **What it does**
388 627
389 This tool takes a AnnData dataset, manipulates it and returns it. 628 This tool takes a AnnData dataset, manipulates it and returns it.
390 629
391 The possible manipulations are: 630 The possible manipulations are:
392 631
393 - Concatenate along the observations axis (`concatenate method <https://anndata.readthedocs.io/en/latest/generated/anndata.AnnData.concatenate.html>`__) 632 - Concatenate along the observations axis (`concatenate method <https://anndata.readthedocs.io/en/latest/generated/anndata.AnnData.concatenate.html>`__)
394 633
395 The `uns`, `varm` and `obsm` attributes are ignored. 634 The `uns`, `varm` and `obsm` attributes are ignored.
396 635
406 645
407 - Rename categories of annotation `key` in `obs`, `var` and `uns` (`rename_categories method <https://anndata.readthedocs.io/en/latest/generated/anndata.AnnData.rename_categories.html>`__) 646 - Rename categories of annotation `key` in `obs`, `var` and `uns` (`rename_categories method <https://anndata.readthedocs.io/en/latest/generated/anndata.AnnData.rename_categories.html>`__)
408 647
409 Besides calling `self.obs[key].cat.categories = categories` - similar for `var` - this also renames categories in unstructured annotation that uses the categorical annotation `key` 648 Besides calling `self.obs[key].cat.categories = categories` - similar for `var` - this also renames categories in unstructured annotation that uses the categorical annotation `key`
410 649
650 - Remove keys from obs or var annotations
651
652 Helps in cleaning up andata with many annotations. For example, helps in removing qc metrics calculated during the preprocesing or already existing cluster annotations.
653
654 - Flag genes start with a pattern
655
656 Useful for flagging the mitochoncdrial or ribosomal protein genes
657
411 - Transform string annotations to categoricals (`strings_to_categoricals method <https://anndata.readthedocs.io/en/latest/generated/anndata.AnnData.strings_to_categoricals.html>`__) 658 - Transform string annotations to categoricals (`strings_to_categoricals method <https://anndata.readthedocs.io/en/latest/generated/anndata.AnnData.strings_to_categoricals.html>`__)
412 659
413 Only affects string annotations that lead to less categories than the total number of observations. 660 Only affects string annotations that lead to less categories than the total number of observations.
414 661
415 - Transpose the data matrix, leaving observations and variables interchanged (`transpose method <https://anndata.readthedocs.io/en/latest/generated/anndata.AnnData.transpose.html>`__) 662 - Transpose the data matrix, leaving observations and variables interchanged (`transpose method <https://anndata.readthedocs.io/en/latest/generated/anndata.AnnData.transpose.html>`__)
416 663
417 Data matrix is transposed, observations and variables are interchanged. 664 Data matrix is transposed, observations and variables are interchanged.
418 665
419 - Add annotation for variables or observations 666 - Add annotation for variables or
667
668 - Split the AnnData object into multiple AnnData objects based on the values of a given obs key
669
670 For example, helps in splitting an anndata objects based on cluster annotation. This function generates a collection with number of elements equal to the number of categories in the input obs key.
420 671
421 - Filter data variables or observations, by index or key 672 - Filter data variables or observations, by index or key
422 673
423 - Freeze the current state into the 'raw' attribute 674 - Freeze the current state into the 'raw' attribute
424 675