寫了個(gè)簡(jiǎn)單的程序用于空間轉(zhuǎn)錄組數(shù)據(jù)的和整合勿锅,包含的合并方法有以下幾種:
1.CCA(基于Seurat)
2.Harmony
3.FastMNN(基于batchelor)
4.scVI
5.基于 feature anchoring
要使用這個(gè)函數(shù)闸婴,您需要安裝以下R包:Seurat个绍、batchelor、reticulate世囊,要是用scVI整合需要以下Python包:scanpy、anndata、scvi-tools萍丐。
使用方法非常簡(jiǎn)單,您只需要提供包含所有spaceranger輸出數(shù)據(jù)的目錄路徑放典,函數(shù)將自動(dòng)讀取數(shù)據(jù)并將它們整合逝变。使此函數(shù)正常工作基茵,數(shù)據(jù)需要以下目錄結(jié)構(gòu)組織好spaceranger處理后的數(shù)據(jù):
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
│
按照這種方式組織您的數(shù)據(jù),即將所有的spaceranger 結(jié)果放到一個(gè)result 目錄下壳影,并提供Result目錄的路徑拱层,函數(shù)將自動(dòng)讀取數(shù)據(jù)并進(jìn)行整合。
scVI:
要使用此方法宴咧,您需要為scVI設(shè)置一個(gè)工作的conda環(huán)境根灯,請(qǐng)?jiān)O(shè)置conda_env=您環(huán)境的路徑,例如conda_env="/home/USER/miniconda3/envs/scvi"掺栅, 此處USER是你的用戶名
要在R終端加載此函數(shù)并運(yùn)行:
加載代碼:
source(url('https://raw.githubusercontent.com/Polligator/Integrated-Visium-Spatial-transcriptomics-data/main/integration.r'))
運(yùn)行程序整合:
inetgrated_ST<-ST_Data_Integration(visium_dir = visium_dir, method = "SCVI", conda_env = "/miniconda3/envs/scvi",epochs = 100)
visium_dir是您目錄的路徑烙肺,其中應(yīng)包含所有單個(gè)spaceranger數(shù)據(jù)文件夾。
整合結(jié)果可視化:
DimPlot(inetgrated_ST, reduction = "umap.integrated", group.by = c("integrated_clusters", "orig.ident"), pt.size = 3)
FastMNN:
此方法使用batchelor包整合ST數(shù)據(jù):https://bioconductor.org/packages/release/bioc/html/batchelor.html氧卧,此方法有兩個(gè)選項(xiàng):FastMNN_all和FastNMF_variable桃笙。FastMNN_all使用所有樣本中存在的所有公共基因來整合數(shù)據(jù),F(xiàn)astNMF_variable僅使用由Seurat函數(shù)VariableFeatures()識(shí)別的可變特征來整合數(shù)據(jù)假抄。
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包怎栽,它使用特征錨定函數(shù)來整合數(shù)據(jù),該函數(shù)將自動(dòng)選擇最大數(shù)量的可變特征來整合數(shù)據(jù)宿饱⊙椋基本上,它是Seurat函數(shù)FindIntegrationAnchors和IntegrateData包裝后的結(jié)果谬以,即下面的函數(shù)打包后的結(jié)果
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")
結(jié)果可視化:
DimPlot(inetgrated_ST, reduction = "umap", group.by = c("ident", "orig.ident"))