@@ -26,55 +26,62 @@ class WorkflowPaths:
26
26
def __init__ (self , config : dict ) -> None :
27
27
self .config = _sanity_check_config (config )
28
28
29
+ # spatialdata object files
29
30
self .sdata_path = Path (self .config ["sdata_path" ])
30
31
self .data_path = self .config ["data_path" ]
31
32
self .sdata_zgroup = self .sdata_path / ".zgroup" # trick to fix snakemake ChildIOException
32
33
34
+ # spatial elements directories
33
35
self .shapes_dir = self .sdata_path / "shapes"
34
36
self .points_dir = self .sdata_path / "points"
35
37
self .images_dir = self .sdata_path / "images"
36
38
self .table_dir = self .sdata_path / "table"
37
39
40
+ # sdata.shapes
38
41
self .baysor_boundaries = self .shapes_dir / "baysor_boundaries"
39
42
self .cellpose_boundaries = self .shapes_dir / "cellpose_boundaries"
40
43
self .patches = self .shapes_dir / "sopa_patches"
41
44
45
+ # snakemake cache / intermediate files
42
46
self .sopa_cache = self .sdata_path / ".sopa_cache"
43
47
self .smk_table = self .sopa_cache / "table"
44
48
self .smk_patches = self .sopa_cache / "patches"
45
49
self .smk_patches_file_image = self .sopa_cache / "patches_file_image"
46
50
self .smk_patches_file_baysor = self .sopa_cache / "patches_file_baysor"
47
- self .smk_cellpose_boundaries = self .sopa_cache / "cellpose_boundaries"
48
- self .smk_baysor_boundaries = self .sopa_cache / "baysor_boundaries"
51
+ self .smk_cellpose_temp_dir = self .sopa_cache / "cellpose_boundaries"
52
+ self .smk_baysor_temp_dir = self .sopa_cache / "baysor_boundaries"
53
+ self .smk_cellpose_boundaries = self .sopa_cache / "cellpose_boundaries_done"
54
+ self .smk_baysor_boundaries = self .sopa_cache / "baysor_boundaries_done"
49
55
self .smk_aggregation = self .sopa_cache / "aggregation"
50
56
57
+ # annotation files
51
58
self .annotations = []
52
59
if "annotation" in self .config :
53
60
key = self .config ["annotation" ].get ("args" , {}).get ("cell_type_key" , "cell_type" )
54
61
self .annotations = self .table_dir / "table" / "obs" / key
55
62
56
- self .cellpose_temp_dir = self .sopa_cache / "cellpose_boundaries"
57
- self .baysor_temp_dir = self .sopa_cache / "baysor_boundaries"
58
-
63
+ # user-friendly output files
59
64
self .explorer_directory = self .sdata_path .with_suffix (".explorer" )
60
65
self .explorer_directory .mkdir (parents = True , exist_ok = True )
61
-
62
66
self .explorer_experiment = self .explorer_directory / "experiment.xenium"
63
67
self .explorer_image = self .explorer_directory / "morphology.ome.tif"
64
-
65
68
self .report = self .explorer_directory / "analysis_summary.html"
66
69
67
70
def cells_paths (self , file_content : str , name , dirs : bool = False ):
68
71
if name == "cellpose" :
69
- return [str (self .cellpose_temp_dir / f"{ i } .parquet" ) for i in range (int (file_content ))]
72
+ return [
73
+ str (self .smk_cellpose_temp_dir / f"{ i } .parquet" ) for i in range (int (file_content ))
74
+ ]
70
75
if name == "baysor" :
71
76
indices = map (int , file_content .split ())
72
77
BAYSOR_FILES = ["segmentation_polygons.json" , "segmentation_counts.loom" ]
73
78
74
79
if dirs :
75
- return [str (self .baysor_temp_dir / str (i )) for i in indices ]
80
+ return [str (self .smk_baysor_temp_dir / str (i )) for i in indices ]
76
81
return [
77
- str (self .baysor_temp_dir / str (i ) / file ) for i in indices for file in BAYSOR_FILES
82
+ str (self .smk_baysor_temp_dir / str (i ) / file )
83
+ for i in indices
84
+ for file in BAYSOR_FILES
78
85
]
79
86
80
87
@@ -114,7 +121,8 @@ def where(self, keys: Optional[list[str]] = None, contains: Optional[str] = None
114
121
115
122
def dump_baysor_patchify (self ):
116
123
return (
117
- str (self ["segmentation" ]["baysor" ]) + f" --baysor-temp-dir { self .paths .baysor_temp_dir } "
124
+ str (self ["segmentation" ]["baysor" ])
125
+ + f" --baysor-temp-dir { self .paths .smk_baysor_temp_dir } "
118
126
)
119
127
120
128
@classmethod
0 commit comments