LearnSeurat_Intergrate
0. 说明
更为详细的使用,可以参考Seurat官方教程,或者Seurat进行单细胞RNA-seq数据整合。
1. 快速进行
实际分析中,如果细胞数目很多的话,进行整合分析的时候就会很慢,一种方式是将任务提交通过命令行提交到服务器或者集群上运行,并输出。
传递命令行的参数的脚本可以这么写:
#### reference base Integration
.libPaths("/home/user/lib/R/library")
library(Seurat)
= commandArgs(trailingOnly=TRUE)
args # test if there is at least one argument: if not, return an error
if (length(args)==0) {
stop("At least one argument must be supplied (input file).n", call.=FALSE)
}
###args[1] seu.list.rds
###args[2] seu.intergrated.rds
###args[3] UMAPplot.pdf
## program...
<- readRDS(file = args[1])
seu.list
for (i in names(seu.list)) {
<- SCTransform(seu.list[[i]], verbose = FALSE)
seu.list[[i]] }
<- SelectIntegrationFeatures(object.list = seu.list,
seu.list.features nfeatures = 3000)
<- PrepSCTIntegration(object.list = seu.list,
seu.list anchor.features = seu.list.features)
<- 1
reference_dataset names(seu.list)[1]
<- FindIntegrationAnchors(object.list = seu.list,
seu.list.anchors normalization.method = "SCT",
anchor.features = seu.list.features,
reference = reference_dataset)
<- IntegrateData(anchorset = seu.list.anchors,
seu.list.integrated normalization.method = "SCT")
<- RunPCA(object = seu.list.integrated, verbose = FALSE)
seu.list.integrated <- RunUMAP(object = seu.list.integrated, umap.method = "umap-learn",
seu.list.integrated dims = 1:30)
saveRDS(seu.list.integrated,file = args[2])
#### show Integrated result
<- DimPlot(seu.list.integrated,
plots group.by = c("orig.ident", "cell.type"))
& theme(legend.position = "top") &
plots guides(color = guide_legend(nrow = 4, byrow = TRUE,
override.aes = list(size = 2.5)))
ggsave(filename = args[3],width = 12,height = 6)
将其命名为Integrated_ref_based.R
然后在终端输入nohup Rscript Integrated_ref_based.R seu.list.rds seu.intergrated.rds UMAPplot.pdf > log.txt &
提交即可;
2. 评论
当然,这个脚本读者还可以根据自己需求加以完善。