open2c / pairtools

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

Scaling by pairs error #240

Open DekkerBastiaan opened 2 months ago

DekkerBastiaan commented 2 months ago

Hi,

While running scaling by pairs I ran into the following error.

File ~/miniconda3/envs/tools/lib/python3.10/site-packages/pairtools/lib/scaling.py:54, in (.0) def assign_regs(chroms, pos, regs): gb_regs = regs.sort_values(["chrom", "start", "end"]).groupby(["chrom"]) regs_dict = { ---> chrom.encode(): regs_per_chrom[["start", "end"]] .values.flatten() .astype(np.int64) for chrom, regs_per_chrom in gb_regs } return assign_regs_c(np.asarray(chroms).astype("bytes"), np.asarray(pos), regs_dict) AttributeError: 'tuple' object has no attribute 'encode'

Perhaps it is due to how my regions dataframe was constructed, but the following change at the groupby function did fix the issue.

regs.sort_values(["chrom", "start", "end"]).groupby(["chrom"])

regs.sort_values(["chrom", "start", "end"]).groupby("chrom")

Let me know if this this is due to my regions formatting or if others will have the same problem.

golobor commented 2 months ago

Hi Bastiaan, Thank you for the report! Is there any chance you could submit this fix as a PR? :)

On Thu, May 9, 2024, 19:50 DekkerBastiaan @.***> wrote:

Hi,

While running scaling by pairs I ran into the following error.

File ~/miniconda3/envs/tools/lib/python3.10/site-packages/pairtools/lib/scaling.py:54, in (.0) def assign_regs(chroms, pos, regs): gb_regs = regs.sort_values(["chrom", "start", "end"]).groupby(["chrom"]) regs_dict = { ---> chrom.encode(): regs_per_chrom[["start", "end"]] .values.flatten() .astype(np.int64) for chrom, regs_per_chrom in gb_regs } return assign_regs_c(np.asarray(chroms).astype("bytes"), np.asarray(pos), regs_dict) AttributeError: 'tuple' object has no attribute 'encode'

Perhaps it is due to how my regions dataframe was constructed, but the following change at the groupby function did fix the issue.

regs.sort_values(["chrom", "start", "end"]).groupby(["chrom"])

regs.sort_values(["chrom", "start", "end"]).groupby("chrom")

Let me know if this this is due to my regions formatting or if others will have the same problem.

— Reply to this email directly, view it on GitHub https://github.com/open2c/pairtools/issues/240, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG64CS2K35AWHYHXJLMQ7TZBOZPFAVCNFSM6AAAAABHPHKVPOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI4DQMJXGU2DSMA . You are receiving this because you are subscribed to this thread.Message ID: @.***>