Skip to contents

This tutorial shows how to apply SecAct to Visium HD spatial transcriptomics data. SpaCET reads and stores the Space Ranger output, and SecAct infers secreted protein activity for each retained spatial unit.

The example uses the public Visium HD human brain cancer dataset processed with Space Ranger 4.1.0. The same workflow can be applied to other Visium HD samples.

Choose the analysis unit

Space Ranger provides binned outputs at several resolutions and segmented outputs generated from the H&E image. Select the representation that matches the intended analysis:

Representation Analysis unit Recommended SecAct use
square_002um/ 2 µm bin Usually too sparse for whole-slide SecAct analysis
square_008um/ 8 µm bin High-resolution bin-level activity and (spatial patterns or cell-cell communication)
square_016um/ 16 µm bin Bin-level activity and spatial patterns
segmented_outputs/ Segmented cell Cell-level activity and cell-cell communication

The 16 µm representation in Workflow 1 corresponds most closely to the multicellular ST tutorial. The segmented cells in Workflow 2 correspond to the single-cell-resolution ST tutorial. Workflow 3 uses 8 µm bins, which provide higher spatial resolution.

Prepare the data

Load SecAct and SpaCET, then download data:

library(SecAct)
library(SpaCET)

# Download "Binned outputs" and "Segmented outputs" from:
# https://www.10xgenomics.com/datasets/visium-hd-cytassist-6p5mm-human-brain-cancer
# Extract both archives into "~/Downloads/VisiumHD_BrainCancer/".

Workflow 1: 16 µm bins

The 16 µm representation aggregates more transcripts per spatial unit and may improve sensitivity to sparse signals. Each bin can contain material from multiple cells, so this representation is best suited to regional activity, signaling pattern, and signaling velocity analyses.

SpaCET_obj <- create.SpaCET.object.10X(
  dataPath = "~/Downloads/VisiumHD_BrainCancer/binned_outputs/square_016um",
  platform = "VisiumHD",
  organism = "human"
)

# Example only. Select this threshold from the observed distribution.
SpaCET_obj <- SpaCET.quality.control(
  SpaCET_obj,
  min.genes = 10
)

SpaCET.visualize.spatialFeature(
  SpaCET_obj,
  spatialType = "QualityControl",
  spatialFeatures = c("UMI", "Gene"),
  imageBg = TRUE,
  pointSize = 0.1
)

Continue with the multicellular ST tutorial for signaling pattern and bin-level velocity analyses.

Workflow 2: segmented cells

Use segmented outputs for cell-level activity inference and cell-cell communication.

Load and inspect the data

SpaCET_obj <- create.SpaCET.object.10X(
  dataPath = "~/Downloads/VisiumHD_BrainCancer/segmented_outputs",
  platform = "VisiumHD",
  organism = "human"
)

SpaCET_obj <- SpaCET.quality.control(
  SpaCET_obj,
  min.genes = 10
)

SpaCET.visualize.spatialFeature(
  SpaCET_obj,
  spatialType = "QualityControl",
  spatialFeatures = c("UMI", "Gene"),
  imageBg = TRUE,
  pointSize = 0.1
)

Add cell-type annotations

Cell-type annotations are required for cell-cell communication analysis and must be stored in SpaCET_obj@input$metaData. They can be generated by following the SpaCET high-resolution ST workflow or imported from a custom annotation or the Space Ranger cell-type annotation output.

For example, import the Space Ranger 10x Cloud annotations as follows:

cell_types <- read.csv(
  "~/Downloads/VisiumHD_BrainCancer/segmented_outputs/cell_types/10x_Cloud/cell_types.csv",
  stringsAsFactors = FALSE,
  row.names = 1,
  check.names = FALSE
)

cell_ids <- rownames(SpaCET_obj@input$metaData)

SpaCET_obj@input$metaData[, "cellType"] <- cell_types[cell_ids, "coarse_cell_type"]
  

See the single-cell-resolution ST tutorial for communication heatmaps, circle plots, dot plots, and signaling velocity.

Workflow 3: 8 µm bins

SpaCET_obj <- create.SpaCET.object.10X(
  dataPath = "~/Downloads/VisiumHD_BrainCancer/binned_outputs/square_008um",
  platform = "VisiumHD",
  organism = "human"
)

SpaCET_obj <- SpaCET.quality.control(
  SpaCET_obj,
  min.genes = 10
)

SpaCET.visualize.spatialFeature(
  SpaCET_obj,
  spatialType = "QualityControl",
  spatialFeatures = c("UMI", "Gene"),
  imageBg = TRUE,
  pointSize = 0.1
)

Follow Workflow 1 if you treat each 8 µm bin as a spatial unit. Follow Workflow 2 if you treat each 8 µm bin as a single cell.