我用R中的TidyVerse制作了一个我最满意的情节,但这个情节需要显示更多的信息,我还没有想出如何做到这一点.
这个情节的重点是展示来自三种不同动物的一堆细胞是如何根据它们的生物学通过算法分类和Bundle 在一起的.每种动物都有很多不同的细胞类型,并且有很多输出的细胞群;我正在绘制一个输出的群,在查看了每个动物被分类到这个群中的所有细胞后,我 Select 显示进入该图的源动物的前5个细胞类型名称.该图很好地显示了这一点(至少在我看来是这样),但它没有显示给定源细胞类型的所有细胞是否都Bundle 到了这个新的集群中,或者是一半,或者几乎没有,等等.
这是我使用的代码,以及我得到的情节(大部分都是喜欢的!)
library(tidyverse)
# create the contents of the toy dataset, then add together
species_organ <- c(rep("frog", 5),
rep("bat", 5),
rep("bird", 5)
)
annotation <- c("celltype1", "celltype2", "celltype3", "celltype4", "celltype5",
"celltypeA", "celltypeB", "celltypeC", "celltypeD", "celltypeE",
"celltypeAlpha", "celltypeBeta", "celltypeGamma", "celltypeDelta", "celltypeEpsilon"
)
count_in_integratedcluster <- c(253, 245, 226, 187, 185, 42, 18, 17, 11, 9, 58, 16, 8, 8, 7)
annotation_count_in_source_dataset <- c(413, 312, 349, 410, 233, 195, 198, 56, 166, 238, 82, 68, 270, 226, 81)
fraction_of_total_celltype_abundance <- count_in_integratedcluster / annotation_count_in_source_dataset
fake_dataframe <- data.frame(species_organ, annotation, count_in_integratedcluster, annotation_count_in_source_dataset, fraction_of_total_celltype_abundance)
# a few other things to decorate the plot with
how_many_cells_in_this_integrated_cluster <- 5056
cluster_name = "cluster6"
# now we make a lollipop plot
plot_lollipop_faceted.top5 <- ggplot(fake_dataframe) +
geom_segment( aes(x=annotation, xend=annotation, y=0, yend=count_in_integratedcluster), color="grey") +
geom_point( aes(x=annotation, y=count_in_integratedcluster, color=species_organ), size=3 ) +
coord_flip()+
theme(
legend.position = "none",
panel.border = element_blank(),
panel.spacing = unit(0.1, "lines"),
strip.text.x = element_text(size = 8)
) +
xlab("") +
ylab("How many times cells of this original annotation (y-axis)\nshowed up in this integrated cluster (plot title)") +
facet_wrap(~species_organ, ncol=1, scale="free_y") +
labs(title = paste(paste("integrated", cluster_name, sep = " "), ",", how_many_cells_in_this_integrated_cluster, "total cells"),
subtitle = "In this integrated cluster, see what cells contribute per species")
(plot I mostly like but which needs improvement)
一个简单的图形化解决办法是用一个可爱的小饼形图替换geom_point,用 colored颜色 填充来报告算法最终将90%的"鸟类肌肉细胞"还是只有10%的"鸟类肌肉细胞"分配到这个集群.
这里是一个铅笔素描的图形可能是什么样子,如果我做了我正在寻找的交换.
pencil sketch of improved plot个
任何解决方案都必须是R的,我会喜欢基于TidyVerse的方法,但我愿意try 其他方法来传达所需的信息集.
我已经研究了其他相关问题,但不幸的是,我无法使建议的方法对我起作用,或者建议的解决方案在我的场景中似乎没有用;到目前为止,我已经判断了:
R::ggplot2::geom_points: how to swap points with pie charts?(杂乱无章的文档并没有帮助我理解该怎么做才能实现建议) ggplot use small pie charts as points with geom_point(馅饼很不错,但我不想失go 我的情节目前传达的其他信息) Plotting pie charts in ggplot2(标题听起来不错,但内容没有帮助) create floating pie charts with ggplot(这是我第二次看到coord_poll(),但在摆弄了一下它/阅读了它的文档后,我不知道如何使用它)