Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to plot jaccard and region_type 'Axes' object is not subscriptable error leads to malformed file output #12

Open
byee4 opened this issue Jan 19, 2025 · 2 comments

Comments

@byee4
Copy link
Member

byee4 commented Jan 19, 2025

I think there is a bug near or at this line:

print('Fail to plot jaccard and region_type', e)

It seems to be causing incomplete file creation for some RBPs, and I'm not sure yet what is different about these RBPs than others, but it ends up creating a partial file (attachment)

errored_windows.txt

@byee4
Copy link
Member Author

byee4 commented Jan 21, 2025

Just kidding. I think changing "ax" to "axes" fixes the error, but the bad files still remain

ax[0].legend(bbox_to_anchor=(1,1))
ax[1].legend(bbox_to_anchor=(1,1))

@byee4
Copy link
Member Author

byee4 commented Jan 22, 2025

For some reason I don't understand, these RBPs fail the masking step and thus do not have any windows to output (enriched_windows is an empty DataFrame). Do you think adding a shape[0] > 0 check would simply fix the error?

As in, replace these lines:

except Exception as e:
print('Fail to plot jaccard and region_type', e)
# ====== Generate Output ======
# --- output by individual RBP ---
columns = ['chrom', 'start', 'end', 'name', 'score',
'strand', 'feature_id', 'feature_bin', 'feature_type_top',
'feature_types', 'gene_name', 'gene_id', 'transcript_ids',
'gene_type_top', 'transcript_type_top', 'gene_types',
'transcript_types','logLR', 'BF_assignment',]
# output per RBP enrich windows
for c in anno.columns:
enriched_windows = data_bf_dmm_masked.loc[data_bf_dmm_masked[c], columns]
enriched_windows['p_bar']=p_bar[c]
enriched_windows['p_raw']=p_raw[c]
enriched_windows['fc_raw']=fc_raw[c]
enriched_windows['fc_bar']=fc_bar[c]
enriched_windows['p_bar_std']=std_bar[c]
enriched_windows.to_csv(basedir / 'DMM'/ f'{c}.enriched_windows.tsv', sep = '\t')
print(f'found {c} enriched windows:', enriched_windows.shape)

with this?

    except Exception as e:
        print('Fail to plot jaccard and region_type', e)

    # ====== Generate Output ======
    # --- output by individual RBP ---
    columns = ['chrom', 'start', 'end', 'name', 'score',
    'strand', 'feature_id', 'feature_bin', 'feature_type_top',
    'feature_types', 'gene_name', 'gene_id', 'transcript_ids',
    'gene_type_top', 'transcript_type_top', 'gene_types',
    'transcript_types','logLR', 'BF_assignment',]
    # output per RBP enrich windows

    for c in anno.columns:
        enriched_windows = data_bf_dmm_masked.loc[data_bf_dmm_masked[c], columns]
        if enriched_windows.shape[0] > 0:
            enriched_windows['p_bar']=p_bar[c]
            enriched_windows['p_raw']=p_raw[c]
            enriched_windows['fc_raw']=fc_raw[c]
            enriched_windows['fc_bar']=fc_bar[c]
            enriched_windows['p_bar_std']=std_bar[c]
        enriched_windows.to_csv(basedir / 'DMM'/ f'{c}.enriched_windows.tsv', sep = '\t')
        print(f'found {c} enriched windows:', enriched_windows.shape)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant