parklab / MuSiCal

A comprehensive toolkit for mutational signature analysis
Other
31 stars 5 forks source link

"maximum number of iterations reached" in de novo signatures extraction #83

Open Spirit-booze opened 3 weeks ago

Spirit-booze commented 3 weeks ago

Hi.

Tried to use the package for de novo extraction of mutational signatures.

Got an error

RemoteTraceback Traceback (most recent call last) RemoteTraceback: """ Traceback (most recent call last): File "/usr/lib/python3.10/multiprocessing/pool.py", line 125, in worker result = (True, func(*args, *kwds)) File "/usr/lib/python3.10/multiprocessing/pool.py", line 48, in mapstar return list(map(args)) File "/home/spirit-booze/venvs/mut_signatures/lib/python3.10/site-packages/musical/mvnmf.py", line 406, in _job model.fit() File "/home/spirit-booze/venvs/mut_signatures/lib/python3.10/site-packages/musical/mvnmf.py", line 305, in fit H = nnls(self.X, W) File "/home/spirit-booze/venvs/mutsignatures/lib/python3.10/site-packages/musical/nnls.py", line 11, in nnls h, = sp.optimize.nnls(W, x) File "/home/spirit-booze/venvs/mut_signatures/lib/python3.10/site-packages/scipy/optimize/_nnls.py", line 93, in nnls raise RuntimeError("Maximum number of iterations reached.") RuntimeError: Maximum number of iterations reached. """

The above exception was the direct cause of the following exception:

RuntimeError Traceback (most recent call last) Cell In[7], line 7 1 mut_sigs = musical.DenovoSig(mut_data, 2 min_n_components=1, 3 max_n_components=16, 4 ncpu=22, 5 verbose=2 6 ) ----> 7 mut_sigs.fit() 9 with open('../temp_data/mut_results_01_11_2024.pkl', 'wb') as f: 10 pickle.dump(XPC_sigs, f)

File ~/venvs/mut_signatures/lib/python3.10/site-packages/musical/denovo.py:869, in DenovoSig.fit(self) 868 def fit(self): --> 869 self._run_jobs() 870 self.postprocess() 871 return self

File ~/venvs/mut_signatures/lib/python3.10/site-packages/musical/denovo.py:750, in DenovoSig._run_jobs(self) 734 X_in = normalize(X_in, norm='l1', axis=0) 735 model = wrappedMVNMF(X_in, 736 n_components, 737 init=self.init, (...) 748 noise=self.mvnmf_noise 749 ) --> 750 model.fit() 751 models = [model] 752 lambda_tilde = model.lambda_tilde

File ~/venvs/mut_signatures/lib/python3.10/site-packages/musical/mvnmf.py:443, in wrappedMVNMF.fit(self) 441 else: 442 workers = multiprocessing.Pool(self.ncpu) --> 443 models = workers.map(self._job, list(self.lambda_tilde_grid)) 444 workers.close() 445 workers.join()

File /usr/lib/python3.10/multiprocessing/pool.py:367, in Pool.map(self, func, iterable, chunksize) 362 def map(self, func, iterable, chunksize=None): 363 ''' 364 Apply func to each element in iterable, collecting the results 365 in a list that is returned. 366 ''' --> 367 return self._map_async(func, iterable, mapstar, chunksize).get()

File /usr/lib/python3.10/multiprocessing/pool.py:774, in ApplyResult.get(self, timeout) 772 return self._value 773 else: --> 774 raise self._value

RuntimeError: Maximum number of iterations reached.

Any ideas on how to resolve this?

Hu-JIN commented 3 weeks ago

Hi,

Someone else reported a similar error recently. We thought it may be related to this issue of a recent version of Scipy: https://github.com/scipy/scipy/issues/20813. Could you check what version of Scipy you are using, and try downgrading it and run again?