Closed mdmanurung closed 1 month ago
I had the same error, changing s.shape
to np.shape
in the mofapy2/core/distributions/basic_distributions.py
file and s.outer
to np.outer
in the mofapy2/core/BayesNet.py
files fixed the error for me.
Thanks @cheny36 it worked for me too!
This is due to a deprecation in SciPy 1.12.0 where they decided not to re-export NumPy functions anymore.
See the release notes for SciPy 1.13.0. In particular:
Functions from NumPy's main namespace which were exposed in SciPy's main namespace, such as numpy.histogram exposed by scipy.histogram, have been removed from SciPy's main namespace. Please use the functions directly from numpy. This was originally performed for SciPy 1.12.0 however was missed from the release notes so is included here for completeness.
Hi, I had a similar issue which may be related to this. The version of mofapy2 is 0.7.1
######################################
## Training the model with seed 2023 ##
######################################
ELBO before training:
Z=-261260.27 W=-2048499.87 Tau=-1131537.48 Y=-24105205301.50 AlphaZ=-3679.08 AlphaW=-1839.54 ThetaW=0.00
Total: -24108652117.74
- ELBO decomposition: Z=-104160.44 W=-1594968.94 Tau=-2030458.39 Y=518485963.26 AlphaZ=-4168.85 AlphaW=-2110.58 ThetaW=0.00
- Time spent in ELBO computation: 0.3%
Traceback (most recent call last):
File "/work/home/software/anaconda3/envs/scanpy/lib/python3.10/site-packages/scipy/__init__.py", line 137, in __getattr__
return globals()[name]
KeyError: 'asarray'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/work/home/project/multiome/mofa_multiome/multiome_40samp/mofa_test.py", line 116, in <module>
mdata = run_mofa(mdata=mdata, outfile=f"{outdir}/data/mofa_test_model.hdf5")
File "/work/home/project/multiome/mofa_multiome/multiome_40samp/mofa_test.py", line 62, in run_mofa
mu.tl.mofa(mdata, groups_label=groups_label, n_factors=n_factors, seed=2023,
File "/work/home/software/anaconda3/envs/scanpy/lib/python3.10/site-packages/muon/_core/tools.py", line 586, in mofa
ent.run()
File "/work/home/software/anaconda3/envs/scanpy/lib/python3.10/site-packages/mofapy2/run/entry_point.py", line 26, in saver
func(self, *args, **kwargs)
File "/work/home/software/anaconda3/envs/scanpy/lib/python3.10/site-packages/mofapy2/run/entry_point.py", line 1400, in run
train_model(self.model)
File "/work/home/software/anaconda3/envs/scanpy/lib/python3.10/site-packages/mofapy2/build_model/train_model.py", line 26, in train_model
model.iterate()
File "/work/home/software/anaconda3/envs/scanpy/lib/python3.10/site-packages/mofapy2/core/BayesNet.py", line 368, in iterate
self.print_verbose_message(i)
File "/work/home/software/anaconda3/envs/scanpy/lib/python3.10/site-packages/mofapy2/core/BayesNet.py", line 404, in print_verbose_message
r2 = s.asarray(self.calculate_variance_explained(total=True)).mean(axis=0)
File "/work/home/software/anaconda3/envs/scanpy/lib/python3.10/site-packages/scipy/__init__.py", line 139, in __getattr__
raise AttributeError(
AttributeError: Module 'scipy' has no attribute 'asarray'
Hi, changing scipy to numpy solved the issue.
r2 = np.asarray(self.calculate_variance_explained(total=True)).mean(axis=0)
Pull request #27 would fix this, but we need one of the package developers to look at it. @gtca maybe?
Me too I had similar problems.
Downgrading to scipy 1.11.4 solved it for me.
pip install scipy==1.11.4
Hi same here, I have scipy 1.13.0 and got the error: "Module 'scipy' has no attribute 'mod'" Downgrading also to scipy 1.11.4 solved the previous bug.
@gtca this should also be fixed now by PR #27 and should be closed
Dear authors,
I encountered this error when running mofapy2 (v 0.7.0) via muon.
It reached this point:
But then the error kicks in.
Do you know how to solve this? My scipy version is 1.12.0. Thanks in advance.
Regards, Mikhael