Hi,
How can I make this scatterplot "wider" around the 0 (or better between -1.5 and +1.5) to see clearly if there is any trend?
I would like to make a magnification of the area where all the points are overlapping without having to subset/select only those genes and plot it in again? is it possible to do in R (to be honest I am not sure even how to search for it)?
here my code:
#scatterplot
library(ggplot2)
library(ggrepel)
#general graph no labels
ggplot(data = Dpg_TF, aes(x= log2FC, y= -1*log10(p_value)))+ ggtitle("Transcription factors genes Dpg dataset") +
geom_point() +
geom_point(data= dfdown, aes(x= log2FC, y= -1*log10(p_value)), color = "blue")+
geom_point(data= dfup, aes(x= log2FC, y= -1*log10(p_value)), color = "red")+
geom_hline(yintercept = -1*log10(0.05),linetype = "dashed") +
geom_hline(yintercept = -1*log10(0.01),linetype = "dashed", color = "black")+
geom_text(mapping=aes(x=-140,y=2.0),label=paste("0.01"), color = "black", size = 2.5, vjust=-0.5) +
geom_hline(yintercept = -1*log10(0.001),linetype = "dashed", color = "black") +
geom_text(mapping=aes(x=-140,y=3.0),label=paste("0.001"), color = "black", size = 2.5, vjust=-0.5)+
geom_vline(xintercept = 1.5,linetype = "dashed")+
geom_vline(xintercept = -1.5,linetype = "dashed")
thank you!!
Camilla
2 answers
Hi Camilla,
I think that you may try ggforce::facet_zoom(): https://www.data-imaginist.com/2019/the-ggforce-awakens-again/
Kevin
geom_text(mapping=aes(x=-140,y=2.0),label=paste("0.01"), color = "black", size = 2.5, vjust=-0.5) +
geom_text(mapping=aes(x=-140,y=3.0),label=paste("0.001"), color = "black", size = 2.5, vjust=-0.5)+
These two lines are likely expanding your scale unnecessarily. Set them to like aes(x=-1.5,y=3.0) and see what it looks like. Set the x-value to something that is at the extreme of your dataset - for example if your furthest point is at +/-2.5 set the x-value to 3.
Even easier is just add this at the end + xlim(-1.5,1.5) it will hide your labels but at least you will be able to see what the resolution looks like with those boundary conditions.
Log in to answer this question.
your code
+ coord_cartesian(xlim = c(-1.5,1.5))zooms onto the coordinates.