> 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/analysis-methods.md).

# Analysis Methods

## A) Demultiplexing Strategy

Each read contains a spatial barcode (SBC) that encodes the location on the substrate where the read originated. The pipeline uses the SBC to spatially locate each read on the substrate, then assigns the read to a sample based on the tissue masks from the ISIT OME-TIFFs. Reads whose spatial location falls outside of any tissue mask are not assigned to a sample.

## B) UMI Processing

To avoid overcounting UMIs based on sequence errors, UMI error correction is performed among all reads with the same cell-barcode mapping to the same gene. UMI sequences that are likely errors of another UMI are not counted. After correction, reads that share the same SBC, UMI, and gene assignment are collapsed into a single molecule so that downstream counts reflect unique transcripts rather than read counts. The number of molecules after collapsing is reported as `n_deduplicated_reads`, and the fraction of reads removed as duplicates is reported as `sequencing_saturation` (see [Alignment Stats](/dragen-stratamap/dragen-spatial-transcriptome/outputs/intermediates-folder.md#alignment-stats-csv)).

## C) Read Trimming

DRAGEN Spatial Transcriptome performs a single combined trimming step on the cDNA payload read. It trims:

* **Adapter sequences**
* **Low-quality bases** (Q-score < 20)
* **polyA** tails
* **polyG** tails

Reads shorter than 22 nt after trimming are discarded. Per-category percentages are reported in the [Trimming Stats](/dragen-stratamap/dragen-spatial-transcriptome/outputs/intermediates-folder.md#trimming-stats) file.

## D) Tissue Mask Filtering

When a registered OME-TIFF is provided, the pipeline uses its tissue mask to restrict analysis to SBCs that fall within the tissue region. The unfiltered matrix (all SBCs on the substrate) is preserved for reference, but all downstream binning, clustering, and reporting use the tissue-mask-filtered matrix.

## E) Sample Splitting and Subsamples

Because tissue samples can vary widely in size — from a few square millimeters up to the full capacity of the flow cell — DRAGEN Spatial Transcriptome automatically splits very large samples into smaller **subsamples** for alignment, then merges the results back together. This keeps memory and runtime bounded for any size of input and lets subsamples be aligned in parallel.

#### 1) How splitting works

1. During sample prep, the pipeline computes how many SBCs each sample covers based on its tissue mask.
2. If a sample has more SBCs than the per-subsample limit (configured by `SBCs-per-subsample`), its SBCs are partitioned into approximately-equal groups. Each group becomes a subsample named `{Sample_ID}_x001`, `{Sample_ID}_x002`, and so on.
3. Samples that fall under the limit are not split and have no `_x00#` suffix.

All subsamples of a sample share the same `Sample_ID` and are reassembled at the end of alignment.

#### 2) What you see in the alignments folder

For a small sample that was not split, the alignments folder contains a single per-sample folder:

```
01_alignments/
└── SampleA/
    ├── SampleA_alignment_table_user_friendly.csv
    ├── SampleA.spatial.multimap_ties.tsv
    ├── Alignment_stats.csv
    ├── Fastqc_stats.csv
    ├── Quant_stats.csv
    └── Trimming_stats.csv
```

For a larger sample that was split into three subsamples, you'll see the parent folder plus one folder per subsample:

```
01_alignments/
├── SampleB/                    <-- merged, sample-level results
│   ├── SampleB_alignment_table_user_friendly.csv
│   ├── SampleB.spatial.multimap_ties.tsv
│   ├── Alignment_stats.csv
│   ├── Fastqc_stats.csv
│   ├── Quant_stats.csv
│   └── Trimming_stats.csv
├── SampleB_x001/               <-- per-subsample DRAGEN outputs
│   ├── SampleB_x001.mapping_metrics.csv
│   ├── SampleB_x001.quant_metrics.csv
│   ├── SampleB_x001.trimmer_metrics.csv
│   └── ...
├── SampleB_x002/
│   └── ...
└── SampleB_x003/
    └── ...
```

* The `{Sample_ID}/` folder contains the merged, sample-level results that you should use for analysis.
* The `{Sample_ID}_x00#/` folders contain the raw per-subsample DRAGEN outputs and are preserved for debugging and traceability. You generally do not need to interact with them directly.

#### 3) Merging

After alignment, per-subsample count matrices and metrics are merged back into a single per-sample matrix and a single set of per-sample stats. All downstream steps (tissue mask filtering, binning, clustering, reporting) operate on the merged, sample-level matrix, so downstream outputs are always reported per-sample regardless of whether splitting occurred.

## F) Read Alignment

#### 1) Exonic and Intronic Alignments

By default, only exonic alignments are counted. Intronic alignments can be enabled through the UI. Exonic alignments have at least 50% overlap with annotated exons in the GTF file. Intronic reads require 20% overlap with an annotated gene but do not meet the exonic alignment criteria.

#### 2) Multimapping

By default, the pipeline attempts to assign reads that exactly match multiple locations in the genome. Hits are rank-ordered, and each read is assigned to the top hit.

**Rank Order:**

1. Protein-coding gene
2. Non-protein coding gene
3. Ambiguous hit
4. Wrong strand
5. No feature

If a read maps equally well to two different protein-coding genes, the algorithm picks the first one listed in the GTF. These molecules are tracked and reported in the `[SampleID]_multimap_ties.tsv` and `[SampleID]_multimap_ties_summary.csv` files in the `intermediate_results/alignment` folder.

## G) Cell Segmentation

**What it does:** Identifies individual nuclei masks from H\&E-stained tissue images and expands the nuclei borders to estimate cell boundaries.

**How it works:** Uses a StarDist-based deep learning model trained from scratch on extensive, high-quality nuclei annotations from H\&E images. For each image, the model performs instance segmentation and outputs nuclei masks, where positive integers (`1`, `2`, `3`, ...) denote individual nuclei instances (cell IDs) at `1 µm/px` resolution. After nuclei segmentation, each nucleus mask is expanded outward by up to the user-defined distance (`expansion_um`, default 5 µm) to estimate the cell border. The expansion is capped if it runs into a neighboring cell's expansion: the boundary between two adjacent cells is placed at the midpoint between them, so a nucleus never expands further than half the distance to its nearest neighbor. On sides with no neighbor within the expansion distance, the boundary reaches the full `expansion_um` (illustration of cell border expansion below)

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

## H) Cell and Grid Binning

Both methods consolidate individual sequencing barcodes (SBCs) into larger analytical units. This reduces data complexity while preserving spatial information.

#### 1) Grid Binning

**What it does:** Grid binning divides the tissue sample into a regular, rectangular grid of uniform bins, then aggregates all transcripts within each bin.

**How it works:**

* You specify a bin size in micrometers, such as `10 µm` or `20 µm`.
* The pipeline creates a uniform grid overlay across the entire tissue sample.
* Each sequencing barcode is assigned to the grid bin containing its spatial coordinates.
* All transcripts from barcodes in the same bin are summed together.
* Each bin is identified by its center coordinates, such as `bin10:150:200` for a `10 µm` bin centered at `x=150, y=200`.

<figure><img src="/files/wyx9df85LErLRqNmW3gJ" alt="" width="458"><figcaption></figcaption></figure>

#### 2) Cell Binning

**What it does:** Cell binning groups transcripts by parent cell. It uses a cell segmentation mask to identify individual cells and aggregate their transcripts.

**How it works:**

* It uses the cell segmentation image from the cell segmentation module, which is a labeled mask where each pixel contains a cell ID.
* The pipeline identifies the centroid of each cell.
* Each sequencing barcode is mapped to the cell containing its coordinates.
* All transcripts from barcodes within the same cell are summed together.
* Each cell is identified by its label and centroid coordinates, such as `cell42:150:200` for cell `42` centered at `x=150, y=200`.

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

## I) Sequencing Saturation Curves

Saturation curves estimate how many additional molecules or genes would be recovered at higher sequencing depths. They are produced for both cell-binned and grid-binned data.

**How it works:**

* The pipeline subsamples the aligned reads at a range of depths (expressed as fractions of the reads actually sequenced).
* At each depth, the reads are re-deduplicated using the same SBC/UMI/gene collapsing rule used in the main analysis. The number of unique molecules and unique genes per bin or cell is re-computed.
* A curve is fit to these subsampled points to extrapolate how recovery scales with depth.

Saturation is reported as `1 - (unique molecules / aligned reads)`. A value near `0` means nearly every additional read yields a new molecule (under-sequenced); a value near `1` means the library is saturated and additional reads will mostly be duplicates.

Output files and plot variants are described in [02 Sequencing Saturation](/dragen-stratamap/dragen-spatial-transcriptome/outputs/intermediates-folder.md#id-02-sequencing-saturation).

## J) Tertiary Analysis

After binning, each bin type (cell, grid, and optionally nuclei) is taken through the same tertiary analysis pipeline. Parameter names and defaults for each step are listed in the [analysis config](/dragen-stratamap/dragen-spatial-transcriptome/analysis-inputs/analysis-config-file-optional.md).

#### 1) Cell and Bin Filtering

Low-quality cells and bins are removed before clustering. A cell or bin is dropped if **any** of the following apply:

* Its percent mitochondrial transcripts is above `mt_threshold`.
* Its total unique-molecule count is below `umi_count_threshold` **and** below the `umi_percentile_threshold` of the sample. Whichever threshold is stricter (higher) is applied.

Filtering is performed independently for each bin type, so a cell that is dropped from the cell-binned analysis does not affect the grid-binned analysis. Filtered-out cells are retained in the raw AnnData object but are not shown in the clustered output and appear as the "NA cluster" in downstream visualizations.

#### 2) Normalization

Each remaining cell or bin is scaled so that its total UMI count equals `normalize_target_sum` (by default, the median total count of the sample prior to normalization). The normalized counts are then `log1p`-transformed. This makes UMI distributions comparable between cells of different library sizes.

#### 3) Feature Selection

To reduce noise and computation, only the top `top_n_genes` most variable genes are retained for dimensionality reduction. Variability is measured on the log-normalized matrix using the standard Scanpy highly-variable-genes method.

#### 4) Dimensionality Reduction

* **PCA** is run on the filtered, normalized, highly-variable gene matrix using `n_pcs` principal components.
* A nearest-neighbor graph is built in PCA space using `n_neighbors` neighbors.
* **UMAP** is computed on the neighbor graph using `umap_min_dist` as the minimum embedding distance. Smaller values preserve local structure; larger values emphasize global relationships.

#### 5) Clustering

Cells and bins are clustered using the **Leiden** algorithm on the nearest-neighbor graph, controlled by `leiden_resolution`. Higher resolution values produce more, smaller clusters; lower values produce fewer, larger clusters. Cluster labels are written to the `clustered.h5ad` output and used to color the UMAP and spatial-cluster plots described in [05 Clustering](/dragen-stratamap/dragen-spatial-transcriptome/outputs/intermediates-folder.md#id-05-clustering).

#### 6) Reproducibility

UMAP and Leiden are stochastic, but the pipeline uses fixed random seeds so that a rerun on the same inputs with the same parameters produces the same embedding and cluster labels.


---

# 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/analysis-methods.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.
