Skip to content

Commit 4267ea6

Browse files
committed
MCQ TRAPI implementation
1 parent 5e4df67 commit 4267ea6

3 files changed

Lines changed: 359 additions & 185 deletions

File tree

cohd/cohd_trapi.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class TrapiStatusCode(Enum):
2727
UNSUPPORTED_ATTR_CONSTRAINT = 'UnsupportedAttributeConstraint'
2828
UNSUPPORTED_QUAL_CONSTRAINT = 'UnsupportedQualifierConstraint'
2929
UNSUPPORTED_SET_INTERPRETATION = 'UnsupportedSetInterpretation'
30+
MISSING_MEMBER_IDS = 'MissingMemberIDs'
3031

3132

3233
class CohdTrapi(ABC):
@@ -210,6 +211,28 @@ def criteria_confidence(cohd_result, confidence, threshold=CohdTrapi.default_ln_
210211
return True
211212

212213

214+
def criteria_mcq_score(cohd_result, threshold=CohdTrapi.default_ln_ratio_ci_thresohld):
215+
""" Checks the confidence interval of the result for significance using alpha. Only applies to observed-expected
216+
frequency ratio. Returns True for all other types of results.
217+
218+
Parameters
219+
----------
220+
cohd_result
221+
confidence
222+
threshold
223+
224+
Returns
225+
-------
226+
True if significant
227+
"""
228+
if 'ln_ratio_score' in cohd_result:
229+
# obsExpFreq
230+
return abs(cohd_result['ln_ratio_score']) >= threshold
231+
else:
232+
# Missing the score to filter on
233+
return False
234+
235+
213236
mappings_domain_ontology = {
214237
'_DEFAULT': ['ICD9CM', 'RxNorm', 'UMLS', 'DOID', 'MONDO']
215238
}
@@ -318,7 +341,7 @@ def sort_cohd_results(cohd_results, sort_field='ln_ratio_ci', ascending=False):
318341
if cohd_results is None or len(cohd_results) == 0:
319342
return cohd_results
320343

321-
if sort_field in ['p-value', 'ln_ratio', 'relative_frequency']:
344+
if sort_field in ['p-value', 'ln_ratio', 'relative_frequency', 'ln_ratio_score']:
322345
sort_values = [x[sort_field] for x in cohd_results]
323346
elif sort_field == 'ln_ratio_ci':
324347
sort_values = [score_cohd_result(x) for x in cohd_results]

0 commit comments

Comments
 (0)