> For the complete documentation index, see [llms.txt](https://docs.owkin.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.owkin.com/explore-and-analyse-data/data-analysis/spatial/spatial-slide-display.md).

# Spatial slide display

Display Visium spots on a slide colored by metadata, gene expression, cell type deconvolution, or spatial colocalization.

Display Visium spots on a slide colored by metadata, gene expression, cell type deconvolution, or spatial colocalization.

## Spots coloured by categorical metadata

### Description

#### Analysis summary

Shows each Visium spot on the slide coloured by a categorical metadata column such as tumour region, pathologist annotation, or dominant cell type. Useful to see where categorical features sit on the tissue.

#### Computation

Each spot is placed at its slide coordinates and coloured by its category from the value column; the data is displayed as-is, with no transformation. The analysis also computes spatial statistics: each category is tested in turn — its Moran's I over the spots carrying it, with z-score, p-value and Benjamini-Hochberg-adjusted q-value across the categories — on a spot adjacency within a two-spot radius, telling whether that category's spots cluster spatially or scatter. The descriptive stats add the spot count per category.

#### When to use

Use for where-is-it questions on categorical annotations: tumor region, cell type annotation, pathologist annotation, dominantcelltype\_cohort\_level\_2, or any categorical metadata column.

#### Caveats

One slide per run: with several sample\_ids the analysis keeps the first (alphabetical) and reports a note — run it once per sample to see each slide.

### Example questions

<details>

<summary><code>example questions</code></summary>

* Spatial slide display colored by metadata variable

</details>

### Input columns

<details>

<summary><code>input columns</code></summary>

| column                  | type                 | required | description                                                                                                                                                      |
| ----------------------- | -------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| spot\_id                | any                  | required | Spot identifier shown in the hover tooltip.                                                                                                                      |
| spatial\_1              | numeric              | required | Raw (unscaled) x-coordinate of the spot.                                                                                                                         |
| spatial\_2              | numeric              | required | Raw (unscaled) y-coordinate of the spot.                                                                                                                         |
| tissue\_hires\_scalef   | numeric              | required | Scale factor used to convert raw coordinates to image coordinates.                                                                                               |
| spot\_diameter\_fullres | numeric              | required | Spot diameter in full-resolution image pixels; used to size spot circles.                                                                                        |
| hires\_image\_path      | any                  | required | File-system or S3 path to the high-resolution H\&E image.                                                                                                        |
| alignment\_status       | any                  | required | Boolean — whether the H\&E image has been aligned with the spot grid.                                                                                            |
| value                   | categorical, numeric | required | Value to color each spot by. Alias any metadata column or expression value to 'value' in SQL. String/categorical values trigger mode='categorical'; numeric val… |
| sample\_id              | any                  | required | Sample identifier. When multiple samples are present, the first (alphabetically) is selected and the others are discarded.                                       |
| patient\_id             | categorical          | required | Patient identifier required for population summary plots.                                                                                                        |

</details>

### Visualizations

* `spt_slide_display` How to read: One dot per Visium spot, placed at its raw slide coordinates over the H\&E tissue image when the slide is aligned; dot colour is the spot's category, keyed by the legend titled with value\_label. Read it as a map of where each categorical feature sits on the tissue. The accompanying statistics give, one row per category, that category's Moran's I with z-score, p-value and FDR-adjusted q-value — a significant positive score marks a category whose spots cluster spatially rather than scatter — plus the spot count per category.

### Example analysis 1

#### Name — Tumor Region Distribution — PAT\_B\_099UHY7A

#### Analysis parameters

<details>

<summary><code>analysis_name, analysis_params, viz_params</code></summary>

```json
{
  "analysis_name": "spt_slide_display_analysis",
  "analysis_params": {
    "mode": "categorical"
  },
  "viz_params": {
    "plot_name": "spt_slide_display",
    "title": "Tumor Region Distribution \u2014 PAT_B_099UHY7A",
    "value_label": "Tumor Region"
  }
}
```

</details>

#### Visualization — `spt_slide_display`

![Tumor Region Distribution — PAT\_B\_099UHY7A](https://1034377358-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTmCjUj6W0sltjW7q2vBp%2Fuploads%2Fgit-blob-9d723431f439699b41c3646b21811c4a5f3d6e9e%2Fspt_slide_display_analysis__categorical__spt_slide_display.png?alt=media)

#### Output table

<details>

<summary><code>descriptive_stats</code> (3 rows)</summary>

| category    | n    |
| ----------- | ---- |
| Stroma      | 1747 |
| Tumor Edge  | 188  |
| Tumor Islet | 2845 |

</details>

<details>

<summary><code>statistical_tests</code> (3 rows)</summary>

| Test used for pairwise comparison | Group              | Statistic | P-value | Adjusted P-value | Score  |
| --------------------------------- | ------------------ | --------- | ------- | ---------------- | ------ |
| Moran's I test                    | value\_Stroma      |           |         |                  | 0.8518 |
| Moran's I test                    | value\_Tumor Edge  |           |         |                  | 0.1417 |
| Moran's I test                    | value\_Tumor Islet |           |         |                  | 0.8299 |

</details>

## Spots coloured by continuous value

### Description

#### Analysis summary

Shows each Visium spot on the slide coloured by a continuous value such as gene expression or a signature score. Useful to see the spatial distribution of a quantitative measurement on the tissue.

#### Computation

Each spot is placed at its slide coordinates and coloured by its continuous value from the value column; the data is displayed as-is, with no transformation. The analysis also computes spatial statistics: Moran's I on the value — whether similar values form spatial patches — with its z-score and p-value, and, in the descriptive stats, the summary of the value distribution.

#### When to use

Use for spatial-distribution questions on quantitative values: log-normalized gene expression, a gene-signature score, or any continuous metadata value.

#### Caveats

One slide per run: with several sample\_ids the analysis keeps the first (alphabetical) and reports a note — run it once per sample to see each slide.

### Example questions

<details>

<summary><code>example questions</code></summary>

* Spatial slide display colored by gene expression

</details>

### Input columns

<details>

<summary><code>input columns</code></summary>

| column                  | type                 | required | description                                                                                                                                                      |
| ----------------------- | -------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| spot\_id                | any                  | required | Spot identifier shown in the hover tooltip.                                                                                                                      |
| spatial\_1              | numeric              | required | Raw (unscaled) x-coordinate of the spot.                                                                                                                         |
| spatial\_2              | numeric              | required | Raw (unscaled) y-coordinate of the spot.                                                                                                                         |
| tissue\_hires\_scalef   | numeric              | required | Scale factor used to convert raw coordinates to image coordinates.                                                                                               |
| spot\_diameter\_fullres | numeric              | required | Spot diameter in full-resolution image pixels; used to size spot circles.                                                                                        |
| hires\_image\_path      | any                  | required | File-system or S3 path to the high-resolution H\&E image.                                                                                                        |
| alignment\_status       | any                  | required | Boolean — whether the H\&E image has been aligned with the spot grid.                                                                                            |
| value                   | categorical, numeric | required | Value to color each spot by. Alias any metadata column or expression value to 'value' in SQL. String/categorical values trigger mode='categorical'; numeric val… |
| sample\_id              | any                  | required | Sample identifier. When multiple samples are present, the first (alphabetically) is selected and the others are discarded.                                       |
| patient\_id             | categorical          | required | Patient identifier required for population summary plots.                                                                                                        |

</details>

### Visualizations

* `spt_slide_display` How to read: One dot per Visium spot over the H\&E tissue image (when the slide is aligned), coloured on a Viridis gradient by the continuous value; the legend is titled with value\_label. A smooth gradient tracks the measurement across the tissue; sharp patches mark locally elevated values. The accompanying statistics report Moran's I with its z-score and p-value — whether high values form spatial patches rather than scatter.

### Example analysis 1

#### Name — ERBB2 expression — PAT\_B\_099UHY7A

#### Analysis parameters

<details>

<summary><code>analysis_name, analysis_params, viz_params</code></summary>

```json
{
  "analysis_name": "spt_slide_display_analysis",
  "analysis_params": {
    "mode": "continuous"
  },
  "viz_params": {
    "plot_name": "spt_slide_display",
    "title": "ERBB2 expression \u2014 PAT_B_099UHY7A",
    "value_label": "ERBB2 expression"
  }
}
```

</details>

#### Visualization — `spt_slide_display`

![ERBB2 expression — PAT\_B\_099UHY7A](https://1034377358-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTmCjUj6W0sltjW7q2vBp%2Fuploads%2Fgit-blob-dd3c45a9edc0b4ac236e95a10fb6c784b48bb403%2Fspt_slide_display_analysis__continuous__spt_slide_display.png?alt=media)

#### Output table

<details>

<summary><code>descriptive_stats</code> (1 rows)</summary>

| n    | n\_zeros | mean\_all | mean\_non\_zero | std\_non\_zero | p50\_non\_zero | max\_non\_zero |
| ---- | -------- | --------- | --------------- | -------------- | -------------- | -------------- |
| 4780 | 1702     | 3.02      | 4.69            | 0.5807         | 4.735          | 6.888          |

</details>

<details>

<summary><code>statistical_tests</code> (1 rows)</summary>

| test           | score  | statistic | p\_value |
| -------------- | ------ | --------- | -------- |
| Moran's I test | 0.3942 |           |          |

</details>

## Pie-chart spots from cell-type deconvolution

### Description

#### Analysis summary

Shows each Visium spot's cell-type deconvolution fractions, each spot rendered as a tiny pie chart. Useful for a one-glance view of cell-population composition across the tissue, including immune infiltration patterns.

#### Computation

Each spot's pie slices are its cell-type deconvolution fractions (cohort-level-2). The deconvolution columns are auto-detected — every column ending in the cohort-level-2 suffix — unless an explicit list is given. The analysis also computes composition statistics: per cell type, its mean deconvolution fraction across the slide's spots and the share of spots where it is the dominant type.

#### When to use

Use when asked about cell type distribution, immune infiltration, tumor-immune colocalization, or spatial distribution of cell populations.

#### Caveats

One slide per run: with several sample\_ids the analysis keeps the first (alphabetical) and reports a note — run it once per sample to see each slide.

### Example questions

<details>

<summary><code>example questions</code></summary>

* Spatial slide display with per-spot cell type deconvolution pie charts

</details>

### Input columns

<details>

<summary><code>input columns</code></summary>

| column                             | type        | required | description                                                                                                                                                           |
| ---------------------------------- | ----------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| spot\_id                           | any         | required | Spot identifier shown in the hover tooltip.                                                                                                                           |
| spatial\_1                         | numeric     | required | Raw (unscaled) x-coordinate of the spot.                                                                                                                              |
| spatial\_2                         | numeric     | required | Raw (unscaled) y-coordinate of the spot.                                                                                                                              |
| tissue\_hires\_scalef              | numeric     | required | Scale factor used to convert raw coordinates to image coordinates.                                                                                                    |
| spot\_diameter\_fullres            | numeric     | required | Spot diameter in full-resolution image pixels; used to size spot circles.                                                                                             |
| hires\_image\_path                 | any         | required | File-system or S3 path to the high-resolution H\&E image.                                                                                                             |
| alignment\_status                  | any         | required | Boolean — whether the H\&E image has been aligned with the spot grid.                                                                                                 |
| \*\_deconv\_cohort\_level\_2\_frac | numeric     | required | Cell type deconvolution fraction columns (one per cell type). Each column is named after a cell type with the suffix '\_deconv\_cohort\_level\_2\_frac' (for instanc… |
| sample\_id                         | any         | required | Sample identifier. When multiple samples are present, the first (alphabetically) is selected and the others are discarded.                                            |
| patient\_id                        | categorical | required | Patient identifier required for population summary plots.                                                                                                             |

</details>

### Visualizations

* `spt_slide_display` How to read: One tiny pie chart per Visium spot over the H\&E tissue image (when the slide is aligned); each slice is a cell type's deconvolution fraction at that spot, coloured by the shared cell-type palette (cell\_type\_colors overrides it). Glance across the slide for composition gradients — immune-infiltration rims, tumour-dominated cores. The statistics table lists each cell type's mean fraction across spots and the share of spots where it is the dominant type.

### Example analysis 1

#### Name — Cell Type Distribution in Tissue for PAT\_B\_099UHY7A

#### Analysis parameters

<details>

<summary><code>analysis_name, analysis_params, viz_params</code></summary>

```json
{
  "analysis_name": "spt_slide_display_analysis",
  "analysis_params": {
    "mode": "cell_types"
  },
  "viz_params": {
    "plot_name": "spt_slide_display",
    "title": "Cell Type Distribution in Tissue for PAT_B_099UHY7A"
  }
}
```

</details>

#### Visualization — `spt_slide_display`

![Cell Type Distribution in Tissue for PAT\_B\_099UHY7A](https://1034377358-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTmCjUj6W0sltjW7q2vBp%2Fuploads%2Fgit-blob-de439f780179170050967e1cdd67eed8ce1dd9c5%2Fspt_slide_display_analysis__cell_types__spt_slide_display.png?alt=media)

#### Output table

<details>

<summary><code>statistical_tests</code> (first 10 of 13 rows)</summary>

| cell\_type  | mean\_fraction | dominant\_spot\_count | dominant\_fraction |
| ----------- | -------------- | --------------------- | ------------------ |
| malignant   | 0.2984         | 2146                  | 0.449              |
| muscle      | 0.2852         | 1867                  | 0.3906             |
| fibroblast  | 0.1453         | 422                   | 0.08828            |
| momac       | 0.07316        | 11                    | 0.002301           |
| t\_nk       | 0.04578        | 81                    | 0.01695            |
| plasma      | 0.0339         | 117                   | 0.02448            |
| endothelial | 0.02938        | 33                    | 0.006904           |
| b\_cell     | 0.0224         | 97                    | 0.02029            |
| mast        | 0.01566        | 1                     | 0.0002092          |
| granulocyte | 0.01554        | 1                     | 0.0002092          |

</details>

## Spatial colocalization (LIANA+ bivariate)

### Description

#### Analysis summary

Shows local spatial similarity between two features (gene-gene or gene-cell-type) on each Visium spot, computed by LIANA+'s bivariate analysis. High scores indicate neighbourhoods where the two features co-occur. Useful for spatial colocalization questions like 'are T cells and tumour cells colocalized here?'.

#### Computation

Computes LIANA+'s bivariate cosine similarity per spot between the two features — gene-gene (a second gene) or gene-vs-cell-type (a deconvolution fraction) — over the spot × gene expression matrix built on the Visium array grid, with a permutation test per spot; the long spot × gene input is then collapsed to one row per spot carrying its score. The stats table reports the mean association score across spots and the fraction of spots with a significant score (p < 0.05).

#### When to use

Use for spatial colocalization questions like 'are T cells and tumour cells colocalized here?' — gene-gene co-expression or gene-cell-type colocalization on a single slide.

#### Caveats

One slide per run: with several sample\_ids the analysis keeps the first (alphabetical) and reports a note — run it once per sample to see each slide.

LIANA+ — the ligand-receptor / bivariate spatial analysis toolkit. Documentation: <https://liana.readthedocs.io/en/stable/> — method paper: <https://www.nature.com/articles/s41556-024-01469-w>.

### Example questions

<details>

<summary><code>example questions</code></summary>

* Spatial slide display gene-gene colocalization
* Spatial slide display gene-cell type colocalization

</details>

### Input columns

<details>

<summary><code>input columns</code></summary>

| column                             | type        | required | description                                                                                                                                                           |
| ---------------------------------- | ----------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| spot\_id                           | any         | required | Spot identifier shown in the hover tooltip.                                                                                                                           |
| spatial\_1                         | numeric     | required | Raw (unscaled) x-coordinate of the spot.                                                                                                                              |
| spatial\_2                         | numeric     | required | Raw (unscaled) y-coordinate of the spot.                                                                                                                              |
| tissue\_hires\_scalef              | numeric     | required | Scale factor used to convert raw coordinates to image coordinates.                                                                                                    |
| spot\_diameter\_fullres            | numeric     | required | Spot diameter in full-resolution image pixels; used to size spot circles.                                                                                             |
| hires\_image\_path                 | any         | required | File-system or S3 path to the high-resolution H\&E image.                                                                                                             |
| alignment\_status                  | any         | required | Boolean — whether the H\&E image has been aligned with the spot grid.                                                                                                 |
| \*\_deconv\_cohort\_level\_2\_frac | numeric     | required | Cell type deconvolution fraction columns (one per cell type). Each column is named after a cell type with the suffix '\_deconv\_cohort\_level\_2\_frac' (for instanc… |
| gene\_name                         | any         | required | Gene name column. Include in the SELECT for mode='continuous' (gene expression) and mode='colocalization' (long-format, one row per spot × gene). Required for …      |
| count\_lognorm                     | numeric     | required | Log-normalised gene expression value. Used to build the per-spot × gene expression matrix for LIANA+. Required for mode='colocalization'.                             |
| array\_row                         | numeric     | required | Spot array row index from Space Ranger. Used together with array\_col to normalise spatial coordinates for LIANA. Required for mode='colocalization'.                 |
| array\_col                         | numeric     | required | Spot array column index from Space Ranger. Required for mode='colocalization'.                                                                                        |
| sample\_id                         | any         | required | Sample identifier. When multiple samples are present, the first (alphabetically) is selected and the others are discarded.                                            |
| patient\_id                        | categorical | required | Patient identifier required for population summary plots.                                                                                                             |

</details>

### Visualizations

* `spt_slide_display` How to read: One dot per Visium spot over the H\&E tissue image (when the slide is aligned), coloured by the local colocalization score between the two features — high scores mark neighbourhoods where they co-occur. Hovering a spot gives the score and its permutation-based p-value. The statistics report the mean association score and the fraction of spots with p < 0.05.

### Example analysis 1

#### Name — Spatial Co-expression of ERBB2 and TP53 — PAT\_B\_099UHY7A

#### Analysis parameters

<details>

<summary><code>analysis_name, analysis_params, viz_params</code></summary>

```json
{
  "analysis_name": "spt_slide_display_analysis",
  "analysis_params": {
    "mode": "colocalization",
    "gene_a": "ERBB2",
    "gene_b": "TP53"
  },
  "viz_params": {
    "plot_name": "spt_slide_display",
    "title": "Spatial Co-expression of ERBB2 and TP53 \u2014 PAT_B_099UHY7A",
    "value_label": "ERBB2\u2013TP53 co-expression"
  }
}
```

</details>

#### Visualization — `spt_slide_display`

![Spatial Co-expression of ERBB2 and TP53 — PAT\_B\_099UHY7A](https://1034377358-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTmCjUj6W0sltjW7q2vBp%2Fuploads%2Fgit-blob-064562d0cb08477980c7279896b6ff46b599e467%2Fspt_slide_display_analysis__colocalization__spt_slide_display.png?alt=media)

#### Output table

<details>

<summary><code>descriptive_stats</code> (1 rows)</summary>

| n    | n\_zeros | mean\_all | mean\_non\_zero | std\_non\_zero | p50\_non\_zero | max\_non\_zero |
| ---- | -------- | --------- | --------------- | -------------- | -------------- | -------------- |
| 4780 | 2261     | 0.3233    | 0.6135          | 0.2955         | 0.684          | 0.9835         |

</details>

<details>

<summary><code>statistical_tests</code> (1 rows)</summary>

| mean\_sp\_association | fraction\_significant |
| --------------------- | --------------------- |
| 0.3233                | 0.2117                |

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.owkin.com/explore-and-analyse-data/data-analysis/spatial/spatial-slide-display.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
