BaselAbujamous / clust

Automatic and optimised consensus clustering of one or more heterogeneous datasets
Other
160 stars 35 forks source link

AttributeError: Module 'scipy' has no attribute 'random' #77

Closed gazalk closed 1 year ago

gazalk commented 2 years ago

Hello,

I was wondering if you've encountered anything like this. Going through stackoverflow and similar github issues, this seems to me like a versioning issue of scipy. Please let me know if you have any idea how to fix it. Thank you very much!

Gazal

gazal@delllaptop:~/Documents/PSU_work/transcriptomics$ clust data/ -r replicates_metadata.txt 

/===========================================================================\
|                                   Clust                                   |
|    (Optimised consensus clustering of multiple heterogenous datasets)     |
|           Python package version 1.17.0 (2022) Basel Abu-Jamous           |
+---------------------------------------------------------------------------+
| Analysis started at: Thursday 11 August 2022 (17:48:23)                   |
| 1. Reading dataset(s)                                                     |
| 2. Data pre-processing                                                    |
|  - Automatic normalisation mode (default in v1.7.0+).                     |
|    Clust automatically normalises your dataset(s).                        |
|    To switch it off, use the `-n 0` option (not recommended).             |
|    Check https://github.com/BaselAbujamous/clust for details.             |
/usr/local/lib/python3.8/dist-packages/clust/scripts/preprocess_data.py:107: FutureWarning: Unlike other reduction functions (e.g. `skew`, `kurtosis`), the default behavior of `mode` typically preserves the axis it acts along. In SciPy 1.11.0, this behavior will change: the default value of `keepdims` will become False, the `axis` over which the statistic is taken will be eliminated, and the value None will no longer be accepted. Set `keepdims` to True or False to avoid this warning.
  mode = spst.mode(xd)[0]
|  - Flat expression profiles filtered out (default in v1.7.0+).            |
|    To switch it off, use the --no-fil-flat option (not recommended).      |
|    Check https://github.com/BaselAbujamous/clust for details.             |
| 3. Seed clusters production (the Bi-CoPaM method)                         |
| 10%                                                                       |
| 20%                                                                       |
| 30%                                                                       |
| 40%                                                                       |
| 50%                                                                       |
| 60%                                                                       |
| 70%                                                                       |
| 80%                                                                       |
/usr/local/lib/python3.8/dist-packages/clust/scripts/clustering.py:52: ConvergenceWarning: Number of distinct clusters (6) found smaller than n_clusters (8). Possibly due to duplicate points in X.
  C = skcl.KMeans(K, init=init, max_iter=max_iter, n_init=n_init).fit(X).labels_
/usr/local/lib/python3.8/dist-packages/clust/scripts/clustering.py:52: ConvergenceWarning: Number of distinct clusters (7) found smaller than n_clusters (12). Possibly due to duplicate points in X.
  C = skcl.KMeans(K, init=init, max_iter=max_iter, n_init=n_init).fit(X).labels_
| 90%                                                                       |
/usr/local/lib/python3.8/dist-packages/clust/scripts/clustering.py:52: ConvergenceWarning: Number of distinct clusters (6) found smaller than n_clusters (16). Possibly due to duplicate points in X.
  C = skcl.KMeans(K, init=init, max_iter=max_iter, n_init=n_init).fit(X).labels_
/usr/local/lib/python3.8/dist-packages/clust/scripts/clustering.py:52: ConvergenceWarning: Number of distinct clusters (11) found smaller than n_clusters (20). Possibly due to duplicate points in X.
  C = skcl.KMeans(K, init=init, max_iter=max_iter, n_init=n_init).fit(X).labels_
| 100%                                                                      |
| 4. Cluster evaluation and selection (the M-N scatter plots technique)     |
| 10%                                                                       |
| 20%                                                                       |
| 30%                                                                       |
| 40%                                                                       |
| 50%                                                                       |
| 60%                                                                       |
| 70%                                                                       |
| 80%                                                                       |
| 90%                                                                       |
| 100%                                                                      |
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/scipy/__init__.py", line 214, in __getattr__
    return globals()[name]
KeyError: 'random'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/clust", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/clust/__main__.py", line 102, in main
    clustpipeline.clustpipeline(args.datapath, args.m, args.r, args.n, args.o, args.K, args.t,
  File "/usr/local/lib/python3.8/dist-packages/clust/clustpipeline.py", line 126, in clustpipeline
    mnres = mn.mnplotsgreedy(X_summarised_normalised, ures.B, GDM=GDM, tightnessweight=tightnessweight,
  File "/usr/local/lib/python3.8/dist-packages/clust/scripts/mnplots.py", line 248, in mnplotsgreedy
    allDists[n] += alpha * sp.random.normal()
  File "/usr/local/lib/python3.8/dist-packages/scipy/__init__.py", line 216, in __getattr__
    raise AttributeError(
AttributeError: Module 'scipy' has no attribute 'random'
ahosseinian commented 2 years ago

You are correct. It's a versioning issue of Scipy. In version 1.9.0, the alias scipy.random is removed.

strawberrylady commented 1 year ago

Hello Gazal,

I have the same issue and the Scipy version is 1.9.1. Could you let me know if you have fixed the issue and how? Thank you.

Best regards, Susanne

gazalk commented 1 year ago

I tried uninstalling it first. And then a clean install with conda worked!

strawberrylady commented 1 year ago

Thank you Gazal. I will try your approach then.

strawberrylady commented 1 year ago

I had no luck after a clean install. Tried Scipy 1.9.0, no luck either.

BaselAbujamous commented 1 year ago

Hi and thanks for reporting this. I will try to fix with a new release then in the next couple of days.

On Sat, 15 Oct 2022 at 23:26, strawberrylady @.***> wrote:

I had no luck after a clean install. Tried Scipy 1.9.0, no luck either.

— Reply to this email directly, view it on GitHub https://github.com/BaselAbujamous/clust/issues/77#issuecomment-1279843316, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJFLQZ5PXMCHNZOHK3H46LWDMVPZANCNFSM56KBT64Q . You are receiving this because you are subscribed to this thread.Message ID: @.***>

strawberrylady commented 1 year ago

Great. Thank you for looking after this issue. Looking forward to the new release.

strawberrylady commented 1 year ago

Hi, Any luck on fixing the issue?

BaselAbujamous commented 1 year ago

Done and a new release is out now :)

strawberrylady commented 1 year ago

Sounds great. Thank you very much. Will give it a try.

BaselAbujamous commented 1 year ago

Has it worked? :)

strawberrylady commented 1 year ago

Worked like a charm! Thank you so much.

BaselAbujamous commented 1 year ago

Great!