This is a test version of Biostars. For the public version, visit https://www.biostars.org.
GOSt Plot

I have been using GOSt in R to run GO analysis and create a plot with various terms highlighted. All went well, data exported etc but as someone relatively unfamiliar with R I have two questions.

  1. How do I change the point size on the plot? I know how to do this in ggplot, but can't find a command here to do this, even though the cran package says this is now a ggplot object.
  2. Can I export a plot from R as a PDF (so it would be a vector object in publishing software)? I can only find the options fro jpeg or png.

Thank you! For reference, here is my script:

install.packages("gprofiler2")
library(gprofiler2)

input <- as.vector(Genes_DMR_Stage[,'Gene'])

gostres <- gost(query = input, 
                organism = "hsapiens", ordered_query = FALSE, 
                multi_query = FALSE, significant = TRUE, exclude_iea = FALSE, 
                measure_underrepresentation = FALSE, evcodes = FALSE, 
                user_threshold = 0.05, correction_method = "fdr", 
                domain_scope = "annotated", custom_bg = NULL, 
                numeric_ns = "", sources = NULL, as_short_link = FALSE, highlight = TRUE)

df <- as.data.frame(gostres$result)
df <- apply(da,2,as.character)
write.csv2(df, "GO.csv")

p <- gostplot(gostres, capped = FALSE, interactive = FALSE)

pp <- publish_gostplot(p, highlight_terms = c("GO:0032502", "GO:0048856", "GO:0048869", "GO:0051216", "GO:0060173", "GO:0001501"), 
                       width = NA, height = NA, filename = NULL)
gost ggplot2

2 answers

A hacky solution would be to use trace(gostplot, edit=TRUE) and manually change the size of the points. Changes are temporary and not reproducible. You could also recreate the Manhattan plot in ggplot so you have more control over it.

How do I change the point size on the plot? I know how to do this in ggplot, but can't find a command here to do this, even though the cran package says this is now a ggplot object.

You can use ggplot function scale_size_continuous(range = c(x,y)) to increase or decrease the point sizes.

p <- gostplot(gostres, capped = TRUE, interactive = FALSE)+scale_size_continuous(range = c(5,10))

Can I export a plot from R as a PDF (so it would be a vector object in publishing software)? I can only find the options fro jpeg or png.

You can save your plot as pdf.

pdf("publish_gostplot.pdf", h=6, w=8)
pp <- publish_gostplot(p, highlight_terms = c("GO:0032502", "GO:0048856", "GO:0048869", "GO:0051216", "GO:0060173", "GO:0001501"), 
                       width = NA, height = NA, filename = NULL)
dev.off()

Log in to answer this question.