Analysis of Slide-seqV2 data with singleCellHaystack"

knitr::opts_chunk$set(
    fig.align = "center",
    message = TRUE,
    warning = TRUE,
  collapse = TRUE,
  comment = "#>",
  fig.align = 'center'
)

library(Seurat)
library(SeuratData)
library(singleCellHaystack)

set.seed(1)

We can apply singleCellHaystack to spatial transcriptomics data as well. Here we use Seurat and the spatial transcriptomics data available in the SeuratData package. For this example we use Slide-seqV2 hippocampus data. For more details about analyzing spatial transcriptomics with Seurat take a look at their spatial transcriptomics vignette here.

Preparing input data

library(Seurat)
library(SeuratData)
library(singleCellHaystack)

We focus on the ssHippo slice.

if (!"ssHippo" %in% SeuratData::InstalledData()[["Dataset"]]) {
  SeuratData::InstallData("ssHippo")
}

ssHippo <- LoadData("ssHippo")
ssHippo

We filter genes with less 10 cells with non-zero counts. This reduces the computational time by eliminating very lowly expressed genes.

counts <- GetAssayData(ssHippo, slot = "counts")
sel.ok <- Matrix::rowSums(counts > 1) > 10

ssHippo <- ssHippo[sel.ok, ]
ssHippo

We can plot the total number of counts per bead, superimposed on the image of the brain.

SpatialFeaturePlot(ssHippo, features = "nCount_Spatial")

We normalize the data we use log normalization.

ssHippo <- NormalizeData(ssHippo)

Running haystack on the spatial coordinates

The two inputs to singleCellHaystack are 1) the gene expression data and 2) the spatial coordinates of the Slide-seq V2 pucks. Please note that we are not using an embedding as input space here, but the actual 2D coordinates of spots inside the tissue. Since this dataset contains about 53k spots and 11k genes, a run of singleCellHaystack can take a few minutes.

dat.expression <- GetAssayData(ssHippo, slot = "data")
dat.coord <- GetTissueCoordinates(ssHippo)

set.seed(123)
res <- haystack(dat.coord[,1:2], dat.expression)

We can check the top genes with spatial biased distribution.

show_result_haystack(res.haystack = res, n = 10)

And we can visualize the expression of the 6 top-scoring genes in the spatial plot.

top6 <- show_result_haystack(res.haystack = res, n = 6)
SpatialFeaturePlot(ssHippo, features = rownames(top6))


Try the singleCellHaystack package in your browser

Any scripts or data that you put into this service are public.

singleCellHaystack documentation built on Dec. 28, 2022, 1:29 a.m.