FlowKit icon indicating copy to clipboard operation
FlowKit copied to clipboard

Issue when custom gates are childs of group gates

Open blabarthe1 opened this issue 2 years ago • 5 comments

Describe the bug When custom gates are childs of group gates attached to sample, the parent gate of custom gate cannot be founded and exception is thrown during wsp import. The exception is : Parent gate CD4+ not CD185-ext does not exist in the gating strategy flowkit/flowkit/_models/gating_strategy.py in add_gate(self, gate, gate_path) 106 if matched_parent_count == 0: 107 # TODO: need to double-check whether this scenario could be in a quadrant gate --> 108 raise ValueError("Parent gate %s does not exist in the gating strategy" % parent_gate_name) 109 elif matched_parent_count == 1: 110 # There's only one match for the parent, so we're done

The schema of wsp is : sample :

  • subpop1 owninggourp = 'group1'
    • subpop2 owninggourp = 'group1'
      • subpop3 owninggroup = '' -> exception parent gate subpop2 does not exist in gating strategy

Code To Reproduce Code to reproduce the behavior: the data can be founded here : https://flowrepository.org/experiments/606/download_ziped_files

import flowkit as fk
wsp_path = 'OMIP_PBMC_example.wsp'
fcs_paths = ['PBMC_control 1-4_cct.fcs']
sample_lists = [fk.Sample(str(f), ignore_offset_error=True) for f in fcs_paths]
session = fk.Session(sample_lists)
session.import_flowjo_workspace(
                wsp_path,
                ignore_missing_files=True
            )
...

Expected behavior Get parent gate in group gate

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Ubuntu 20.04
  • Python 3.8.8
  • FlowKit 0.8.2

Additional context OMIP_PBMC_example.zip

Add any other context about the problem here. Include traceback here

blabarthe1 avatar Mar 18 '22 14:03 blabarthe1

Baptiste,

Yes, this is a limitation in the current version, and I do plan on supporting this. The way custom sample gates in a sample group are saved in a WSP file is a bit strange...they basically have an empty string for the sample group assignment yet they do belong to a sample group.

A workaround for this that I use is to open the WSP in FlowJo and delete the sample group. FlowJo will then ask if you want to move the gates to the "All Samples" group. When that is done, all the gates become custom sample gates but because they are all in the "All Samples" group and not a reference to somewhere else, FlowKit will parse them.

I realize this is inconvenient, but it should work. I also use the opportunity when making one of these modded WSP files to remove any non-essential files (comp bead files, files w/ no gates, etc.). Just makes for a cleaner import of the data.

I'll mark this as a bug and leave it open, but it may be some time before I can fix it.

-Scott

whitews avatar Mar 18 '22 15:03 whitews

Scott,

I've applied the workaround and it's work. I'll try to script a sanity check before importing wsp that automatically remove group name when there is custom gates. Thanks a lot for your reply

Baptiste

blabarthe1 avatar Mar 18 '22 15:03 blabarthe1

Hi Scott,

Any updates on this bug?

Regards, Sridevi

srideviks avatar Aug 04 '22 16:08 srideviks

Hi Sridevi,

Yes, this is the big one for the upcoming 1.0 release and will make the FlowJo workspace support nearly complete, at least for reading in the wsp files. It's taking some time because of the complicated way these custom gates are stored in the XML tree & due to some FlowKit design decisions that were made early on. I'm currently refactoring a good chunk of the GatingStrategy class in preparation for this. I'm hopeful I can get this out sometime in September, depends on how many other projects I have.

-Scott

whitews avatar Aug 04 '22 19:08 whitews

Thanks Scott. I will use the work around till then:)

Regards, Sridevi

srideviks avatar Aug 04 '22 22:08 srideviks