Skip to content

Retain gate names as IDs when converting FlowJo workspace to GatingML #69

Description

@whitews

I'm using CytoML to convert FlowJo workspaces to GatingML 2.0. However, somewhere in the process, the gate names that are present in the FlowJo workspace get converted to what appears like automatically incremented gate IDs. This makes it difficult to track the original meaning of the gates in the hierarchy.

For example, here is a gate in the original FJ workspace:

<Polygon name="FSC-A, SSC-A subset" bounds="139,51,256,236" editable="0" selected="1" gateBitID="1" lineColor="Transparent" lineArrow="None" xAxisName="FSC-A" yAxisName="SSC-A" annotationOffset="42,-37">
    <Polygon>
    <Vertex x="2.416640043258667e5" y="76800" />
    ...
    </Polygon>
    </Polygon>
</PolygonGate>

And the resulting GatingML gate:

<gating:PolygonGate gating:id="gate_1_1">
    <gating:dimension gating:compensation-ref="Spill_defaultCompensation">
      <data-type:fcs-dimension data-type:name="FSC-A"/>
    </gating:dimension>
    <gating:dimension gating:compensation-ref="Spill_defaultCompensation">
      <data-type:fcs-dimension data-type:name="SSC-A"/>
    </gating:dimension>
    <gating:vertex>
    ...
</gating:PolygonGate>

You can see that the gate name "FSC-A, SSC-A subset" gets converted to a gate ID of "gate_1_1".

Here is the code I am using for the conversion:

library(flowWorkspace)
library(CytoML)
library(flowUtils)

fcs_dir = "/path/to/flow_data"
setwd(fcs_dir)

path <- system.file("", package="flowWorkspaceData");
wsfile <- list.files(fcs_dir, pattern="flowjo_workspace.xml", full=TRUE)
ws <- open_flowjo_xml(wsfile)

gs_chx <- parseWorkspace(ws, name='CHX')

# create empty flowEnv
flowEnv <- new.env(parent = emptyenv())
res <- CytoML:::export_comp_trans(
    gs_chx, 
    flowEnv, 
    cytobank.default.scale=FALSE, 
    type="cytobank"
)
# export gates
CytoML:::export_gates_cytobank(
    gs_chx, 
    flowEnv, 
    res[["trans.Gm2objs"]], 
    res[["trans"]], 
    res[["compId"]], 
    showHidden=FALSE
)

write.gatingML(flowEnv, 'gml_output.xml')

Is there any way to retain the original names in the GatingML file? I know the gate names are repeated in the FlowJo workspace because of multiple samples & sample groups, but it seems the automatically incremented gate IDs could be concatenated with the original names to ensure their uniqueness and retain their context in the gating hierarchy. Or, even better would be to only perform the concatenation if non-unique names are found in the resulting GatingML output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions