-
Notifications
You must be signed in to change notification settings - Fork 75
Open
Description
Hello!
I am trying to merge several samples into a single spatialdata object, and currently this is what I'm doing:
adatas = {
"square_002um": [],
"square_008um": [],
"square_016um": [],
}
images = {}
for sample in sample_folders:
sdata = spatialdata_io.visium_hd(
f"{outs}/{sample}/outs",
dataset_id=sample,
fullres_image_file=id_to_image[sample],
)
# Collect tables
for size, table in sdata.tables.items():
table.var_names_make_unique()
table.obs[f"sample_id"] = sample
#Add mapping from dictionary above:
table.obs["sfh_id"] = sample_mapping[sample]
adatas.setdefault(size, []).append(table)
# Collect images
for name, img in sdata.images.items():
images[f"{sample}_{name}"] = img
# Build one SpatialData object with merged table + all images
merged_bin_sizes = {}
for size, adata in adatas.items():
temp_merged = ad.concat(adata, join="outer", label="sample_id", fill_value=0)
merged_bin_sizes[size] = temp_merged
sdata_merged = SpatialData(
images=images,
tables=merged_bin_sizes
)
Which ultimately gives me this:
To me it seems like the way to go, but I was wondering if this is recommended or if there is another specific way of doing things to easy the downstream analysis? Perhaps even split things a bit further with the tables between 02,08 and 16 mu? Thanks
Metadata
Metadata
Assignees
Labels
No labels