bcgsc / ntJoin

🔗Genome assembly scaffolder using minimizer graphs
GNU General Public License v3.0
82 stars 15 forks source link

Mann-Kendall gives error with Numpy 1.24 #94

Closed COMInterop closed 1 year ago

COMInterop commented 1 year ago

Hello,

I have found some nice results with ntJoin, but now I find that 'mkt=True' throws this error:

Traceback (most recent call last):

  File "/Users/cmccabe/miniconda3/bin/share/ntjoin-1.1.1-0/bin/ntjoin_assemble.py", line 1115, in <module>

    main()

  File "/Users/cmccabe/miniconda3/bin/share/ntjoin-1.1.1-0/bin/ntjoin_assemble.py", line 1112, in main

    Ntjoin().main()

  File "/Users/cmccabe/miniconda3/bin/share/ntjoin-1.1.1-0/bin/ntjoin_assemble.py", line 1091, in main

    paths, incorporated_segments = self.find_paths(graph)

  File "/Users/cmccabe/miniconda3/bin/share/ntjoin-1.1.1-0/bin/ntjoin_assemble.py", line 456, in find_paths

    paths = [self.find_paths_process(component) for component in components]

  File "/Users/cmccabe/miniconda3/bin/share/ntjoin-1.1.1-0/bin/ntjoin_assemble.py", line 456, in <listcomp>

    paths = [self.find_paths_process(component) for component in components]

  File "/Users/cmccabe/miniconda3/bin/share/ntjoin-1.1.1-0/bin/ntjoin_assemble.py", line 431, in find_paths_process

    ctg_path = self.format_path(path, self.args.s,

  File "/Users/cmccabe/miniconda3/bin/share/ntjoin-1.1.1-0/bin/ntjoin_assemble.py", line 330, in format_path

    ori = self.determine_orientation(positions)

  File "/Users/cmccabe/miniconda3/bin/share/ntjoin-1.1.1-0/bin/ntjoin_assemble.py", line 181, in determine_orientation

    mkt_result = mk.original_test(positions)

  File "/Users/cmccabe/miniconda3/lib/python3.9/site-packages/pymannkendall/pymannkendall.py", line 248, in original_test

    x, c = __preprocessing(x_old)

  File "/Users/cmccabe/miniconda3/lib/python3.9/site-packages/pymannkendall/pymannkendall.py", line 19, in __preprocessing

    x = np.asarray(x).astype(np.float)

  File "/Users/cmccabe/miniconda3/lib/python3.9/site-packages/numpy/__init__.py", line 284, in __getattr__

    raise AttributeError("module {!r} has no attribute "

AttributeError: module 'numpy' has no attribute 'float'

make: *** [/Users/cmccabe/miniconda3/bin/share/ntjoin-1.1.1-0/ntJoin:227: pr-2.4.fa.k32.w1000.n1.assigned.scaffolds.fa] Error 1

I read that this relates to the deprecation of the numpy.float alias in recent versions of numpy.

I do not know what this means, so I downgraded to numpy 1.19.5 (and python 3.9.5), and now I can use the mkt flag again.

I am not sure if, for my purpose, Mann-Kendall is worth the trouble. In this SyRI plot the reference is middle, mkt=true is at top, and mkt=false at bottom. I think I prefer the smaller inversion seen at right.

Captura de Pantalla 2023-01-28 a la(s) 19 29 24

But I thought you might like to know about the bug. It seems to have arisen when Python updated to 3.10.

While I have your attention I will also mention that I find setting 'overlap=True' results in the loss of 140 BUSCO genes.

Thank you for the nice tool and good day.

lcoombe commented 1 year ago

Hello @paracontias,

Thanks very much for the information and the report! I'll take a look to see what's causing that issue with the newer numpy version and update when I have a resolution.

For what it's worth, I agree - by default we don't generally use the Mann-Kendall test for orienting contigs in our ntJoin runs either. The more naive logic works fairly well and is much faster. It's really interesting to see your results - I'm glad that you're seeing some good results with our tool.

Thank you for your interest and support of ntJoin! Lauren

lcoombe commented 1 year ago

Hello again @paracontias,

I looked into it, and the issue is in the pymannkendall dependency. There was a reported error in that GitHub repository related to numpy 1.24.0+ (https://github.com/mmhs013/pyMannKendall/issues/27). The newest pymannkendall release (v1.4.3) includes a fix for newer numpy versions, but it just hasn't made its way to the conda recipe yet. I do see a PR open (https://github.com/conda-forge/pymannkendall-feedstock/pull/4) for updating the recipe, so it should just be a matter of time before the version is updated in conda, and the issue should be fixed.

Thanks again for the report! Lauren