From a06d8982f281360ddbf5313dc4ee87a3c2e14ed5 Mon Sep 17 00:00:00 2001 From: dmalzl Date: Tue, 5 Aug 2025 10:48:56 +0200 Subject: [PATCH 1/2] add selectable weights --- src/cooler/cli/show.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cooler/cli/show.py b/src/cooler/cli/show.py index 43fc493..1476f7e 100644 --- a/src/cooler/cli/show.py +++ b/src/cooler/cli/show.py @@ -17,7 +17,10 @@ def get_matrix_size(c, row_region, col_region): return ncols * nrows -def load_matrix(c, row_region, col_region, field, balanced, scale): +def load_matrix(c, row_region, col_region, field, balanced, scale, weights): + if balanced and weights != 'weight': + balanced = weights + mat = c.matrix(balance=balanced, field=field).fetch(row_region, col_region) if scale == "log2": @@ -177,8 +180,11 @@ def update_heatmap(event): @click.option( "--field", default="count", show_default=True, help="Pixel values to display." ) +@click.option( + "--weights", default="weight", show_default=True, help="weight column to use when --balanced = True" +) def show( - cool_uri, range, range2, balanced, out, dpi, scale, force, zmin, zmax, cmap, field + cool_uri, range, range2, balanced, out, dpi, scale, force, zmin, zmax, cmap, field, weights ): """ Display and browse a cooler in matplotlib. @@ -222,7 +228,7 @@ def show( plt.get_current_fig_manager().set_window_title("Contact matrix") plt.title("") plt.imshow( - load_matrix(c, row_region, col_region, field, balanced, scale), + load_matrix(c, row_region, col_region, field, balanced, scale, weights), interpolation="none", extent=[col_lo, col_hi, row_hi, row_lo], vmin=zmin, From 60aafa2f55cde2a76fbdf89a9c52b899b5aa5d22 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 5 Aug 2025 08:56:33 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/cooler/cli/show.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cooler/cli/show.py b/src/cooler/cli/show.py index 1476f7e..b68ba02 100644 --- a/src/cooler/cli/show.py +++ b/src/cooler/cli/show.py @@ -20,7 +20,7 @@ def get_matrix_size(c, row_region, col_region): def load_matrix(c, row_region, col_region, field, balanced, scale, weights): if balanced and weights != 'weight': balanced = weights - + mat = c.matrix(balance=balanced, field=field).fetch(row_region, col_region) if scale == "log2":