whitews / FlowKit

A Python toolkit for flow cytometry analysis supporting GatingML and FlowJo workspaces
https://flowkit.readthedocs.io
BSD 3-Clause "New" or "Revised" License
153 stars 38 forks source link

Non-rectangular gates introduce errors in get_analysis_report() #194

Closed nettilor closed 4 months ago

nettilor commented 4 months ago

Hi!

I was loading a FlowJo workspace and using analyze_samples() and then get_analysis_report() to get counts out of my FlowJo file. I noticed rectangular gates report the events that fall into the gate correctly but for other gates (I tried ellipses and polygons) the events that Flowkit assigns to the gates are always less than FlowJo.

See screenshot here, I used the 8_color_data_set. FlowJo counts and Flowkit counts from get_analysis_report() do not match

SCR-20240428-ljjn

Edit: this also happens if you just try to read the file 8_color_ICS_with_ellipse.wsp included in the dataset. For the non-rectangular gates the counts won't match

Thank you for your work!

Some more info if useful:

whitews commented 4 months ago

Hi @nettilor

Yes, this is due to FlowJo applying gates on binned data instead of the actual event data. It does this for polygon and ellipse gates but the rectangular gates (and simple line thresholds) use the event data b/c it is easier to calculate. FlowKit uses the event data for all gates without binning. I wrote a more detailed explanation here:

https://github.com/whitews/FlowKit/issues/113

Hope that clarifies what is happening, Scott

nettilor commented 4 months ago

Yes! thank you!