Skip to content

Commit 798c923

Browse files
Merge pull request #56 from scverse/fix/remove_napari
2 parents 3c903e3 + b7b17f0 commit 798c923

14 files changed

+1479
-1918
lines changed

conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
html_theme_options = {
132132
"repository_url": repository_url,
133133
"use_repository_button": True,
134+
"navigation_with_keys": True,
134135
}
135136

136137
pygments_style = "default"

notebooks/examples/aggregation.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@
11831183
"name": "python",
11841184
"nbconvert_exporter": "python",
11851185
"pygments_lexer": "ipython3",
1186-
"version": "3.10.9"
1186+
"version": "3.10.12"
11871187
},
11881188
"vscode": {
11891189
"interpreter": {

notebooks/examples/alignment_using_landmarks.ipynb

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,12 @@
4848
},
4949
"tags": []
5050
},
51-
"outputs": [
52-
{
53-
"name": "stderr",
54-
"output_type": "stream",
55-
"text": [
56-
"/Users/macbook/miniconda3/envs/ome/lib/python3.10/site-packages/geopandas/_compat.py:123: UserWarning: The Shapely GEOS version (3.11.1-CAPI-1.17.1) is incompatible with the GEOS version PyGEOS was compiled with (3.10.4-CAPI-1.16.2). Conversions between both will be slow.\n",
57-
" warnings.warn(\n",
58-
"/Users/macbook/embl/projects/basel/spatialdata/src/spatialdata/__init__.py:9: UserWarning: Geopandas was set to use PyGEOS, changing to shapely 2.0 with:\n",
59-
"\n",
60-
"\tgeopandas.options.use_pygeos = True\n",
61-
"\n",
62-
"If you intended to use PyGEOS, set the option to False.\n",
63-
" _check_geopandas_using_shapely()\n",
64-
"/Users/macbook/miniconda3/envs/ome/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
65-
" from .autonotebook import tqdm as notebook_tqdm\n"
66-
]
67-
}
68-
],
51+
"outputs": [],
6952
"source": [
7053
"import numpy as np\n",
7154
"import spatialdata as sd\n",
72-
"from napari_spatialdata import Interactive"
55+
"\n",
56+
"# from napari_spatialdata import Interactive"
7357
]
7458
},
7559
{
@@ -85,10 +69,11 @@
8569
},
8670
"outputs": [
8771
{
88-
"name": "stdout",
72+
"name": "stderr",
8973
"output_type": "stream",
9074
"text": [
91-
"\u001b[34mINFO \u001b[0m Instance key `cell_id` could be of type `pd.Categorical`. Consider casting it. \n"
75+
"/Users/macbook/miniconda3/envs/ome/lib/python3.10/site-packages/anndata/_core/anndata.py:183: ImplicitModificationWarning: Transforming to str index.\n",
76+
" warnings.warn(\"Transforming to str index.\", ImplicitModificationWarning)\n"
9277
]
9378
},
9479
{
@@ -99,24 +84,23 @@
9984
"│ ├── 'morphology_focus': MultiscaleSpatialImage[cyx] (1, 25778, 35416), (1, 12889, 17708), (1, 6444, 8854), (1, 3222, 4427), (1, 1611, 2213)\n",
10085
"│ └── 'morphology_mip': MultiscaleSpatialImage[cyx] (1, 25778, 35416), (1, 12889, 17708), (1, 6444, 8854), (1, 3222, 4427), (1, 1611, 2213)\n",
10186
"├── Points\n",
102-
"│ └── 'transcripts': DataFrame with shape: (42638083, 9) (3D points)\n",
87+
"│ └── 'transcripts': DataFrame with shape: (42638083, 8) (3D points)\n",
10388
"├── Shapes\n",
10489
"│ ├── 'cell_boundaries': GeoDataFrame shape: (167780, 1) (2D shapes)\n",
10590
"│ ├── 'cell_circles': GeoDataFrame shape: (167780, 2) (2D shapes)\n",
10691
"│ ├── 'nucleus_boundaries': GeoDataFrame shape: (167780, 1) (2D shapes)\n",
107-
"│ ├── 'visium_landmarks': GeoDataFrame shape: (3, 2) (2D shapes)\n",
10892
"│ └── 'xenium_landmarks': GeoDataFrame shape: (3, 2) (2D shapes)\n",
10993
"└── Table\n",
11094
" └── AnnData object with n_obs × n_vars = 167780 × 313\n",
111-
" obs: 'cell_id', 'transcript_counts', 'control_probe_counts', 'control_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'region', 'dataset', 'celltype_major', 'celltype_minor'\n",
95+
" obs: 'cell_id', 'transcript_counts', 'control_probe_counts', 'control_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'region'\n",
11296
" var: 'gene_ids', 'feature_types', 'genome'\n",
11397
" uns: 'spatialdata_attrs'\n",
11498
" obsm: 'spatial': AnnData (167780, 313)\n",
11599
"with coordinate systems:\n",
116100
"▸ 'aligned', with elements:\n",
117-
" morphology_focus (Images), morphology_mip (Images), transcripts (Points), cell_boundaries (Shapes), cell_circles (Shapes), nucleus_boundaries (Shapes)\n",
101+
" morphology_mip (Images)\n",
118102
"▸ 'global', with elements:\n",
119-
" morphology_focus (Images), morphology_mip (Images), transcripts (Points), cell_boundaries (Shapes), cell_circles (Shapes), nucleus_boundaries (Shapes), visium_landmarks (Shapes), xenium_landmarks (Shapes)"
103+
" morphology_focus (Images), morphology_mip (Images), transcripts (Points), cell_boundaries (Shapes), cell_circles (Shapes), nucleus_boundaries (Shapes), xenium_landmarks (Shapes)"
120104
]
121105
},
122106
"execution_count": 2,
@@ -149,23 +133,27 @@
149133
"│ ├── 'CytAssist_FFPE_Human_Breast_Cancer_full_image': MultiscaleSpatialImage[cyx] (3, 21571, 19505), (3, 10785, 9752), (3, 5392, 4876), (3, 2696, 2438), (3, 1348, 1219)\n",
150134
"│ ├── 'CytAssist_FFPE_Human_Breast_Cancer_hires_image': SpatialImage[cyx] (3, 2000, 1809)\n",
151135
"│ └── 'CytAssist_FFPE_Human_Breast_Cancer_lowres_image': SpatialImage[cyx] (3, 600, 543)\n",
136+
"├── Points\n",
137+
"│ ├── 'Points': DataFrame with shape: (3, 2) (2D points)\n",
138+
"│ └── 'Points_1': DataFrame with shape: (1, 2) (2D points)\n",
152139
"├── Shapes\n",
153-
"│ └── 'CytAssist_FFPE_Human_Breast_Cancer': GeoDataFrame shape: (4992, 2) (2D shapes)\n",
140+
"│ ├── 'CytAssist_FFPE_Human_Breast_Cancer': GeoDataFrame shape: (4992, 2) (2D shapes)\n",
141+
"│ └── 'visium_landmarks': GeoDataFrame shape: (3, 2) (2D shapes)\n",
154142
"└── Table\n",
155143
" └── AnnData object with n_obs × n_vars = 4992 × 18085\n",
156144
" obs: 'in_tissue', 'array_row', 'array_col', 'spot_id', 'region', 'dataset', 'clone'\n",
157145
" var: 'gene_ids', 'feature_types', 'genome'\n",
158-
" uns: 'clone_colors', 'region_colors', 'spatial', 'spatialdata_attrs'\n",
146+
" uns: 'spatial', 'spatialdata_attrs'\n",
159147
" obsm: 'spatial': AnnData (4992, 18085)\n",
160148
"with coordinate systems:\n",
161149
"▸ 'aligned', with elements:\n",
162-
" CytAssist_FFPE_Human_Breast_Cancer_full_image (Images), CytAssist_FFPE_Human_Breast_Cancer (Shapes)\n",
150+
" CytAssist_FFPE_Human_Breast_Cancer_full_image (Images), Points (Points), Points_1 (Points), CytAssist_FFPE_Human_Breast_Cancer (Shapes), visium_landmarks (Shapes)\n",
163151
"▸ 'downscaled_hires', with elements:\n",
164152
" CytAssist_FFPE_Human_Breast_Cancer_hires_image (Images), CytAssist_FFPE_Human_Breast_Cancer (Shapes)\n",
165153
"▸ 'downscaled_lowres', with elements:\n",
166154
" CytAssist_FFPE_Human_Breast_Cancer_lowres_image (Images), CytAssist_FFPE_Human_Breast_Cancer (Shapes)\n",
167155
"▸ 'global', with elements:\n",
168-
" CytAssist_FFPE_Human_Breast_Cancer_full_image (Images), CytAssist_FFPE_Human_Breast_Cancer (Shapes)"
156+
" CytAssist_FFPE_Human_Breast_Cancer_full_image (Images), CytAssist_FFPE_Human_Breast_Cancer (Shapes), visium_landmarks (Shapes)"
169157
]
170158
},
171159
"execution_count": 3,
@@ -196,6 +184,7 @@
196184
"end_time": "2023-04-10T18:59:26.909684Z",
197185
"start_time": "2023-04-10T18:59:25.642148Z"
198186
},
187+
"collapsed": false,
199188
"jupyter": {
200189
"outputs_hidden": false
201190
}
@@ -254,7 +243,7 @@
254243
"id": "5890a6dc",
255244
"metadata": {},
256245
"source": [
257-
"For reproducibility, we hardcoded in this notebook the landmark annotations for the Visium and Xenium data. We will add them to the respective `SpatialData` objects, as if they were were saved with napari."
246+
"For reproducibility, we hardcoded in this notebook the landmark annotations for the Visium and Xenium data. We will add them to the respective `SpatialData` objects, both in-memory and on-disk, as if they were were saved with napari."
258247
]
259248
},
260249
{
@@ -275,12 +264,12 @@
275264
"visium_landmarks = ShapesModel.parse(\n",
276265
" np.array([[10556.699, 7829.764], [13959.155, 13522.025], [10621.200, 17392.116]]), geometry=0, radius=500\n",
277266
")\n",
278-
"visium_sdata.shapes[\"visium_landmarks\"] = visium_landmarks\n",
267+
"visium_sdata.add_shapes(\"visium_landmarks\", visium_landmarks, overwrite=True)\n",
279268
"\n",
280269
"xenium_landmarks = ShapesModel.parse(\n",
281270
" np.array([[9438.385, 13933.017], [24847.866, 5948.002], [34082.584, 15234.235]]), geometry=0, radius=500\n",
282271
")\n",
283-
"xenium_sdata.shapes[\"xenium_landmarks\"] = xenium_landmarks"
272+
"xenium_sdata.add_shapes(\"xenium_landmarks\", xenium_landmarks, overwrite=True)"
284273
]
285274
},
286275
{
@@ -444,7 +433,7 @@
444433
},
445434
{
446435
"cell_type": "code",
447-
"execution_count": 8,
436+
"execution_count": 7,
448437
"id": "5c442fdb-94a9-488c-8d87-cfcc109f9388",
449438
"metadata": {
450439
"tags": []
@@ -528,22 +517,23 @@
528517
},
529518
{
530519
"cell_type": "code",
531-
"execution_count": 10,
532-
"id": "076fa9b5-452e-4228-994c-f4be656b9d6b",
520+
"execution_count": 8,
521+
"id": "474410bd-2d02-45c1-b073-eba1152ab615",
533522
"metadata": {
534523
"tags": []
535524
},
536525
"outputs": [],
537526
"source": [
538527
"from spatialdata import save_transformations\n",
539528
"\n",
540-
"save_transformations(visium_sdata)"
529+
"save_transformations(visium_sdata)\n",
530+
"save_transformations(xenium_sdata)"
541531
]
542532
}
543533
],
544534
"metadata": {
545535
"kernelspec": {
546-
"display_name": "base",
536+
"display_name": "Python 3 (ipykernel)",
547537
"language": "python",
548538
"name": "python3"
549539
},
@@ -557,7 +547,7 @@
557547
"name": "python",
558548
"nbconvert_exporter": "python",
559549
"pygments_lexer": "ipython3",
560-
"version": "3.10.8 | packaged by conda-forge | (main, Nov 22 2022, 08:25:13) [Clang 14.0.6 ]"
550+
"version": "3.10.12"
561551
},
562552
"vscode": {
563553
"interpreter": {

0 commit comments

Comments
 (0)