> For the complete documentation index, see [llms.txt](https://help.connected.illumina.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.connected.illumina.com/dragen-stratamap/dragen-spatial-transcriptome/outputs/results-folder/global-and-local-coordinates.md).

# Global and Local Coordinates

### Overview

When working with spatial transcriptomics data, it is crucial to understand the difference between **local** and **global** coordinate systems:

* **Local Coordinates**: Coordinates relative to an individual sample/region (0,0 starts at the sample's top-left corner).
* **Global Coordinates**: Coordinates relative to the entire substrate (flow cell) that contains all samples.

### Coordinate System Summary

<table><thead><tr><th width="418">Data Type</th><th>Coordinate System</th></tr></thead><tbody><tr><td>Registered images (OME-TIFF)</td><td><strong>Local</strong> (sample-specific)</td></tr><tr><td>Cell/nuclei masks (TIFF)</td><td><strong>Local</strong> (sample-specific)</td></tr><tr><td>Transcript data (barcodes.tsv.gz)</td><td><strong>Global</strong> (substrate-wide)</td></tr><tr><td>Cell contour coordinates (CSV)</td><td><strong>Global</strong> (substrate-wide)</td></tr></tbody></table>

<figure><img src="/files/YGhn7iY6IuBhIzIC7JLb" alt=""><figcaption></figcaption></figure>

### Why Two Coordinate Systems?

The substrate (flow cell) can contain multiple samples, each positioned at different locations. Global coordinates allow all transcripts from all samples to be referenced in a single coordinate space, while local coordinates make it easier to work with individual sample images and masks.

***

### 1. Transcript Coordinates (Global Space)

Transcript coordinates are always in **global substrate coordinate space**.

#### Raw Transcripts/Grid-Binned Data/Cell-Binned Data (`barcodes.tsv.gz`)

<pre><code>Format: 
sbc:Y:X (in micrometers)
bin10:Y:X (in micrometers)
cell&#x3C;ID>:Y:X (in micrometers)

<strong>Example: cell100003:6441:3653
</strong>  - cell100003 = cell ID (matches cell mask files)
  - 6441 = Y-coordinate of cell centroid (µm)
  - 3653 = X-coordinate of cell centroid (µm)
</code></pre>

### 2. Image Coordinates (Local Space)

Registered OME-TIFF files contain multiple image planes in **local sample coordinate space**:

1. **Original-resolution H\&E image** (1 pixel = variable µm, depends on microscope)
2. **1 µm/pixel H\&E image** (1 pixel = 1 µm)
3. **Tissue mask** (1 pixel = 1 µm)

#### Global Positioning Information

Each sample has a global position on the substrate stored as:

* **Global\_top**: Y-coordinate offset (µm)
* **Global\_left**: X-coordinate offset (µm)

These values define where the sample's local (0,0) is positioned in global substrate space.

***

### 3. Cell/Nuclei Mask Coordinates

Cell and nuclei mask files come in two formats:

#### TIFF Masks (Local Space)

* Format: TIFF with pixel intensities = cell IDs
* Resolution: 1 µm/pixel
* Coordinate system: **Local** to the sample

#### Contour CSV Files (Global Space)

* `*nuclei_contour_coords.csv`
* `*Expanded_5um_cell_contour_coords.csv`
* Format: 3 columns (cell-ID, X-coordinate µm, Y-coordinate µm)
* Coordinate system: **Global** substrate space

***

### How to Extract Global Coordinates

#### Method 1: From CSV Stats File (Recommended)

The easiest way to get global coordinates is from the stats CSV file.

**File location:**

```
intermediate_results/summary/[RunName]_all_stats.csv
or
intermediate_results/stats/sample_prep_stats_sample.csv
```

The columns of interest are Global\_top and Global\_left.

#### Method 2: From OME-TIFF Metadata

Global coordinates are also embedded in the OME-TIFF metadata:

**Python code using tifffile:**

```python
import tifffile
from ome_types import from_xml

# Read OME-TIFF
ome_tiff_path = "results/15WF_Rep2/15WF_Rep2_registered.ome.tiff"

with tifffile.TiffFile(ome_tiff_path) as tif:
    ome_xml = tif.ome_metadata
    ome = from_xml(ome_xml)
    
    # Get first image metadata
    if ome.images:
        image = ome.images[0]
        if image.pixels and image.pixels.planes:
            # Get position from first plane
            plane = image.pixels.planes[0]
            global_left = plane.position_x  # X-offset (µm)
            global_top = plane.position_y   # Y-offset (µm)
            
            print(f"Sample: {image.name}")
            print(f"Global Top (Y-offset): {global_top} µm")
            print(f"Global Left (X-offset): {global_left} µm")
```

**Installation requirements:**

```bash
pip install tifffile ome-types
```


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.connected.illumina.com/dragen-stratamap/dragen-spatial-transcriptome/outputs/results-folder/global-and-local-coordinates.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
