SigProfilerMatrixGenerator icon indicating copy to clipboard operation
SigProfilerMatrixGenerator copied to clipboard

SigProfilerMatrixGenerator: SciPy version 1.12.0 removed binom_test, so matrix generation run crashes

Open toddajohnson opened this issue 11 months ago • 7 comments

I just updated the SigProfiler packages, and the update installed the latest SciPy 1.12.0. When running SigProfilerMatrixGenerator, it eventually crashed because the SciPy stats function binom_test, which was previously deprecated with a warning from SciPy 1.10.0, has been removed and replaced. The crash trace ended with: AttributeError: module 'scipy.stats' has no attribute 'binom_test'. Did you mean: 'binomtest'?

I suppose the installation requirements need to be modified to scipy>=1.1.0,<1.12.0 in place of scipy>=1.1.0

toddajohnson avatar Mar 08 '24 08:03 toddajohnson

Hi @toddajohnson,

Thanks for letting us know that as of SigProfilerMatrixGenerator v1.2.25 that SciPy 1.12.0 breaks the code. We will look into updating this dependency.

mdbarnesUCSD avatar Mar 08 '24 17:03 mdbarnesUCSD

Hello,

Just wanted to say I also am experiencing this issue. I think changing all instances of binom_test to binomtest should do it.

image

Thanks!

mattjmeier avatar Mar 13 '24 15:03 mattjmeier

I guess the added complexity is that they also changed the syntax a bit.

So instead of [successes, failures] it needs to be [successes, trials]

For example:

pval = stats.binom_test(
    [
        current_tsb.loc[mut_type][sample],
        current_tsb.loc["U:" + mut_type[2:]][sample],
    ]
)

instead becomes:

pval = stats.binomtest(
    current_tsb.loc[mut_type][sample],
    n=current_tsb.loc[mut_type][sample] + current_tsb.loc["U:" + mut_type[2:]][sample],
)

Noting that it's no longer an array, and the n keyword is required (I think)

I'm going through my virtual environment and fixing them, seems to work so far

mattjmeier avatar Mar 13 '24 16:03 mattjmeier

One more issue is that, at least in some edge cases, there are going to be 0s for sparse data where not every mutation subtype is getting sampled. I don't know how/if this was handled before, but now it throws an error when n is 0.

mattjmeier avatar Mar 13 '24 19:03 mattjmeier

Hi @mdbarnesUCSD , have you had any luck looking into this? I think any new installs of the software are going to be broken, unless someone has a workaround that I'm not finding. Is it possible to roll back the version in setup.py as a quick fix as suggested by @toddajohnson ?

mattjmeier avatar Mar 27 '24 13:03 mattjmeier

Our cluster just got upgraded to new OS, compilers, and installed module programs, meaning that I had to re-install everything I've been using. Others noted that they only had luck with Python 3.8, but the installed python on the new infrastructure is 3.12. Nevertheless, the following installed successfully on our v100 nodes and I have run SigProfilerExtractor on multiple tumor types on nodes with 4 gpus and 12 cpus assigned per run, and they have not thrown any errors: cd ~/tools; python3 -m venv sigprofiler_x86_64_v100; source ${HOME}/tools/sigprofiler/sigprofiler_x86_64_v100/bin/activate; python3 -m pip install --upgrade pip; pip install torch torchvision torchaudio pandas==1.5.3 scipy==1.11.4; pip install SigProfilerExtractor

For non-gpu nodes i replaced last two lines with: pip install SigProfilerExtractor pandas==1.5.3 scipy==1.11.4

@mdbarnesUCSD, if using python 3.12.0 was an extremely bad idea, please let me know.

toddajohnson avatar Mar 27 '24 13:03 toddajohnson

Thanks for that information! I appreciate it. Nice simple solution. I'll try this workaround in our environment until a permanent fix is available.

mattjmeier avatar Mar 27 '24 15:03 mattjmeier

Hi both,

There may be some issues that crop up due to dependency requirements and deprecations. We mostly test with Python 3.11, so if you come across any issues with Python 3.12 and newer please reach out.

Thanks for reaching out with the details in regards to the issues with binom_test. The v1.2.26 (pull #180) update should resolve these issues.

mdbarnesUCSD avatar Apr 25 '24 20:04 mdbarnesUCSD

Thanks @mdbarnesUCSD ! I'll let you know when we've tested it out.

mattjmeier avatar Apr 26 '24 19:04 mattjmeier