|
48 | 48 | },
|
49 | 49 | "tags": []
|
50 | 50 | },
|
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": [], |
69 | 52 | "source": [
|
70 | 53 | "import numpy as np\n",
|
71 | 54 | "import spatialdata as sd\n",
|
72 |
| - "from napari_spatialdata import Interactive" |
| 55 | + "\n", |
| 56 | + "# from napari_spatialdata import Interactive" |
73 | 57 | ]
|
74 | 58 | },
|
75 | 59 | {
|
|
85 | 69 | },
|
86 | 70 | "outputs": [
|
87 | 71 | {
|
88 |
| - "name": "stdout", |
| 72 | + "name": "stderr", |
89 | 73 | "output_type": "stream",
|
90 | 74 | "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" |
92 | 77 | ]
|
93 | 78 | },
|
94 | 79 | {
|
|
99 | 84 | "│ ├── 'morphology_focus': MultiscaleSpatialImage[cyx] (1, 25778, 35416), (1, 12889, 17708), (1, 6444, 8854), (1, 3222, 4427), (1, 1611, 2213)\n",
|
100 | 85 | "│ └── 'morphology_mip': MultiscaleSpatialImage[cyx] (1, 25778, 35416), (1, 12889, 17708), (1, 6444, 8854), (1, 3222, 4427), (1, 1611, 2213)\n",
|
101 | 86 | "├── Points\n",
|
102 |
| - "│ └── 'transcripts': DataFrame with shape: (42638083, 9) (3D points)\n", |
| 87 | + "│ └── 'transcripts': DataFrame with shape: (42638083, 8) (3D points)\n", |
103 | 88 | "├── Shapes\n",
|
104 | 89 | "│ ├── 'cell_boundaries': GeoDataFrame shape: (167780, 1) (2D shapes)\n",
|
105 | 90 | "│ ├── 'cell_circles': GeoDataFrame shape: (167780, 2) (2D shapes)\n",
|
106 | 91 | "│ ├── 'nucleus_boundaries': GeoDataFrame shape: (167780, 1) (2D shapes)\n",
|
107 |
| - "│ ├── 'visium_landmarks': GeoDataFrame shape: (3, 2) (2D shapes)\n", |
108 | 92 | "│ └── 'xenium_landmarks': GeoDataFrame shape: (3, 2) (2D shapes)\n",
|
109 | 93 | "└── Table\n",
|
110 | 94 | " └── 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", |
112 | 96 | " var: 'gene_ids', 'feature_types', 'genome'\n",
|
113 | 97 | " uns: 'spatialdata_attrs'\n",
|
114 | 98 | " obsm: 'spatial': AnnData (167780, 313)\n",
|
115 | 99 | "with coordinate systems:\n",
|
116 | 100 | "▸ '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", |
118 | 102 | "▸ '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)" |
120 | 104 | ]
|
121 | 105 | },
|
122 | 106 | "execution_count": 2,
|
|
149 | 133 | "│ ├── '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",
|
150 | 134 | "│ ├── 'CytAssist_FFPE_Human_Breast_Cancer_hires_image': SpatialImage[cyx] (3, 2000, 1809)\n",
|
151 | 135 | "│ └── '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", |
152 | 139 | "├── 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", |
154 | 142 | "└── Table\n",
|
155 | 143 | " └── AnnData object with n_obs × n_vars = 4992 × 18085\n",
|
156 | 144 | " obs: 'in_tissue', 'array_row', 'array_col', 'spot_id', 'region', 'dataset', 'clone'\n",
|
157 | 145 | " var: 'gene_ids', 'feature_types', 'genome'\n",
|
158 |
| - " uns: 'clone_colors', 'region_colors', 'spatial', 'spatialdata_attrs'\n", |
| 146 | + " uns: 'spatial', 'spatialdata_attrs'\n", |
159 | 147 | " obsm: 'spatial': AnnData (4992, 18085)\n",
|
160 | 148 | "with coordinate systems:\n",
|
161 | 149 | "▸ '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", |
163 | 151 | "▸ 'downscaled_hires', with elements:\n",
|
164 | 152 | " CytAssist_FFPE_Human_Breast_Cancer_hires_image (Images), CytAssist_FFPE_Human_Breast_Cancer (Shapes)\n",
|
165 | 153 | "▸ 'downscaled_lowres', with elements:\n",
|
166 | 154 | " CytAssist_FFPE_Human_Breast_Cancer_lowres_image (Images), CytAssist_FFPE_Human_Breast_Cancer (Shapes)\n",
|
167 | 155 | "▸ '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)" |
169 | 157 | ]
|
170 | 158 | },
|
171 | 159 | "execution_count": 3,
|
|
196 | 184 | "end_time": "2023-04-10T18:59:26.909684Z",
|
197 | 185 | "start_time": "2023-04-10T18:59:25.642148Z"
|
198 | 186 | },
|
| 187 | + "collapsed": false, |
199 | 188 | "jupyter": {
|
200 | 189 | "outputs_hidden": false
|
201 | 190 | }
|
|
254 | 243 | "id": "5890a6dc",
|
255 | 244 | "metadata": {},
|
256 | 245 | "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." |
258 | 247 | ]
|
259 | 248 | },
|
260 | 249 | {
|
|
275 | 264 | "visium_landmarks = ShapesModel.parse(\n",
|
276 | 265 | " np.array([[10556.699, 7829.764], [13959.155, 13522.025], [10621.200, 17392.116]]), geometry=0, radius=500\n",
|
277 | 266 | ")\n",
|
278 |
| - "visium_sdata.shapes[\"visium_landmarks\"] = visium_landmarks\n", |
| 267 | + "visium_sdata.add_shapes(\"visium_landmarks\", visium_landmarks, overwrite=True)\n", |
279 | 268 | "\n",
|
280 | 269 | "xenium_landmarks = ShapesModel.parse(\n",
|
281 | 270 | " np.array([[9438.385, 13933.017], [24847.866, 5948.002], [34082.584, 15234.235]]), geometry=0, radius=500\n",
|
282 | 271 | ")\n",
|
283 |
| - "xenium_sdata.shapes[\"xenium_landmarks\"] = xenium_landmarks" |
| 272 | + "xenium_sdata.add_shapes(\"xenium_landmarks\", xenium_landmarks, overwrite=True)" |
284 | 273 | ]
|
285 | 274 | },
|
286 | 275 | {
|
|
444 | 433 | },
|
445 | 434 | {
|
446 | 435 | "cell_type": "code",
|
447 |
| - "execution_count": 8, |
| 436 | + "execution_count": 7, |
448 | 437 | "id": "5c442fdb-94a9-488c-8d87-cfcc109f9388",
|
449 | 438 | "metadata": {
|
450 | 439 | "tags": []
|
|
528 | 517 | },
|
529 | 518 | {
|
530 | 519 | "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", |
533 | 522 | "metadata": {
|
534 | 523 | "tags": []
|
535 | 524 | },
|
536 | 525 | "outputs": [],
|
537 | 526 | "source": [
|
538 | 527 | "from spatialdata import save_transformations\n",
|
539 | 528 | "\n",
|
540 |
| - "save_transformations(visium_sdata)" |
| 529 | + "save_transformations(visium_sdata)\n", |
| 530 | + "save_transformations(xenium_sdata)" |
541 | 531 | ]
|
542 | 532 | }
|
543 | 533 | ],
|
544 | 534 | "metadata": {
|
545 | 535 | "kernelspec": {
|
546 |
| - "display_name": "base", |
| 536 | + "display_name": "Python 3 (ipykernel)", |
547 | 537 | "language": "python",
|
548 | 538 | "name": "python3"
|
549 | 539 | },
|
|
557 | 547 | "name": "python",
|
558 | 548 | "nbconvert_exporter": "python",
|
559 | 549 | "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" |
561 | 551 | },
|
562 | 552 | "vscode": {
|
563 | 553 | "interpreter": {
|
|
0 commit comments