Mercurial > repos > goeckslab > scimap_phenotyping
annotate mcmicro_to_anndata.py @ 1:dcfcad35e847 draft
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit d20d6f5d08b43de71182459f8a6452c564a5becc
author | goeckslab |
---|---|
date | Mon, 29 Aug 2022 23:55:18 +0000 |
parents | 7ed4b55b11f7 |
children | ce22e846c5e4 |
rev | line source |
---|---|
0
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
1 import argparse |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
2 import json |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
3 import warnings |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
4 |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
5 import scimap as sm |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
6 |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
7 |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
8 def main(inputs, outfile): |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
9 """ |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
10 Parameter |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
11 --------- |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
12 inputs : str |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
13 File path to galaxy tool parameter. |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
14 |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
15 outfile : str |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
16 File path to estimator. |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
17 """ |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
18 warnings.simplefilter('ignore') |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
19 |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
20 with open(inputs, 'r') as param_handler: |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
21 params = json.load(param_handler) |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
22 |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
23 image_path = params['image_path'] |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
24 drop_markers = params['drop_markers'] |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
25 if not drop_markers: |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
26 drop_markers = None |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
27 else: |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
28 drop_markers = [x.strip() for x in drop_markers.split(',')] |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
29 options = params['options'] |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
30 for k, v in options.items(): |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
31 if v == '': |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
32 options[k] = None |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
33 |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
34 adata = sm.pp.mcmicro_to_scimap(image_path, drop_markers=drop_markers, **options) |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
35 |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
36 adata.write(outfile) |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
37 |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
38 |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
39 if __name__ == '__main__': |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
40 aparser = argparse.ArgumentParser() |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
41 aparser.add_argument("-i", "--inputs", dest="inputs", required=True) |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
42 aparser.add_argument("-e", "--outfile", dest="outfile", required=True) |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
43 args = aparser.parse_args() |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
44 |
7ed4b55b11f7
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
45 main(args.inputs, args.outfile) |