Replies: 1 comment
-
Hey J, You're almost there! The GatingStrategy and Session classes are different ways of doing similar things. The GatingStrategy class just holds the gates (and their hierarchy), compensation matrices, and transforms. It doesn't store samples but can be used to gate samples individually. The Session class couples a GatingStrategy with multiple samples that are bound to the Session via the It appears you are trying to use both, but you only need to choose one to use. Let's use the Session class. Here's how it would work: # Define transforms
xform = fk.transforms.LogicleTransform('logicle', param_t=262144, param_w=0.5, param_m=4.5, param_a=0)
# Define dimensions
dim_PerCP_a = fk.Dimension('PerCP-A', 'uncompensated',transformation_ref='logicle')
dim_NIR_a = fk.Dimension('LIVE DEAD NIR-A', 'uncompensated',transformation_ref='logicle')
# Define our gates
LiveImmune_vertices = [
[0.64,0.8],
[0.86, 0.8],
[0.64, 0.3],
[0.86, 0.3]
]
live_immune_gate = fk.gates.PolygonGate(
'LiveImmune',
[dim_PerCP_a, dim_NIR_a],
LiveImmune_vertices
)
# NOTE: you reference gates Cells1 & Cells2, but I didn't see them defined
# Let's assume they are already defined somewhere
# Create a Session, add our gate related objects and the sample
session = fk.Session()
# Add samples
session.add_sample(sample) # also assumes sample has been defined somewhere
# Add transforms (you would also add comp matrices in a similar way)
session.add_transform(xform)
# Add gates
g_strat.add_gate(cell_gate1, gate_path=('root',))
g_strat.add_gate(cell_gate2, gate_path=('root',))
g_strat.add_gate(live_immune_gate, gate_path=('root',))
# Analyze all samples (or just one by its sample_id reference)
session.analyze_samples()
# Retrieve gating results (which returns a GatingResults instance and that will contain a report)
gating_results = session.get_gating_results()
# If in a notebook, view the first few rows of the report (which is a pandas DataFrame)
gating_results.report.head() Basically, you never added the transform to the Session, but then went on to define a GatingStrategy (which was not needed). I could show the example with the GatingStrategy method if you want, but I'd use the Session class. Hope this helps and let me know how you get along, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a problem with gating:
I define the transformation:
xform = fk.transforms.LogicleTransform('logicle',param_t=262144,param_w=0.5,param_m=4.5,param_a=0)
Then, I define a gate:
Everything's fine until now...
But Here's the problem:
KeyError Traceback (most recent call last)
in <cell line: 1>()
----> 1 res = g_strat.gate_sample(sample)
1 frames
/usr/local/lib/python3.10/dist-packages/flowkit/_models/gating_strategy.py in _preprocess_sample_events(self, sample, gate, cache_events)
689 comp_ref = None
690
--> 691 xform = self.transformations[dim_xform[i]]
692
693 if cache_events:
KeyError: 'logicle'
What's the problem with the transformation?
Thank you for all your kind help!
J
Beta Was this translation helpful? Give feedback.
All reactions