Skip to content

fix: guard against empty data in plot_cnv_hmm_coverage_track#1307

Open
suhr25 wants to merge 2 commits intomalariagen:masterfrom
suhr25:fix/cnv-hmm-empty-data-crash
Open

fix: guard against empty data in plot_cnv_hmm_coverage_track#1307
suhr25 wants to merge 2 commits intomalariagen:masterfrom
suhr25:fix/cnv-hmm-empty-data-crash

Conversation

@suhr25
Copy link
Copy Markdown
Contributor

@suhr25 suhr25 commented Apr 17, 2026

SUMMARY

This PR fixes a crash in plot_cnv_hmm_coverage_track when filtering leaves no data. Instead of throwing an error, the function now safely returns None.

The change is small and limited to malariagen_data/anoph/cnv_data.py.


FIX

Before:

data = data.query("call_CN >= 0")

x_min = data["variant_position"].values[0]  # crashes if empty

After:

data = data.query("call_CN >= 0")

if len(data) == 0:
    return None

VERIFICATION

Run the function on a region where all HMM calls are filtered out. Previously, this caused a crash. Now, it returns None cleanly.
Normal cases still behave exactly the same.

Signed-off-by: Suhrid Marwah <suhridmarwah07@gmail.com>
@suhr25
Copy link
Copy Markdown
Contributor Author

suhr25 commented Apr 17, 2026

Hi @jonbrenas,
This PR fixes a crash in plot_cnv_hmm_coverage_track, kindly take a look.
Thanks!

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

Successfully merging this pull request may close these issues.

1 participant