Entering edit mode
4.5 years ago
anikcropscience
▴
270
Hello, I am using the following codes for producing an overlapping QQ-plot from two GWAS result files.
# first model
a<-read.table("GWAS_result_1.txt" , header=T)
o = -log10(sort(a$P.value, decreasing = FALSE))
e = -log10(ppoints(length(a$P.value)))
# second model
b<-read.table("GWAS_result_2.txt" , header=T)
o2 = -log10(sort(b$P.value, decreasing = FALSE))
e2 = -log10(ppoints(length(b$P.value)))
plotly::plot_ly(x = ~e, y = ~o, name = "p1",
type = "scatter", mode = "markers") %>%
add_trace(x = ~e2, y = ~o2, name = "p2") %>%
add_trace(x = c(0, max(e,e2)), y = c(0, max(e,e2)),
mode="lines", name = "Log normal") %>%
layout(xaxis = list(title = 'Expected -log[10](<i>p</i>)'),
yaxis = list(title = 'Observed -log[10](<i>p</i>)'))
But I am having lots of trouble in saving the image from Plot_ly. I used orca to save the image but it is not working and messing up my R-studio.
Is there any way to use the above plot_ly code in ggplot2 to make life easier while saving a figure?
Thanks
plot_lysyntax directly borrows much fromggplot2. You should be able to refactor the code to useggplot2instead pretty easily, and it may even lift over directly if the graph is quite simple.There is no way to save a
plot_lyobject 'through'ggplot2however, you will have to do some code refactoring, or simply save the plots withplot_lyitself.Ok thank you. I will try that.