|
18 | 18 | "\n", |
19 | 19 | "We use the real Xenium `cells` dataset from `squidpy` (its `transcripts` element), downloaded and\n", |
20 | 20 | "cached on first use. Point colouring uses the **matplotlib backend** (`method=\"matplotlib\"`) so every\n", |
21 | | - "point keeps its own colour; `render_points` otherwise switches to datashader for very large sets — see\n", |
22 | | - "the *Point density maps* and *Speeding up rendering* notebooks." |
| 21 | + "point keeps its own colour; `render_points` otherwise switches to datashader above ~10,000 points, which aggregates them and so\n", |
| 22 | + "cannot keep a distinct colour per point — see the *Point density maps* and *Speeding up rendering*\n", |
| 23 | + "notebooks." |
23 | 24 | ] |
24 | 25 | }, |
25 | 26 | { |
|
36 | 37 | "id": "5817284b", |
37 | 38 | "metadata": { |
38 | 39 | "execution": { |
39 | | - "iopub.execute_input": "2026-08-18T22:55:02.428168Z", |
40 | | - "iopub.status.busy": "2026-08-18T22:55:02.428050Z", |
41 | | - "iopub.status.idle": "2026-08-18T22:55:08.716436Z", |
42 | | - "shell.execute_reply": "2026-08-18T22:55:08.715732Z" |
| 40 | + "iopub.execute_input": "2026-08-19T03:34:33.702060Z", |
| 41 | + "iopub.status.busy": "2026-08-19T03:34:33.701942Z", |
| 42 | + "iopub.status.idle": "2026-08-19T03:34:44.267379Z", |
| 43 | + "shell.execute_reply": "2026-08-19T03:34:44.266804Z" |
43 | 44 | } |
44 | 45 | }, |
45 | 46 | "outputs": [ |
|
98 | 99 | "sdata" |
99 | 100 | ] |
100 | 101 | }, |
| 102 | + { |
| 103 | + "cell_type": "markdown", |
| 104 | + "id": "71aaf0d7", |
| 105 | + "metadata": {}, |
| 106 | + "source": [ |
| 107 | + "The `cells` dataset is a small (~3 MB) crop of a real 10x **Xenium** breast-cancer section,\n", |
| 108 | + "cached locally after the first download. The colouring below draws on the columns of its\n", |
| 109 | + "`transcripts` points element:" |
| 110 | + ] |
| 111 | + }, |
| 112 | + { |
| 113 | + "cell_type": "code", |
| 114 | + "execution_count": 2, |
| 115 | + "id": "6b3a72dc", |
| 116 | + "metadata": { |
| 117 | + "execution": { |
| 118 | + "iopub.execute_input": "2026-08-19T03:34:44.269152Z", |
| 119 | + "iopub.status.busy": "2026-08-19T03:34:44.269024Z", |
| 120 | + "iopub.status.idle": "2026-08-19T03:34:44.271734Z", |
| 121 | + "shell.execute_reply": "2026-08-19T03:34:44.271293Z" |
| 122 | + } |
| 123 | + }, |
| 124 | + "outputs": [ |
| 125 | + { |
| 126 | + "data": { |
| 127 | + "text/plain": [ |
| 128 | + "['x',\n", |
| 129 | + " 'y',\n", |
| 130 | + " 'z',\n", |
| 131 | + " 'feature_name',\n", |
| 132 | + " 'cell_id',\n", |
| 133 | + " 'fov_name',\n", |
| 134 | + " 'codeword_index',\n", |
| 135 | + " 'qv',\n", |
| 136 | + " 'transcript_id',\n", |
| 137 | + " 'is_gene',\n", |
| 138 | + " 'codeword_category',\n", |
| 139 | + " 'nucleus_distance',\n", |
| 140 | + " 'overlaps_nucleus']" |
| 141 | + ] |
| 142 | + }, |
| 143 | + "execution_count": 2, |
| 144 | + "metadata": {}, |
| 145 | + "output_type": "execute_result" |
| 146 | + } |
| 147 | + ], |
| 148 | + "source": [ |
| 149 | + "list(sdata[\"transcripts\"].columns)" |
| 150 | + ] |
| 151 | + }, |
101 | 152 | { |
102 | 153 | "cell_type": "markdown", |
103 | 154 | "id": "997ac2bb", |
|
111 | 162 | }, |
112 | 163 | { |
113 | 164 | "cell_type": "code", |
114 | | - "execution_count": 2, |
| 165 | + "execution_count": 3, |
115 | 166 | "id": "10814cf1", |
116 | 167 | "metadata": { |
117 | 168 | "execution": { |
118 | | - "iopub.execute_input": "2026-08-18T22:55:08.718347Z", |
119 | | - "iopub.status.busy": "2026-08-18T22:55:08.718197Z", |
120 | | - "iopub.status.idle": "2026-08-18T22:55:09.502886Z", |
121 | | - "shell.execute_reply": "2026-08-18T22:55:09.502377Z" |
| 169 | + "iopub.execute_input": "2026-08-19T03:34:44.273223Z", |
| 170 | + "iopub.status.busy": "2026-08-19T03:34:44.273107Z", |
| 171 | + "iopub.status.idle": "2026-08-19T03:34:45.082341Z", |
| 172 | + "shell.execute_reply": "2026-08-19T03:34:45.081737Z" |
122 | 173 | } |
123 | 174 | }, |
124 | 175 | "outputs": [ |
|
150 | 201 | }, |
151 | 202 | { |
152 | 203 | "cell_type": "code", |
153 | | - "execution_count": 3, |
| 204 | + "execution_count": 4, |
154 | 205 | "id": "5dcf7754", |
155 | 206 | "metadata": { |
156 | 207 | "execution": { |
157 | | - "iopub.execute_input": "2026-08-18T22:55:09.504957Z", |
158 | | - "iopub.status.busy": "2026-08-18T22:55:09.504838Z", |
159 | | - "iopub.status.idle": "2026-08-18T22:55:09.971854Z", |
160 | | - "shell.execute_reply": "2026-08-18T22:55:09.971254Z" |
| 208 | + "iopub.execute_input": "2026-08-19T03:34:45.084350Z", |
| 209 | + "iopub.status.busy": "2026-08-19T03:34:45.084224Z", |
| 210 | + "iopub.status.idle": "2026-08-19T03:34:45.580457Z", |
| 211 | + "shell.execute_reply": "2026-08-19T03:34:45.579838Z" |
161 | 212 | } |
162 | 213 | }, |
163 | 214 | "outputs": [ |
|
197 | 248 | }, |
198 | 249 | { |
199 | 250 | "cell_type": "code", |
200 | | - "execution_count": 4, |
| 251 | + "execution_count": 5, |
201 | 252 | "id": "b1c3160f", |
202 | 253 | "metadata": { |
203 | 254 | "execution": { |
204 | | - "iopub.execute_input": "2026-08-18T22:55:09.973713Z", |
205 | | - "iopub.status.busy": "2026-08-18T22:55:09.973609Z", |
206 | | - "iopub.status.idle": "2026-08-18T22:55:10.444836Z", |
207 | | - "shell.execute_reply": "2026-08-18T22:55:10.444356Z" |
| 255 | + "iopub.execute_input": "2026-08-19T03:34:45.582257Z", |
| 256 | + "iopub.status.busy": "2026-08-19T03:34:45.582150Z", |
| 257 | + "iopub.status.idle": "2026-08-19T03:34:46.080758Z", |
| 258 | + "shell.execute_reply": "2026-08-19T03:34:46.080053Z" |
208 | 259 | } |
209 | 260 | }, |
210 | 261 | "outputs": [ |
|
244 | 295 | "## 4. Subsetting categories — `groups` and `na_color`\n", |
245 | 296 | "\n", |
246 | 297 | "`groups` restricts colouring to selected categories; everything else is drawn in `na_color`. Here we\n", |
247 | | - "pick a few marker genes and grey out the rest." |
| 298 | + "pick a few marker genes and grey out the rest. Omit `na_color` and the non-matching points are hidden\n", |
| 299 | + "entirely instead of greyed." |
248 | 300 | ] |
249 | 301 | }, |
250 | 302 | { |
251 | 303 | "cell_type": "code", |
252 | | - "execution_count": 5, |
| 304 | + "execution_count": 6, |
253 | 305 | "id": "d90642f4", |
254 | 306 | "metadata": { |
255 | 307 | "execution": { |
256 | | - "iopub.execute_input": "2026-08-18T22:55:10.447033Z", |
257 | | - "iopub.status.busy": "2026-08-18T22:55:10.446917Z", |
258 | | - "iopub.status.idle": "2026-08-18T22:55:10.814005Z", |
259 | | - "shell.execute_reply": "2026-08-18T22:55:10.813480Z" |
| 308 | + "iopub.execute_input": "2026-08-19T03:34:46.082524Z", |
| 309 | + "iopub.status.busy": "2026-08-19T03:34:46.082396Z", |
| 310 | + "iopub.status.idle": "2026-08-19T03:34:46.473842Z", |
| 311 | + "shell.execute_reply": "2026-08-19T03:34:46.473257Z" |
260 | 312 | } |
261 | 313 | }, |
262 | 314 | "outputs": [ |
|
294 | 346 | }, |
295 | 347 | { |
296 | 348 | "cell_type": "code", |
297 | | - "execution_count": 6, |
| 349 | + "execution_count": 7, |
298 | 350 | "id": "092260ad", |
299 | 351 | "metadata": { |
300 | 352 | "execution": { |
301 | | - "iopub.execute_input": "2026-08-18T22:55:10.815615Z", |
302 | | - "iopub.status.busy": "2026-08-18T22:55:10.815495Z", |
303 | | - "iopub.status.idle": "2026-08-18T22:55:11.308237Z", |
304 | | - "shell.execute_reply": "2026-08-18T22:55:11.307597Z" |
| 353 | + "iopub.execute_input": "2026-08-19T03:34:46.475950Z", |
| 354 | + "iopub.status.busy": "2026-08-19T03:34:46.475813Z", |
| 355 | + "iopub.status.idle": "2026-08-19T03:34:46.985787Z", |
| 356 | + "shell.execute_reply": "2026-08-19T03:34:46.985061Z" |
305 | 357 | } |
306 | 358 | }, |
307 | 359 | "outputs": [ |
|
333 | 385 | "- A **categorical** `color=` column draws a legend; set colours with `palette`, subset with `groups`,\n", |
334 | 386 | " and style the remainder with `na_color`.\n", |
335 | 387 | "- `size` and `alpha` tune the markers.\n", |
336 | | - "- Per-point colouring uses the matplotlib backend; for millions of points switch to datashader\n", |
337 | | - " (`method=\"datashader\"`, or `density=True`) — see the *Point density maps* and *Speeding up\n", |
338 | | - " rendering* notebooks." |
| 388 | + "- Per-point colouring uses the matplotlib backend; `render_points` auto-switches to datashader above\n", |
| 389 | + " 10,000 points (which drops per-point colour), so pass `method=\"matplotlib\"` to force it — or reach\n", |
| 390 | + " for datashader deliberately (`method=\"datashader\"`, or `density=True`) for millions of points. See\n", |
| 391 | + " the *Point density maps* and *Speeding up rendering* notebooks." |
339 | 392 | ] |
340 | 393 | }, |
341 | 394 | { |
|
348 | 401 | }, |
349 | 402 | { |
350 | 403 | "cell_type": "code", |
351 | | - "execution_count": 7, |
| 404 | + "execution_count": 8, |
352 | 405 | "id": "b23aeab2", |
353 | 406 | "metadata": { |
354 | 407 | "execution": { |
355 | | - "iopub.execute_input": "2026-08-18T22:55:11.310421Z", |
356 | | - "iopub.status.busy": "2026-08-18T22:55:11.310312Z", |
357 | | - "iopub.status.idle": "2026-08-18T22:55:11.343903Z", |
358 | | - "shell.execute_reply": "2026-08-18T22:55:11.343228Z" |
| 408 | + "iopub.execute_input": "2026-08-19T03:34:46.987964Z", |
| 409 | + "iopub.status.busy": "2026-08-19T03:34:46.987836Z", |
| 410 | + "iopub.status.idle": "2026-08-19T03:34:47.020451Z", |
| 411 | + "shell.execute_reply": "2026-08-19T03:34:47.019656Z" |
359 | 412 | } |
360 | 413 | }, |
361 | 414 | "outputs": [ |
|
0 commit comments