open2c / pairtools

Extract 3D contacts (.pairs) from sequencing alignments
MIT License
104 stars 32 forks source link

Error when computing scalings using a narrow distance range #150

Closed itsameerkat closed 2 years ago

itsameerkat commented 2 years ago

I'm using pairtools.lib.scaling.compute_scaling from the latest master branch (SHA: 1e8d518) to create interaction decay curves from pairs files.

When I use the default value of the keyword argument dist_range, the function runs without errors but if I choose a distance range that is narrower e.g. dist_range=(int(1e1), int(1e6)), I get the following error:

Screen Shot 2022-11-07 at 5 14 55 PM

The error seems easy enough to fix: append np.inf to the end of dist_bins array provided to bins_pairs_by_distance and change this line in scaling.py from pairs_reduced_df["dist_bin_idx"] < len(dist_bins), to pairs_reduced_df["dist_bin_idx"] < len(dist_bins) - 1,

Thoughts? I'm happy to create a pull request with these changes.

agalitsyna commented 2 years ago

Sounds reasonable. Yeah, PR is welcome, thanks!