单细胞前期工作重要的是如何将测序得到的多样本整合同步分析:
library(Seurat)
folders=list.files('./') #列出文件夹
folders=folders[-7] #删除第七个代码文件
sceList = lapply(folders,function(folder){ CreateSeuratObject(counts = Read10X(folder), project = folder )})#读取文件生成列表
sce.merge <- merge(sceList[[1]], y = c(sceList[[2]],sceList[[3]],sceList[[4]],sceList[[5]], sceList[[6]],sceList[[7]],sceList[[8]],sceList[[9]],sceList[[10]]), add.cell.ids = folders, project = "PBMC")#整合列表对象,sce.merge就是整合后的单细胞合并文件了
sce.merge
sce.subset <- subset(sce.merge, subset = nFeature_RNA > 500 & percent.mt < 5) #对细胞进行过滤,若需要对基因进行整体过滤,可以在保存完文件后读入的时候设置参数
write.table(sce.subset@assays$RNA@counts,"filter.txt",sep="\t")