From 39efdb15c0ea8e0855403d5dd966071946a3eefe Mon Sep 17 00:00:00 2001 From: Simeon <51403284+simeross@users.noreply.github.com> Date: Fri, 27 Oct 2023 19:49:43 +0200 Subject: [PATCH] Update plot_repeats.R --- R/plot_repeats.R | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/R/plot_repeats.R b/R/plot_repeats.R index b8b79ad..16c89ee 100644 --- a/R/plot_repeats.R +++ b/R/plot_repeats.R @@ -7,6 +7,7 @@ #' #' @return A ggplot object displaying both positions and quantities of repeated sequences. #' @import dplyr forcats stringr tidyr +#' @importFrom cowplot plot_grid ggdraw draw_label #' @importFrom Biostrings DNAStringSet #' @export plot_repeats <- function(sequences = DNAStringSet(), @@ -26,10 +27,21 @@ plot_repeats <- function(sequences = DNAStringSet(), pos_pl <- plot_repeat_positions(pos_data) quant_pl <- plot_repeat_quantity(quant_data) - combo_pl <- ggpubr::ggarrange(pos_pl, quant_pl) - combo_pl <- ggpubr::annotate_figure(combo_pl, top = ggpubr::text_grob( - paste('Repeat', repeat_sequence, 'in', clus_name, 'cluster'), - vjust = 0.5, x = 0.01, hjust = 0)) + combo_pl <- cowplot::plot_grid(pos_pl, quant_pl) + title <- ggdraw() + + draw_label( + paste('Repeat', repeat_sequence, 'in', clus_name, 'cluster'), + fontface = 'bold', + x = 0, + hjust = 0 + ) + + theme( + # add margin on the left of the drawing canvas, + # so title is aligned with left edge of first plot + plot.margin = margin(0, 0, 0, 7) + ) + combo_pl_with_title <- cowplot::plot_grid(title, combo_pl, + ncol = 1, rel_heights = c(.1, 1)) return(combo_pl) } -- GitLab