bioFAM / mofapy2

Multi-omics factor analysis v2
https://biofam.github.io/MOFA2/
GNU Lesser General Public License v3.0
34 stars 28 forks source link

not training #19

Closed hongruhusanofi closed 9 months ago

hongruhusanofi commented 10 months ago

Hi, I have some issue with training

######################################
## Training the model with seed 1 ##
######################################

Attempting to save the model at the current iteration...
Saving model in /mofa_train_interrupted.hdf5...
Note: the model to be saved is not trained.

and AttributeError: 'BayesNet' object has no attribute 'train_stats'

jjuhyunkim commented 10 months ago

I got the same error. These are versions of my models.

mofapy2 = v0.7.0
pandas = 1.5.3
numpy = 1.26.0
jjuhyunkim commented 10 months ago

When I downgraded mofapy2 to 0.6.7, I got different error message below:

IndexError                                Traceback (most recent call last)
Cell In[76], line 1
----> 1 mu.tl.mofa(mdata, n_factors=20, gpu_mode=True)

File ~/mambaforge/envs/multiome/lib/python3.9/site-packages/muon/_core/tools.py:642, in mofa(data, groups_label, use_raw, use_layer, use_var, use_obs, likelihoods, n_factors, scale_views, scale_groups, center_groups, ard_weights, ard_factors, spikeslab_weights, spikeslab_factors, n_iterations, convergence_mode, use_float32, gpu_mode, gpu_device, svi_mode, svi_batch_size, svi_learning_rate, svi_forgetting_rate, svi_start_stochastic, smooth_covariate, smooth_warping, smooth_kwargs, save_parameters, save_data, save_metadata, seed, outfile, expectations, save_interrupted, verbose, quiet, copy)
    639 if use_var:
    640     # Set the weights of features that were not used to zero
    641     data.varm["LFs"] = np.zeros(shape=(data.n_vars, w.shape[1]))
--> 642     data.varm["LFs"][data.var[use_var]] = w
    643 else:
    644     data.varm["LFs"] = w

IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

mofapy2 : v0.6.7 numpy : v1.22.4 pandas : v1.5.3

jjuhyunkim commented 10 months ago

I was able to run through the entire Jupyter notebook named getting_started_python.ipynb, which could be downloaded from the mofapy2 GitHub without any errors. However, the error was triggered by another Jupyter notebook and a sample data file downloaded from the muon-tutorials."

But the Mu data has a new embedding X_mofa.

And the iteration stopped at 13 with the message 'Converged!'. While I believe this number of iterations is too low, can I still use the X_mofa in mdata for downstream analysis in this situation?

hongruhusanofi commented 9 months ago

just tried using the data.frame option following the mofapy2, it worked fine so there should be something wrong wit the MOUN mu.tl.mofa wrapper. @jjuhyunkim maybe we could open another issue under the moun github page

jjuhh commented 9 months ago

Yes, you are right,

I was able to resolve the error by executing the following line of code before running MOFA to integrate my data

mdata.var['highly_variable']=mdata.var['highly_variable'].to_list()

Thank you for your comments