|
30 | 30 | "outputs": [], |
31 | 31 | "source": [ |
32 | 32 | "import spatialdata\n", |
33 | | - "from os.path import join" |
| 33 | + "from os.path import join\n", |
| 34 | + "import pandas as pd\n", |
| 35 | + "from anndata import AnnData" |
34 | 36 | ] |
35 | 37 | }, |
36 | 38 | { |
|
39 | 41 | "metadata": {}, |
40 | 42 | "outputs": [], |
41 | 43 | "source": [ |
42 | | - "sdata = spatialdata.datasets.blobs()" |
| 44 | + "sdata = spatialdata.datasets.blobs()\n", |
| 45 | + "sdata" |
43 | 46 | ] |
44 | 47 | }, |
45 | 48 | { |
|
48 | 51 | "metadata": {}, |
49 | 52 | "outputs": [], |
50 | 53 | "source": [ |
51 | | - "spatialdata_filepath = join(\"data\", \"blobs.spatialdata.zarr\")" |
| 54 | + "# This blobs dataset only contains a table with a var.index corresponding to the shapes features.\n", |
| 55 | + "# We need to construct a table with a var.index corresponding to the points features:\n", |
| 56 | + "ddf = sdata.points[\"blobs_points\"]\n", |
| 57 | + "unique_gene_ids = ddf[\"genes\"].unique().compute().tolist()\n", |
| 58 | + "points_var_df = pd.DataFrame(index=unique_gene_ids, data=[], columns=[])\n", |
| 59 | + "points_table = AnnData(var=points_var_df, obs=None, X=None)\n", |
| 60 | + "sdata.tables['table_points'] = points_table" |
52 | 61 | ] |
53 | 62 | }, |
54 | 63 | { |
|
57 | 66 | "metadata": {}, |
58 | 67 | "outputs": [], |
59 | 68 | "source": [ |
60 | | - "sdata.write(spatialdata_filepath, overwrite=True)" |
| 69 | + "spatialdata_filepath = join(\"data\", \"blobs.spatialdata.zarr\")" |
61 | 70 | ] |
62 | 71 | }, |
63 | 72 | { |
|
66 | 75 | "metadata": {}, |
67 | 76 | "outputs": [], |
68 | 77 | "source": [ |
69 | | - "# Change data type of x and y columns from int64 to int32\n", |
70 | | - "# Temporary workaround, will be resolved by https://github.com/vitessce/vitessce/issues/2292\n", |
71 | | - "ddf = sdata[\"blobs_points\"]\n", |
72 | | - "ddf[\"x\"] = ddf[\"x\"].astype('int32')\n", |
73 | | - "ddf[\"y\"] = ddf[\"y\"].astype('int32')\n", |
74 | | - "sdata[\"blobs_points_2\"] = ddf\n", |
75 | | - "sdata.write_element(\"blobs_points_2\")" |
| 78 | + "sdata.write(spatialdata_filepath, overwrite=True)" |
76 | 79 | ] |
77 | 80 | }, |
78 | 81 | { |
|
112 | 115 | ")\n", |
113 | 116 | "# Add data to the configuration:\n", |
114 | 117 | "wrapper = SpatialDataWrapper(\n", |
115 | | - " sdata_store=spatialdata_filepath,\n", |
| 118 | + " sdata_path=spatialdata_filepath,\n", |
116 | 119 | " # The following paths are relative to the root of the SpatialData zarr store on-disk.\n", |
117 | 120 | " image_path=\"images/blobs_image\",\n", |
118 | 121 | " obs_segmentations_path=\"labels/blobs_labels\",\n", |
| 122 | + " obs_embedding_paths=[\"tables/table/obsm/X_umap\"],\n", |
| 123 | + " obs_feature_matrix_path=\"tables/table/X\",\n", |
119 | 124 | " coordinate_system=\"global\",\n", |
120 | 125 | " coordination_values={\n", |
121 | 126 | " \"obsType\": \"blob\",\n", |
| 127 | + " \"featureType\": \"channel\",\n", |
122 | 128 | " \"fileUid\": \"my_unique_id\"\n", |
123 | 129 | " }\n", |
124 | 130 | ")\n", |
125 | 131 | "points_wrapper = SpatialDataWrapper(\n", |
126 | | - " sdata_store=spatialdata_filepath,\n", |
| 132 | + " sdata_path=spatialdata_filepath,\n", |
127 | 133 | " # The following paths are relative to the root of the SpatialData zarr store on-disk.\n", |
128 | | - " obs_points_path=\"points/blobs_points_2\",\n", |
| 134 | + " obs_points_path=\"points/blobs_points\",\n", |
| 135 | + " obs_feature_matrix_path=\"tables/table_points/X\", # TODO\n", |
129 | 136 | " coordinate_system=\"global\",\n", |
130 | 137 | " coordination_values={\n", |
131 | 138 | " \"obsType\": \"point\",\n", |
| 139 | + " \"featureType\": \"gene\",\n", |
132 | 140 | " \"fileUid\": \"other_unique_id\"\n", |
133 | 141 | " }\n", |
134 | 142 | ")\n", |
|
169 | 177 | " 'segmentationChannel': CL([{\n", |
170 | 178 | " 'spatialChannelVisible': True,\n", |
171 | 179 | " 'obsType': 'blob',\n", |
| 180 | + " \"featureType\": \"channel\",\n", |
172 | 181 | " }]),\n", |
173 | 182 | " }]),\n", |
174 | 183 | "}, scope_prefix=get_initial_coordination_scope_prefix(\"A\", \"obsSegmentations\"))\n", |
|
177 | 186 | " 'pointLayer': CL([{\n", |
178 | 187 | " \"fileUid\": \"other_unique_id\",\n", |
179 | 188 | " \"obsType\": \"point\",\n", |
| 189 | + " \"featureType\": \"gene\",\n", |
180 | 190 | " \"obsHighlight\": None,\n", |
| 191 | + " \"obsColorEncoding\": \"randomByFeature\",\n", |
| 192 | + " \"spatialLayerOpacity\": 1.0,\n", |
181 | 193 | " }]),\n", |
182 | 194 | "}, scope_prefix=get_initial_coordination_scope_prefix(\"A\", \"obsPoints\"))\n", |
183 | 195 | "\n", |
|
0 commit comments