dafabet手机黄金版_dafabet黄金手机版

晶诚所至 生命所能

Engage to Life Energy

 
单细胞转录组基础分析五:细胞再聚类
发布日期:2021-07-16浏览:

 

 

 

 

单细胞数据分析中,一般需要对可以细分的细胞再聚类,比如本次分析中的T细胞群体可以细分为Naive T cells、CD8+ T cells、Treg cells、Tmemory cells等。细胞子集的提取使用subset函数,主要依据meta.data的分类项目选择,也可以自定义细胞barcode提取。

 

提取细胞子集

 

	library(Seurat)library(monocle)library(tidyverse)library(patchwork)rm(list=ls())dir.create("subcluster")scRNA <- readRDS("scRNA.rds")##提取细胞子集Cells.sub <- subset(scRNA@meta.data, celltype=="T_cells")scRNAsub <- subset(scRNA, cells=row.names(Cells.sub))

 

重新降维聚类

 

因为再聚类的细胞之间差异比较小,所以聚类函数FindClusters()控制分辨率的参数建议调高到resolution = 0.9

	##PCA降维scRNAsub <- FindVariableFeatures(scRNAsub, selection.method = "vst", nfeatures = 2000)scale.genes <-  rownames(scRNAsub)scRNAsub <- ScaleData(scRNAsub, features = scale.genes)scRNAsub <- RunPCA(scRNAsub, features = VariableFeatures(scRNAsub))ElbowPlot(scRNAsub, ndims=20, reduction="pca")pc.num=1:10##细胞聚类scRNAsub <- FindNeighbors(scRNAsub, dims = pc.num) scRNAsub <- FindClusters(scRNAsub, resolution = 0.9)table(scRNAsub@meta.data$seurat_clusters)metadata <- scRNAsub@meta.datacell_cluster <- data.frame(cell_ID=rownames(metadata), cluster_ID=metadata$seurat_clusters)write.csv(cell_cluster,'subcluster/cell_cluster.csv',row.names = F)##非线性降维#tSNEscRNAsub = RunTSNE(scRNAsub, dims = pc.num)embed_tsne <- Embeddings(scRNAsub, 'tsne')write.csv(embed_tsne,'subcluster/embed_tsne.csv')plot1 = DimPlot(scRNAsub, reduction = "tsne") ggsave("subcluster/tSNE.pdf", plot = plot1, width = 8, height = 7)ggsave("subcluster/tSNE.png", plot = plot1, width = 8, height = 7)#UMAPscRNAsub <- RunUMAP(scRNAsub, dims = pc.num)embed_umap <- Embeddings(scRNAsub, 'umap')write.csv(embed_umap,'subcluster/embed_umap.csv') plot2 = DimPlot(scRNAsub, reduction = "umap") ggsave("subcluster/UMAP.pdf", plot = plot2, width = 8, height = 7)ggsave("subcluster/UMAP.png", plot = plot2, width = 8, height = 7)#合并tSNE与UMAPplotc <- plot1+plot2+ plot_layout(guides = 'collect')ggsave("subcluster/tSNE_UMAP.pdf", plot = plotc, width = 10, height = 5)ggsave("subcluster/tSNE_UMAP.png", plot = plotc, width = 10, height = 5)

 

Cluster差异分析

 

	diff.wilcox = FindAllMarkers(scRNAsub)all.markers = diff.wilcox %>% select(gene, everything()) %>% subset(p_val<0.05)top10 = all.markers %>% group_by(cluster) %>% top_n(n = 10, wt = avg_logFC)write.csv(all.markers, "subcluster/diff_genes_wilcox.csv", row.names = F)write.csv(top10, "subcluster/top10_diff_genes_wilcox.csv", row.names = F)

 

SingleR细胞鉴定

 

Subcluster的细胞同样可以使用SingleR鉴定细胞类型。使用的时候注意调整参考数据库和分类标签,以便鉴定结果更有针对性。上节使用SingleR时使用的参考数据库是人类主要细胞图谱(HumanPrimaryCellAtlasData),采用分类标签是主分类标签(label.main);这次建议使用人类免疫细胞数据(MonacoImmuneData),分类标签采用精细分类标签(label.fine)。希望详细了解SingleR的朋友可以到github看看:

https://github.com/dviraran/singler

	##细胞类型鉴定library(SingleR)refdata <- MonacoImmuneData()testdata <- GetAssayData(scRNAsub, slot="data")clusters <- scRNAsub@meta.data$seurat_clusterscellpred <- SingleR(test = testdata, ref = refdata, labels = refdata$label.fine,                      method = "cluster", clusters = clusters,                      assay.type.test = "logcounts", assay.type.ref = "logcounts")celltype = data.frame(ClusterID=rownames(cellpred), celltype=cellpred$labels, stringsAsFactors = F)write.csv(celltype,"subcluster/celltype_singleR.csv",row.names = F)scRNAsub@meta.data$celltype = "NA"for(i in 1:nrow(celltype)){scRNAsub@meta.data[which(scRNAsub@meta.data$seurat_clusters == celltype$ClusterID[i]),'celltype'] <- celltype$celltype[i]}p1 = DimPlot(scRNAsub, group.by="celltype", label=T, label.size=5, reduction='tsne')p2 = DimPlot(scRNAsub, group.by="celltype", label=T, label.size=5, reduction='umap')p3 = plotc <- p1+p2+ plot_layout(guides = 'collect')ggsave("subcluster/tSNE_celltype.pdf", p1, width=7 ,height=6)ggsave("subcluster/UMAP_celltype.pdf", p2, width=7 ,height=6)ggsave("subcluster/celltype.pdf", p3, width=10 ,height=5)ggsave("subcluster/celltype.png", p3, width=10 ,height=5)



 

 

 

上一条:上课笔记|通过直接引导 RNA 捕获和靶向测序进行组合单细胞 CRISPR 筛选
下一条:dafabet黄金手机版学院直播上新|类转录效应子的高通量发现和表征
返回
网站地图 | 法律声明 | 联系我们

地址:上海市松江区中心路1158号5幢5楼

电话:400-9200-612  传真:+86 21 6090 1207/1208-8154

dafabet手机黄金版技术(上海)有限公司 Copyright 2012 Genergy Inc. 沪ICP备10017363号

友情链接: