Mercurial > repos > goeckslab > gate_finder
comparison gate_finder.py @ 5:e860ca30cd0b draft
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 90f081e58b5ee41bba3a7e6f01d97b5bd9392759
author | goeckslab |
---|---|
date | Wed, 28 May 2025 21:14:52 +0000 |
parents | 5f4a4dd06bc9 |
children |
comparison
equal
deleted
inserted
replaced
4:5f4a4dd06bc9 | 5:e860ca30cd0b |
---|---|
51 gate = np.mean(gmm.means_) | 51 gate = np.mean(gmm.means_) |
52 | 52 |
53 return get_gate_phenotype(gate, np.ravel(data_norm)) | 53 return get_gate_phenotype(gate, np.ravel(data_norm)) |
54 | 54 |
55 | 55 |
56 def main(inputs, output, image, anndata, offsets=None, masks=None): | 56 def main(inputs, output, image, anndata, offsets=None, masks=None, config_path=None): |
57 """ | 57 """ |
58 Parameter | 58 Parameter |
59 --------- | 59 --------- |
60 inputs : str | 60 inputs : str |
61 File path to galaxy tool parameter. | 61 File path to galaxy tool parameter. |
65 File path to the OME Tiff image. | 65 File path to the OME Tiff image. |
66 anndata : str | 66 anndata : str |
67 File path to anndata containing phenotyping info. | 67 File path to anndata containing phenotyping info. |
68 masks : str | 68 masks : str |
69 File path to the image masks. | 69 File path to the image masks. |
70 config_path : str | |
71 File path to the config containing galaxy_url and dataset_id. | |
70 """ | 72 """ |
71 warnings.simplefilter('ignore') | 73 warnings.simplefilter('ignore') |
72 | 74 |
73 with open(inputs, 'r') as param_handler: | 75 with open(inputs, 'r') as param_handler: |
74 params = json.load(param_handler) | 76 params = json.load(param_handler) |
77 | |
78 with open(config_path) as conf_fh: | |
79 config = json.load(conf_fh) | |
75 | 80 |
76 marker = params['marker'].strip() | 81 marker = params['marker'].strip() |
77 from_gate = params['from_gate'] | 82 from_gate = params['from_gate'] |
78 to_gate = params['to_gate'] | 83 to_gate = params['to_gate'] |
79 increment = params['increment'] | 84 increment = params['increment'] |
80 x_coordinate = params['x_coordinate'].strip() or 'X_centroid' | 85 x_coordinate = params['x_coordinate'].strip() or 'X_centroid' |
81 y_coordinate = params['y_coordinate'].strip() or 'Y_centroid' | 86 y_coordinate = params['y_coordinate'].strip() or 'Y_centroid' |
87 | |
88 galaxy_url = config["galaxy_url"] | |
89 dataset_id = config["dataset_id"] | |
90 | |
91 # Build the prefix that Vitessce should use | |
92 display_prefix = (f"{galaxy_url}/api/datasets/{dataset_id}/display?filename=") | |
82 | 93 |
83 adata = read_h5ad(anndata) | 94 adata = read_h5ad(anndata) |
84 | 95 |
85 # If no raw data is available make a copy | 96 # If no raw data is available make a copy |
86 if adata.raw is None: | 97 if adata.raw is None: |
189 | (cell_set_sizes / lc) | 200 | (cell_set_sizes / lc) |
190 | (spatial) | 201 | (spatial) |
191 ) | 202 ) |
192 | 203 |
193 # export config file | 204 # export config file |
194 config_dict = vc.export(to='files', base_url='http://localhost', out_dir=output) | 205 config_dict = vc.export(to='files', base_url=display_prefix, out_dir=output) |
195 | 206 |
196 with open(Path(output).joinpath('config.json'), 'w') as f: | 207 with open(Path(output).joinpath('config.json'), 'w') as f: |
197 json.dump(config_dict, f, indent=4) | 208 json.dump(config_dict, f, indent=4) |
198 | 209 |
199 | 210 |
203 aparser.add_argument("-e", "--output", dest="output", required=True) | 214 aparser.add_argument("-e", "--output", dest="output", required=True) |
204 aparser.add_argument("-g", "--image", dest="image", required=True) | 215 aparser.add_argument("-g", "--image", dest="image", required=True) |
205 aparser.add_argument("-a", "--anndata", dest="anndata", required=True) | 216 aparser.add_argument("-a", "--anndata", dest="anndata", required=True) |
206 aparser.add_argument("-f", "--offsets", dest="offsets", required=False) | 217 aparser.add_argument("-f", "--offsets", dest="offsets", required=False) |
207 aparser.add_argument("-m", "--masks", dest="masks", required=False) | 218 aparser.add_argument("-m", "--masks", dest="masks", required=False) |
219 aparser.add_argument("--galaxy_config", dest="config_path", required=True) | |
208 | 220 |
209 args = aparser.parse_args() | 221 args = aparser.parse_args() |
210 | 222 |
211 main(args.inputs, args.output, args.image, args.anndata, args.offsets, args.masks) | 223 main(args.inputs, args.output, args.image, args.anndata, args.offsets, args.masks, args.config_path) |