From 2f475dca08f47a60acc2beb8dd897e77b7495ca4 Mon Sep 17 00:00:00 2001 From: Chris Flerin Date: Tue, 9 Feb 2021 11:57:01 +0100 Subject: [PATCH] Fixes to avoid dask metadata mismatch error - Change computation fallback result to return the empty dataframe(s) instead of None - Handle special case where only 1 TF is present - Make the retry output more clear that it is a warning and not an error. --- arboreto/core.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arboreto/core.py b/arboreto/core.py index 3988db2..7e7cb25 100644 --- a/arboreto/core.py +++ b/arboreto/core.py @@ -311,6 +311,11 @@ def infer_partial_network(regressor_type, def fn(): (clean_tf_matrix, clean_tf_matrix_gene_names) = clean(tf_matrix, tf_matrix_gene_names, target_gene_name) + # special case in which only a single TF is passed and the target gene + # here is the same as the TF (clean_tf_matrix is empty after cleaning): + if clean_tf_matrix.size==0: + raise ValueError("Cleaned TF matrix is empty, skipping inference of target {}.".format(target_gene_name)) + try: trained_regressor = fit_model(regressor_type, regressor_kwargs, clean_tf_matrix, target_gene_expression, early_stop_window_length, seed) @@ -327,11 +332,11 @@ def fn(): else: return links_df - fallback_result = (None, None) if include_meta else None + fallback_result = (_GRN_SCHEMA, _META_SCHEMA) if include_meta else _GRN_SCHEMA return retry(fn, fallback_result=fallback_result, - warning_msg='infer_data failed for target {0}'.format(target_gene_name)) + warning_msg='WARNING: infer_data failed for target {0}'.format(target_gene_name)) def target_gene_indices(gene_names,