How do ggplot and plot handle inf values differently?

Viewed 2648

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))

enter image description here

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)")

enter image description here

Source of inf values:

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

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

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

1 Answers
Related