diff --git a/R/figure.R b/R/figure.R index 07a53b12b79def0de188d9d2044cd29add17931a..1b98bd794319fb4903e968d0b9128b6778d6e02b 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() }