Mercurial > repos > goeckslab > vitessce_spatial
annotate vitessce_spatial.py @ 3:7cc457aa78b1 draft default tip
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit af71ccb3b89c9735c6f985a3e8ffe22cd14c0e04
author | goeckslab |
---|---|
date | Thu, 30 May 2024 17:24:44 +0000 |
parents | 9f60ef2d586e |
children |
rev | line source |
---|---|
0
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
1 import argparse |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
2 import json |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
3 import warnings |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
4 from pathlib import Path |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
5 |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
6 import scanpy as sc |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
7 from anndata import read_h5ad |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
8 from vitessce import ( |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
9 AnnDataWrapper, |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
10 Component as cm, |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
11 MultiImageWrapper, |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
12 OmeTiffWrapper, |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
13 VitessceConfig, |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
14 ) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
15 |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
16 |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
17 def main(inputs, output, image, anndata=None, masks=None): |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
18 """ |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
19 Parameter |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
20 --------- |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
21 inputs : str |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
22 File path to galaxy tool parameter. |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
23 output : str |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
24 Output folder for saving web content. |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
25 image : str |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
26 File path to the OME Tiff image. |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
27 anndata : str |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
28 File path to anndata containing phenotyping info. |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
29 masks : str |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
30 File path to the image masks. |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
31 """ |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
32 warnings.simplefilter('ignore') |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
33 |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
34 with open(inputs, 'r') as param_handler: |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
35 params = json.load(param_handler) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
36 |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
37 vc = VitessceConfig(name=None, description=None) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
38 dataset = vc.add_dataset() |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
39 image_wrappers = [OmeTiffWrapper(img_path=image, name='OMETIFF')] |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
40 if masks: |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
41 image_wrappers.append( |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
42 OmeTiffWrapper(img_path=masks, name='MASKS', is_bitmask=True) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
43 ) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
44 dataset.add_object(MultiImageWrapper(image_wrappers)) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
45 |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
46 status = vc.add_view(dataset, cm.STATUS) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
47 spatial = vc.add_view(dataset, cm.SPATIAL) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
48 lc = vc.add_view(dataset, cm.LAYER_CONTROLLER) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
49 |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
50 if not anndata: |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
51 vc.layout(status / lc | spatial) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
52 config_dict = vc.export(to='files', base_url='http://localhost', out_dir=output) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
53 with open(Path(output).joinpath('config.json'), 'w') as f: |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
54 json.dump(config_dict, f, indent=4) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
55 return |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
56 |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
57 adata = read_h5ad(anndata) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
58 |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
59 params = params['do_phenotyping'] |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
60 embedding = params['scatterplot_embeddings']['embedding'] |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
61 embedding_options = params['scatterplot_embeddings']['options'] |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
62 if embedding == 'umap': |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
63 sc.pp.neighbors(adata, **embedding_options) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
64 sc.tl.umap(adata) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
65 mappings_obsm = 'X_umap' |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
66 mappings_obsm_name = "UMAP" |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
67 elif embedding == 'tsne': |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
68 sc.tl.tsne(adata, **embedding_options) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
69 mappings_obsm = 'X_tsne' |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
70 mappings_obsm_name = "tSNE" |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
71 else: # pca |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
72 sc.tl.pca(adata, **embedding_options) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
73 mappings_obsm = 'X_pca' |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
74 mappings_obsm_name = "PCA" |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
75 |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
76 adata.obsm['XY_centroid'] = adata.obs[['X_centroid', 'Y_centroid']].values |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
77 |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
78 cell_set_obs = params['phenotype_factory']['phenotypes'] |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
79 if not isinstance(cell_set_obs, list): |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
80 cell_set_obs = [x.strip() for x in cell_set_obs.split(',')] |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
81 cell_set_obs_names = [obj[0].upper() + obj[1:] for obj in cell_set_obs] |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
82 dataset.add_object( |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
83 AnnDataWrapper( |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
84 adata, |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
85 mappings_obsm=[mappings_obsm], |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
86 mappings_obsm_names=[mappings_obsm_name], |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
87 spatial_centroid_obsm='XY_centroid', |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
88 cell_set_obs=cell_set_obs, |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
89 cell_set_obs_names=cell_set_obs_names, |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
90 expression_matrix="X" |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
91 ) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
92 ) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
93 |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
94 cellsets = vc.add_view(dataset, cm.CELL_SETS) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
95 scattorplot = vc.add_view(dataset, cm.SCATTERPLOT, mapping=mappings_obsm_name) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
96 heatmap = vc.add_view(dataset, cm.HEATMAP) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
97 genes = vc.add_view(dataset, cm.GENES) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
98 cell_set_sizes = vc.add_view(dataset, cm.CELL_SET_SIZES) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
99 cell_set_expression = vc.add_view(dataset, cm.CELL_SET_EXPRESSION) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
100 vc.layout( |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
101 (status / genes / cell_set_expression) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
102 | (cellsets / lc / scattorplot) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
103 | (cell_set_sizes / heatmap / spatial) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
104 ) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
105 config_dict = vc.export(to='files', base_url='http://localhost', out_dir=output) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
106 |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
107 with open(Path(output).joinpath('config.json'), 'w') as f: |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
108 json.dump(config_dict, f, indent=4) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
109 |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
110 |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
111 if __name__ == '__main__': |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
112 aparser = argparse.ArgumentParser() |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
113 aparser.add_argument("-i", "--inputs", dest="inputs", required=True) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
114 aparser.add_argument("-e", "--output", dest="output", required=True) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
115 aparser.add_argument("-g", "--image", dest="image", required=True) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
116 aparser.add_argument("-a", "--anndata", dest="anndata", required=False) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
117 aparser.add_argument("-m", "--masks", dest="masks", required=False) |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
118 |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
119 args = aparser.parse_args() |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
120 |
9f60ef2d586e
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 9b2dc921e692af8045773013d9f87d4d790e2ea1
goeckslab
parents:
diff
changeset
|
121 main(args.inputs, args.output, args.image, args.anndata, args.masks) |