setwd('~/Desktop')
Path=getwd()
if(dir.exists(Path)){
path=paste(Path,"/00_scRNA-seq_analysis/00_rawdt",sep='')
if(!dir.exists(path)){
dir.create(path,recursive=TRUE)
}
}
# R1 ** read 10X **
# 10Xgenomics:barcodes.tsv.gz;features.tsv.gz;matrix.mtx.gz
#*----------------------multiple file-----------------------*#
dt.dir=paste(Path,"/00_scRNA-seq_analysis/00_rawdt",sep='')
#dirs=list.dirs(dt.dir, recursive = FALSE)
sam_name=list.files(dt.dir)
sce_List=lapply(sam_name,function(proj){
print(proj)
folder=file.path(dt.dir, proj)
sce=CreateSeuratObject(counts=Read10X(data.dir=folder),
project=proj,
min.cells=5,
min.features=200)
return(sce)
})
#sam_name = c('Control1','Treat1','Treat2')
sce_all = merge(x = sce_List[[1]],
y = sce_List[-1],
add.cell.ids = sam_name,
merge.data = TRUE)
sce_combined <- JoinLayers(sce_all)
filename=paste(Path,"/00_scRNA-seq_analysis/00_rawdt/sce_all_rawdt.rds",sep='')
saveRDS(sce_combined ,file=filename)
#*----------------------single file-----------------------*#
dt.dir=paste(Path,"/00_scRNA-seq_analysis/00_rawdt",sep='')
sam_name=list.files(dt.dir)
sce = Read10X(data.dir = paste(dt.dir,sam_name,sep = '/'))
sce_all = CreateSeuratObject(counts = sce,
project = sam_name,
min.cells = 20,
min.features = 200)
filename=paste(Path,"/00_scRNA-seq_analysis/00_rawdt/sce.",sam_name,".rawdt.rds",sep='')
saveRDS(sce_all,file=filename)
# R2 ** Expression matrix **
# expression_matrix.txt.gz
dt.dir=paste(Path,"/00_scRNA-seq_analysis/00_rawdt",sep='')
#dirs=list.dirs(dt.dir, recursive = FALSE)
sam_name=list.files(dt.dir)
sce_List = lapply(sam_name,function(proj){
print(proj)
folder=file.path(dt.dir, proj)
exp_mat=fread(folder,data.table = F)
EM=exp_mat[,-1]
rownames(EM)=exp_mat[,1]
sce=CreateSeuratObject(EM, project=gsub('_.*$','',proj))
return(sce)
})
#names(sceList)
sce_all = merge(x = sceList[[1]],
y = sceList[ -1 ],
add.cell.ids = sam_name)
filename=paste(Path,"/00_scRNA-seq_analysis/00_rawdt/sce_all_rawdt.rds",sep='')
saveRDS(sce_all,file=filename)
#*----------------------single file-----------------------*#
dt.dir=paste(Path,"/00_scRNA-seq_analysis/00_rawdt",sep='')
#dirs=list.dirs(dt.dir, recursive = FALSE)
sam_name=list.files(dt.dir)
folder=file.path(dt.dir, sam_name)
exp_mat=fread(folder,data.table = F)
EM=exp_mat[,-1]
rownames(EM)=exp_mat[,1]
sce_all=CreateSeuratObject(EM, project=gsub('_.*$','',sam_name))
filename=paste(Path,"/00_scRNA-seq_analysis/00_rawdt/sce_all_rawdt.rds",sep='')
saveRDS(sce_all,file=filename)
# R3 ** h5 **
dt.file = paste(Path,"/00_scRNA-seq_analysis/*_h5.h5",sep='')
# list.files(dt.file)
dt = Read10X_h5(filename = dt.file)
sce_seurat = CreateSeuratObject(counts = dt)
# R4 ** h5ad **
library(SeuratDisk)
dt.file = paste(Path,"/00_scRNA-seq_analysis/*_raw_counts.h5ad",sep='')
Convert(dt.file, "h5seurat", overwrite = TRUE, assay = "RNA")
sce_seurat=LoadH5Seurat(paste(Path,"/00_scRNA-seq_analysis/*_raw_counts.h5seurat",sep=''))
R读取单细胞数据
?著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 最近开始接触单细胞数据,网上也有很多学习资料,琳琅满目,我也挑了一些视频资料进行学习,不过感觉还是需要进行实战训练...
- 相信经过大家这一个礼拜的学习,已经能够熟练的掌握R语言与Linux,现在我们就正式开始课程!有疑惑欢迎后台交流。 ...
- 这篇文章我们将介绍从geo数据库下载单细胞测序数据后,多种数据格式多样本情况下,如何读取数据并创建seurat对象...