comparison anndata_to_csv.py @ 2:ce22e846c5e4 draft

planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit 9fb5578191db8a559191e45156cfb95350f01aea
author goeckslab
date Mon, 10 Jun 2024 18:44:25 +0000
parents
children
comparison
equal deleted inserted replaced
1:dcfcad35e847 2:ce22e846c5e4
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, outfile):
10 """
11 Parameters
12 ---------
13 inputs : str
14 File path to galaxy tool parameter.
15 anndata : str
16 File path to anndata.
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(params['anndata'])
26
27 if params['layer'] == 'x':
28 params['layer'] = None
29
30 df = sm.hl.scimap_to_csv(
31 adata=adata,
32 layer=params['layer'],
33 CellID=params['cellid'],
34 )
35
36 df.to_csv(outfile, index=False)
37
38
39 if __name__ == '__main__':
40 aparser = argparse.ArgumentParser()
41 aparser.add_argument("-i", "--inputs", dest="inputs", required=True)
42 aparser.add_argument("-e", "--outfile", dest="outfile", required=True)
43 args = aparser.parse_args()
44
45 main(args.inputs, args.outfile)