专栏名称: 生信技能树
生物信息学学习资料分析,常见数据格式及公共数据库资料分享。常见分析软件及流程,基因检测及癌症相关动态。
目录
相关文章推荐
丁香医生  ·  为什么我劝你马上开始治脚气? ·  5 小时前  
丁香生活研究所  ·  备孕、怀孕、分娩……有很多问题不明白?这份攻 ... ·  2 天前  
丁香医生  ·  运动 VS 不运动,大脑居然真的会差这么多 ·  2 天前  
丁香医生  ·  盘点作为医生,从来不会做的事 ·  3 天前  
51好读  ›  专栏  ›  生信技能树

单细胞转录组的普通降维聚类分群流程(仅需800元)

生信技能树  · 公众号  ·  · 2024-09-30 10:08

正文


网罗了一大波生物信息学数据分析方面的工程师,是时候官宣咱们的单细胞数据处理 业务列表

现在介绍10x的fastq文件的数据分析流程

我们的单细胞产品线还是蛮丰富的:

只需要人民币800元,我们会提供基本的表达量矩阵开始的降维聚类分群和生物学注释!如下所示:

这里展现的是数据集GSE129516的分析流程,通常读取10x数据需要三个文件:barcodes.tsv, genes.tsv, matrix.mtx,但是这个研究者仅仅是上传了matrix文件。

本来呢,我之前似乎看到过教程,将表达矩阵逆转为10x的标准输出三个文件,还是直接用readMM()读入稀疏矩阵然后转为普通矩阵然后构建seurat对象。但是感觉太麻烦了,很明显我的技术是hold不住的啊!

这个数据集GSE129516,就是拿到了如下所示的数据文件:

GEO下载的

我首先读取了一个文件,看了看,就是表达矩阵,所以直接CreateSeuratObject即可,都省去了3个文件的组合命令。

表达矩阵例子

首先批量读取每个10x样品的表达矩阵

保证当前工作目录下面有后缀是matrices.csv.gz的文件,就是前面下载的6个文件:

rm(list=ls())
options(stringsAsFactors = F)
library(Seurat)

fs=list.files(pattern = 'matrices.csv.gz')
fs

sceList <-  lapply(fs, function(x){
  a=read.csv( x )
  a[1:4,1:4]
  raw.data=a[,-1]
  rownames(raw.data)=a[,1]
  library(stringr)
  p=str_split(x,'_',simplify = T)[,2]
  sce <- CreateSeuratObject(counts = raw.data,project = p )
})

每个matrices.csv.gz文件都读取后,提供CreateSeuratObject构建成为对象。如果是读取10x数据需要三个文件:barcodes.tsv, genes.tsv, matrix.mtx,那个更简单哦!

然后使用seurat最出名的多个10x合并算法

多个单细胞对象的整合,这里直接使用标准代码即可:


pro='integrated' 


for (i in 1:length(sceList)) {
  sceList[[i]] <- NormalizeData(sceList[[i]], verbose = FALSE)
  sceList[[i]] <- FindVariableFeatures(sceList[[i]], selection.method = "vst"
                                             nfeatures = 2000, verbose = FALSE)
}
sceList
sce.anchors <- FindIntegrationAnchors(object.list = sceList, dims = 1:30)
sce.integrated <- IntegrateData(anchorset = sce.anchors, dims = 1:30)

因为是6个10X样品,所以这个步骤会略微有点耗费时间哦!

接着走标准的降维聚类分群

因为是构建好的对象,所以后续分析都是常规代码:


library(ggplot2)
library(cowplot)
# switch to integrated assay. The variable features of this assay are automatically
# set during IntegrateData
DefaultAssay(sce.integrated) <- "integrated"

# Run the standard workflow for visualization and clustering
sce.integrated <- ScaleData(sce.integrated, verbose = FALSE)
sce.integrated <- RunPCA(sce.integrated, npcs = 30, verbose = FALSE)
sce.integrated <- RunUMAP(sce.integrated, reduction = "pca", dims = 1:30)
p1 <- DimPlot(sce.integrated, reduction = "umap", group.by = "orig.ident")
p2 <- DimPlot(sce.integrated, reduction = "umap", group.by = "orig.ident", label = TRUE
              repel = TRUE) + NoLegend()
plot_grid(p1, p2)
p2
ggsave(filename = paste0(pro,'_umap.pdf') )


sce=sce.integrated
DimHeatmap(sce, dims = 1:12, cells = 100, balanced = TRUE)
ElbowPlot(sce)
sce <- FindNeighbors(sce, dims = 1:15)
sce <- FindClusters(sce, resolution = 0.2)
table([email protected]$integrated_snn_res.0.2) 
sce <- FindClusters(sce, resolution = 0.8)
table([email protected]$integrated_snn_res.0.8) 

DimPlot(sce, reduction = "umap")
ggsave(filename = paste0(pro,'_umap_seurat_res.0.8.pdf') )
DimPlot(sce, reduction = "umap"






请到「今天看啥」查看全文