From 2e22c2e786c5ca67fadc58de2a4a27a553f2530e Mon Sep 17 00:00:00 2001 From: OganM Date: Wed, 7 Aug 2024 22:26:31 -0700 Subject: [PATCH] previous fix for get_result_sets --- gemmapy/_processors.py | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/gemmapy/_processors.py b/gemmapy/_processors.py index 9b9e285..4a684b0 100644 --- a/gemmapy/_processors.py +++ b/gemmapy/_processors.py @@ -157,15 +157,15 @@ def add_missing(x): relevant_ids = [x for x in ids if not any(sub.list_in_list(x, baseline_ids))] - def get_factor_vals(x): - vals = sub.access_field(x,'values') + def get_factor_vals(y): + vals = sub.access_field(y,'values') out = sub.process_FactorValueValueObject_list(vals) - out.factor_ID = x.id - out.factor_category = x.category - out.factor_category_URI = x.category_uri + out.factor_ID = y.id + out.factor_category = y.category + out.factor_category_URI = y.category_uri return out - all_factors = pd.concat([get_factor_vals(x) for x in exp_factors]) + all_factors = pd.concat([get_factor_vals(y) for y in exp_factors]) @@ -239,8 +239,19 @@ def process_DifferentialExpressionAnalysisResultSetValueObject(d:list,api): size = len(contrast_id) experimental_factors = [sub.process_FactorValueValueObject(x) for x in non_control_factors] - + + factor_ID = x.experimental_factors[0].id + factor_category = x.experimental_factors[0].category + factor_category_URI = x.experimental_factors[0].category_uri + + def add_missing(x): + x.factor_ID = factor_ID + x.factor_category = factor_category + x.factor_category_URI = factor_category_URI + return x + experimental_factors = [add_missing(x) for x in experimental_factors] + baseline_factors = sub.process_FactorValueBasicValueObject(x.baseline_group) else: @@ -265,11 +276,16 @@ def process_DifferentialExpressionAnalysisResultSetValueObject(d:list,api): relevant_ids = [x for x in ids if not any(sub.list_in_list(x, baseline_ids))] - fac_vals = [sub.access_field(y,'values') for y in x.experimental_factors] - all_factors = pd.concat( - [sub.process_FactorValueValueObject_list(y) for y in fac_vals], - ignore_index = True - ) + def get_factor_vals(y): + vals = sub.access_field(y,'values') + out = sub.process_FactorValueValueObject_list(vals) + out.factor_ID = y.id + out.factor_category = y.category + out.factor_category_URI = y.category_uri + return out + + all_factors = pd.concat([get_factor_vals(y) for y in x.experimental_factors]) + baseline_factors = all_factors.loc[all_factors.ID.isin(baseline_ids)] experimental_factors = [