flowGate vs. new ggplot2/ggcyto

With the new ggplot2 version 4 switching to S7 internals, ggcyto broke. With ggcyto now fixed in devel, checked to see if flowGate is still working and encountered a couple issues.

Getting Started

Package Versions

packageVersion("ggplot2")
[1] '4.0.2'
packageVersion("ggcyto")
[1] '1.39.1'
packageVersion("flowGate")
[1] '1.10.0'

Load via library()

library(ggplot2)
library(ggcyto)
Loading required package: flowCore
Loading required package: ncdfFlow
Loading required package: BH
Loading required package: flowWorkspace
As part of improvements to flowWorkspace, some behavior of
GatingSet objects has changed. For details, please read the section
titled "The cytoframe and cytoset classes" in the package vignette:

  vignette("flowWorkspace-Introduction", "flowWorkspace")
library(flowGate)

Load to Gating Set

# Loading internal .fcs files
path_to_fcs <- system.file("extdata", package = "flowGate")
fs <- read.flowSet(path = path_to_fcs,
   pattern = ".FCS$", full.names = TRUE)
gs <- GatingSet(fs)

Launch Attempt

flowGate::gs_gate_interactive(gs, "TestGate1", dims=list("FSC-H", "SSC-H"))

Upon attempted launch, results in the following error within the ShinyApp:


And the following output to the console:

Upstream Changes to ggplot2 and ggcyto

ggplot2 in it’s rollout to version 4 switched to using S7 internals. This caused some breaking changes to ggcyto, that were initially addressed here.

These changes however left the as.ggplot() function broken. These were subsequently patched here and finally here in ggcyto.

flowGate hotspots

In my flowGate fork, the main areas driving the shinyApp to error out appear to be:

With the changes to ggcyto, there appears to be a residual “ggcyto_GatingSet” class present that when passed to as.ggplot() is causing dispatch issues and causing the error out. Similar to what was done in the initial attempted ggcyto fix, I updated the code removed this class designation. Once this is done, as.ggplot() works again, and the ShinyApp launches successfully.

After gates were drawn, and done clicked, additional errors were outputed with colnames not found. This appears to be due to a ggplot2 internal change. When I updated the code as shown below, the X and Y axis names were retrieved, and new gates were correctly saved to the GatingSet object, and could be visualized as well.

Unit Tests

Wrote some additional unit test using testthat and vdiffr for the functions affected. These can be found here