Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified scaling.bins_pairs_by_distance to fix error thrown by narrow distance ranges. #152

Merged
merged 2 commits into from
Nov 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pairtools/lib/scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def bins_pairs_by_distance(
pairs_df, dist_bins, regions=None, chromsizes=None, ignore_trans=False
):

dist_bins = np.r_[dist_bins, np.iinfo(np.int64).max]
if regions is None:
if chromsizes is None:
chroms = sorted(
Expand Down Expand Up @@ -208,7 +209,7 @@ def bins_pairs_by_distance(
)

pairs_reduced_df["max_dist"] = np.where(
pairs_reduced_df["dist_bin_idx"] < len(dist_bins),
pairs_reduced_df["dist_bin_idx"] < len(dist_bins)-1,
dist_bins[pairs_reduced_df["dist_bin_idx"]],
np.iinfo(np.int64).max,
)
Expand All @@ -220,6 +221,8 @@ def bins_pairs_by_distance(
(pairs_reduced_df.chrom1 == pairs_reduced_df.chrom2)
& (pairs_reduced_df.start1 == pairs_reduced_df.start2)
& (pairs_reduced_df.end1 == pairs_reduced_df.end2)
& (pairs_reduced_df.min_dist > 0)
& (pairs_reduced_df.max_dist < np.iinfo(np.int64).max)
)

pairs_for_scaling_df = pairs_reduced_df.loc[pairs_for_scaling_mask]
Expand Down