Skip to content

fix: preserve missing signal when clustering heatmaps - #1505

Open
rpinho wants to merge 1 commit into
deeptools:masterfrom
rpinho:fix-heatmap-preserve-missing
Open

rpinho wants to merge 1 commit into
deeptools:masterfrom
rpinho:fix-heatmap-preserve-missing

Conversation

@rpinho

@rpinho rpinho commented Nov 18, 2026 •

Copy link
Copy Markdown

Running plotHeatmap --hclust changes NaNs to zeros in the matrix written by --outFileNameMatrix.
Use a matrix with gaps in coverage and compare the values by region before and after clustering.
The patch substitutes zeros only in the arrays used to cluster rows and calculate distances.
The test matches rows by coordinates and name and compares every bin in the export with the input.

  • Does the PR contain new feature?
  • Does the PR contain bugfix?
  • Does the PR contain documentation changes?
  • Does the PR contain changes to the galaxy wrapper?
  • Does the PR title follow Conventional Commits?

🤖 Generated with Claude Code

https://claude.ai/code/session_01LKxc9GKLwnyeV2jaZBxH9N

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

Walkthrough

Heatmap clustering and silhouette calculations now replace NaNs with zeros for computation. A regression test checks that clustering preserves original region keys and values, including NaNs.

Changes: Heatmap clustering

Layer / File(s) Summary
NaN handling and output preservation
pydeeptools/deeptools/heatmapper.py, pydeeptools/deeptools/test/test_plotHeatmap.py
hmcluster and computeSilhouette replace NaNs with zeros for calculations. The regression test checks that clustered output retains original region keys and values, including NaNs.

Change: Bug fix

Merge Risk: Minimal · up to bd7ee

This fixes the case where missing values in the exported heatmap matrix became zeros during hierarchical clustering. The change is narrow and includes a regression test, so no actionable merge risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed Title follows Conventional Commits: type 'fix' is allowed, lowercase, colon present. It describes the main change: preserving missing (NaN) signal when clustering heatmaps.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed PR description is specific and relates to the changeset. It says plotHeatmap --hclust turns NaNs into zeros in the --outFileNameMatrix export. It says the patch replaces zeros only in clustering and d…
Full details: Description check

Explanation

PR description is specific and relates to the changeset. It says plotHeatmap --hclust turns NaNs into zeros in the --outFileNameMatrix export. It says the patch replaces zeros only in clustering and distance arrays. It also describes the new test, which compares exported bins by region with the input.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
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