>计算cluster细胞数目
library(ggsci)
cell_stat_df <- table(sce_all.intergrated@meta.data$celltype, sce_all.intergrated@meta.data$orig.ident) %>%
reshape2::melt()
colnames(cell_stat_df) <- c("ClusterName","Sample","Count")
cell_stat_df$ClusterName <- factor(cell_stat_df$ClusterName)
Colors = pal_igv("default")(51)
ggplot(data = cell_stat_df, aes(x = Count, y = Sample, fill = ClusterName)) +
geom_bar(stat = "identity", width=0.8, position="fill")+
scale_fill_manual(values = Colors_vector[1:15]) +
theme_bw()+
theme(panel.grid =element_blank()) +
labs(x="Ratio",y="")+
theme(axis.text.y = element_text(size=12, colour = "black"))+
theme(axis.text.x = element_text(size=12, colour = "black"))+
theme(axis.text.x.bottom = element_text(hjust = 1, vjust = 1, angle = 45))
>计算cluster细胞比率
cell_ratio_df <- prop.table(table(Idents(sce_all.intergrated), sce_all.intergrated$orig.ident), margin = 2)
cell_ratio_df <- cell_ratio_df %>% as.data.frame()
cell_ratio_df $Var1 <- as.integer(cell_ratio_df $Var1)
cell_ratio_df <- cell_ratio_df %>% left_join(celltype, by = c("Var1"="ClusterID"))
Colors = pal_igv("default")(51)
ggplot(data = cell_ratio_df , aes(x =Var2, y = Freq, fill = celltype)) +
geom_bar(stat = "identity", width=0.8, position="fill")+
scale_fill_manual(values = Colors[1:15]) +
theme_bw()+
theme(panel.grid =element_blank()) +
labs(x="",y="Ratio")+
theme(axis.text.y = element_text(size=12, colour = "black"))+
theme(axis.text.x = element_text(size=12, colour = "black"))+
theme(axis.text.x.bottom = element_text(hjust = 1, vjust = 1, angle = 45))
细胞数据统计
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 前情回顾:Gephi网络图极简教程[https://www.jianshu.com/p/86145943695a]...
- A.使用量统计: 我们会针对产品用户做出一套数据分析系统,用于监测用户在产品场当中所触发的行为,亦可以用现成的数据...
- 以下是一些简单的步骤来创建数据透视表: 需要新建一列数量B列,填充数字1,用于做求和用,选择您要进行分析的数据范围...
- 最近一直在研究数据分析的相关知识,把自己学到的会一点一点分享出来,先从百度统计说起。 数据统计工具:百度统计 百度...