Skip to content

Pandas 2.3+ compatibility issue with homozygous diploid samples #255

@lixiang117423

Description

@lixiang117423

Summary

Smudgeplot crashes when analyzing homozygous diploid samples (no heterozygous k-mer pairs) with pandas 2.3+ due to strict type checking.

Environment

  • Smudgeplot: 0.5.4
  • Python: 3.14.2
  • Pandas: 2.3.3 (affects 2.3.0+)
  • OS: Linux

Steps to Reproduce

echo -e "covB\tcovA\tfreq" > empty_test.smu
smudgeplot all -o empty_test -cov 15.85 empty_test.smu

Error

AttributeError: Can only use .str accessor with string values!

Full details in attached: https://github.com/KamilSJaron/smudgeplot/files/xxxxx

Proposed Fix

Two-line fix in src/smudgeplot/smudgeplot.py:

1. Line 224: Add .astype({"structure": str})
2. Line 731: Add orient='index' parameter

See attached patch: https://github.com/KamilSJaron/smudgeplot/files/xxxxx

Testing

✅ Tested with real homozygous diploid (5.01% heterozygosity)
✅ Generates empty reports and plots correctly
✅ Backward compatible with pandas < 2.3

[ISSUE_TEMPLATE_pandas23_compatibility.md](https://github.com/user-attachments/files/26015008/ISSUE_TEMPLATE_pandas23_compatibility.md)
[pandas23_compat_fix.patch](https://github.com/user-attachments/files/26015007/pandas23_compat_fix.patch)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions