Skip to content

Commit

Permalink
Fixes to avoid dask metadata mismatch error
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
cflerin committed Feb 9, 2021
1 parent e2ec203 commit 2f475dc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions arboreto/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand Down

0 comments on commit 2f475dc

Please sign in to comment.