作者,Evil Genius
今天我们分享一个简单的内容,Seurat V5 整合空间的visium数据和HD数据
脚本就不封装了,大家自己封装吧。
首先是visium,大家还记得如何判断空转的整合效果吧,忘记的赶紧复习一下。
未封装的脚本
suppressMessages({
library(Seurat)
library(argparse)
library(dplyr)
library(ggplot2)
library(Banksy)
library(SeuratWrappers)
library(harmony)
})
HC_1L = Load10X_Spatial('/home/samples/DB/Spatial/visium_data/HC_1L',slice = "HC_1L")
HCC_1L = Load10X_Spatial('/home/samples/DB/Spatial/visium_data/HCC_1L',slice = "HCC_1L")
HCC_1N = Load10X_Spatial('/home/samples/DB/Spatial/visium_data/HCC_1N',slice = "HCC_1N")
HCC_1T = Load10X_Spatial('/home/samples/DB/Spatial/visium_data/HCC_1T',slice = "HCC_1T")
sceList = list(HC_1L,HCC_1L,HCC_1N,HCC_1T)
sceMerged <- merge(x = sceList[[1]], y = sceList[-1], add.cell.ids = c("HC_1L","HCC_1L","HCC_1N","HCC_1T"))
DefaultAssay(sceMerged) = 'Spatial'
sceMerged <- NormalizeData(sceMerged)
sceMerged <- FindVariableFeatures(sceMerged)
sceMerged <- ScaleData(sceMerged)
sceMerged <- RunPCA(sceMerged)
obj <- IntegrateLayers(object = sceMerged, method = HarmonyIntegration,orig.reduction = "pca", new.reduction = "harmony",verbose = FALSE)
sce <- FindNeighbors(obj, reduction = "harmony",dims = 1:20)
sce <- FindClusters(sce,resolution = 0.5)
sce <- RunUMAP(sce, reduction = "harmony",dims = 1:20)
dual.plot <- function(fig, file.prefix, w=7, h=7, res=75){
pdf(paste(file.prefix,".pdf",sep=""), width = w, height = h)
print(fig)
dev.off()
png(paste(file.prefix,".png",sep=""), width = w*res, height = h*res, res = res, type="cairo-png")
print(fig)
dev.off()
}
low_res = 70
mid_res = 150
high_res = 300
mid_res = 300
p <- SpatialDimPlot(sce, group.by = "seurat_clusters", label = T, repel = T, label.size = 4,pt.size.factor = 2.5)
outdir = '/home/samples/DB/Spatial/visium_data'
prefix = 'combined'
dual.plot(p, file.path(outdir, paste(prefix,'.Spatial.cluster',sep="")), w=20, h=6, res=mid_res)
那么对于HD呢?因为涉及到banksy的用法(识别空间域),所以复杂一点,需要大算力服务器
其中HD的数据质量大家要自己控制一下,8um的基因中位数过少是没办法进行下游分析的。
未封装的脚本