kassambara / fastqcr

fastqcr: Quality Control of Sequencing Data
http://www.sthda.com/english/rpkgs/fastqcr
67 stars 22 forks source link

Wondering if possible to modify the color/ggplot parameters of qc_plot_collection #27

Open irvinng98 opened 1 year ago

irvinng98 commented 1 year ago

Hello, I was wondering if it is possible to edit the ggplot parameters of the qc_plot_collection function? I see the source code where I would like to edit on the github repo (R/qc_plot_collection.R) but when I check the R folder in my directory, it only has fastqcr, fastqcr.rdb and fastqcr.rdx.

I would like to change this section:

# Per base sequence quality
.plot_base_quality_collection <- function(qc, ggtheme = theme_minimal(), ...){

  .names <- names(qc)
  if(!("per_base_sequence_quality" %in% .names))
    return(NULL)
  . <- NULL

  d <- qc$per_base_sequence_quality
  if(nrow(d) == 0) return(NULL)

  colnames(d) <- make.names(colnames(d))
  d$Base <- factor(d$Base, levels = unique(d$Base))
  # Select some breaks
  nlev <- nlevels(d$Base)
  breaks <- scales::extended_breaks()(1:nlev)[-1] %>% # index
    c(1, ., nlev) %>% # Add the minimum & the max
    d$Base[.] %>% # Values
    as.vector()

  ggplot()+
    geom_line(data = d, aes_string(x = "Base", y = "Median", group = 'sample', color = 'sample')) +
    expand_limits(x = 0, y = 0)+
    geom_rect(aes(xmin = 0, ymin = 0, ymax = 20, xmax = Inf),
              fill = "red", alpha = 0.2)+
    geom_rect(aes(xmin = 0, ymin = 20, ymax = 28, xmax = Inf),
              fill = "yellow", alpha = 0.2)+
    geom_rect(aes(xmin = 0, ymin = 28, ymax = Inf, xmax = Inf),
              fill = "#00AFBB", alpha = 0.2)+
    scale_x_discrete(breaks = breaks)+
    labs(title = "Per base sequence quality", x = "Position in read (pb)",
         y = "Median quality scores",
         subtitle = "Red: low quality zone")+
    theme_minimal()
}

Specifically the part where the color = sample as I would like all the lines to just be "color = "grey40", alpha = 0.35".

Thank you for making such an awesome package!