|
20 | 20 | 'coordinate_system': 'global', |
21 | 21 | 'output': './temp/methods/baysor/baysor_assigned_transcripts.zarr', |
22 | 22 |
|
23 | | - 'force_2d': 'false', |
| 23 | + 'force_2d': True, #'false', |
24 | 24 | 'min_molecules_per_cell': 50, |
25 | 25 | 'scale': -1.0, #NOTE: For parameter selection see https://github.com/gustaveroussy/sopa/tree/main/workflow/config |
26 | 26 | 'scale_std': "25%", |
|
37 | 37 | TMP_DIR = Path(meta["temp_dir"] or "/tmp") |
38 | 38 | TMP_DIR.mkdir(parents=True, exist_ok=True) |
39 | 39 |
|
40 | | -CONFIG_TOML = TMP_DIR / "config.toml" |
| 40 | +#CONFIG_TOML = TMP_DIR / "config.toml" |
41 | 41 |
|
42 | 42 |
|
43 | 43 | ############################## |
|
70 | 70 | label_image = sdata_segm["segmentation"]["scale0"].image.to_numpy() |
71 | 71 | else: |
72 | 72 | label_image = sdata_segm["segmentation"].to_numpy() |
73 | | - |
| 73 | + |
74 | 74 | cell_id_dask_series = dask.dataframe.from_dask_array( |
75 | 75 | dask.array.from_array( |
76 | 76 | label_image[y_coords, x_coords], chunks=tuple(sdata[par['transcripts_key']].map_partitions(len).compute()) |
|
91 | 91 | }, |
92 | 92 | ) |
93 | 93 |
|
94 | | -# Write config to toml |
95 | | -print('Writing config to toml', flush=True) |
96 | | -toml_str = f"""[data] |
97 | | -x = "x" |
98 | | -y = "y" |
99 | | -z = "z" |
100 | | -gene = "feature_name" |
101 | | -force_2d = {par['force_2d']} |
102 | | -min_molecules_per_cell = {int(par['min_molecules_per_cell'])} |
103 | | -exclude_genes = "" |
104 | | -
|
105 | | -[segmentation] |
106 | | -scale = {float(par['scale'])} |
107 | | -scale_std = "{par['scale_std']}" |
108 | | -n_clusters = {int(par['n_clusters'])} |
109 | | -prior_segmentation_confidence = {float(par['prior_segmentation_confidence'])} |
110 | | -""" |
111 | | -with open(CONFIG_TOML, "w") as toml_file: |
112 | | - toml_file.write(toml_str) |
113 | | - |
| 94 | +## Write config to toml #NOTE: lead to an error since sopa v2.1.5, instead use config dict |
| 95 | +#print('Writing config to toml', flush=True) |
| 96 | +#toml_str = f"""[data] |
| 97 | +#x = "x" |
| 98 | +#y = "y" |
| 99 | +#z = "z" |
| 100 | +#gene = "feature_name" |
| 101 | +#force_2d = {par['force_2d']} |
| 102 | +#min_molecules_per_cell = {int(par['min_molecules_per_cell'])} |
| 103 | +#exclude_genes = "" |
| 104 | +# |
| 105 | +#[segmentation] |
| 106 | +#scale = {float(par['scale'])} |
| 107 | +#scale_std = "{par['scale_std']}" |
| 108 | +#n_clusters = {int(par['n_clusters'])} |
| 109 | +#prior_segmentation_confidence = {float(par['prior_segmentation_confidence'])} |
| 110 | +#""" |
| 111 | +#with open(CONFIG_TOML, "w") as toml_file: |
| 112 | +# toml_file.write(toml_str) |
| 113 | + |
| 114 | +config = { |
| 115 | + "data": { |
| 116 | + "x": "x", |
| 117 | + "y": "y", |
| 118 | + "z": "z", |
| 119 | + "gene": "feature_name", |
| 120 | + "force_2d": par['force_2d'], |
| 121 | + "min_molecules_per_cell": int(par['min_molecules_per_cell']), |
| 122 | + "exclude_genes": "", |
| 123 | + }, |
| 124 | + "segmentation": { |
| 125 | + "scale": float(par['scale']), |
| 126 | + "scale_std": str(par['scale_std']), |
| 127 | + "n_clusters": int(par['n_clusters']), |
| 128 | + "prior_segmentation_confidence": float(par['prior_segmentation_confidence']), |
| 129 | + }, |
| 130 | +} |
114 | 131 |
|
115 | 132 |
|
116 | 133 | # Make transcript patches |
|
124 | 141 | # (called with sopa -->) subprocess.CalledProcessError: Command 'baysor ...' returned non-zero exit status 139. |
125 | 142 | # When reproducing the error with `baysor ...` it reports a signal (11.1) Segmentation fault Allocations: 5017730 (Pool: 5013281; Big: 4449); GC: 8 |
126 | 143 | os.environ['JULIA_NUM_THREADS'] = str(n_threads) |
127 | | -sopa.segmentation.baysor(sdata_sopa, config=str(CONFIG_TOML)) |
| 144 | +sopa.segmentation.baysor(sdata_sopa, config=config) #str(CONFIG_TOML)) |
128 | 145 |
|
129 | 146 | # Assign transcripts to cell ids |
130 | 147 | sopa.spatial.assign_transcript_to_cell( |
|
0 commit comments