HaghverdiLab / velocity_package

GNU Affero General Public License v3.0
2 stars 2 forks source link

`ValueError: setting an array element with a sequence.` when running `velocity.tl.fit.recover_reaction_rate_pars()` #3

Open lconan opened 11 months ago

lconan commented 11 months ago

Hi, thanks for the tool. When I try to run the tutorial or the figure note books (3 of them), I got the similar error: ValueError: setting an array element with a sequence. For example: when try Pancreas dataset - complete pipeline:

### recover dynamics for all genes
velocity.tl.fit.recover_reaction_rate_pars(adata, use_raw=False, n=100, 
                                 fit_kappa=True, fit_scaling=True)

this line of code, raises error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[14], line 2
      1 ### recover dynamics for all genes
----> 2 velocity.tl.fit.recover_reaction_rate_pars(adata, use_raw=False, n=100, 
      3                                  fit_kappa=True, fit_scaling=True)

File ~/sw/velocity_package/velocity/tools/fit.py:10, in recover_reaction_rate_pars(adata, use_raw, n, key, fit_scaling, parallel, n_cores, n_parts, inplace, fit_kappa)
      8 unspliced, spliced = adata.layers["unspliced" if use_raw else "Mu"], adata.layers["spliced" if use_raw else "Ms"]
      9 if parallel:
---> 10     alpha, beta, gamma, U_switch, scaling, likelihood, Pi = fit_all_parallel(unspliced, spliced, n=n,
     11                                                                              n_cores=n_cores, n_parts=n_parts,
     12                                                                              fit_scaling=fit_scaling,
     13                                                                              fit_kappa=fit_kappa)
     14 else:
     15     alpha, beta, gamma, U_switch, scaling, likelihood, Pi = fit_all(unspliced, spliced, n=n,
     16                                                                     fit_scaling=fit_scaling, fit_kappa=fit_kappa)

File ~/sw/velocity_package/velocity/tools/fit.py:88, in fit_all_parallel(unspliced, spliced, n, n_cores, n_parts, fit_scaling, fit_kappa)
     86 for i in result:
     87     r.extend(i)
---> 88 r = np.array(r)
     90 alpha, beta, gamma, U_switch, scaling, likelihood = r[:, 0], r[:, 1], r[:, 2], r[:, 3], r[:, 4], r[:, 5]
     91 Pi = np.stack(r[:, 6]).T

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (406, 7) + inhomogeneous part.
Baschdl commented 3 weeks ago

This error unfortunately still persists.