# alternately : DimPlot(pbmc, reduction = 'umap', group.by = 'replicate') you can pass the # shape.by to label points by both replicate and cell type
# Switch back to cell type labels Idents(pbmc)<-"CellType"
分别或同时统计不同聚类或者不同样本来源的细胞数目
# 每个聚类包含多少细胞? table(Idents(pbmc))
## ## Naive CD4 T Memory CD4 T CD14+ Mono B CD8 T ## 697 483 480 344 271 ## FCGR3A+ Mono NK DC Platelet ## 162 155 32 14
# 每组重复包含多少细胞? table(pbmc$replicate)
## ## rep1 rep2 ## 1348 1290
# 每个聚类细胞数占比 prop.table(table(Idents(pbmc)))
## ## Naive CD4 T Memory CD4 T CD14+ Mono B CD8 T ## 0.264215315 0.183093252 0.181956027 0.130401820 0.102729340 ## FCGR3A+ Mono NK DC Platelet ## 0.061410159 0.058756634 0.012130402 0.005307051
## An object of class Seurat ## 13714 features across 414 samples within 1 assay ## Active assay: RNA (13714 features) ## 2 dimensional reductions calculated: pca, umap
subset(pbmc, subset = replicate =="rep2")
## An object of class Seurat ## 13714 features across 1290 samples within 1 assay ## Active assay: RNA (13714 features) ## 2 dimensional reductions calculated: pca, umap
# 选择两个细胞类型 subset(pbmc, idents =c("NK","B"))
## An object of class Seurat ## 13714 features across 499 samples within 1 assay ## Active assay: RNA (13714 features) ## 2 dimensional reductions calculated: pca, umap
## An object of class Seurat ## 13714 features across 2139 samples within 1 assay ## Active assay: RNA (13714 features) ## 2 dimensional reductions calculated: pca, umap
# note that if you wish to perform additional rounds of clustering after subsetting we recommend # re-running FindVariableFeatures() and ScaleData()
## An object of class Seurat ## 13714 features across 9 samples within 1 assay ## Active assay: RNA (13714 features)
# How can I plot the average expression of NK cells vs. CD8 T cells? Pass do.hover = T for an # interactive plot to identify gene outliers CellScatter(cluster.averages, cell1 ="NK", cell2 ="CD8_T")
# How can I calculate expression averages separately for each replicate? cluster.averages <- AverageExpression(pbmc, return.seurat =TRUE, add.ident ="replicate") CellScatter(cluster.averages, cell1 ="CD8_T_rep1", cell2 ="CD8_T_rep2")
# You can also plot heatmaps of these 'in silico' bulk datasets to visualize agreement between # replicates DoHeatmap(cluster.averages, features = unlist(TopFeatures(pbmc[["pca"]], balanced =TRUE)), size =3, draw.lines =FALSE)