单细胞空间转录组分析

2020-04-01 16:05:45 浏览数 (4)

代码语言:javascript复制
#Installation
devtools::install_github("satijalab/seurat", ref = "spatial")

加载需要的R包

代码语言:javascript复制
library(Seurat)
library(SeuratData)
library(ggplot2)
library(cowplot)
library(dplyr)

安装测试的数据集

代码语言:javascript复制
InstallData("stxBrain")
brain <- LoadData("stxBrain", type = "anterior1")

计算一下所有细胞的counts分布情况,发现counts差距比较大,因此需要normalize

代码语言:javascript复制
plot1 <- VlnPlot(brain, features = "nCount_Spatial", pt.size = 0.1)   NoLegend()
plot2 <- SpatialFeaturePlot(brain, features = "nCount_Spatial")   theme(legend.position = "right")
plot_grid(plot1, plot2)

image.png

常用的LogNormalize会损失不同的位置本身存在的counts差距的信息,因此选用SCTransform

代码语言:javascript复制
brain <- SCTransform(brain, assay = "Spatial", verbose = FALSE)

SpatialFeaturePlot查看基因的位置表达信息

代码语言:javascript复制
SpatialFeaturePlot(brain, features = c("Hpca", "Ttr"))

image.png

调整点的大小和透明度

代码语言:javascript复制
p1 <- SpatialFeaturePlot(brain, features = "Ttr", pt.size.factor = 1)
p2 <- SpatialFeaturePlot(brain, features = "Ttr", alpha = c(0.1, 1))
plot_grid(p1, p2)

image.png

下面就是跟单细胞一样的流程:降维聚类

代码语言:javascript复制
brain <- RunPCA(brain, assay = "SCT", verbose = FALSE)
brain <- FindNeighbors(brain, reduction = "pca", dims = 1:30)
brain <- FindClusters(brain, verbose = FALSE)
brain <- RunUMAP(brain, reduction = "pca", dims = 1:30)

可视化

代码语言:javascript复制
p1 <- DimPlot(brain, reduction = "umap", label = TRUE)
p2 <- SpatialDimPlot(brain, label = TRUE, label.size = 3)
plot_grid(p1, p2)

image.png

交互式展示

代码语言:javascript复制
# move your mouse
SpatialDimPlot(brain, do.hover = TRUE)

image.png

用cells.highlight展示感兴趣的细胞的位置

代码语言:javascript复制
SpatialDimPlot(brain, cells.highlight = CellsByIdentities(object = brain, idents = c(1, 2, 5, 3, 4, 8)), facet.highlight = TRUE, ncol = 3)

image.png

(未完待续) 原文选自:https://satijalab.org/seurat/v3.1/spatial_vignette.html

0 人点赞