Skip to content

Commit 0d6ce8d

Browse files
Merge pull request #79 from scverse/improve/docs
Improved documentation
2 parents 515a6f3 + 6e98986 commit 0d6ce8d

11 files changed

+1889
-1445
lines changed

notebooks/examples/aggregation.ipynb

Lines changed: 222 additions & 127 deletions
Large diffs are not rendered by default.

notebooks/examples/alignment_using_landmarks.ipynb

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"name": "stderr",
7373
"output_type": "stream",
7474
"text": [
75-
"/Users/macbook/miniconda3/envs/ome/lib/python3.10/site-packages/anndata/_core/anndata.py:183: ImplicitModificationWarning: Transforming to str index.\n",
75+
"/mnt/miniconda3/envs/ome/lib/python3.10/site-packages/anndata/_core/aligned_df.py:67: ImplicitModificationWarning: Transforming to str index.\n",
7676
" warnings.warn(\"Transforming to str index.\", ImplicitModificationWarning)\n"
7777
]
7878
},
@@ -88,19 +88,14 @@
8888
"├── Shapes\n",
8989
"│ ├── 'cell_boundaries': GeoDataFrame shape: (167780, 1) (2D shapes)\n",
9090
"│ ├── 'cell_circles': GeoDataFrame shape: (167780, 2) (2D shapes)\n",
91-
"│ ├── 'nucleus_boundaries': GeoDataFrame shape: (167780, 1) (2D shapes)\n",
92-
"│ └── 'xenium_landmarks': GeoDataFrame shape: (3, 2) (2D shapes)\n",
93-
"└── Table\n",
94-
" └── AnnData object with n_obs × n_vars = 167780 × 313\n",
95-
" obs: 'cell_id', 'transcript_counts', 'control_probe_counts', 'control_codeword_counts', 'total_counts', 'cell_area', 'nucleus_area', 'region'\n",
96-
" var: 'gene_ids', 'feature_types', 'genome'\n",
97-
" uns: 'spatialdata_attrs'\n",
98-
" obsm: 'spatial': AnnData (167780, 313)\n",
91+
"│ └── 'nucleus_boundaries': GeoDataFrame shape: (167780, 1) (2D shapes)\n",
92+
"└── Tables\n",
93+
" └── 'table': AnnData (167780, 313)\n",
9994
"with coordinate systems:\n",
10095
"▸ 'aligned', with elements:\n",
10196
" morphology_mip (Images)\n",
10297
"▸ 'global', with elements:\n",
103-
" morphology_focus (Images), morphology_mip (Images), transcripts (Points), cell_boundaries (Shapes), cell_circles (Shapes), nucleus_boundaries (Shapes), xenium_landmarks (Shapes)"
98+
" morphology_focus (Images), morphology_mip (Images), transcripts (Points), cell_boundaries (Shapes), cell_circles (Shapes), nucleus_boundaries (Shapes)"
10499
]
105100
},
106101
"execution_count": 2,
@@ -133,27 +128,19 @@
133128
"│ ├── '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",
134129
"│ ├── 'CytAssist_FFPE_Human_Breast_Cancer_hires_image': SpatialImage[cyx] (3, 2000, 1809)\n",
135130
"│ └── '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",
139131
"├── 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",
142-
"└── Table\n",
143-
" └── AnnData object with n_obs × n_vars = 4992 × 18085\n",
144-
" obs: 'in_tissue', 'array_row', 'array_col', 'spot_id', 'region', 'dataset', 'clone'\n",
145-
" var: 'gene_ids', 'feature_types', 'genome'\n",
146-
" uns: 'spatial', 'spatialdata_attrs'\n",
147-
" obsm: 'spatial': AnnData (4992, 18085)\n",
132+
"│ └── 'CytAssist_FFPE_Human_Breast_Cancer': GeoDataFrame shape: (4992, 2) (2D shapes)\n",
133+
"└── Tables\n",
134+
" └── 'table': AnnData (4992, 18085)\n",
148135
"with coordinate systems:\n",
149136
"▸ 'aligned', with elements:\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",
137+
" CytAssist_FFPE_Human_Breast_Cancer_full_image (Images), CytAssist_FFPE_Human_Breast_Cancer (Shapes)\n",
151138
"▸ 'downscaled_hires', with elements:\n",
152139
" CytAssist_FFPE_Human_Breast_Cancer_hires_image (Images), CytAssist_FFPE_Human_Breast_Cancer (Shapes)\n",
153140
"▸ 'downscaled_lowres', with elements:\n",
154141
" CytAssist_FFPE_Human_Breast_Cancer_lowres_image (Images), CytAssist_FFPE_Human_Breast_Cancer (Shapes)\n",
155142
"▸ 'global', with elements:\n",
156-
" CytAssist_FFPE_Human_Breast_Cancer_full_image (Images), CytAssist_FFPE_Human_Breast_Cancer (Shapes), visium_landmarks (Shapes)"
143+
" CytAssist_FFPE_Human_Breast_Cancer_full_image (Images), CytAssist_FFPE_Human_Breast_Cancer (Shapes)"
157144
]
158145
},
159146
"execution_count": 3,
@@ -184,7 +171,10 @@
184171
"end_time": "2023-04-10T18:59:26.909684Z",
185172
"start_time": "2023-04-10T18:59:25.642148Z"
186173
},
187-
"collapsed": false
174+
"collapsed": false,
175+
"jupyter": {
176+
"outputs_hidden": false
177+
}
188178
},
189179
"source": [
190180
"Interactive([visium_sdata, xenium_sdata], points=False, shapes=False)"
@@ -335,6 +325,9 @@
335325
"id": "e71718a2",
336326
"metadata": {
337327
"collapsed": false,
328+
"jupyter": {
329+
"outputs_hidden": false
330+
},
338331
"tags": []
339332
},
340333
"outputs": [
@@ -498,25 +491,44 @@
498491
"id": "be9277db",
499492
"metadata": {},
500493
"source": [
501-
"### Saving the alignment back to Zarr\n"
494+
"### Saving the landmarks and the alignment back to Zarr\n"
502495
]
503496
},
504497
{
505498
"cell_type": "markdown",
506499
"id": "2e98374c-85cd-45ad-ac62-b2bc075c9631",
507500
"metadata": {},
508501
"source": [
509-
"We will now save the transformations to disk. Notice that this is a lightweight operation because we are just mofiying the objects metadata, not transforming the actual data. This is useful when dealing with large images and when one may need to reiterate multiple steps of landmark-based alignment in order to improve the spatial agreement of the alignment."
502+
"We will now save the landmark points and the transformations of the other elements to disk. \n",
503+
"\n",
504+
"Notice that these are both lightweight operations because the two sets of landmark points are small, and when saving the transformation of the other elements we are modifying the objects metadata, not transforming the actual data. This is useful when dealing with large images and when one may need to reiterate multiple steps of landmark-based alignment in order to improve the spatial agreement of the alignment."
505+
]
506+
},
507+
{
508+
"cell_type": "markdown",
509+
"id": "a30ee131-40a4-44a2-b736-763532cf570e",
510+
"metadata": {},
511+
"source": [
512+
"WARNING: unfortunately the modular saving of transformation and elements have been refactored out of the latest release and is still not finalized. This function will be re-enabled with high priority, please see the issue tracker here: https://github.com/scverse/spatialdata/issues/496."
510513
]
511514
},
512515
{
513516
"cell_type": "code",
514-
"execution_count": 8,
517+
"execution_count": 10,
515518
"id": "474410bd-2d02-45c1-b073-eba1152ab615",
516519
"metadata": {
517520
"tags": []
518521
},
519-
"outputs": [],
522+
"outputs": [
523+
{
524+
"name": "stdout",
525+
"output_type": "stream",
526+
"text": [
527+
"\u001b[34mINFO \u001b[0m Not saving the transformation to element shapes/visium_landmarks as it is not found in Zarr storage \n",
528+
"\u001b[34mINFO \u001b[0m Not saving the transformation to element shapes/xenium_landmarks as it is not found in Zarr storage \n"
529+
]
530+
}
531+
],
520532
"source": [
521533
"from spatialdata import save_transformations\n",
522534
"\n",
@@ -541,7 +553,7 @@
541553
"name": "python",
542554
"nbconvert_exporter": "python",
543555
"pygments_lexer": "ipython3",
544-
"version": "3.10.12"
556+
"version": "3.10.13"
545557
},
546558
"vscode": {
547559
"interpreter": {

0 commit comments

Comments
 (0)