From 3f4c69f19953c2dc03b5f6938aaa745959d4566b Mon Sep 17 00:00:00 2001 From: gfudenberg Date: Tue, 1 Feb 2022 15:44:36 -0800 Subject: [PATCH 1/6] fix-test_expected-after-bioframe-make_viewframe-name_style-update --- tests/test_expected.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_expected.py b/tests/test_expected.py index 31b0171d..936a158e 100644 --- a/tests/test_expected.py +++ b/tests/test_expected.py @@ -107,7 +107,7 @@ def _blocksum_asymm_dense(matrix, bad_bin_rows=None, bad_bin_cols=None): common_regions.append(reg1) common_regions.append(reg2) -view_df = bioframe.make_viewframe(common_regions) +view_df = bioframe.make_viewframe(common_regions, name_style='ucsc') def test_diagsum_symm(request): From 282b9f2d45735f08573bb73c28192ca4fc4334d4 Mon Sep 17 00:00:00 2001 From: gfudenberg Date: Tue, 1 Feb 2022 18:08:58 -0800 Subject: [PATCH 2/6] replace-at-with-loc-for-pandas-1.4.0 --- cooltools/api/eigdecomp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cooltools/api/eigdecomp.py b/cooltools/api/eigdecomp.py index 26d2f50c..5bc56ce0 100644 --- a/cooltools/api/eigdecomp.py +++ b/cooltools/api/eigdecomp.py @@ -471,9 +471,9 @@ def _each(region): # output table eigvec_table and eigvals_table for _region, _eigvals, _eigvecs in results: idx = bioframe.select(eigvec_table, _region).index - eigvec_table.at[idx, eigvec_columns] = _eigvecs.T + eigvec_table.loc[idx, eigvec_columns] = _eigvecs.T idx = bioframe.select(eigvals_table, _region).index - eigvals_table.at[idx, eigval_columns] = _eigvals + eigvals_table.loc[idx, eigval_columns] = _eigvals return eigvals_table, eigvec_table From 8ebeab573eb2de644b9203ac3a03ee1bb8aafbfe Mon Sep 17 00:00:00 2001 From: gfudenberg Date: Tue, 1 Feb 2022 18:09:28 -0800 Subject: [PATCH 3/6] first-index-before-groupby-for-pd-1.4.0 --- cooltools/sandbox/expected_smoothing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cooltools/sandbox/expected_smoothing.py b/cooltools/sandbox/expected_smoothing.py index cadd2276..7eaae476 100644 --- a/cooltools/sandbox/expected_smoothing.py +++ b/cooltools/sandbox/expected_smoothing.py @@ -214,7 +214,7 @@ def _agg_smooth_cvd( cvd, groupby, sigma_log10, window_sigma, points_per_sigma, cols=None ): if groupby: - cvd = cvd.groupby(groupby).apply( + cvd = cvd.set_index(groupby).groupby(groupby).apply( _smooth_cvd_group, sigma_log10=sigma_log10, window_sigma=window_sigma, From dbca0ff2d82dc92a53a18e9794590b6d85f315f3 Mon Sep 17 00:00:00 2001 From: Nezar Abdennur Date: Thu, 11 Aug 2022 12:52:39 -0400 Subject: [PATCH 4/6] Fix uninitialized binedges #361 --- cooltools/api/saddle.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cooltools/api/saddle.py b/cooltools/api/saddle.py index d04c4e5e..afd8f1a1 100644 --- a/cooltools/api/saddle.py +++ b/cooltools/api/saddle.py @@ -566,7 +566,7 @@ def saddleplot( saddledata, n_bins, vrange=None, - qrange=(0.0, 1.0), + qrange=None, cmap="coolwarm", scale="log", vmin=0.5, @@ -646,13 +646,13 @@ def __call__(self, x, pos=None): track_value_col = track.columns[3] track_values = track[track_value_col].values + if vrange is None and qrange is None: + qrange = (0.0, 1.0) digitized_track, binedges = digitize(track, n_bins, vrange=vrange, qrange=qrange) x = digitized_track[digitized_track.columns[3]].values.astype(int).copy() x = x[(x > -1) & (x < len(binedges) + 1)] hist = np.bincount(x, minlength=len(binedges) + 1) - if qrange is not None: - lo, hi = qrange - binedges = np.linspace(lo, hi, n_bins + 1) + lo, hi = binedges[0], binedges[-1] # Histogram and saddledata are flanked by outlier bins n = saddledata.shape[0] From 8dd9b7316841459d9cbfada58a0d2ca591e41bc0 Mon Sep 17 00:00:00 2001 From: Nezar Abdennur Date: Thu, 11 Aug 2022 13:13:51 -0400 Subject: [PATCH 5/6] Use value limits for vrange, use q limits for qrange --- cooltools/api/saddle.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cooltools/api/saddle.py b/cooltools/api/saddle.py index afd8f1a1..3d931235 100644 --- a/cooltools/api/saddle.py +++ b/cooltools/api/saddle.py @@ -566,7 +566,7 @@ def saddleplot( saddledata, n_bins, vrange=None, - qrange=None, + qrange=(0.0, 1.0), cmap="coolwarm", scale="log", vmin=0.5, @@ -646,13 +646,18 @@ def __call__(self, x, pos=None): track_value_col = track.columns[3] track_values = track[track_value_col].values - if vrange is None and qrange is None: - qrange = (0.0, 1.0) + # Digitize the track and calculate histogram digitized_track, binedges = digitize(track, n_bins, vrange=vrange, qrange=qrange) x = digitized_track[digitized_track.columns[3]].values.astype(int).copy() x = x[(x > -1) & (x < len(binedges) + 1)] hist = np.bincount(x, minlength=len(binedges) + 1) - lo, hi = binedges[0], binedges[-1] + + if vrange is not None: + lo, hi = vrange + if qrange is not None: + lo, hi = qrange + # Reset the binedges for plotting + binedges = np.linspace(lo, hi, n_bins + 1) # Histogram and saddledata are flanked by outlier bins n = saddledata.shape[0] From 8e8699d61db21d9ea2c356c26027e0bad3525539 Mon Sep 17 00:00:00 2001 From: gfudenberg Date: Fri, 12 Aug 2022 17:14:43 +0200 Subject: [PATCH 6/6] test-png-output-for-previous-bug --- tests/test_compartments_saddle.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_compartments_saddle.py b/tests/test_compartments_saddle.py index 69ef0681..d125aa62 100644 --- a/tests/test_compartments_saddle.py +++ b/tests/test_compartments_saddle.py @@ -158,6 +158,8 @@ def test_saddle_cli(request, tmpdir): "30", "--scale", "log", + "--fig", + "png", in_cool, f"{out_eig_prefix}.cis.vecs.tsv", out_expected,