knitr::opts_chunk$set(echo = TRUE)

iSpatail Tutorial

Load package

Install iSpatial package from Github. iSpatial is based on Seurat, you need install Seurat first .

# install iSpatial package
# devtools::install_github("Czh3/iSpatial")

# load
library(iSpatial)

library(Seurat)
library(ggplot2)

Load data

Load scRNA-seq and STARmap of Mouse Cortex. scRNA-seq is downlaod from Allen Brain STARmap is from Xiao et al.

# scRNA-seq data
# scRNA_VISp can be download from: https://www.dropbox.com/s/kej7wj2k7hvy5o2/Cortex_scRNA.RDS?dl=0
# use "readRDS" to load

# STARmap data
# starmap can be download from: https://www.dropbox.com/s/yjcp49djv1zbqo6/Cortex_starmap.RDS?dl=0

Normalize data

The data need be log normalized.

# scRNA-seq data
scRNA_VISp = NormalizeData(scRNA_VISp, verbose = FALSE)

# merFISH data
starmap = NormalizeData(starmap, verbose = FALSE)

infer transcriptome-wide spatial expression

# infer spatial transcriptome
starmap_iSpatial = iSpatial::infer(starmap, scRNA_VISp)

enhance expression

# cell type makers 
p1 = FeaturePlot(starmap, features = c("Slc17a7", "Gad1", "Plp1", "Aqp4", "Cldn5"), pt.size = 1, ncol=5)  & NoAxes() &
  theme(legend.position = "none") &
  scale_color_gradientn(colours = c(rainbow(10)[5:10], "red"))

starmap_iSpatial[["umap"]] = starmap[["umap"]]
p2 = FeaturePlot(starmap_iSpatial, features = c("Slc17a7", "Gad1", "Plp1", "Aqp4", "Cldn5"), pt.size = 1, ncol=5)  & NoAxes() &
  theme(legend.position = "none") &
  scale_color_gradientn(colours = c(rainbow(10)[5:10], "red"))
p1 / p2


# layer makers
g = c( "Cux2", "Nov", "Rorb", "Rspo1", "Fezf2", "Foxp2", "Ctgf", "Plp1")

# raw
SpatialFeaturePlot(starmap, features = g, stroke = 0, 
                        pt.size.factor = 4, 
                        crop = T, slot = "data",
                        ncol = 4) &
    theme_void() & theme(legend.position = "none") & coord_flip() &
    scale_fill_gradientn(colours = c(rainbow(10)[5:10], "red", "red2")) 

# inferred
SpatialFeaturePlot(starmap_iSpatial, features = g, stroke = 0, 
                        pt.size.factor = 4, 
                        crop = T, slot = "data",
                        ncol = 4) &
    theme_void() & theme(legend.position = "none") & coord_flip() &
    scale_fill_gradientn(colours = c(rainbow(10)[5:10], "red", "red2")) 

infer nontargeted gene

# infer
g = c("Pvrl3", "Evc2", "Tshz1", "Adra1d", "Serinc2", "Col5a1", "Mag", "Ugt8a")
SpatialFeaturePlot(starmap_iSpatial, features = g, stroke = 0, 
                        pt.size.factor = 4, 
                        crop = T, slot = "data",
                        ncol = 4) &
    theme(legend.position = "none") & coord_flip() &
    scale_fill_gradientn(colours = c(rainbow(10)[5:10], "red", "red2")) 
sessionInfo()


Czh3/iSpatial documentation built on Sept. 15, 2022, 10:32 p.m.