ggplot和plot如何处理inf值? [英] How do ggplot and plot handle inf values differently?

查看:70
本文介绍了ggplot和plot如何处理inf值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力理解为什么 ggplot plot 会生成相同数据的略有不同的图. ggplot 首先包含inf值,而 plot 不包含inf值.

I am struggling to understand why ggplot and plot are producing slightly different plots of the same data. ggplot is including inf values up top, while plot isn't.

with(geneFDR, plot(log2(FC), -log10(FDR), pch=20, main="FDR vs. Real FC",
col=geneFDR$FDRColor))

ggplot(data=geneFDR, aes(x=log2(FC), y=-log10(FDR), color=FDRFCthreshold)) +
  geom_point(alpha=0.4, size=1.75) +
  ggtitle("FDR vs. Real Fold Change") +
  xlab("log2 Real Fold Change") + ylab("-log10(FDR)")

inf值的来源:

min(geneFDR$FDR)
[1] 0
max(geneFDR$FDR)
[1] 0.009883703

min(-log10(geneFDR$FDR))
[1] 2.00508
max(-log10(geneFDR$FDR))
[1] Inf

默认的 plot 函数处理inf值与 ggplot 的方法有何不同?

How is the default plot function handling inf values differently than ggplot?

推荐答案

尝试

scale_y_continuous(oob=scales::discard)

这篇关于ggplot和plot如何处理inf值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆