This bug is a continuation of bug 113.
In the following example the call to as.ggplot() gives an error. Or rather, when
the result of as.ggplot(p2) gets evaluated by ggcyto:::print.ggcyto(), the implementation calls as.ggplot()
again, which then later results into error. The problems seems to be that as.ggplot() isn't idempotent, as
the result changes, if it is called multiple times.
library(ggcyto)
#> Loading required package: ggplot2
#> 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")
data(GvHD)
flow_set <- GvHD[1:3]
gating_set <- GatingSet(flow_set)
p2 <- ggcyto(gating_set, subset="root", aes(x = "FSC-H", y = "SSC-H")) + geom_hex()
p2

p2 |> class()
#> [1] "ggcyto_GatingSet" "ggcyto_flowSet" "ggcyto" "ggplot2::ggplot"
#> [5] "ggplot" "ggplot2::gg" "S7_object" "gg"
p2 |> as.ggplot() |> class()
#> [1] "ggcyto" "ggplot2::ggplot" "ggplot" "ggplot2::gg"
#> [5] "S7_object" "gg"
p2 |> as.ggplot() |> as.ggplot() |> class()
#> [1] "ggplot" "ggplot2::gg" "S7_object" "gg"
as.ggplot(p2)
#> Error in `UseMethod()`:
#> ! no applicable method for 'ggplot_build' applied to an object of class "c('ggplot', 'ggplot2::gg', 'S7_object', 'gg')"
Created on 2026-05-20 with reprex v2.1.1
I'm running R version 4.6.0.
packageVersion("ggplot2")
#> [1] '4.0.3'
packageVersion("ggcyto")
#> [1] '1.39.4'
Created on 2026-05-19 with reprex v2.1.1
This bug is a continuation of bug 113.
In the following example the call to
as.ggplot()gives an error. Or rather, whenthe result of
as.ggplot(p2)gets evaluated byggcyto:::print.ggcyto(), the implementation callsas.ggplot()again, which then later results into error. The problems seems to be that
as.ggplot()isn't idempotent, asthe result changes, if it is called multiple times.
Created on 2026-05-20 with reprex v2.1.1
I'm running R version 4.6.0.
Created on 2026-05-19 with reprex v2.1.1