1212# ' used in analysis (default: \code{c(20, 35)}).
1313# ' @param merge_rep Logical. Whether to merge replicate samples by \code{sample_group}. Default is \code{FALSE}.
1414# ' @param text_size Numeric, size of the text labels showing periodicity percentages (default: 3).
15+ # ' @param facet A ggplot2 faceting specification, e.g.
16+ # ' \code{ggplot2::facet_wrap(~sample, scales = "free")}.
17+ # ' Default is \code{ggplot2::facet_wrap(~sample, scales = "free")}.
1518# ' @param add_periodicity_label Logical, whether to annotate each frame with periodicity
1619# ' (percentage of total reads per sample) (default: \code{TRUE}).
1720# ' @param return_data Logical, if \code{TRUE}, return data frame used to build the plot instead of a plot (default: \code{FALSE}).
@@ -53,6 +56,7 @@ setMethod("frame_plot",
5356 read_length = c(20 ,35 ),
5457 merge_rep = FALSE ,
5558 text_size = 3 ,
59+ facet = ggplot2 :: facet_wrap(~ sample ,scales = " free" ),
5660 add_periodicity_label = TRUE ,
5761 return_data = FALSE ){
5862 pltdf <- object @ summary_info %> %
@@ -102,7 +106,7 @@ setMethod("frame_plot",
102106 theme(panel.grid = element_blank(),
103107 strip.text = element_text(colour = " black" ,face = " bold" ,size = rel(1 )),
104108 axis.text = element_text(colour = " black" )) +
105- facet_wrap( ~ sample , scales = " free " ) +
109+ facet +
106110 scale_y_continuous(labels = scales :: label_log(base = 10 ,digits = 1 )) +
107111 xlab(" Read length (nt)" ) + ylab(" Number of reads" ) +
108112 scale_fill_brewer(direction = - 1 ,name = " Frame" )
@@ -483,6 +487,9 @@ setMethod("length_plot",
483487# '
484488# ' @param object A `ribotrans` object that contains summary read information.
485489# ' @param merge_rep Logical. Whether to merge replicate samples by \code{sample_group}. Default is \code{FALSE}.
490+ # ' @param facet A ggplot2 faceting specification, e.g.
491+ # ' \code{ggplot2::facet_wrap(~sample, scales = "free")}.
492+ # ' Default is \code{ggplot2::facet_wrap(~sample, scales = "free")}.
486493# ' @param return_data A logical value indicating whether to return the processed
487494# ' summary data instead of the plot. Default is `FALSE` (returns a `ggplot` object).
488495# ' @param ... Additional arguments (currently unused).
@@ -515,7 +522,9 @@ setGeneric("feature_plot",function(object,...) standardGeneric("feature_plot"))
515522# ' @export
516523setMethod ("feature_plot ",
517524 signature(object = " ribotrans" ),
518- function (object ,merge_rep = FALSE ,return_data = FALSE ){
525+ function (object ,merge_rep = FALSE ,
526+ facet = ggplot2 :: facet_wrap(~ sample ,scales = " free_y" ),
527+ return_data = FALSE ){
519528 # assign features
520529 sry <- object @ summary_info %> %
521530 fastplyr :: f_filter(mstart != 0 | mstop != 0 ) %> %
@@ -541,7 +550,7 @@ setMethod("feature_plot",
541550 p <-
542551 ggplot(sry ) +
543552 geom_col(aes(x = type ,y = counts ,fill = type ),width = 0.6 ,show.legend = F ) +
544- facet_wrap( ~ sample , scales = " free_y " ) +
553+ facet +
545554 theme(panel.grid = element_blank(),
546555 strip.text = element_text(colour = " black" ,face = " bold" ,size = rel(1 )),
547556 axis.text = element_text(colour = " black" )) +
0 commit comments