问:
image.png
答:
首先,你需要对单细胞测序的数据基础分析有一定的理解,我们的教程也更了好几期了,你需要掌握下面的内容后再进行后续学习:
手把手教你做单细胞测序数据分析(一)
手把手教你做单细胞测序数据分析(二)
手把手教你做单细胞测序数据分析(三)——单样本分析
手把手教你做单细胞测序数据分析(四)——多样本整合手把手教你做单细胞测序数据分析(五)细胞类型注释——从入门到入土
在完成了上述内容的学习之后,我们再来看一看分析亚群时的具体操作:
亚群分析
先看一下数据结构
将Endothelial cells单独取出分析
End <- subset(pbmc,idents = 'Endothelial cells')
End <- FindNeighbors(End, dims = 1:10)#需要重新计算一下临近关系
## Computing nearest neighbor graph
## Computing SNN
End <- FindClusters(End,resolution = 0.1)
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
##
## Number of nodes: 14442
## Number of edges: 376656
##
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.9419
## Number of communities: 3
## Elapsed time: 1 seconds
p1 <- DimPlot(End)
p1
image.png
###看一下各亚群的独有标记基因#####
End.markers <- FindAllMarkers(End, only.pos = TRUE, min.pct = 0.25, logfc.threshold = 0.25)
## Calculating cluster 0
## Calculating cluster 1
## Calculating cluster 2
#寻找每一个分类群与其他所有细胞之间的标记基因,并只显示positive结果
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.0.5
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
top5gene <- End.markers %>% group_by(cluster) %>% top_n(n = 5, wt = avg_log2FC)
head(top5gene)
## Registered S3 method overwritten by 'cli':
## method from
## print.boxx spatstat.geom
## # A tibble: 6 x 7
## # Groups: cluster [2]
## p_val avg_log2FC pct.1 pct.2 p_val_adj cluster gene
## <dbl> <dbl> <dbl> <dbl> <dbl> <fct> <chr>
## 1 0 3.14 0.991 0.533 0 0 Cldn5
## 2 0 3.10 0.996 0.623 0 0 Ly6a
## 3 0 3.07 0.941 0.596 0 0 Ctla2a
## 4 0 3.05 0.97 0.435 0 0 Pglyrp1
## 5 0 3.04 0.942 0.404 0 0 Itm2a
## 6 0 5.69 0.986 0.237 0 1 Acta2
VlnPlot(End,features = top5gene$gene,pt.size = 0)
image.png
原位分离亚群
names(pbmc@graphs)#graph.name的选择在这里找
## [1] "RNA_nn" "RNA_snn"
pbmc<- FindSubCluster(pbmc,cluster = 'Endothelial cells',graph.name = "RNA_nn",subcluster.name = 'ENC.Sub',resolution = 0.5)
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
##
## Number of nodes: 14442
## Number of edges: 133462
##
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.8203
## Number of communities: 17
## Elapsed time: 0 seconds
## 9 singletons identified. 8 final clusters.
Idents(pbmc) <- 'ENC.Sub'
p2<-DimPlot(pbmc)
p2#Endothelial cells确实被分出了一些亚群
image.png
最后看一下分亚群之前、以及两种亚群提取方式的效果
library(patchwork)
p0|p1|p2
image.png
欢迎关注同名公众号~
网友评论