Day 02A - Liver spatial transcriptomics analysis

Author

Saket Choudhary for QSCB 2025

Published

December 18, 2025

1 Dataset

Take from http://livercellatlas.org/ human single-nuclei and spatial datasets

2 Look at spatial data

Code
suppressPackageStartupMessages({
  library(tidyverse)
  library(Seurat)
})

object.names <- c("H35_1", "H35_2", "H36", "H37", "H38")

spatial.rna.objects <- list()
for (object.name in object.names) {
  object <- readRDS(paste0("/NAS/qscb2025/Guilliams_2022_livercellatlas/data/liver/spatial/", object.name, ".rds"))
  object2 <- CreateSeuratObject(
    counts = LayerData(object, assay = "Spatial", layer = "counts"),
    meta.data = object@meta.data
  )
  object2 <- NormalizeData(object2)
  spatial.rna.objects[[object.name]] <- object2
}
Normalizing layer: counts
Normalizing layer: counts
Normalizing layer: counts
Normalizing layer: counts
Normalizing layer: counts
Code
spatial.rna.merged <- merge(spatial.rna.objects[[1]], spatial.rna.objects[2:length(spatial.rna.objects)])
spatial.rna.merged <- SCTransform(spatial.rna.merged, verbose = FALSE)
spatial.rna.merged <- RunPCA(spatial.rna.merged, verbose = FALSE)
spatial.rna.merged <- FindNeighbors(spatial.rna.merged, dims = 1:30, verbose = FALSE)
spatial.rna.merged <- RunUMAP(spatial.rna.merged, dims = 1:30, verbose = FALSE)
Warning: The default method for RunUMAP has changed from calling Python UMAP via reticulate to the R-native UWOT using the cosine metric
To use Python UMAP via reticulate, set umap.method to 'umap-learn' and metric to 'correlation'
This message will be shown once per session

3 Exercise 1: Does this require integration?

If so show implement it

Code
DimPlot(spatial.rna.merged, group.by = "sample_name")

Code
# YOUR CODE HERE

4 Exercise 2: Does this require integration?

If so show implement it

Code
rna.merged <- readRDS("/NAS/qscb2025/Guilliams_2022_livercellatlas/data/liver/rna/GSE192740_rna.rds")

# check metadata
head(rna.merged)
Code
# Perform steps
# YOUR CODE HERE
Code
DimPlot(rna.merged, group.by = "sample")

Code
# YOUR CODE HERE

5 Exercise 3: Subset H37 patient and predict the celltypes in H38 patient

Code
# YOUR CODE HERE

6 Exercise 4: You were given the objects pre-processed (to some extent)

Go to http://livercellatlas.org/ or search GSE192740 to download the raw counts file and metadata and create the seurat objects

7 Exercise 5: Integrate the mouse and the human datasets