我有看起来像这样的数据(expanded.plot.dat):
expanded UMAP_1 UMAP_2
a 339 -2.3 -5
b NA 0.4 2.7
c 3044 -1.2 4
d NA 3 -5.7
[NA值很多,我希望将它们绘制出来,但是NA值遮盖了许多非NA值,我想这可以通过先绘制NA值来解决。
扩展列是一个因数,我尝试将其转换为数值,进行排序,然后将其恢复为因数,我还尝试对ggplot对象本身中的数据进行重新排序,但是无论我将数据按什么顺序排列ggplot似乎与该顺序无关。
感谢您的协助!
ggplot行:
expanded.plot <- ggplot(expanded.plot.dat, aes(UMAP_1, UMAP_2, color=expanded)) + geom_point()
当前的输出:
也许使用forcats软件包中的fct_explicit_na()函数将NA更改为其他内容,可能会帮助您。在绘制之前,还要考虑对因子进行重新排序。
在评论中致谢@Jon Spring,稍加调整即可实现: