Hi!
I want to make a scatterplot where the down-regulated genes (log2FC <= -1.5 & p_value <= 0.05) are highlighted in blue and the up-regulated (log2FC >= 1.5 & p_value <= 0.05) in red but, even if I used ggrepel
I still have a couple of genes that despite all, still overlap because they re very close to each other. is there a way to specify which gene I do not want to overlap?
here is my code:
#subset
dfup <- Dpg_JNKst %>% filter(log2FC >= 1.5 & p_value <= 0.05)
dfdown <- Dpg_JNKst %>% filter(log2FC <= -1.5 & p_value <= 0.05)
#scatterplot
library(ggplot2)
library(ggrepel)
ggplot(data = Dpg_JNKst, aes(x= log2FC, y= -1*log10(p_value)))+ ggtitle("Stress-activated kinase signaling cascade") +
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_vline(xintercept = 1.5,linetype = "dashed")+
geom_vline(xintercept = -1.5,linetype = "dashed")+
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=-7,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=-7,y=3.0),label=paste("0.001"), color = "black", size = 2.5, vjust=-0.5)+
geom_text(mapping=aes(x=-7,y=1.30),label=paste("0.05"), size = 2.5, vjust=-0.5) +
geom_text_repel(data=dfdown, aes(label=`Associated.Gene.Name`), color = "blue") +
geom_text_repel(data=dfup, aes(label=`Associated.Gene.Name`), color = "red", max.overlaps = Inf, nudge_x = .15, box.padding = 1)
Maybe is a stupid question but thank you in advance!
camilla
probably you can try a data frame containing only genes of interest and pass it to geom_text_repel, instead of using up and down regulated genes.