@@ -75,6 +75,16 @@ def _process_results(self):
7575
7676 self .report = df .sort_values (['sample' , 'level' , 'gate_name' ])
7777
78+ def _filter_gate_report (self , gate_name , gate_path = None ):
79+ results = self .report [(self .report ['sample' ] == self .sample_id ) & (self .report ['gate_name' ] == gate_name )]
80+
81+ if gate_path is not None :
82+ results = results [results .gate_path == gate_path ]
83+ elif len (results ) > 1 :
84+ raise ValueError ("Gate name %s is ambiguous, specify the full gate path" )
85+
86+ return results
87+
7888 def get_gate_membership (self , gate_name , gate_path = None ):
7989 """
8090 Retrieve a boolean array indicating gate membership for the events in the GatingResults sample.
@@ -108,45 +118,39 @@ def get_gate_membership(self, gate_name, gate_path=None):
108118 else :
109119 raise ValueError ("Report as bug: The gate %s appears to have multiple quadrant parents." % gate_name )
110120
111- def get_gate_count (self , gate_name ):
121+ def get_gate_count (self , gate_name , gate_path = None ):
112122 """
113123 Retrieve event count for the specified gate ID for the gating results sample
114124
115125 :param gate_name: text string of a gate name
126+ :param gate_path: tuple of ancestor gate names
116127 :return: integer count of events in gate ID
117128 """
118- results = self .report [(self .report ['sample' ] == self .sample_id ) & (self .report ['gate_name' ] == gate_name )]
119-
120- if len (results ) > 1 :
121- raise NotImplementedError ("Gate ID %s is ambiguous and gate_path is not yet implemented for this method" )
129+ results = self ._filter_gate_report (gate_name , gate_path = gate_path )
122130
123131 return results ['count' ].values [0 ]
124132
125- def get_gate_absolute_percent (self , gate_name ):
133+ def get_gate_absolute_percent (self , gate_name , gate_path = None ):
126134 """
127135 Retrieve percent of events, relative to the total sample events, of the specified gate ID for the
128136 gating results sample
129137
130138 :param gate_name: text string of a gate name
139+ :param gate_path: tuple of ancestor gate names
131140 :return: floating point number of the absolute percent
132141 """
133- results = self .report [(self .report ['sample' ] == self .sample_id ) & (self .report ['gate_name' ] == gate_name )]
134-
135- if len (results ) > 1 :
136- raise NotImplementedError ("Gate ID %s is ambiguous and gate_path is not yet implemented for this method" )
142+ results = self ._filter_gate_report (gate_name , gate_path = gate_path )
137143
138144 return results ['absolute_percent' ].values [0 ]
139145
140- def get_gate_relative_percent (self , gate_name ):
146+ def get_gate_relative_percent (self , gate_name , gate_path = None ):
141147 """
142148 Retrieve percent of events, relative to parent gate, of the specified gate ID for the gating results sample
143149
144150 :param gate_name: text string of a gate name
151+ :param gate_path: tuple of ancestor gate names
145152 :return: floating point number of the relative percent
146153 """
147- results = self .report [(self .report ['sample' ] == self .sample_id ) & (self .report ['gate_name' ] == gate_name )]
148-
149- if len (results ) > 1 :
150- raise NotImplementedError ("Gate ID %s is ambiguous and gate_path is not yet implemented for this method" )
154+ results = self ._filter_gate_report (gate_name , gate_path = gate_path )
151155
152156 return results ['relative_percent' ].values [0 ]
0 commit comments