Error when displaying a graph in the execution of a bioinformatics pipeline


As part of bioinformatics analysis, I'm viualising a coverage profile using a Rmarkdown script in an analysis pipeline. When I first developed the code, I encountered no problems. However when the code is run in my pipeline I get the following error which I don't observe in any other circumstances :

Quitting from lines 433-478 [coverage-Fig_profil_cov] (tmpfoizokz0.myscript.Rmd)
! Discrete value supplied to continuous scale
  1. rmarkdown::render(...)
  2. knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
  3. knitr:::process_file(text, output)
  7. knitr:::process_group.block(group)
  8. knitr:::call_block(x)
 37. ggplot2 (local) FUN(X[[i]], ...)
 38. scales[[i]][[method]](data[[var]][scale_index[[i]]])
 39. ggplot2 (local) train(..., self = self)
 40. self$range$train(x)
 41. scales::train_continuous(x, self$range)
Execution halted

The part of the code that works very well locally but not when running the pipeline is as follows:

threshold_coverage <- 5
  ~platform,          ~CHROM, ~genome_part, ~mean_raw_depth,
      "category1",      "genome1",           0L,            20.5,
      "category1",      "genome1",          20L,            29.8,
      "category1",      "genome1",          40L,              35,
      "category1",      "genome1",          60L,            35.8,
      "category1",      "genome1",          80L,            36.6,
      "category1",      "genome1",         100L,            40.4,
      "category1",      "genome1",         120L,            42.8,
      "category1",      "genome1",         140L,            45.4,
      "category1",      "genome1",         160L,            42.8,
      "category1",      "genome1",         180L,              38,
      "category2", "genome2",     4437L,           0.682,
      "category2", "genome2",     4438L,            1.93,
      "category2", "genome2",     4439L,           0.275,
      "category2", "genome2",     4472L,           0.316,
      "category2", "genome2",     4473L,            1.81,
      "category2", "genome2",     4474L,           0.578
  ) %>% 
  mutate(reference = glue::glue("{CHROM} {platform}"),
         genome_part = base::as.integer(genome_part),
         mean_raw_depth = base::as.numeric(mean_raw_depth)) %>% 
   ggplot(aes(genome_part,mean_raw_depth, fcategory1 = platform, color = platform)) +
    geom_area(alpha=0.2) +
    geom_point(size = 0.01, alpha=0.5) +
    labs(y = NULL,
         x = NULL) +
    theme_minimal() +
    facet_wrap(~ fct_reorder(reference, genome_part,.na_rm = FALSE , .desc=TRUE), scales = "free", ncol = 1) +
    geom_hline(yintercept = threshold_coverage, linetype = "dotdash", linewidth = 0.5, color = "#808080")

As this is a Discrete value supplied to continuous scale type error, I have specified via a mutate to transform the values into numbers, but this does not change anything. I'd like to point out that I don't think it's an env problem because I've checked that my conda env on the pipeline and two different working envs but only execution on the pipeline is not possible.

Please let me know if anyone has a clue why I'm getting this error!

All I can offer is to confirm that I can reproduce the behavior. The code block executes as an RScript but not as a Rmarkdown chunk.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.