comparison scimap_spatial.py @ 0:42e6c251bfd0 draft

planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
author goeckslab
date Tue, 19 Jul 2022 20:30:34 +0000
parents
children fd38e533a54b
comparison
equal deleted inserted replaced
-1:000000000000 0:42e6c251bfd0
1 import argparse
2 import json
3 import warnings
4
5 import scimap as sm
6 from anndata import read_h5ad
7
8
9 def main(inputs, anndata, output):
10 """
11 Parameter
12 ---------
13 inputs : str
14 File path to galaxy tool parameter.
15 anndata : str
16 File path to anndata containing phenotyping info.
17 output : str
18 File path to output.
19 """
20 warnings.simplefilter('ignore')
21
22 with open(inputs, 'r') as param_handler:
23 params = json.load(param_handler)
24
25 adata = read_h5ad(anndata)
26
27 tool = params['analyses']['selected_tool']
28 tool_func = getattr(sm.tl, tool)
29
30 options = params['analyses']['options']
31 if tool == 'cluster':
32 options['method'] = params['analyses']['method']
33 subset_genes = options.pop('subset_genes')
34 if subset_genes:
35 options['subset_genes'] = \
36 [x.strip() for x in subset_genes.split(',')]
37 sub_cluster_group = options.pop('sub_cluster_group')
38 if sub_cluster_group:
39 options['sub_cluster_group'] = \
40 [x.strip() for x in sub_cluster_group.split(',')]
41
42 for k, v in options.items():
43 if v == '':
44 options[k] = None
45
46 tool_func(adata, **options)
47
48 adata.write(output)
49
50
51 if __name__ == '__main__':
52 aparser = argparse.ArgumentParser()
53 aparser.add_argument("-i", "--inputs", dest="inputs", required=True)
54 aparser.add_argument("-e", "--output", dest="output", required=True)
55 aparser.add_argument("-a", "--anndata", dest="anndata", required=True)
56
57 args = aparser.parse_args()
58
59 main(args.inputs, args.anndata, args.output)