写了个简单的程序用于空间转录组数据的和整合,包含的合并方法有以下几种:
1.CCA(基于Seurat)
2.Harmony
3.FastMNN(基于batchelor)
4.scVI
5.基于 feature anchoring
要使用这个函数,您需要安装以下R包:Seurat、batchelor、reticulate,要是用scVI整合需要以下Python包:scanpy、anndata、scvi-tools。
使用方法非常简单,您只需要提供包含所有spaceranger输出数据的目录路径,函数将自动读取数据并将它们整合。使此函数正常工作,数据需要以下目录结构组织好spaceranger处理后的数据:
Result
├── Sample1
│ ├── outs
│ │ ├── analysis
│ │ ├── filtered_feature_bc_matrix
│ │ ├── raw_feature_bc_matrix
│ │ ├── spatial
│ │ ├── tissue_positions.csv
│ │ ├── scalefactors_json.json
│ │ ├── image.tif
│ │ ├── tissue_hires_image.png
│ │ ├── tissue_lowres_image.png
│ │ ├── aligned_fiducials.jpg
│ │ ├── detected_tissue_image.jpg
│ │ ├── spatial_enrichment.csv
├── Sample2
├── Sample3
│--- Sample4
│--- Sample5
│--- Sample6
│--- Sample7
│--- Sample8
│
按照这种方式组织您的数据,即将所有的spaceranger 结果放到一个result 目录下,并提供Result目录的路径,函数将自动读取数据并进行整合。
scVI:
要使用此方法,您需要为scVI设置一个工作的conda环境,请设置conda_env=您环境的路径,例如conda_env="/home/USER/miniconda3/envs/scvi", 此处USER是你的用户名
要在R终端加载此函数并运行:
加载代码:
source(url('https://raw.githubusercontent.com/Polligator/Integrated-Visium-Spatial-transcriptomics-data/main/integration.r'))
运行程序整合:
inetgrated_ST<-ST_Data_Integration(visium_dir = visium_dir, method = "SCVI", conda_env = "/miniconda3/envs/scvi",epochs = 100)
visium_dir是您目录的路径,其中应包含所有单个spaceranger数据文件夹。
整合结果可视化:
DimPlot(inetgrated_ST, reduction = "umap.integrated", group.by = c("integrated_clusters", "orig.ident"), pt.size = 3)
FastMNN:
此方法使用batchelor包整合ST数据:https://bioconductor.org/packages/release/bioc/html/batchelor.html,此方法有两个选项:FastMNN_all和FastNMF_variable。FastMNN_all使用所有样本中存在的所有公共基因来整合数据,FastNMF_variable仅使用由Seurat函数VariableFeatures()识别的可变特征来整合数据。
inetgrated_ST <- ST_Data_Integration(visium_dir = visium_dir, method = "FastNMF_variable") inetgrated_ST <- ST_Data_Integration(visium_dir = visium_dir, method = "FastNMF_all")
可视化:
DimPlot(inetgrated_ST, reduction = "umap.NMF", group.by = c("integrated_clusters", "orig.ident"), pt.size = 3)
CCA或Harmony
CCA
inetgrated_ST <- ST_Data_Integration(visium_dir = visium_dir, method = "CCA")
Harmony
inetgrated_ST <- ST_Data_Integration(visium_dir = visium_dir, method = "Harmony")
可视化:
DimPlot(inetgrated_ST, reduction = "umap.integrated", group.by = c("integrated_clusters", "orig.ident"), pt.size = 3)
FeatureAnchoring
此方法基于Seurat包,它使用特征锚定函数来整合数据,该函数将自动选择最大数量的可变特征来整合数据。基本上,它是Seurat函数FindIntegrationAnchors和IntegrateData包装后的结果,即下面的函数打包后的结果
int.anchors <- FindIntegrationAnchors(object.list = st.list, normalization.method = "SCT", verbose = FALSE, anchor.features = st.features)
integrated <- IntegrateData(anchorset = int.anchors, normalization.method = "SCT", verbose = FALSE)
要使用此FeatureAnchoring方法
inetgrated_ST <- ST_Data_Integration(visium_dir = visium_dir, method = "FeatureAnchoring")
结果可视化:
DimPlot(inetgrated_ST, reduction = "umap", group.by = c("ident", "orig.ident"))