nloyfer / wgbs_tools

tools for working with Bisulfite Sequencing data while preserving reads intrinsic dependencies
Other
134 stars 37 forks source link

beta_to_table: np.float deprecated in NumPy>=1.20 #72

Closed ssj1739 closed 6 months ago

ssj1739 commented 6 months ago

Hi Netanel,

We've been trying to use beta_to_table to check on a new set of blocks we generated, and are running into issues with the latest version of wgbstools beta_to_table, with the following error:

File ".../wgbs_tools-0.2.2/src/python/dmb.py", line 28, in load_uxm
    return r.astype(np.float)
                    ^^^^^^^^
  File ".../miniconda3/lib/python3.12/site-packages/numpy/__init__.py", line 324, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError:` module 'numpy' has no attribute 'float'.
AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.

When I tried to modify the return r.astype(np.float) to return r.astype(np.float64), that seemed to work, but then ran into another KeyError in get_table:

File ".../wgbs_tools-0.2.2/src/python/beta_to_table.py", line 137, in beta2table_generator
    yield get_table(subset_blocks, gf, min_cov, threads, verbose)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../wgbs_tools-0.2.2/src/python/beta_to_table.py", line 103, in get_table
    np.concatenate([dres[k][None, :] for k in gf['fname'][gf['group'] == ugroup]]), axis=0).T
                    ~~~~^^^
KeyError: '<basename of sample lbeta file>'

Any ideas how to resolve these errors?

Thanks, Sid (Georgetown U.)

nloyfer commented 6 months ago

Hi Sid :) The np.float error is indeed trivial to fix, but I think the more important bug you caught was that beta_to_table can't handle lbeta files! You should have never reached that part of the code (load_uxm method). Anyway, I fixed it (commit 1709918). Thanks for this issue. Let me know if anything else goes wrong.

ssj1739 commented 5 months ago

Thanks Netanel! And congrats on the pre-print, best of luck!