Mercurial > repos > goeckslab > scimap_spatial
annotate mcmicro_to_anndata.py @ 1:fd38e533a54b 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:43 +0000 |
parents | 42e6c251bfd0 |
children | d19c068c2490 |
rev | line source |
---|---|
0
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
1 import argparse |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
2 import json |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
3 import warnings |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
4 |
42e6c251bfd0
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 |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
6 |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
7 |
42e6c251bfd0
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): |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
9 """ |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
10 Parameter |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
11 --------- |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
12 inputs : str |
42e6c251bfd0
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. |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
14 |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
15 outfile : str |
42e6c251bfd0
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. |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
17 """ |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
18 warnings.simplefilter('ignore') |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
19 |
42e6c251bfd0
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: |
42e6c251bfd0
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) |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
22 |
42e6c251bfd0
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'] |
42e6c251bfd0
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'] |
42e6c251bfd0
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: |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
26 drop_markers = None |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
27 else: |
42e6c251bfd0
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(',')] |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
29 options = params['options'] |
42e6c251bfd0
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(): |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
31 if v == '': |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
32 options[k] = None |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
33 |
42e6c251bfd0
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) |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
35 |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
36 adata.write(outfile) |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
37 |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
38 |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
39 if __name__ == '__main__': |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
40 aparser = argparse.ArgumentParser() |
42e6c251bfd0
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) |
42e6c251bfd0
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) |
42e6c251bfd0
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() |
42e6c251bfd0
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit b19cb55dfb751cccc857b95a432890299bfeebb5
goeckslab
parents:
diff
changeset
|
44 |
42e6c251bfd0
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) |