0

I'm editing an R code block that's supposed to produce a compounded circos-plot figure page. When the code reaches a particular line, it generates the error:

"Error in UseMethod("ggplot_build") : no applicable method for 'ggplot_build' applied to an object of class "NULL" Calls: ... update.reargraph -> ggplotGrob -> ggplot_gtable -> ggplot_build Execution halted"

These are the libraries:

library(ggplot2)
library(tidyverse)
library(dplyr)
library(trellis)
library(magrittr)
library(here)
library(grid)
library(gridExtra)

The code block that causes the error is:

## Look for split read joining chr19 and chr22
lb <- linkedBins(r.161t)
is_19.22 <- as.character(seqnames(lb)) == "chr19" &
    as.character(seqnames(linkedTo(lb))) == "chr22"
r.161t2 <- r.161t[ is_19.22 ]
r.161t3 <- r.161t2[1] %>%
    fiveTo3List() %>%
    ## manual inspection
    "[["(1) %>%
    rearDataFrame(build="hg18")
r161.grob <- ggRearrange(r.161t3)
r161.grob <- update.reargraph(r161.grob)  ### This line is generating an error

r.172t <- rlist2[["CGOV172T"]]
lb <- linkedBins(r.172t)
is_10.10 <- as.character(seqnames(lb)) == "chr10" &
    as.character(seqnames(linkedTo(lb))) == "chr10"
r.172t2 <- r.172t[ is_10.10 ]
r.172t3 <- r.172t2[3] %>%
    fiveTo3List() %>%
    ## manual inspection
    "[["(1) %>%
    rearDataFrame(build="hg18")
r172.grob <- ggRearrange(r.172t3)
r172.grob <- update.reargraph(r172.grob)  ### This line is generating an error

I've pointed out the 2 lines where the code fails, both have to do with the update.reargraph() method. The individual figures generate, but not the composite.

I'm not entirely familiar with ggplot2 so any help would be greatly appreciated.

Lou_A
  • 249
  • 1
  • 11
  • As the error message says your code passes a `NULL` object to `ggplot_build` inside the function `update.reargraph. But without a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) it's impossible to figure out what's causing this issue. – stefan Oct 11 '22 at 19:21
  • I was afraid of that. The problem is that the data is too large to introduce here. I was hoping the code itself would reveal the problem. The best I can do is post the entire code. The only interesting observation I can offer is that everything works as expected up until the two lines I point that generates the error. I don't know enough ggplot2 to even begin to trace the problem. – Lou_A Oct 11 '22 at 19:45

0 Answers0