From 111882dc03a556d90fa36b8941c789eeab4db4d1 Mon Sep 17 00:00:00 2001 From: Fontrodona Nicolas <nicolas.fontrodona@ens-lyon.fr> Date: Wed, 25 Sep 2024 13:15:24 +0200 Subject: [PATCH] fix figures --- R/figure.R | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/R/figure.R b/R/figure.R index 07a53b1..1b98bd7 100644 --- a/R/figure.R +++ b/R/figure.R @@ -17,10 +17,12 @@ build_figure <- function(top_go_result, go_term_type, outfile) { } top_go_result$fish <- as.numeric(gsub("< ", "", top_go_result$fish)) top_go_result <- top_go_result %>% - mutate(sigv = -log10(padj), - significance = ifelse(sigv < 400, sigv, 400), - ft = paste(GO.ID, ":", Term)) %>% - filter(padj <= 0.05) %>% + mutate( + sigv = -log10(padj), + significance = ifelse(sigv < 400, sigv, 400), + ft = paste(GO.ID, ":", Term) + ) %>% + filter(pvalue <= 0.05) %>% arrange(desc(significance)) fig <- ggplot(top_go_result, mapping = aes( x = significance, y = fct_reorder(ft, significance), @@ -30,19 +32,23 @@ build_figure <- function(top_go_result, go_term_type, outfile) { if (min(top_go_result$significance) * 0.95 < -log10(0.05)) { fig <- fig + geom_vline(aes(xintercept = -log10(0.05), linetype = "significance"), - size = 0.5, color = "black") + + size = 0.5, color = "black" + ) + scale_linetype_manual( - name = "Vertical line", values=c(2, 2), - guide = guide_legend(override.aes = list(size = c(0.5)))) + name = "Vertical line", values = c(2, 2), + guide = guide_legend(override.aes = list(size = c(0.5))) + ) } fig <- fig + - geom_point() + - xlab("-log10(pvalue)") + - ylab(go_name) + - theme_bw() + - coord_cartesian(xlim = c(min(top_go_result$significance, 50) * 0.95, - max(top_go_result$significance)) * 1.05) + - guides(color = "none", size = guide_legend(title = "# input genes")) + geom_point() + + xlab("-log10(padj)") + + ylab(go_name) + + theme_bw() + + coord_cartesian(xlim = c( + min(top_go_result$significance, 50) * 0.95, + max(top_go_result$significance) + ) * 1.05) + + guides(color = "none", size = guide_legend(title = "# input genes")) if (max(top_go_result$significance) > 100) { fig <- fig + scale_x_log10() } -- GitLab