Mercurial > repos > ebi-gxa > anndata_ops
comparison anndata_operations.xml @ 0:086d850271a2 draft
planemo upload for repository https://github.com/ebi-gene-expression-group/container-galaxy-sc-tertiary/tree/develop/tools/tertiary-analysis/scanpy commit 39b0809db1e17c2a24930fe8fb8ceaf3ea454a7d
author | ebi-gxa |
---|---|
date | Tue, 19 Nov 2019 13:00:14 -0500 |
parents | |
children | ba18139e7400 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:086d850271a2 |
---|---|
1 <?xml version="1.0" encoding="utf-8"?> | |
2 <tool id="anndata_ops" name="AnnData Operations" version="0.0.1+galaxy0"> | |
3 <description>modifies metadata and flags genes</description> | |
4 <macros> | |
5 <import>scanpy_macros2.xml</import> | |
6 </macros> | |
7 <expand macro="requirements"/> | |
8 <command detect_errors="exit_code"><![CDATA[ | |
9 ln -s '${input_obj_file}' input.h5 && | |
10 python $operations | |
11 ]]></command> | |
12 <configfiles> | |
13 <configfile name="operations"> | |
14 import scanpy as sc | |
15 import logging | |
16 | |
17 adata = sc.read('input.h5') | |
18 | |
19 gene_name = '${gene_symbols_field}' | |
20 qc_vars = list() | |
21 | |
22 #for $i, $s in enumerate($modifications) | |
23 adata.obs['${s.to_obs}'] = adata.obs['${s.from_obs}'] | |
24 #end for | |
25 | |
26 gene_names = getattr(adata.var, gene_name) | |
27 | |
28 #for $i, $flag in enumerate($gene_flags) | |
29 k_cat = gene_names.str.startswith('${flag.startswith}') | |
30 if k_cat.sum() > 0: | |
31 adata.var['${flag.flag}'] = k_cat | |
32 qc_vars.append('${flag.flag}') | |
33 else: | |
34 logging.warning('No genes starting with {} found, skip calculating expression of {} genes'.format('${flag.startswith}', '${flag.flag}')) | |
35 #end for | |
36 | |
37 | |
38 if len(qc_vars) > 0: | |
39 pct_top = [${top_genes}] | |
40 sc.pp.calculate_qc_metrics(adata, qc_vars=qc_vars, percent_top=pct_top, inplace=True) | |
41 | |
42 if 'n_genes' not in adata.obs.columns: | |
43 sc.pp.filter_cells(adata, min_genes=0) | |
44 if 'n_counts' not in adata.obs.columns: | |
45 sc.pp.filter_cells(adata, min_counts=0) | |
46 if 'n_cells' not in adata.var.columns: | |
47 sc.pp.filter_genes(adata, min_cells=0) | |
48 if 'n_counts' not in adata.var.columns: | |
49 sc.pp.filter_genes(adata, min_counts=0) | |
50 | |
51 adata.write('output.h5', compression='gzip') | |
52 </configfile> | |
53 </configfiles> | |
54 | |
55 <inputs> | |
56 <param name="input_obj_file" argument="input-object-file" type="data" format="h5" label="Input object in hdf5 AnnData format"/> | |
57 <repeat name="modifications" title="Change field names in AnnData observations" min="0"> | |
58 <param name="from_obs" type="text" label="Original name" help="Name in observations that you want to change"> | |
59 <sanitizer> | |
60 <valid initial="string.printable"/> | |
61 </sanitizer> | |
62 </param> | |
63 <param name="to_obs" type="text" label="New name" help="New name in observations that you want to change"/> | |
64 </repeat> | |
65 <param name="gene_symbols_field" value='index' type="text" label="Gene symbols field in AnnData" help="Field inside var.params where the gene symbols are, normally 'index' or 'gene_symbols'"/> | |
66 <repeat name="gene_flags" title="Flag genes that start with these names"> | |
67 <param name="startswith" type="text" label="Starts with" help="Text that you expect the genes to be flagged to start with, such as 'MT-' for mito genes"/> | |
68 <param name="flag" type="text" label="Var name" help="Name of the column in var.names where this boolean flag is stored, for example 'mito' for mitochondrial genes."/> | |
69 </repeat> | |
70 <param name="top_genes" label="Number of top genes" value='50' help="to calculate percentage of the flagged genes in that number of top genes. Used by sc.pp.calculate_qc_metrics (integer)." type="integer"/> | |
71 </inputs> | |
72 | |
73 <outputs> | |
74 <data name="output" format="h5" from_work_dir="output.h5" label="${tool.name} on ${on_string}: anndata with metadata changes."/> | |
75 </outputs> | |
76 | |
77 <tests> | |
78 <test> | |
79 <param name="input_obj_file" value="find_cluster.h5"/> | |
80 <param name="input_format" value="anndata"/> | |
81 <param name="color_by" value="louvain"/> | |
82 <output name="output" file="output.h5" ftype="h5" compare="sim_size"/> | |
83 </test> | |
84 </tests> | |
85 | |
86 <help><![CDATA[ | |
87 ============================= | |
88 Operations on AnnData objects | |
89 ============================= | |
90 | |
91 Performs the following operations: | |
92 | |
93 * Change observation fields, mostly for downstreaming processes convenience. Multiple fields can be changed as one. | |
94 * Flag genes that start with a certain text: useful for flagging mitochondrial, spikes or other groups of genes. | |
95 * For the flags created, calculates qc metrics (pct_<flag>_counts). | |
96 * Calculates `n_genes`, `n_counts` for cells and `n_cells`, `n_counts` for genes. | |
97 * For top <N> genes specified, calculate qc metrics (pct_counts_in_top_<N>_genes). | |
98 | |
99 This functionality will probably be added in the future to a larger package. | |
100 ]]></help> | |
101 <expand macro="citations"/> | |
102 </tool> |