Chapter 6: Data Import into Seurat v5 & Spatial Normalization (LogNormalize vs SCTransform)
Tested Stacks:
GATK 4.6.1
Samtools 1.21
Nextflow 24.10
Seurat v5.1
Python 3.12
Prerequisites: Basic Linux CLI & Sequencing Formats
Day 3 • Data Import & Normalization
Track 21 • 10 Modular Chapters
Visium HD • Seurat v5 • Space Ranger
Chapter 6: Data Import into Seurat v5 & Spatial Normalization (LogNormalize vs SCTransform)
Loading Visium HD into Seurat v5 via Load10X_Spatial; selecting bin resolutions; inspecting assays, layers, and coordinate images; spatial normalization strategies: log-normalization vs regularized negative binomial SCTransform v2.
⏱️ Estimated Time: 55 min
💻 Environment: R 4.4+ • Seurat v5 • Space Ranger 3.0+
📁 Dataset: 10x Genomics Visium HD Colorectal Cancer (FFPE)
Key Learning Deliverables & Competencies
- Understand the multi-layer assay architecture of Seurat v5 for spatial datasets.
- Select the optimal bin resolution (2 µm vs 8 µm vs 16 µm) based on biological objectives.
- Compare Log-Normalization with regularized Negative Binomial regression (
SCTransform v2). - Mitigate depth-associated technical variation without erasing true biological density differences across tissue niches.
1. Spatial Normalization: LogNormalize vs SCTransform
Spatial transcriptomics datasets exhibit pronounced sequencing depth variation driven by physical differences in cellular density: a high-cellularity tumor nest may contain 4 cells per 8 µm bin, whereas an adjacent acellular matrix area contains only sparse interstitial fluid.
| Normalization Method | Mathematical Formulation | Pros | When to Apply |
|---|---|---|---|
| Standard Log-Normalization | $Y_{ij} = \log\left( rac{X_{ij}}{\sum_k X_{kj}} \cdot 10^4 + 1 ight)$ | Fast, lightweight memory footprint | Initial exploratory QC, low-memory workstation environments |
| SCTransform v2 (Regularized NB) | $X_{ij} \sim ext{NB}\left(\mu_{ij}, heta_i ight); \ \log(\mu_{ij}) = eta_{0,i} + eta_{1,i} \log(N_j)$ | Removes technical sequencing depth bias while preserving true biological variation | Recommended standard for Visium HD clustering and spatial domain discovery |
2. Executing SCTransform on Visium HD Data
# Execute SCTransform v2 on 8 µm Spatial Assay
seurat_obj <- SCTransform(
seurat_obj,
assay = "Spatial.008um",
vst.flavor = "v2",
variable.features.n = 3000,
vars.to.regress = c("percent.mt"),
verbose = TRUE
)
# Inspect Pearson Residuals and Variable Features
head(VariableFeatures(seurat_obj), 10)⚠️ Common Pitfalls & Troubleshooting in Spatial Genomics
- Out-Of-Memory (OOM) Crashes on 2 µm/8 µm Grids: Never run default
FindVariableFeatures()or dense Euclidean distance matrices across raw unsketched 2 µm arrays. Always leverage Seurat v5'sSketchData()with on-disk BPCells streaming. - Tissue Detachment & Optical Misalignment: Inspect fiducial edge coordinates in Loupe Browser before downstream R processing. If tissue folds or lifts during CytAssist transfer, manually flag and filter affected spatial barcodes.
- Over-Filtering Low-Cellularity Stromal Bins: Dense desmoplastic collagen or mucinous lakes naturally possess low transcript abundance. Setting an overly aggressive $nFeature$ threshold risks completely discarding critical acellular microenvironments.
⚠️
Common Pitfalls & Troubleshooting Checklist
- Java Heap Exhaustion (GATK / Picard): If processes terminate with
java.lang.OutOfMemoryError, set your environment variable explicitly:export _JAVA_OPTIONS="-Xmx16g -Djava.io.tmpdir=/tmp". - Index Timestamp Mismatch: If tools complain that a BAM index is missing or out of date, regenerate with
samtools index -@ 4 sample.bam. - Conda Channel Conflicts: Avoid ABI incompatibilities between bioconda and conda-forge by setting strict priority:
conda config --set channel_priority strict. - Chromosome Naming Contamination: Always verify whether reference FASTA headers use
chr1or1; divergent naming causes silent alignment drops.
Was this guide helpful to your research?
Help us maintain 100% accurate, peer-reviewed bioinformatics standards.