Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do ggplot and plot handle inf values differently?

Tags:

plot

r

ggplot2

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?

like image 940
user8121557 Avatar asked Oct 28 '25 18:10

user8121557


1 Answers

try

scale_y_continuous(oob=scales::discard)
like image 83
baptiste Avatar answered Oct 30 '25 09:10

baptiste