Skip to content

Commit d8a99ce

Browse files
authored
Fix renaming issue in vizgen loader and rename table in vizgen & cosmx loaders (#91)
* Fix renaming issue in vizgen loader * Rename tables in vizgen and cosmx loaders
1 parent 34ef0d3 commit d8a99ce

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/datasets/loaders/bruker_cosmx/script.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@
227227
"stitched_labels" : "cell_labels",
228228
"points" : "transcripts",
229229
"cells_polygons" : "cell_boundaries",
230-
"table" : "metadata",
230+
#"table" : "metadata",
231231
}
232232

233233
for old_key, new_key in elements_renaming_map.items():

src/datasets/loaders/bruker_cosmx_nsclc/script.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def fixed_get_morphology_coords(images_dir: Path) -> list[str]:
170170
"stitched_labels" : "cell_labels",
171171
"points" : "transcripts",
172172
"cells_polygons" : "cell_boundaries",
173-
"table" : "metadata",
173+
#"table" : "metadata",
174174
}
175175

176176
for old_key, new_key in elements_renaming_map.items():

src/datasets/loaders/vizgen_merscope/script.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def read_boundary_hdf5(folder):
188188
f"{name}_z3": "morphology_mip", # TODO: that is actually not the morphology_mip, i.e. either we should rename the label later, or we should actually project over z. But we also want to have 3d at some point anyway
189189
f"{name}_transcripts": "transcripts",
190190
f"{name}_polygons": "cell_boundaries",
191-
"table": "metadata",
191+
#"table": "metadata",
192192
}
193193

194194
for old_key, new_key in elements_renaming_map.items():
@@ -201,8 +201,10 @@ def read_boundary_hdf5(folder):
201201
sdata["transcripts"] = sdata["transcripts"].rename(columns={"global_z": "z", "transcript_id": "ensembl_id"})#, "gene": "feature_name"})
202202
if "gene" in sdata["transcripts"].columns:
203203
# No idea why, but somehow dask dataframe renaming for the 'gene' column ends up in a key error when assigning it to sdata["transcripts"].
204+
# update: see https://github.com/scverse/spatialdata/issues/996
204205
sdata["transcripts"]["feature_name"] = sdata["transcripts"]["gene"]
205206
del sdata["transcripts"]["gene"]
207+
sdata['transcripts'].attrs["spatialdata_attrs"]["feature_key"] = "feature_name"
206208
print(datetime.now() - t0, "Renamed transcripts column 'global_z' -> 'z' and 'gene' -> 'feature_name' and 'transcript_id' -> 'ensembl_id'", flush=True)
207209

208210
print(datetime.now() - t0, "Columns in sdata['transcripts']:", sdata["transcripts"].columns, flush=True)

0 commit comments

Comments
 (0)