diff --git a/notebooks/examples/alignment_using_landmarks.ipynb b/notebooks/examples/alignment_using_landmarks.ipynb
index 631d884..6fcef5c 100644
--- a/notebooks/examples/alignment_using_landmarks.ipynb
+++ b/notebooks/examples/alignment_using_landmarks.ipynb
@@ -279,7 +279,10 @@
"from spatialdata.transformations import Identity\n",
"\n",
"visium_landmarks = ShapesModel.parse(\n",
- " np.array([[10556.699, 7829.764], [13959.155, 13522.025], [10621.200, 17392.116]]), geometry=0, radius=500, transformations={'CytAssist_FFPE_Human_Breast_Cancer': Identity()}\n",
+ " np.array([[10556.699, 7829.764], [13959.155, 13522.025], [10621.200, 17392.116]]),\n",
+ " geometry=0,\n",
+ " radius=500,\n",
+ " transformations={\"CytAssist_FFPE_Human_Breast_Cancer\": Identity()},\n",
")\n",
"visium_sdata[\"visium_landmarks\"] = visium_landmarks\n",
"\n",
diff --git a/notebooks/paper_reproducibility/00_xenium_and_visium.ipynb b/notebooks/paper_reproducibility/00_xenium_and_visium.ipynb
index c40eb0c..91efbbf 100644
--- a/notebooks/paper_reproducibility/00_xenium_and_visium.ipynb
+++ b/notebooks/paper_reproducibility/00_xenium_and_visium.ipynb
@@ -34,34 +34,7 @@
"execution_count": 2,
"id": "dc57c08e-08bc-49f2-a332-14230d042deb",
"metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- " \n",
- " "
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"%load_ext jupyter_black"
]
@@ -143,7 +116,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "current working directory: /mnt/repos/spatialdata-notebooks/notebooks/paper_reproducibility\n"
+ "current working directory: /Users/macbook/embl/projects/basel/spatialdata-notebooks/notebooks/paper_reproducibility\n"
]
}
],
@@ -377,7 +350,21 @@
"metadata": {
"tags": []
},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "WARNING:ome_zarr.io:version mismatch: detected: RasterFormatV02, requested: FormatV04\n",
+ "WARNING:ome_zarr.io:version mismatch: detected: RasterFormatV02, requested: FormatV04\n",
+ "WARNING:ome_zarr.io:version mismatch: detected: RasterFormatV02, requested: FormatV04\n",
+ "WARNING:ome_zarr.io:version mismatch: detected: RasterFormatV02, requested: FormatV04\n",
+ "WARNING:ome_zarr.io:version mismatch: detected: RasterFormatV02, requested: FormatV04\n",
+ "WARNING:ome_zarr.io:version mismatch: detected: RasterFormatV02, requested: FormatV04\n",
+ "WARNING:ome_zarr.io:version mismatch: detected: RasterFormatV02, requested: FormatV04\n"
+ ]
+ }
+ ],
"source": [
"bc_sc_atlas_adata = sc.read(BC_SC_ATLAS_PATH)\n",
"bc_sc_atlas_adata.obs[\"dataset\"] = \"atlas\"\n",
@@ -409,7 +396,7 @@
{
"data": {
"text/plain": [
- "SpatialData object, with associated Zarr store: /mnt/repos/spatialdata-sandbox/generated_data/xenium_visium_integration/sandbox.zarr\n",
+ "SpatialData object, with associated Zarr store: /Users/macbook/embl/projects/basel/spatialdata-sandbox/generated_data/xenium_visium_integration/sandbox.zarr\n",
"└── Shapes\n",
" ├── 'box': GeoDataFrame shape: (1, 1) (2D shapes)\n",
" ├── 'rois': GeoDataFrame shape: (4, 1) (2D shapes)\n",
@@ -501,8 +488,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "CPU times: user 213 ms, sys: 175 ms, total: 387 ms\n",
- "Wall time: 2.98 s\n"
+ "CPU times: user 70.5 ms, sys: 40.5 ms, total: 111 ms\n",
+ "Wall time: 114 ms\n"
]
}
],
@@ -633,7 +620,7 @@
" reference_element=xenium_subset.images[\"xe_rep1\"],\n",
" moving_element=xenium_subset.images[\"visium\"],\n",
" reference_coordinate_system=\"global\",\n",
- " moving_coordinate_system=\"global\",\n",
+ " moving_coordinate_system=\"CytAssist_FFPE_Human_Breast_Cancer\",\n",
" new_coordinate_system=\"aligned\",\n",
")"
]
@@ -702,7 +689,7 @@
"postpone_transformation(\n",
" sdata=visium_sdata,\n",
" transformation=affine_visium_to_rep1,\n",
- " source_coordinate_system=\"global\",\n",
+ " source_coordinate_system=\"CytAssist_FFPE_Human_Breast_Cancer\",\n",
" target_coordinate_system=\"aligned\",\n",
")"
]
@@ -762,15 +749,21 @@
"outputs": [],
"source": [
"xe_rep1_transformed_sdata = sd.SpatialData(\n",
- " shapes=xe_rep1_sdata.shapes, points=xe_rep1_sdata.points, tables={\"table\": xe_rep1_sdata[\"table\"]}\n",
+ " shapes=xe_rep1_sdata.shapes,\n",
+ " points=xe_rep1_sdata.points,\n",
+ " tables={\"table\": xe_rep1_sdata[\"table\"]},\n",
")\n",
"\n",
"xe_rep2_transformed_sdata = sd.SpatialData(\n",
- " shapes=xe_rep2_sdata.shapes, points=xe_rep2_sdata.points, tables={\"table\": xe_rep2_sdata[\"table\"]}\n",
+ " shapes=xe_rep2_sdata.shapes,\n",
+ " points=xe_rep2_sdata.points,\n",
+ " tables={\"table\": xe_rep2_sdata[\"table\"]},\n",
")\n",
"\n",
"visium_transformed_sdata = sd.SpatialData(\n",
- " shapes=visium_sdata.shapes, points=visium_sdata.points, tables={\"table\": visium_sdata[\"table\"]}\n",
+ " shapes=visium_sdata.shapes,\n",
+ " points=visium_sdata.points,\n",
+ " tables={\"table\": visium_sdata[\"table\"]},\n",
")\n",
"\n",
"xe_rep1_transformed_sdata = xe_rep1_transformed_sdata.transform_to_coordinate_system(\"aligned\")\n",
@@ -856,8 +849,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "CPU times: user 2min 25s, sys: 1min 9s, total: 3min 35s\n",
- "Wall time: 8min 4s\n"
+ "CPU times: user 54.2 s, sys: 10.8 s, total: 1min 4s\n",
+ "Wall time: 1min 2s\n"
]
}
],
@@ -865,7 +858,10 @@
"%%time\n",
"# let's keep only the shapes inside the query polygon (roi)\n",
"xe_rep1_roi_sdata = polygon_query(\n",
- " xe_rep1_transformed_sdata, polygon=box, target_coordinate_system=\"aligned\", filter_table=False\n",
+ " xe_rep1_transformed_sdata,\n",
+ " polygon=box,\n",
+ " target_coordinate_system=\"aligned\",\n",
+ " filter_table=False,\n",
")"
]
},
@@ -881,15 +877,18 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "CPU times: user 2min 6s, sys: 38.4 s, total: 2min 45s\n",
- "Wall time: 5min 39s\n"
+ "CPU times: user 48.5 s, sys: 9.46 s, total: 57.9 s\n",
+ "Wall time: 54.8 s\n"
]
}
],
"source": [
"%%time\n",
"xe_rep2_roi_sdata = polygon_query(\n",
- " xe_rep2_transformed_sdata, polygon=box, target_coordinate_system=\"aligned\", filter_table=False\n",
+ " xe_rep2_transformed_sdata,\n",
+ " polygon=box,\n",
+ " target_coordinate_system=\"aligned\",\n",
+ " filter_table=False,\n",
")"
]
},
@@ -905,8 +904,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "CPU times: user 537 ms, sys: 197 ms, total: 734 ms\n",
- "Wall time: 7.09 s\n"
+ "CPU times: user 125 ms, sys: 42.4 ms, total: 168 ms\n",
+ "Wall time: 170 ms\n"
]
}
],
@@ -998,7 +997,8 @@
"new_table.obs[\"region\"] = new_table.obs[\"region\"].astype(\"category\")\n",
"new_table = TableModel.parse(new_table, region=\"cell_boundaries\", region_key=\"region\", instance_key=\"cell_id\")\n",
"xe_rep1_roi_sdata_polygons = SpatialData(\n",
- " shapes={\"cell_boundaries\": xe_rep1_roi_sdata[\"cell_boundaries\"]}, tables={\"table\": new_table}\n",
+ " shapes={\"cell_boundaries\": xe_rep1_roi_sdata[\"cell_boundaries\"]},\n",
+ " tables={\"table\": new_table},\n",
")\n",
"\n",
"# replicate 2\n",
@@ -1008,7 +1008,8 @@
"new_table.obs[\"region\"] = new_table.obs[\"region\"].astype(\"category\")\n",
"new_table = TableModel.parse(new_table, region=\"cell_boundaries\", region_key=\"region\", instance_key=\"cell_id\")\n",
"xe_rep2_roi_sdata_polygons = SpatialData(\n",
- " shapes={\"cell_boundaries\": xe_rep2_roi_sdata[\"cell_boundaries\"]}, tables={\"table\": new_table}\n",
+ " shapes={\"cell_boundaries\": xe_rep2_roi_sdata[\"cell_boundaries\"]},\n",
+ " tables={\"table\": new_table},\n",
")"
]
},
@@ -1030,8 +1031,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "CPU times: user 7.31 s, sys: 89 ms, total: 7.4 s\n",
- "Wall time: 11.1 s\n"
+ "CPU times: user 2.56 s, sys: 330 ms, total: 2.89 s\n",
+ "Wall time: 2.9 s\n"
]
}
],
@@ -1080,7 +1081,7 @@
},
{
"cell_type": "code",
- "execution_count": 51,
+ "execution_count": 33,
"id": "d5a42829-1d00-4c32-aba1-19560f27913f",
"metadata": {},
"outputs": [
@@ -1088,8 +1089,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "CPU times: user 5.77 s, sys: 183 ms, total: 5.96 s\n",
- "Wall time: 23.8 s\n"
+ "CPU times: user 2.07 s, sys: 41.5 ms, total: 2.12 s\n",
+ "Wall time: 2.12 s\n"
]
}
],
@@ -1130,7 +1131,7 @@
},
{
"cell_type": "code",
- "execution_count": 52,
+ "execution_count": 34,
"id": "73312a29-f774-40fd-b100-2542f5ce1c0d",
"metadata": {},
"outputs": [
@@ -1138,8 +1139,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "CPU times: user 5.71 s, sys: 247 μs, total: 5.71 s\n",
- "Wall time: 5.72 s\n"
+ "CPU times: user 2.07 s, sys: 50.9 ms, total: 2.12 s\n",
+ "Wall time: 2.12 s\n"
]
}
],
@@ -1180,7 +1181,7 @@
},
{
"cell_type": "code",
- "execution_count": 53,
+ "execution_count": 35,
"id": "64452e20-b145-4ccb-83ed-fa102aadf968",
"metadata": {},
"outputs": [
@@ -1188,8 +1189,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "CPU times: user 39.3 s, sys: 25.1 s, total: 1min 4s\n",
- "Wall time: 5min 5s\n"
+ "CPU times: user 15.5 s, sys: 3.02 s, total: 18.5 s\n",
+ "Wall time: 18.8 s\n"
]
}
],
@@ -1206,7 +1207,7 @@
},
{
"cell_type": "code",
- "execution_count": 54,
+ "execution_count": 36,
"id": "fc6b00b9-382b-4903-88af-2544096b1389",
"metadata": {},
"outputs": [],
@@ -1217,7 +1218,7 @@
},
{
"cell_type": "code",
- "execution_count": 55,
+ "execution_count": 37,
"id": "d878795a-58b0-423b-9ae8-f4e9deadd8e3",
"metadata": {},
"outputs": [
@@ -1225,8 +1226,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "CPU times: user 36.2 s, sys: 9.93 s, total: 46.1 s\n",
- "Wall time: 1min 10s\n"
+ "CPU times: user 15.7 s, sys: 2.85 s, total: 18.5 s\n",
+ "Wall time: 18.9 s\n"
]
}
],
@@ -1243,7 +1244,7 @@
},
{
"cell_type": "code",
- "execution_count": 56,
+ "execution_count": 38,
"id": "e3ffd863-4f39-43b2-9dcb-3657ff741ecc",
"metadata": {},
"outputs": [],
@@ -1270,7 +1271,7 @@
},
{
"cell_type": "code",
- "execution_count": 57,
+ "execution_count": 39,
"id": "24a629bc-7c6c-442c-9eef-3577f7565c88",
"metadata": {
"tags": []
@@ -1279,21 +1280,20 @@
{
"data": {
"text/plain": [
- "SpatialData object, with associated Zarr store: /mnt/repos/spatialdata-sandbox/generated_data/xenium_visium_integration/xe_rep1_roi.zarr\n",
+ "SpatialData object\n",
"├── Points\n",
"│ └── 'transcripts': DataFrame with shape: (, 8) (3D points)\n",
"├── Shapes\n",
"│ ├── 'cell_boundaries': GeoDataFrame shape: (100849, 1) (2D shapes)\n",
- "│ ├── 'cell_circles': GeoDataFrame shape: (100637, 2) (2D shapes)\n",
- "│ └── 'xenium_landmarks': GeoDataFrame shape: (2, 2) (2D shapes)\n",
+ "│ └── 'cell_circles': GeoDataFrame shape: (100801, 2) (2D shapes)\n",
"└── Tables\n",
" └── 'table': AnnData (167780, 307)\n",
"with coordinate systems:\n",
" ▸ 'aligned', with elements:\n",
- " transcripts (Points), cell_boundaries (Shapes), cell_circles (Shapes), xenium_landmarks (Shapes)"
+ " transcripts (Points), cell_boundaries (Shapes), cell_circles (Shapes)"
]
},
- "execution_count": 57,
+ "execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
@@ -1304,7 +1304,7 @@
},
{
"cell_type": "code",
- "execution_count": 58,
+ "execution_count": 40,
"id": "04a42588-4f53-4c36-a152-2a0980eab5ce",
"metadata": {
"tags": []
@@ -1313,12 +1313,12 @@
{
"data": {
"text/plain": [
- "SpatialData object, with associated Zarr store: /mnt/repos/spatialdata-sandbox/generated_data/xenium_visium_integration/xe_rep2_roi.zarr\n",
+ "SpatialData object\n",
"├── Points\n",
"│ └── 'transcripts': DataFrame with shape: (, 8) (3D points)\n",
"├── Shapes\n",
"│ ├── 'cell_boundaries': GeoDataFrame shape: (99923, 1) (2D shapes)\n",
- "│ ├── 'cell_circles': GeoDataFrame shape: (99770, 2) (2D shapes)\n",
+ "│ ├── 'cell_circles': GeoDataFrame shape: (99901, 2) (2D shapes)\n",
"│ └── 'nucleus_boundaries': GeoDataFrame shape: (99761, 1) (2D shapes)\n",
"└── Tables\n",
" └── 'table': AnnData (118752, 307)\n",
@@ -1327,7 +1327,7 @@
" transcripts (Points), cell_boundaries (Shapes), cell_circles (Shapes), nucleus_boundaries (Shapes)"
]
},
- "execution_count": 58,
+ "execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
@@ -1338,7 +1338,7 @@
},
{
"cell_type": "code",
- "execution_count": 59,
+ "execution_count": 41,
"id": "b028abfc-6732-4ef4-afb6-5cf4e675812f",
"metadata": {
"tags": []
@@ -1347,18 +1347,17 @@
{
"data": {
"text/plain": [
- "SpatialData object, with associated Zarr store: /mnt/repos/spatialdata-sandbox/generated_data/xenium_visium_integration/visium_roi.zarr\n",
+ "SpatialData object\n",
"├── Shapes\n",
- "│ ├── 'CytAssist_FFPE_Human_Breast_Cancer': GeoDataFrame shape: (2826, 2) (2D shapes)\n",
- "│ └── 'visium_landmarks': GeoDataFrame shape: (2, 2) (2D shapes)\n",
+ "│ └── 'CytAssist_FFPE_Human_Breast_Cancer': GeoDataFrame shape: (2826, 2) (2D shapes)\n",
"└── Tables\n",
" └── 'table': AnnData (2826, 307)\n",
"with coordinate systems:\n",
" ▸ 'aligned', with elements:\n",
- " CytAssist_FFPE_Human_Breast_Cancer (Shapes), visium_landmarks (Shapes)"
+ " CytAssist_FFPE_Human_Breast_Cancer (Shapes)"
]
},
- "execution_count": 59,
+ "execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
@@ -1369,7 +1368,7 @@
},
{
"cell_type": "code",
- "execution_count": 62,
+ "execution_count": 42,
"id": "c1d66959-8879-4530-8aa3-cb43bece9011",
"metadata": {},
"outputs": [],
@@ -1380,7 +1379,7 @@
},
{
"cell_type": "code",
- "execution_count": 63,
+ "execution_count": 43,
"id": "6e1fe4d7-2331-414d-9d7a-b561d660371c",
"metadata": {
"tags": []
@@ -1390,8 +1389,14 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "CPU times: user 18.6 s, sys: 19.6 s, total: 38.2 s\n",
- "Wall time: 1min 47s\n"
+ "\u001b[34mINFO \u001b[0m The Zarr backing store has been changed from \u001b[3;35mNone\u001b[0m the new file path: \n",
+ " spatialdata-sandbox/generated_data/xenium_visium_integration/xe_rep1_roi.zarr \n",
+ "\u001b[34mINFO \u001b[0m The Zarr backing store has been changed from \u001b[3;35mNone\u001b[0m the new file path: \n",
+ " spatialdata-sandbox/generated_data/xenium_visium_integration/xe_rep2_roi.zarr \n",
+ "\u001b[34mINFO \u001b[0m The Zarr backing store has been changed from \u001b[3;35mNone\u001b[0m the new file path: \n",
+ " spatialdata-sandbox/generated_data/xenium_visium_integration/visium_roi.zarr \n",
+ "CPU times: user 7.88 s, sys: 1.61 s, total: 9.49 s\n",
+ "Wall time: 9.76 s\n"
]
}
],
@@ -1429,42 +1434,10 @@
},
{
"cell_type": "code",
- "execution_count": 64,
+ "execution_count": 44,
"id": "51f10a59badcc47",
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "\u001b[34mINFO \u001b[0m Element images/morphology_focus is not self-contained. The metadata will be saved to the Zarr group of the\n",
- " element in the SpatialData Zarr store. The data outside the element Zarr group will not be affected. \n",
- "\u001b[34mINFO \u001b[0m Element images/morphology_mip is not self-contained. The metadata will be saved to the Zarr group of the \n",
- " element in the SpatialData Zarr store. The data outside the element Zarr group will not be affected. \n",
- "\u001b[34mINFO \u001b[0m Element points/transcripts is not self-contained. The metadata will be saved to the Zarr group of the \n",
- " element in the SpatialData Zarr store. The data outside the element Zarr group will not be affected. \n",
- "\u001b[34mINFO \u001b[0m Element images/morphology_focus is not self-contained. The metadata will be saved to the Zarr group of the\n",
- " element in the SpatialData Zarr store. The data outside the element Zarr group will not be affected. \n",
- "\u001b[34mINFO \u001b[0m Element images/morphology_mip is not self-contained. The metadata will be saved to the Zarr group of the \n",
- " element in the SpatialData Zarr store. The data outside the element Zarr group will not be affected. \n",
- "\u001b[34mINFO \u001b[0m Element labels/cell_labels is not self-contained. The metadata will be saved to the Zarr group of the \n",
- " element in the SpatialData Zarr store. The data outside the element Zarr group will not be affected. \n",
- "\u001b[34mINFO \u001b[0m Element labels/nucleus_labels is not self-contained. The metadata will be saved to the Zarr group of the \n",
- " element in the SpatialData Zarr store. The data outside the element Zarr group will not be affected. \n",
- "\u001b[34mINFO \u001b[0m Element points/transcripts is not self-contained. The metadata will be saved to the Zarr group of the \n",
- " element in the SpatialData Zarr store. The data outside the element Zarr group will not be affected. \n",
- "\u001b[34mINFO \u001b[0m Element images/CytAssist_FFPE_Human_Breast_Cancer_full_image is not self-contained. The metadata will be \n",
- " saved to the Zarr group of the element in the SpatialData Zarr store. The data outside the element Zarr \n",
- " group will not be affected. \n",
- "\u001b[34mINFO \u001b[0m Element images/CytAssist_FFPE_Human_Breast_Cancer_hires_image is not self-contained. The metadata will be \n",
- " saved to the Zarr group of the element in the SpatialData Zarr store. The data outside the element Zarr \n",
- " group will not be affected. \n",
- "\u001b[34mINFO \u001b[0m Element images/CytAssist_FFPE_Human_Breast_Cancer_lowres_image is not self-contained. The metadata will be\n",
- " saved to the Zarr group of the element in the SpatialData Zarr store. The data outside the element Zarr \n",
- " group will not be affected. \n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"# save transformations to disk (it was only in-memory so far)\n",
"\n",
@@ -1483,7 +1456,7 @@
},
{
"cell_type": "code",
- "execution_count": 65,
+ "execution_count": 45,
"id": "453c31e2d032e4fd",
"metadata": {},
"outputs": [],
@@ -1509,7 +1482,7 @@
},
{
"cell_type": "code",
- "execution_count": 66,
+ "execution_count": 46,
"id": "88cfda97a2183b0b",
"metadata": {},
"outputs": [],
@@ -1519,7 +1492,7 @@
},
{
"cell_type": "code",
- "execution_count": 67,
+ "execution_count": 47,
"id": "24481dce2527d2bf",
"metadata": {},
"outputs": [],
@@ -1529,7 +1502,7 @@
},
{
"cell_type": "code",
- "execution_count": 68,
+ "execution_count": 48,
"id": "9a97dc4614140851",
"metadata": {},
"outputs": [],
@@ -1563,7 +1536,7 @@
},
{
"cell_type": "code",
- "execution_count": 69,
+ "execution_count": 49,
"id": "2db2e071-6fa6-4593-835a-fa1a8ee348c8",
"metadata": {
"tags": []
@@ -1577,7 +1550,7 @@
},
{
"cell_type": "code",
- "execution_count": 71,
+ "execution_count": 50,
"id": "9a2f9ce3-03d3-4235-9c52-cc89f1a60c3a",
"metadata": {
"tags": []
@@ -1589,7 +1562,7 @@
"'spatialdata-sandbox/visium_associated_xenium_io/data_aligned.zarr'"
]
},
- "execution_count": 71,
+ "execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
@@ -1639,7 +1612,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.10.13"
+ "version": "3.11.0"
}
},
"nbformat": 4,