Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow plotting of gates without data #62

Open
jacobpwagner opened this issue Feb 27, 2020 · 0 comments
Open

Allow plotting of gates without data #62

jacobpwagner opened this issue Feb 27, 2020 · 0 comments
Assignees

Comments

@jacobpwagner
Copy link
Member

Occasionally a use case arises where it is helpful to be able to plot gates using geom_gate without any underlying data present, just to visually inspect the gate definitions. However, this cannot be accomplished with the current ggcyto method framework without a bit of a hacky workaround. If you try providing a mapping without providing data (e.g. ggcyto(mapping=aes("FSC-H, "SSC-H")), the call ends up here because data=NULL:

ggcyto/R/fortify_fs.R

Lines 27 to 30 in 5ced2c1

fortify_fs.default <- function(model, data, ...) {
stop("ggcyto doesn't know how to deal with data of class ", class(model), call. = FALSE)
}

One workaround is to just give the ggcyto call a dummy flowFrame to work with, but we can't expect users to know to do this:

library(flowCore)
library(flowWorkspace)
library(CytoML)
library(ggcyto)
ws <- open_flowjo_xml(system.file("extdata", "manual.xml", package="flowWorkspaceData"))
gs <- flowjo_to_gatingset(ws, name=2, execute=FALSE)
gate <- gh_pop_get_gate(gs[[1]], "singlets")
dummy <- matrix(as.numeric(c(0,0)), nrow = 1, ncol = 2) # Needs at least one row bc of some min/max calls...
gate_dims <- colnames(gate@boundaries)
colnames(dummy) <- gate_dims
fr <- flowFrame(dummy)
ggcyto(fr, aes_(gate_dims[[1]], gate_dims[[2]])) + 
  geom_gate(gate) + 
  ggcyto_par_set(limits=list(x=c(0,max(gate@boundaries[,1])), y=c(0,max(gate@boundaries[,2]))))

plot_zoom_png

An easy first fix that would have minimal ramifications would be to make a function to wrap up similar logic to just plot a gate. Ideally, we could incorporate this in to the structure of the ggcyto call dispatch, but that requires more careful consideration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant