RGLab / CytoML

A GatingML Interface for Cross Platform Cytometry Data Sharing
GNU Affero General Public License v3.0
29 stars 14 forks source link

error when subsetting in flowjo_to_gatingset #99

Open masato-ogishi opened 4 years ago

masato-ogishi commented 4 years ago

Hi again,

When I tried to wirte an wrapper function, it gave me error of " invalid 'subset' argument!" gs_list <- pbapply::pblapply( FCSfilenames, function(f){ CytoML::flowjo_to_gatingset( wsp, path=path, subset=f, includeGates=T, transform=T ) } )

I believe this is a matter of environment within the function, because if I prepared the f variable by f <- "real path to the FCS file.fcs", it worked as expected.

I think the code within the CytoML::flowjo_to_gatingset is the source of this bug. subset <- try(eval(substitute(subset)), silent = TRUE)

The correct code is perhaps: subset <- try(eval(substitute(subset, env=parent.frame())), silent = TRUE)

Can you kindly fix this? Because on my PC actually I couldn't compile the package even when I forked the same repository...

Thanks a lot!

Masato

jacobpwagner commented 4 years ago

@masato-ogishi , after https://github.com/RGLab/CytoML/commit/93a1d64f43f1cf97c63735df40c94d9f28221dfd you should now be able to use the subset argument filter based on an expression that utilizes keywords stored in the workspace, as was documented before. You will need to also include the relevant keywords in the keywords argument. For example:

library(flowCore)
library(flowWorkspace)
library(CytoML)

dataDir <- system.file("extdata",package="flowWorkspaceData")
wsfile <- list.files(dataDir, pattern="manual.xml",full=TRUE)

ws <- open_flowjo_xml(wsfile);
gs <- flowjo_to_gatingset(ws, path = dataDir, name = 4
                          , subset = CYTNUM == "H79900001"
                          , keywords = "CYTNUM")

You cannot pass an arbitrary function in to the subset arg, however. If you need the function to use outside information to determine which indices or sample names should be included, you can always evaluate that result and pass in a character or numeric vector to subset.

If you encounter any more issues, I'm happy to help troubleshoot.

masato-ogishi commented 4 years ago

Thank you so much!